1 cananian 1.1.2.1 // DataConfigChecker.java, created Thu Oct 25 22:49:32 2001 by cananian 2 cananian 1.1.2.1 // Copyright (C) 2000 C. Scott Ananian <cananian@alumni.princeton.edu> 3 cananian 1.1.2.1 // Licensed under the terms of the GNU GPL; see COPYING for details. 4 cananian 1.1.2.1 package harpoon.Backend.Runtime1; 5 cananian 1.1.2.1 6 cananian 1.1.2.1 import harpoon.Backend.Generic.Frame; 7 cananian 1.1.2.2 import harpoon.ClassFile.HClass; 8 cananian 1.1.2.2 import harpoon.ClassFile.HDataElement; 9 cananian 1.1.2.2 import harpoon.ClassFile.Linker; 10 cananian 1.1.2.2 import harpoon.IR.Tree.ALIGN; 11 cananian 1.3 import harpoon.IR.Tree.CONST; 12 cananian 1.1.2.2 import harpoon.IR.Tree.SEGMENT; 13 cananian 1.1.2.2 import harpoon.IR.Tree.Stm; 14 cananian 1.1.2.2 import harpoon.Temp.Label; 15 cananian 1.1.2.1 16 cananian 1.1.2.2 import java.util.ArrayList; 17 cananian 1.1.2.2 import java.util.Iterator; 18 cananian 1.1.2.2 import java.util.List; 19 cananian 1.1.2.2 import java.util.Set; 20 cananian 1.1.2.1 /** 21 cananian 1.1.2.1 * <code>DataConfigChecker</code> outputs some (never used) references 22 cananian 1.1.2.1 * which will be unresolved (resulting in linker errors at build-time) 23 cananian 1.1.2.1 * unless the runtime configuration matches the flex configuration. 24 cananian 1.1.2.1 * 25 cananian 1.1.2.1 * @author C. Scott Ananian <cananian@alumni.princeton.edu> 26 cananian 1.3 * @version $Id: DataConfigChecker.java,v 1.3 2003/10/21 02:11:02 cananian Exp $ 27 cananian 1.1.2.1 */ 28 cananian 1.1.2.1 public class DataConfigChecker extends Data { 29 cananian 1.1.2.1 30 cananian 1.1.2.1 /** Creates a <code>DataConfigChecker</code>. */ 31 cananian 1.1.2.1 public DataConfigChecker(Frame f, HClass hc) { 32 cananian 1.1.2.1 super("config-checker", hc, f); 33 cananian 1.1.2.1 // only build one of these; wait until hc is java.lang.Object. 34 cananian 1.1.2.1 this.root = (hc==linker.forName("java.lang.Object")) ? 35 cananian 1.1.2.1 build() : null; 36 cananian 1.1.2.1 } 37 cananian 1.1.2.1 private HDataElement build() { 38 cananian 1.1.2.1 List stmlist = new ArrayList(4); 39 cananian 1.1.2.1 stmlist.add(new SEGMENT(tf, null, SEGMENT.TEXT)); 40 cananian 1.1.2.1 stmlist.add(new ALIGN(tf, null, 4)); // word align. 41 cananian 1.1.2.1 // output label for 'object padding' using frame information. 42 cananian 1.1.2.1 int object_padding = frame.getRuntime().getTreeBuilder().objectSize 43 cananian 1.1.2.1 (linker.forName("java.lang.Object")); 44 cananian 1.1.2.1 stmlist.add(_DATUM(new Label 45 cananian 1.1.2.1 ("check_object_padding_should_be_"+object_padding))); 46 cananian 1.1.2.1 // label for '--with-pointer-size', using frame info. 47 cananian 1.1.2.1 stmlist.add(_DATUM(new Label 48 cananian 1.1.2.1 ("check_with_pointer_size_should_be_"+ 49 cananian 1.1.2.1 (frame.pointersAreLong()?8:4)))); 50 cananian 1.1.2.1 // XXX: missing checks for the following Runtime options: 51 cananian 1.1.2.1 // --with-thread-model, --with-gc, --with-clustered_heaps, 52 cananian 1.1.2.1 53 cananian 1.1.2.1 // now emit labels for things in the Runtime.configurationSet. 54 cananian 1.1.2.1 for (Iterator it=frame.getRuntime().configurationSet.iterator(); 55 cananian 1.1.2.1 it.hasNext(); ) 56 cananian 1.1.2.1 stmlist.add(_DATUM(new Label((String)it.next()))); 57 cananian 1.3 58 cananian 1.3 // make sure there's something for the labels to point to. 59 cananian 1.3 stmlist.add(_DATUM(new CONST(tf, null, 0))); 60 cananian 1.1.2.1 61 cananian 1.1.2.1 // done! fold statement list into nested SEQs and return. 62 cananian 1.1.2.1 return (HDataElement) Stm.toStm(stmlist); 63 cananian 1.1.2.1 } 64 cananian 1.2 }