1 kkz      1.1.2.1 // MRA.java, created Mon Oct  1 16:42:17 2001 by kkz
 2 kkz      1.1.2.1 // Copyright (C) 2000 Karen Zee <kkz@tmi.lcs.mit.edu>
 3 kkz      1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details.
 4 kkz      1.1.2.1 package harpoon.Analysis.PreciseGC;
 5 kkz      1.1.2.1 
 6 kkz      1.1.2.1 import harpoon.IR.Quads.Quad;
 7 kkz      1.1.2.5 import harpoon.Util.Tuple;
 8 kkz      1.1.2.1 
 9 kkz      1.1.2.1 /**
10 kkz      1.1.2.3  * <code>MRA</code> is answers the question "which 
11 kkz      1.1.2.1  * <code>Temp<code>s contain the address of the most 
12 kkz      1.1.2.1  * recently allocated object at this program point?"
13 kkz      1.1.2.1  * 
14 kkz      1.1.2.1  * @author  Karen Zee <kkz@tmi.lcs.mit.edu>
15 cananian 1.2      * @version $Id: MRA.java,v 1.2 2002/02/25 20:58:53 cananian Exp $
16 kkz      1.1.2.1  */
17 kkz      1.1.2.4 public abstract class MRA {
18 kkz      1.1.2.1 
19 kkz      1.1.2.5     /** Returns a <code>Tuple</code>. The first element of the
20 kkz      1.1.2.5      *  <code>Tuple</code> contains a <code>Map</code> of
21 kkz      1.1.2.5      *  <code>Temp</code>s that point to the most recently
22 kkz      1.1.2.5      *  allocated object at that program point, to a 
23 kkz      1.1.2.5      *  <code>MRAToken</code> that indicates whether the 
24 kkz      1.1.2.5      *  <code>Temp</code> points to the receiver object and 
25 kkz      1.1.2.5      *  whether the <code>Temp</code> succeeded the receiver 
26 kkz      1.1.2.5      *  object as the most-recently allocated. The second 
27 kkz      1.1.2.5      *  element of the <code>Tuple</code> is a <code>Set</code> 
28 kkz      1.1.2.5      *  of <code>HClass</code>es of which objects may have been 
29 kkz      1.1.2.5      *  allocated that are more recent.
30 kkz      1.1.2.1      */
31 kkz      1.1.2.5     public abstract Tuple mra_before(Quad q);
32 kkz      1.1.2.1 
33 kkz      1.1.2.5     /** The <code>MRAToken</code> class represents the nodes
34 kkz      1.1.2.5      *  on the lattice for the <code>MRA</code> analysis.
35 kkz      1.1.2.5      */
36 kkz      1.1.2.5     public static class MRAToken {
37 kkz      1.1.2.5         public static MRAToken BOTTOM = new MRAToken("Bottom");
38 kkz      1.1.2.5         public static MRAToken RCVR = new MRAToken("Receiver");
39 kkz      1.1.2.5         public static MRAToken SUCC = new MRAToken("Successor");
40 kkz      1.1.2.5         public static MRAToken TOP = new MRAToken("Top");
41 kkz      1.1.2.5 
42 kkz      1.1.2.5         private final String name;
43 kkz      1.1.2.5         
44 kkz      1.1.2.5         /** Creates an <code>MRAToken</code>. Modifier 
45 kkz      1.1.2.5          *  private since all instances should be declared 
46 kkz      1.1.2.5          *  and allocated here.
47 kkz      1.1.2.5          */
48 kkz      1.1.2.5         private MRAToken(String name) {
49 kkz      1.1.2.5             this.name = name;
50 kkz      1.1.2.5         }
51 kkz      1.1.2.5 
52 kkz      1.1.2.5         /** Returns an <code>MRAToken</code> representing
53 kkz      1.1.2.5          *  the join of <code>this</code> with the
54 kkz      1.1.2.5          *  argument. This operation is symmetric, so
55 kkz      1.1.2.5          *  a.join(b) == b.join(a)
56 kkz      1.1.2.5          */
57 kkz      1.1.2.5         public MRAToken join(MRAToken t) {
58 kkz      1.1.2.5             if (this == t) return this;
59 kkz      1.1.2.5             if (this == TOP) return t;
60 kkz      1.1.2.5             return BOTTOM;
61 kkz      1.1.2.5         }
62 kkz      1.1.2.5 
63 kkz      1.1.2.5         /** Returns a <code>String</code> representation
64 kkz      1.1.2.5          *  of the <code>Token</code>.
65 kkz      1.1.2.5          */
66 kkz      1.1.2.5         public String toString() {
67 kkz      1.1.2.5             return "TOKEN<"+name+">";
68 kkz      1.1.2.5         }
69 kkz      1.1.2.5     }
70 kkz      1.1.2.1 }
71 cananian 1.2