< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java

Print this page
rev 54717 : imported patch 8223306


  39     PointerLocation loc = new PointerLocation(a);
  40 
  41     CollectedHeap heap = VM.getVM().getUniverse().heap();
  42     if (heap instanceof GenCollectedHeap) {
  43       GenCollectedHeap genheap = (GenCollectedHeap) heap;
  44       if (genheap.isIn(a)) {
  45         for (int i = 0; i < genheap.nGens(); i++) {
  46           Generation g = genheap.getGen(i);
  47           if (g.isIn(a)) {
  48             loc.gen = g;
  49             break;
  50           }
  51         }
  52 
  53           if (Assert.ASSERTS_ENABLED) {
  54           Assert.that(loc.gen != null, "Should have found this in a generation");
  55         }
  56 
  57         if (VM.getVM().getUseTLAB()) {
  58           // Try to find thread containing it
  59           for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) {


  60             ThreadLocalAllocBuffer tlab = t.tlab();
  61             if (tlab.contains(a)) {
  62               loc.inTLAB = true;
  63               loc.tlabThread = t;
  64               loc.tlab = tlab;
  65               break;
  66             }
  67           }
  68         }
  69 
  70         return loc;
  71       }
  72     } else {
  73       if (heap.isIn(a)) {
  74         loc.heap = heap;
  75         return loc;
  76       }
  77     }
  78 
  79     Interpreter interp = VM.getVM().getInterpreter();


 108 
 109     // Check JNIHandles; both local and global
 110     JNIHandles handles = VM.getVM().getJNIHandles();
 111 
 112     // --- looking in oopstorage should model OopStorage::allocation_status?
 113     // --- that is, if in a block but not allocated, then not valid.
 114 
 115     // Look in global handles
 116     OopStorage storage = handles.globalHandles();
 117     if ((storage != null) && storage.findOop(a)) {
 118       loc.inStrongGlobalJNIHandles = true;
 119       return loc;
 120     }
 121     // Look in weak global handles
 122     storage = handles.weakGlobalHandles();
 123     if ((storage != null) && storage.findOop(a)) {
 124       loc.inWeakGlobalJNIHandles = true;
 125       return loc;
 126     }
 127     // Look in thread-local handles
 128     for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) {


 129       JNIHandleBlock handleBlock = t.activeHandles();
 130       if (handleBlock != null) {
 131         handleBlock = handleBlock.blockContainingHandle(a);
 132         if (handleBlock != null) {
 133           loc.inLocalJNIHandleBlock = true;
 134           loc.handleBlock = handleBlock;
 135           loc.handleThread = t;
 136           return loc;
 137         }
 138       }
 139     }
 140 
 141     // Fall through; have to return it anyway.
 142     return loc;
 143   }
 144 }


  39     PointerLocation loc = new PointerLocation(a);
  40 
  41     CollectedHeap heap = VM.getVM().getUniverse().heap();
  42     if (heap instanceof GenCollectedHeap) {
  43       GenCollectedHeap genheap = (GenCollectedHeap) heap;
  44       if (genheap.isIn(a)) {
  45         for (int i = 0; i < genheap.nGens(); i++) {
  46           Generation g = genheap.getGen(i);
  47           if (g.isIn(a)) {
  48             loc.gen = g;
  49             break;
  50           }
  51         }
  52 
  53           if (Assert.ASSERTS_ENABLED) {
  54           Assert.that(loc.gen != null, "Should have found this in a generation");
  55         }
  56 
  57         if (VM.getVM().getUseTLAB()) {
  58           // Try to find thread containing it
  59           Threads threads = VM.getVM().getThreads();
  60           for (int i = 0; i < threads.getNumberOfThreads(); i++) {
  61             JavaThread t = threads.getJavaThreadAt(i);
  62             ThreadLocalAllocBuffer tlab = t.tlab();
  63             if (tlab.contains(a)) {
  64               loc.inTLAB = true;
  65               loc.tlabThread = t;
  66               loc.tlab = tlab;
  67               break;
  68             }
  69           }
  70         }
  71 
  72         return loc;
  73       }
  74     } else {
  75       if (heap.isIn(a)) {
  76         loc.heap = heap;
  77         return loc;
  78       }
  79     }
  80 
  81     Interpreter interp = VM.getVM().getInterpreter();


 110 
 111     // Check JNIHandles; both local and global
 112     JNIHandles handles = VM.getVM().getJNIHandles();
 113 
 114     // --- looking in oopstorage should model OopStorage::allocation_status?
 115     // --- that is, if in a block but not allocated, then not valid.
 116 
 117     // Look in global handles
 118     OopStorage storage = handles.globalHandles();
 119     if ((storage != null) && storage.findOop(a)) {
 120       loc.inStrongGlobalJNIHandles = true;
 121       return loc;
 122     }
 123     // Look in weak global handles
 124     storage = handles.weakGlobalHandles();
 125     if ((storage != null) && storage.findOop(a)) {
 126       loc.inWeakGlobalJNIHandles = true;
 127       return loc;
 128     }
 129     // Look in thread-local handles
 130     Threads threads = VM.getVM().getThreads();
 131     for (int i = 0; i < threads.getNumberOfThreads(); i++) {
 132       JavaThread t = threads.getJavaThreadAt(i);
 133       JNIHandleBlock handleBlock = t.activeHandles();
 134       if (handleBlock != null) {
 135         handleBlock = handleBlock.blockContainingHandle(a);
 136         if (handleBlock != null) {
 137           loc.inLocalJNIHandleBlock = true;
 138           loc.handleBlock = handleBlock;
 139           loc.handleThread = t;
 140           return loc;
 141         }
 142       }
 143     }
 144 
 145     // Fall through; have to return it anyway.
 146     return loc;
 147   }
 148 }
< prev index next >