< prev index next >

test/hotspot/jtreg/runtime/cds/CDSMapReader.java

Print this page

271                 } else {
272                     nextLine();
273                 }
274             }
275             return mapFile;
276         } catch (Throwable t) {
277             System.out.println("Error parsing line " + lineCount + ": " + line);
278             throw new RuntimeException(t);
279         } finally {
280             System.out.println("Parsed " + lineCount + " lines in " + fileName);
281             System.out.println("Found " + mapFile.heapObjectCount() + " heap objects ("
282                                + mapFile.stringCount + " strings)");
283             mapFile = null;
284             reader = null;
285             line = null;
286             lineCount = 0;
287         }
288     }
289 
290     private static void mustContain(HashMap<Long, HeapObject> allObjects, Field field, long pointer, boolean isNarrow) {
291         if (allObjects.get(pointer) == null) {
292             throw new RuntimeException((isNarrow ? "narrowOop" : "oop") + " pointer 0x" + Long.toHexString(pointer) +
293                                        " on line " + field.lineCount + " doesn't point to a valid heap object");
294         }
295     }
296 
297     // Check that each oop fields in the HeapObjects must point to a valid HeapObject.
298     public static void validate(MapFile mapFile) {
299         int count1 = 0;
300         int count2 = 0;
301         for (HeapObject heapObject : mapFile.heapObjects) {
302             if (heapObject.fields != null) {
303                 for (Field field : heapObject.fields) {
304                     HeapAddress referentAddress = field.referentAddress;
305                     long oop = referentAddress.oop;
306                     long narrowOop = referentAddress.narrowOop;
307                     // Is this test actually doing something?
308                     //     To see how an invalidate pointer may be found, change oop in the
309                     //     following line to oop+1
310                     if (oop != 0) {
311                         mustContain(mapFile.oopToObject, field, oop, false);

271                 } else {
272                     nextLine();
273                 }
274             }
275             return mapFile;
276         } catch (Throwable t) {
277             System.out.println("Error parsing line " + lineCount + ": " + line);
278             throw new RuntimeException(t);
279         } finally {
280             System.out.println("Parsed " + lineCount + " lines in " + fileName);
281             System.out.println("Found " + mapFile.heapObjectCount() + " heap objects ("
282                                + mapFile.stringCount + " strings)");
283             mapFile = null;
284             reader = null;
285             line = null;
286             lineCount = 0;
287         }
288     }
289 
290     private static void mustContain(HashMap<Long, HeapObject> allObjects, Field field, long pointer, boolean isNarrow) {
291         if (pointer != 0x0 && allObjects.get(pointer) == null) {
292             throw new RuntimeException((isNarrow ? "narrowOop" : "oop") + " pointer 0x" + Long.toHexString(pointer) +
293                                        " on line " + field.lineCount + " doesn't point to a valid heap object");
294         }
295     }
296 
297     // Check that each oop fields in the HeapObjects must point to a valid HeapObject.
298     public static void validate(MapFile mapFile) {
299         int count1 = 0;
300         int count2 = 0;
301         for (HeapObject heapObject : mapFile.heapObjects) {
302             if (heapObject.fields != null) {
303                 for (Field field : heapObject.fields) {
304                     HeapAddress referentAddress = field.referentAddress;
305                     long oop = referentAddress.oop;
306                     long narrowOop = referentAddress.narrowOop;
307                     // Is this test actually doing something?
308                     //     To see how an invalidate pointer may be found, change oop in the
309                     //     following line to oop+1
310                     if (oop != 0) {
311                         mustContain(mapFile.oopToObject, field, oop, false);
< prev index next >