1 cananian 1.1.2.1 // OffsetMap.java, created Thu Jan 14 22:17:20 1999 by duncan 2 cananian 1.1.2.2 // Copyright (C) 1998 Duncan Bryce <duncan@lcs.mit.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.Interpret.Tree; 5 cananian 1.1.2.1 6 cananian 1.1.2.1 import harpoon.ClassFile.HMethod; 7 cananian 1.1.2.1 import harpoon.ClassFile.HField; 8 cananian 1.1.2.1 import harpoon.ClassFile.HClass; 9 cananian 1.1.2.1 import harpoon.Temp.Label; 10 cananian 1.1.2.1 11 cananian 1.1.2.1 import java.util.Set; 12 cananian 1.1.2.1 13 cananian 1.1.2.1 /** 14 cananian 1.1.2.1 * An <code>OffsetMap</code> maps an <code>HField</code> or an 15 cananian 1.1.2.1 * <code>HMethod</code> to an offset in bytes. It also reports the 16 cananian 1.1.2.1 * total size of an <code>HClass</code> object. 17 cananian 1.1.2.1 * 18 cananian 1.1.2.2 * @author Duncan Bryce <duncan@lcs.mit.edu> 19 cananian 1.2 * @version $Id: OffsetMap.java,v 1.2 2002/02/25 21:06:01 cananian Exp $ 20 cananian 1.1.2.1 */ 21 cananian 1.1.2.1 abstract class OffsetMap { // use an abstract class, if we can. 22 cananian 1.1.2.1 23 cananian 1.1.2.1 /** Maps an <code>HClass</code> to an offset (in bytes). 24 cananian 1.1.2.1 * Returns the offset from an object reference of the class pointer */ 25 cananian 1.1.2.1 public abstract int clazzPtrOffset(HClass hc); 26 cananian 1.1.2.1 27 cananian 1.1.2.1 /** If returns the offset from the clazz pointer of the component type 28 cananian 1.1.2.1 * of <code>hc</code>. This location in memory will contain 29 cananian 1.1.2.1 * <code>null</code> if <code>hc</code> is not an array. If 30 cananian 1.1.2.1 * <code>hc</code> is an array, contains a pointer to the 31 cananian 1.1.2.1 * component type of the array. */ 32 cananian 1.1.2.1 public abstract int componentTypeOffset(HClass hc); 33 cananian 1.1.2.1 34 cananian 1.1.2.1 /** Returns the size (in bytes) of the display information. 35 cananian 1.1.2.1 */ 36 cananian 1.1.2.1 public abstract int displaySize(); 37 cananian 1.1.2.1 38 cananian 1.1.2.1 /** Maps an <code>HClass</code> to an offset (in bytes). 39 cananian 1.1.2.1 * If hc is an array type, returns the offset of the 40 cananian 1.1.2.1 * array's 0th element. */ 41 cananian 1.1.2.1 public abstract int elementsOffset(HClass hc); 42 cananian 1.1.2.1 43 cananian 1.1.2.1 /** Maps an <code>HClass</code> to an offset (in bytes). 44 cananian 1.1.2.1 * Returns the offset of the object's first field. */ 45 cananian 1.1.2.1 public abstract int fieldsOffset(HClass hc); 46 cananian 1.1.2.1 47 cananian 1.1.2.1 /** Maps an <code>HClass</code> to an offset (in bytes). 48 cananian 1.1.2.1 * Returns the offset from an object reference at which the hashcode 49 cananian 1.1.2.1 * is stored. */ 50 cananian 1.1.2.1 public abstract int hashCodeOffset(HClass hc); 51 cananian 1.1.2.1 52 cananian 1.1.2.1 /** Returns the offset from the class pointer of the list of interfaces 53 cananian 1.1.2.1 * implemented by the specified class 54 cananian 1.1.2.1 */ 55 cananian 1.1.2.1 public abstract int interfaceListOffset(HClass hc); 56 cananian 1.1.2.1 57 cananian 1.1.2.1 /** Maps an <code>HClass</code> to an offset (in bytes). 58 cananian 1.1.2.1 * If <code>hc</code> is an array type, returns the offset from 59 cananian 1.1.2.1 * an object reference of the array's length field. */ 60 cananian 1.1.2.1 public abstract int lengthOffset(HClass hc); 61 cananian 1.1.2.1 62 cananian 1.1.2.1 /** Maps an <code>HClass</code> to an offset (in bytes). 63 cananian 1.1.2.1 * Returns the offset from the class pointer of the specified 64 cananian 1.1.2.1 * class. This will be some function of the class's depth in 65 cananian 1.1.2.1 * the class hierarchy. */ 66 cananian 1.1.2.1 public abstract int offset(HClass hc); 67 cananian 1.1.2.1 68 cananian 1.1.2.1 /** Maps a non-static <code>HField</code> to an offset (in bytes). 69 cananian 1.1.2.1 * If the field is inlined using type 1 inlining (which preserves 70 cananian 1.1.2.1 * the class pointer) then the specified offset points just after the 71 cananian 1.1.2.1 * class descriptor, in the same place a normal object pointer points. 72 cananian 1.1.2.1 * If the field in inlined using type 2 inlining (which omits the 73 cananian 1.1.2.1 * class pointer) then the specified offset points to the first field 74 cananian 1.1.2.1 * of the object. */ 75 cananian 1.1.2.1 public abstract int offset(HField hf); 76 cananian 1.1.2.1 77 cananian 1.1.2.1 /** Maps a non-static <code>HMethod</code> to an offset (in bytes). 78 cananian 1.1.2.1 * This method must work for interface methods as well as class methods.*/ 79 cananian 1.1.2.1 public abstract int offset(HMethod hm); 80 cananian 1.1.2.1 81 cananian 1.1.2.1 /** Maps an <code>HClass</code> to a size (in bytes). */ 82 cananian 1.1.2.1 public abstract int size(HClass hc); 83 cananian 1.1.2.1 84 cananian 1.1.2.1 /** Returns the size (in bytes) of a word in the architecture represented 85 cananian 1.1.2.1 * by this <code>OffsetMap</code>. */ 86 cananian 1.1.2.1 public abstract int wordsize(); 87 cananian 1.1.2.1 } 88 cananian 1.1.2.1 89 cananian 1.1.2.1 90 cananian 1.2