1 kkz      1.1.2.1 // WriteBarrierData.java, created Thu Aug 30 16:49:28 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.Backend.Generic.Frame;
 7 kkz      1.1.2.1 import harpoon.ClassFile.HClass;
 8 kkz      1.1.2.1 import harpoon.ClassFile.HDataElement;
 9 kkz      1.1.2.1 import harpoon.IR.Tree.ALIGN;
10 kkz      1.1.2.1 import harpoon.IR.Tree.CONST;
11 kkz      1.1.2.1 import harpoon.IR.Tree.DATUM;
12 kkz      1.1.2.1 import harpoon.IR.Tree.LABEL;
13 kkz      1.1.2.1 import harpoon.IR.Tree.SEGMENT;
14 kkz      1.1.2.1 import harpoon.IR.Tree.Stm;
15 kkz      1.1.2.1 import harpoon.Temp.Label;
16 kkz      1.1.2.1 import harpoon.Util.Util;
17 kkz      1.1.2.1 
18 kkz      1.1.2.1 import java.util.ArrayList;
19 kkz      1.1.2.1 import java.util.List;
20 kkz      1.1.2.1 
21 kkz      1.1.2.1 /**
22 kkz      1.1.2.1  * <code>WriteBarrierData</code> generates the static data needed
23 kkz      1.1.2.1  * to gather dynamic statistics about write barriers. Should
24 kkz      1.1.2.1  * be used in conjunction with <code>WriteBarrierStats</code>.
25 kkz      1.1.2.1  * 
26 kkz      1.1.2.1  * @author  Karen Zee <kkz@tmi.lcs.mit.edu>
27 kkz      1.5      * @version $Id: WriteBarrierData.java,v 1.5 2002/06/25 18:16:22 kkz Exp $
28 kkz      1.1.2.1  */
29 kkz      1.5     class WriteBarrierData extends harpoon.Backend.Runtime1.Data {
30 kkz      1.1.2.1 
31 kkz      1.1.2.1     /** Creates a <code>WriteBarrierData</code> */
32 kkz      1.1.2.1     WriteBarrierData(HClass hc, Frame f, int datum) {
33 kkz      1.1.2.1         super("write-barrier", hc, f);
34 kkz      1.1.2.1         // only emit this once
35 cananian 1.3.2.1         assert hc == f.getLinker().forName("java.lang.Object");
36 kkz      1.1.2.1         this.root = build(datum);
37 kkz      1.1.2.1     }
38 kkz      1.1.2.1 
39 kkz      1.1.2.1     private HDataElement build(int datum) {
40 kkz      1.1.2.1         List stmlist = new ArrayList(4);
41 kkz      1.1.2.1         stmlist.add(new SEGMENT(tf, null, SEGMENT.TEXT));
42 kkz      1.1.2.1         stmlist.add(new ALIGN(tf, null, 4)); // word align
43 kkz      1.1.2.1         stmlist.add(new LABEL(tf, null,new Label("num_write_barriers"), true));
44 kkz      1.1.2.1         stmlist.add(new DATUM(tf, null, new CONST(tf, null, datum)));
45 kkz      1.1.2.1         return (HDataElement) Stm.toStm(stmlist);
46 kkz      1.1.2.1     }
47 cananian 1.2     }