< prev index next >

test/lib/jdk/test/lib/hprof/model/Snapshot.java

Print this page

 52     public static final long SMALL_ID_MASK = 0x0FFFFFFFFL;
 53     public static final JavaThing[] EMPTY_JAVATHING_ARRAY = new JavaThing[0];
 54 
 55     private static final JavaField[] EMPTY_FIELD_ARRAY = new JavaField[0];
 56     private static final JavaStatic[] EMPTY_STATIC_ARRAY = new JavaStatic[0];
 57 
 58     // all heap objects
 59     private Hashtable<Number, JavaHeapObject> heapObjects =
 60                  new Hashtable<Number, JavaHeapObject>();
 61 
 62     private Hashtable<Number, JavaClass> fakeClasses =
 63                  new Hashtable<Number, JavaClass>();
 64 
 65     // all Roots in this Snapshot
 66     private Vector<Root> roots = new Vector<Root>();
 67 
 68     // name-to-class map
 69     private Map<String, JavaClass> classes =
 70                  new TreeMap<String, JavaClass>();
 71 




 72     // new objects relative to a baseline - lazily initialized
 73     private volatile Map<JavaHeapObject, Boolean> newObjects;
 74 
 75     // allocation site traces for all objects - lazily initialized
 76     private volatile Map<JavaHeapObject, StackTrace> siteTraces;
 77 
 78     // object-to-Root map for all objects
 79     private Map<JavaHeapObject, Root> rootsMap =
 80                  new HashMap<JavaHeapObject, Root>();
 81 
 82     // soft cache of finalizeable objects - lazily initialized
 83     private SoftReference<Vector<?>> finalizablesCache;
 84 
 85     // threads
 86     private ArrayList<ThreadObject> threads = new ArrayList<>();
 87 
 88     // represents null reference
 89     private JavaThing nullThing;
 90 
 91     // java.lang.ref.Reference class

192         int numInts = instSize / 4;
193         int numBytes = instSize % 4;
194         JavaField[] fields = new JavaField[numInts + numBytes];
195         int i;
196         for (i = 0; i < numInts; i++) {
197             fields[i] = new JavaField("unknown-field-" + i, "I");
198         }
199         for (i = 0; i < numBytes; i++) {
200             fields[i + numInts] = new JavaField("unknown-field-" +
201                                                 i + numInts, "B");
202         }
203 
204         // Create fake instance class
205         JavaClass c = new JavaClass(name, 0, 0, 0, 0, fields,
206                                  EMPTY_STATIC_ARRAY, instSize);
207         // Add the class
208         addFakeClass(makeId(classID), c);
209         return c;
210     }
211 



































212 
213     /**
214      * @return true iff it's possible that some JavaThing instances might
215      *          isNew set
216      *
217      * @see JavaThing.isNew()
218      */
219     public boolean getHasNewSet() {
220         return hasNewSet;
221     }
222 
223     //
224     // Used in the body of resolve()
225     //
226     private static class MyVisitor extends AbstractJavaHeapObjectVisitor {
227         JavaHeapObject t;
228         public void visit(JavaHeapObject other) {
229             other.addReferenceFrom(t);
230         }
231     }

 52     public static final long SMALL_ID_MASK = 0x0FFFFFFFFL;
 53     public static final JavaThing[] EMPTY_JAVATHING_ARRAY = new JavaThing[0];
 54 
 55     private static final JavaField[] EMPTY_FIELD_ARRAY = new JavaField[0];
 56     private static final JavaStatic[] EMPTY_STATIC_ARRAY = new JavaStatic[0];
 57 
 58     // all heap objects
 59     private Hashtable<Number, JavaHeapObject> heapObjects =
 60                  new Hashtable<Number, JavaHeapObject>();
 61 
 62     private Hashtable<Number, JavaClass> fakeClasses =
 63                  new Hashtable<Number, JavaClass>();
 64 
 65     // all Roots in this Snapshot
 66     private Vector<Root> roots = new Vector<Root>();
 67 
 68     // name-to-class map
 69     private Map<String, JavaClass> classes =
 70                  new TreeMap<String, JavaClass>();
 71 
 72     private Map<Number, Number> flatArrays = new HashMap<>();
 73 
 74     private Map<Number, ClassInlinedFields[]> inlinedFields = new HashMap<>();
 75 
 76     // new objects relative to a baseline - lazily initialized
 77     private volatile Map<JavaHeapObject, Boolean> newObjects;
 78 
 79     // allocation site traces for all objects - lazily initialized
 80     private volatile Map<JavaHeapObject, StackTrace> siteTraces;
 81 
 82     // object-to-Root map for all objects
 83     private Map<JavaHeapObject, Root> rootsMap =
 84                  new HashMap<JavaHeapObject, Root>();
 85 
 86     // soft cache of finalizeable objects - lazily initialized
 87     private SoftReference<Vector<?>> finalizablesCache;
 88 
 89     // threads
 90     private ArrayList<ThreadObject> threads = new ArrayList<>();
 91 
 92     // represents null reference
 93     private JavaThing nullThing;
 94 
 95     // java.lang.ref.Reference class

196         int numInts = instSize / 4;
197         int numBytes = instSize % 4;
198         JavaField[] fields = new JavaField[numInts + numBytes];
199         int i;
200         for (i = 0; i < numInts; i++) {
201             fields[i] = new JavaField("unknown-field-" + i, "I");
202         }
203         for (i = 0; i < numBytes; i++) {
204             fields[i + numInts] = new JavaField("unknown-field-" +
205                                                 i + numInts, "B");
206         }
207 
208         // Create fake instance class
209         JavaClass c = new JavaClass(name, 0, 0, 0, 0, fields,
210                                  EMPTY_STATIC_ARRAY, instSize);
211         // Add the class
212         addFakeClass(makeId(classID), c);
213         return c;
214     }
215 
216     public void addFlatArray(long objID, long elementClassID) {
217         flatArrays.put(makeId(objID), makeId(elementClassID));
218     }
219 
220     /**
221      * @return null if the array is not flat array
222      */
223     Number findFlatArrayElementType(long arrayObjectID) {
224         return flatArrays.get(makeId(arrayObjectID));
225     }
226 
227     public static class ClassInlinedFields {
228         final int fieldIndex;
229         final int synthFieldCount;
230         final String fieldName;
231         final long fieldClassID;
232 
233         public ClassInlinedFields(int fieldIndex, int synthFieldCount, String fieldName, long fieldClassID) {
234             this.fieldIndex = fieldIndex;
235             this.synthFieldCount = synthFieldCount;
236             this.fieldName = fieldName;
237             this.fieldClassID =  fieldClassID;
238         }
239     }
240 
241     public void addClassInlinedFields(long classID, ClassInlinedFields[] fields) {
242         inlinedFields.put(makeId(classID), fields);
243     }
244 
245     /**
246      * @return null if the class has no inlined fields
247      */
248     ClassInlinedFields[] findClassInlinedFields(long classID) {
249         return inlinedFields.get(makeId(classID));
250     }
251 
252     /**
253      * @return true iff it's possible that some JavaThing instances might
254      *          isNew set
255      *
256      * @see JavaThing.isNew()
257      */
258     public boolean getHasNewSet() {
259         return hasNewSet;
260     }
261 
262     //
263     // Used in the body of resolve()
264     //
265     private static class MyVisitor extends AbstractJavaHeapObjectVisitor {
266         JavaHeapObject t;
267         public void visit(JavaHeapObject other) {
268             other.addReferenceFrom(t);
269         }
270     }
< prev index next >