author | kbarrett |
Tue, 21 Nov 2017 09:47:55 -0500 | |
changeset 48787 | 7638bf98a312 |
parent 47216 | 71c04702a3d5 |
child 54955 | 46409371a691 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
48787
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.utilities; |
|
26 |
||
27 |
import sun.jvm.hotspot.code.*; |
|
28 |
import sun.jvm.hotspot.debugger.*; |
|
30764 | 29 |
import sun.jvm.hotspot.gc.shared.*; |
1 | 30 |
import sun.jvm.hotspot.interpreter.*; |
31 |
import sun.jvm.hotspot.runtime.*; |
|
32 |
import sun.jvm.hotspot.memory.*; |
|
33 |
||
34 |
/** This class, only intended for use in the debugging system, |
|
35 |
provides the functionality of find() in the VM. */ |
|
36 |
||
37 |
public class PointerFinder { |
|
38 |
public static PointerLocation find(Address a) { |
|
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) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6418
diff
changeset
|
54 |
Assert.that(loc.gen != null, "Should have found this in a generation"); |
1 | 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(); |
|
80 |
if (interp.contains(a)) { |
|
81 |
loc.inInterpreter = true; |
|
82 |
loc.interpreterCodelet = interp.getCodeletContaining(a); |
|
83 |
return loc; |
|
84 |
} |
|
85 |
||
86 |
if (!VM.getVM().isCore()) { |
|
87 |
CodeCache c = VM.getVM().getCodeCache(); |
|
88 |
if (c.contains(a)) { |
|
89 |
loc.inCodeCache = true; |
|
90 |
loc.blob = c.findBlobUnsafe(a); |
|
91 |
if (Assert.ASSERTS_ENABLED) { |
|
92 |
Assert.that(loc.blob != null, "Should have found CodeBlob"); |
|
93 |
} |
|
6418 | 94 |
loc.inBlobCode = loc.blob.codeContains(a); |
95 |
loc.inBlobData = loc.blob.dataContains(a); |
|
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
96 |
|
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
97 |
if (loc.blob.isNMethod()) { |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
98 |
NMethod nm = (NMethod) loc.blob; |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
99 |
loc.inBlobOops = nm.oopsContains(a); |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
100 |
} |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
101 |
|
6418 | 102 |
loc.inBlobUnknownLocation = (!(loc.inBlobCode || |
1 | 103 |
loc.inBlobData || |
104 |
loc.inBlobOops)); |
|
105 |
return loc; |
|
106 |
} |
|
107 |
} |
|
108 |
||
109 |
// Check JNIHandles; both local and global |
|
110 |
JNIHandles handles = VM.getVM().getJNIHandles(); |
|
48787
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
111 |
|
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
112 |
// --- looking in oopstorage should model OopStorage::allocation_status? |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
113 |
// --- that is, if in a block but not allocated, then not valid. |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
114 |
|
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
115 |
// Look in global handles |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
116 |
OopStorage storage = handles.globalHandles(); |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
117 |
if ((storage != null) && storage.findOop(a)) { |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
118 |
loc.inStrongGlobalJNIHandles = true; |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
119 |
return loc; |
1 | 120 |
} |
48787
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
121 |
// Look in weak global handles |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
122 |
storage = handles.weakGlobalHandles(); |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
123 |
if ((storage != null) && storage.findOop(a)) { |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
124 |
loc.inWeakGlobalJNIHandles = true; |
1 | 125 |
return loc; |
48787
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
126 |
} |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
127 |
// Look in thread-local handles |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
128 |
for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) { |
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
129 |
JNIHandleBlock handleBlock = t.activeHandles(); |
1 | 130 |
if (handleBlock != null) { |
131 |
handleBlock = handleBlock.blockContainingHandle(a); |
|
132 |
if (handleBlock != null) { |
|
48787
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
133 |
loc.inLocalJNIHandleBlock = true; |
1 | 134 |
loc.handleBlock = handleBlock; |
48787
7638bf98a312
8194312: Support parallel and concurrent JNI global handle processing
kbarrett
parents:
47216
diff
changeset
|
135 |
loc.handleThread = t; |
1 | 136 |
return loc; |
137 |
} |
|
138 |
} |
|
139 |
} |
|
140 |
||
141 |
// Fall through; have to return it anyway. |
|
142 |
return loc; |
|
143 |
} |
|
144 |
} |