annotate agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents a61af66fc99e
children b109e761e927
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
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.code;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 /** ScopeDescs contain the information that makes source-level
a61af66fc99e Initial load
duke
parents:
diff changeset
34 debugging of nmethods possible; each scopeDesc describes a method
a61af66fc99e Initial load
duke
parents:
diff changeset
35 activation */
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public class ScopeDesc {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 /** NMethod information */
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private NMethod code;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private Method method;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private int bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 /** Decoding offsets */
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private int decodeOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private int senderDecodeOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private int localsDecodeOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private int expressionsDecodeOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private int monitorsDecodeOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 public ScopeDesc(NMethod code, int decodeOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 this.code = code;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 this.decodeOffset = decodeOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Decode header
a61af66fc99e Initial load
duke
parents:
diff changeset
54 DebugInfoReadStream stream = streamAt(decodeOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 senderDecodeOffset = stream.readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
57 method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle());
a61af66fc99e Initial load
duke
parents:
diff changeset
58 bci = stream.readBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Decode offsets for body and sender
a61af66fc99e Initial load
duke
parents:
diff changeset
60 localsDecodeOffset = stream.readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
61 expressionsDecodeOffset = stream.readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
62 monitorsDecodeOffset = stream.readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 public NMethod getNMethod() { return code; }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public Method getMethod() { return method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 public int getBCI() { return bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 /** Returns a List<ScopeValue> */
a61af66fc99e Initial load
duke
parents:
diff changeset
70 public List getLocals() {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return decodeScopeValues(localsDecodeOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 /** Returns a List<ScopeValue> */
a61af66fc99e Initial load
duke
parents:
diff changeset
75 public List getExpressions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return decodeScopeValues(expressionsDecodeOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 /** Returns a List<MonitorValue> */
a61af66fc99e Initial load
duke
parents:
diff changeset
80 public List getMonitors() {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 return decodeMonitorValues(monitorsDecodeOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 /** Stack walking. Returns null if this is the outermost scope. */
a61af66fc99e Initial load
duke
parents:
diff changeset
85 public ScopeDesc sender() {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 if (isTop()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 return new ScopeDesc(code, senderDecodeOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 /** Returns where the scope was decoded */
a61af66fc99e Initial load
duke
parents:
diff changeset
94 public int getDecodeOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 return decodeOffset;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 /** Tells whether sender() returns null */
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public boolean isTop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 return (senderDecodeOffset == DebugInformationRecorder.SERIALIZED_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 public boolean equals(Object arg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (arg == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (!(arg instanceof ScopeDesc)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 ScopeDesc sd = (ScopeDesc) arg;
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 return (sd.method.equals(method) && (sd.bci == bci));
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 public void printValue() {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 printValueOn(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 public void printValueOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 tty.print("ScopeDesc for ");
a61af66fc99e Initial load
duke
parents:
diff changeset
123 method.printValueOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 tty.println(" @bci " + bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // FIXME: add more accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
131 //
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 private DebugInfoReadStream streamAt(int decodeOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 return new DebugInfoReadStream(code, decodeOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 /** Returns a List<ScopeValue> or null if no values were present */
a61af66fc99e Initial load
duke
parents:
diff changeset
138 private List decodeScopeValues(int decodeOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142 DebugInfoReadStream stream = streamAt(decodeOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 int length = stream.readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
144 List res = new ArrayList(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 for (int i = 0; i < length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 res.add(ScopeValue.readFrom(stream));
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 /** Returns a List&lt;MonitorValue&gt; or null if no values were present */
a61af66fc99e Initial load
duke
parents:
diff changeset
152 private List decodeMonitorValues(int decodeOffset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 DebugInfoReadStream stream = streamAt(decodeOffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 int length = stream.readInt();
a61af66fc99e Initial load
duke
parents:
diff changeset
158 List res = new ArrayList(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 for (int i = 0; i < length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 res.add(new MonitorValue(stream));
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }