author | twisti |
Thu, 20 May 2010 06:34:23 -0700 | |
changeset 5686 | 5435e77aa3df |
parent 1 | 489c9b5090e2 |
child 5702 | 201c5cde25bb |
permissions | -rw-r--r-- |
1 | 1 |
/* |
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
2 |
* Copyright 2000-2010 Sun Microsystems, Inc. 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 |
* |
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 |
* have any questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.utilities; |
|
26 |
||
27 |
import sun.jvm.hotspot.code.*; |
|
28 |
import sun.jvm.hotspot.debugger.*; |
|
29 |
import sun.jvm.hotspot.gc_interface.*; |
|
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 (loc.gen == null) { |
|
54 |
// Should be in perm gen |
|
55 |
Generation permGen = genheap.permGen(); |
|
56 |
if (Assert.ASSERTS_ENABLED) { |
|
57 |
Assert.that(permGen.isIn(a), "should have been in ordinary or perm gens if it's in the heap"); |
|
58 |
} |
|
59 |
loc.permGen = permGen; |
|
60 |
} |
|
61 |
||
62 |
if (VM.getVM().getUseTLAB()) { |
|
63 |
// Try to find thread containing it |
|
64 |
for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) { |
|
65 |
ThreadLocalAllocBuffer tlab = t.tlab(); |
|
66 |
if (tlab.contains(a)) { |
|
67 |
loc.inTLAB = true; |
|
68 |
loc.tlabThread = t; |
|
69 |
loc.tlab = tlab; |
|
70 |
break; |
|
71 |
} |
|
72 |
} |
|
73 |
} |
|
74 |
||
75 |
return loc; |
|
76 |
} |
|
77 |
} else { |
|
78 |
if (heap.isIn(a)) { |
|
79 |
loc.heap = heap; |
|
80 |
return loc; |
|
81 |
} |
|
82 |
} |
|
83 |
||
84 |
Interpreter interp = VM.getVM().getInterpreter(); |
|
85 |
if (interp.contains(a)) { |
|
86 |
loc.inInterpreter = true; |
|
87 |
loc.interpreterCodelet = interp.getCodeletContaining(a); |
|
88 |
return loc; |
|
89 |
} |
|
90 |
||
91 |
if (!VM.getVM().isCore()) { |
|
92 |
CodeCache c = VM.getVM().getCodeCache(); |
|
93 |
if (c.contains(a)) { |
|
94 |
loc.inCodeCache = true; |
|
95 |
loc.blob = c.findBlobUnsafe(a); |
|
96 |
if (Assert.ASSERTS_ENABLED) { |
|
97 |
Assert.that(loc.blob != null, "Should have found CodeBlob"); |
|
98 |
} |
|
99 |
loc.inBlobInstructions = loc.blob.instructionsContains(a); |
|
100 |
loc.inBlobData = loc.blob.dataContains(a); |
|
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
101 |
|
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
102 |
if (loc.blob.isNMethod()) { |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
103 |
NMethod nm = (NMethod) loc.blob; |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
104 |
loc.inBlobOops = nm.oopsContains(a); |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
105 |
} |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
106 |
|
1 | 107 |
loc.inBlobUnknownLocation = (!(loc.inBlobInstructions || |
108 |
loc.inBlobData || |
|
109 |
loc.inBlobOops)); |
|
110 |
return loc; |
|
111 |
} |
|
112 |
} |
|
113 |
||
114 |
// Check JNIHandles; both local and global |
|
115 |
JNIHandles handles = VM.getVM().getJNIHandles(); |
|
116 |
JNIHandleBlock handleBlock = handles.globalHandles(); |
|
117 |
if (handleBlock != null) { |
|
118 |
handleBlock = handleBlock.blockContainingHandle(a); |
|
119 |
} |
|
120 |
if (handleBlock != null) { |
|
121 |
loc.inStrongGlobalJNIHandleBlock = true; |
|
122 |
loc.handleBlock = handleBlock; |
|
123 |
return loc; |
|
124 |
} else { |
|
125 |
handleBlock = handles.weakGlobalHandles(); |
|
126 |
if (handleBlock != null) { |
|
127 |
handleBlock = handleBlock.blockContainingHandle(a); |
|
128 |
if (handleBlock != null) { |
|
129 |
loc.inWeakGlobalJNIHandleBlock = true; |
|
130 |
loc.handleBlock = handleBlock; |
|
131 |
return loc; |
|
132 |
} else { |
|
133 |
// Look in thread-local handles |
|
134 |
for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) { |
|
135 |
handleBlock = t.activeHandles(); |
|
136 |
if (handleBlock != null) { |
|
137 |
handleBlock = handleBlock.blockContainingHandle(a); |
|
138 |
if (handleBlock != null) { |
|
139 |
loc.inLocalJNIHandleBlock = true; |
|
140 |
loc.handleBlock = handleBlock; |
|
141 |
loc.handleThread = t; |
|
142 |
return loc; |
|
143 |
} |
|
144 |
} |
|
145 |
} |
|
146 |
} |
|
147 |
} |
|
148 |
} |
|
149 |
||
150 |
||
151 |
// Fall through; have to return it anyway. |
|
152 |
return loc; |
|
153 |
} |
|
154 |
} |