src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java
changeset 48787 7638bf98a312
parent 47216 71c04702a3d5
child 54955 46409371a691
equal deleted inserted replaced
48786:cc231bd80c8b 48787:7638bf98a312
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   106       }
   106       }
   107     }
   107     }
   108 
   108 
   109     // Check JNIHandles; both local and global
   109     // Check JNIHandles; both local and global
   110     JNIHandles handles = VM.getVM().getJNIHandles();
   110     JNIHandles handles = VM.getVM().getJNIHandles();
   111     JNIHandleBlock handleBlock = handles.globalHandles();
   111 
   112     if (handleBlock != null) {
   112     // --- looking in oopstorage should model OopStorage::allocation_status?
   113       handleBlock = handleBlock.blockContainingHandle(a);
   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;
   114     }
   120     }
   115     if (handleBlock != null) {
   121     // Look in weak global handles
   116       loc.inStrongGlobalJNIHandleBlock = true;
   122     storage = handles.weakGlobalHandles();
   117       loc.handleBlock = handleBlock;
   123     if ((storage != null) && storage.findOop(a)) {
       
   124       loc.inWeakGlobalJNIHandles = true;
   118       return loc;
   125       return loc;
   119     } else {
   126     }
   120       handleBlock = handles.weakGlobalHandles();
   127     // Look in thread-local handles
       
   128     for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) {
       
   129       JNIHandleBlock handleBlock = t.activeHandles();
   121       if (handleBlock != null) {
   130       if (handleBlock != null) {
   122         handleBlock = handleBlock.blockContainingHandle(a);
   131         handleBlock = handleBlock.blockContainingHandle(a);
   123         if (handleBlock != null) {
   132         if (handleBlock != null) {
   124           loc.inWeakGlobalJNIHandleBlock = true;
   133           loc.inLocalJNIHandleBlock = true;
   125           loc.handleBlock = handleBlock;
   134           loc.handleBlock = handleBlock;
       
   135           loc.handleThread = t;
   126           return loc;
   136           return loc;
   127         } else {
       
   128           // Look in thread-local handles
       
   129           for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) {
       
   130             handleBlock = t.activeHandles();
       
   131             if (handleBlock != null) {
       
   132               handleBlock = handleBlock.blockContainingHandle(a);
       
   133               if (handleBlock != null) {
       
   134                 loc.inLocalJNIHandleBlock = true;
       
   135                 loc.handleBlock = handleBlock;
       
   136                 loc.handleThread = t;
       
   137                 return loc;
       
   138               }
       
   139             }
       
   140           }
       
   141         }
   137         }
   142       }
   138       }
   143     }
   139     }
   144 
       
   145 
   140 
   146     // Fall through; have to return it anyway.
   141     // Fall through; have to return it anyway.
   147     return loc;
   142     return loc;
   148   }
   143   }
   149 }
   144 }