annotate agent/src/share/classes/sun/jvm/hotspot/utilities/PointerFinder.java @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 3e8fbc61cee8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1748
diff changeset
2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.utilities;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import sun.jvm.hotspot.code.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.gc_interface.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.interpreter.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.memory.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 /** This class, only intended for use in the debugging system,
a61af66fc99e Initial load
duke
parents:
diff changeset
35 provides the functionality of find() in the VM. */
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public class PointerFinder {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 public static PointerLocation find(Address a) {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 PointerLocation loc = new PointerLocation(a);
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 CollectedHeap heap = VM.getVM().getUniverse().heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
42 if (heap instanceof GenCollectedHeap) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 GenCollectedHeap genheap = (GenCollectedHeap) heap;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 if (genheap.isIn(a)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 for (int i = 0; i < genheap.nGens(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 Generation g = genheap.getGen(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 if (g.isIn(a)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 loc.gen = g;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 if (Assert.ASSERTS_ENABLED) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1748
diff changeset
54 Assert.that(loc.gen != null, "Should have found this in a generation");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 if (VM.getVM().getUseTLAB()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // Try to find thread containing it
a61af66fc99e Initial load
duke
parents:
diff changeset
59 for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 ThreadLocalAllocBuffer tlab = t.tlab();
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if (tlab.contains(a)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 loc.inTLAB = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 loc.tlabThread = t;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 loc.tlab = tlab;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 return loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 if (heap.isIn(a)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 loc.heap = heap;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 return loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 Interpreter interp = VM.getVM().getInterpreter();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 if (interp.contains(a)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 loc.inInterpreter = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 loc.interpreterCodelet = interp.getCodeletContaining(a);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 return loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 if (!VM.getVM().isCore()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 CodeCache c = VM.getVM().getCodeCache();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 if (c.contains(a)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 loc.inCodeCache = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 loc.blob = c.findBlobUnsafe(a);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 Assert.that(loc.blob != null, "Should have found CodeBlob");
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1579
diff changeset
94 loc.inBlobCode = loc.blob.codeContains(a);
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1579
diff changeset
95 loc.inBlobData = loc.blob.dataContains(a);
1563
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 0
diff changeset
96
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 0
diff changeset
97 if (loc.blob.isNMethod()) {
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 0
diff changeset
98 NMethod nm = (NMethod) loc.blob;
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 0
diff changeset
99 loc.inBlobOops = nm.oopsContains(a);
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 0
diff changeset
100 }
1a5913bf5e19 6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents: 0
diff changeset
101
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1579
diff changeset
102 loc.inBlobUnknownLocation = (!(loc.inBlobCode ||
0
a61af66fc99e Initial load
duke
parents:
diff changeset
103 loc.inBlobData ||
a61af66fc99e Initial load
duke
parents:
diff changeset
104 loc.inBlobOops));
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Check JNIHandles; both local and global
a61af66fc99e Initial load
duke
parents:
diff changeset
110 JNIHandles handles = VM.getVM().getJNIHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
111 JNIHandleBlock handleBlock = handles.globalHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (handleBlock != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 handleBlock = handleBlock.blockContainingHandle(a);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if (handleBlock != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 loc.inStrongGlobalJNIHandleBlock = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 loc.handleBlock = handleBlock;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 handleBlock = handles.weakGlobalHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
121 if (handleBlock != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 handleBlock = handleBlock.blockContainingHandle(a);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 if (handleBlock != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 loc.inWeakGlobalJNIHandleBlock = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 loc.handleBlock = handleBlock;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 return loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Look in thread-local handles
a61af66fc99e Initial load
duke
parents:
diff changeset
129 for (JavaThread t = VM.getVM().getThreads().first(); t != null; t = t.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 handleBlock = t.activeHandles();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (handleBlock != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 handleBlock = handleBlock.blockContainingHandle(a);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 if (handleBlock != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 loc.inLocalJNIHandleBlock = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 loc.handleBlock = handleBlock;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 loc.handleThread = t;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 return loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // Fall through; have to return it anyway.
a61af66fc99e Initial load
duke
parents:
diff changeset
147 return loc;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }