annotate agent/src/share/classes/sun/jvm/hotspot/runtime/JavaVFrame.java @ 1552:c18cbe5936b8

6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
author trims
date Thu, 27 May 2010 19:08:38 -0700
parents a61af66fc99e
children 7588156f5cf9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2000, 2007, 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.runtime;
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 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 public abstract class JavaVFrame extends VFrame {
a61af66fc99e Initial load
duke
parents:
diff changeset
33 /** JVM state */
a61af66fc99e Initial load
duke
parents:
diff changeset
34 public abstract Method getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
35 public abstract int getBCI();
a61af66fc99e Initial load
duke
parents:
diff changeset
36 public abstract StackValueCollection getLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public abstract StackValueCollection getExpressions();
a61af66fc99e Initial load
duke
parents:
diff changeset
38 public abstract List getMonitors(); // List<MonitorInfo>
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 /** Test operation */
a61af66fc99e Initial load
duke
parents:
diff changeset
41 public boolean isJavaFrame() { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 /** Package-internal constructor */
a61af66fc99e Initial load
duke
parents:
diff changeset
44 JavaVFrame(Frame fr, RegisterMap regMap, JavaThread thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 super(fr, regMap, thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 /** Get monitor (if any) that this JavaVFrame is trying to enter */
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // FIXME: not yet implemented
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // public Address getPendingMonitor(int frameCount);
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 /** Printing used during stack dumps */
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // FIXME: not yet implemented
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // void print_lock_info(int frame_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 /** Printing operations */
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 //
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // FIXME: implement visitor pattern for traversing vframe contents?
a61af66fc99e Initial load
duke
parents:
diff changeset
60 //
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 public void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 printOn(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public void printOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 super.printOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 tty.print("\t");
a61af66fc99e Initial load
duke
parents:
diff changeset
70 getMethod().printValueOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 tty.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 tty.println("\tbci:\t" + getBCI());
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 printStackValuesOn(tty, "locals", getLocals());
a61af66fc99e Initial load
duke
parents:
diff changeset
75 printStackValuesOn(tty, "expressions", getExpressions());
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // List<MonitorInfo>
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // FIXME: not yet implemented
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // List list = getMonitors();
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // if (list.isEmpty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // return;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // for (int index = 0; index < list.size(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // MonitorInfo monitor = (MonitorInfo) list.get(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // tty.print("\t obj\t");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // monitor.getOwner().printValueOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // tty.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // tty.print("\t ");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // monitor.lock().printOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // tty.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 public void printActivation(int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 printActivationOn(System.out, index);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 public void printActivationOn(PrintStream tty, int index) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // frame number and method
a61af66fc99e Initial load
duke
parents:
diff changeset
100 tty.print(index + " - ");
a61af66fc99e Initial load
duke
parents:
diff changeset
101 printValueOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 tty.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (VM.getVM().wizardMode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 printOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 tty.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 /** Verification operations */
a61af66fc99e Initial load
duke
parents:
diff changeset
111 public void verify() {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 public boolean equals(Object o) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if (o == null || !(o instanceof JavaVFrame)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 JavaVFrame other = (JavaVFrame) o;
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // Check static part
a61af66fc99e Initial load
duke
parents:
diff changeset
122 if (!getMethod().equals(other.getMethod())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 if (getBCI() != other.getBCI()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // dynamic part - we just compare the frame pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (! getFrame().getFP().equals(other.getFrame().getFP())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public int hashCode() {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 return getMethod().hashCode() ^ getBCI() ^ getFrame().getFP().hashCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 /** Structural compare */
a61af66fc99e Initial load
duke
parents:
diff changeset
142 public boolean structuralCompare(JavaVFrame other) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // Check static part
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (!getMethod().equals(other.getMethod())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 if (getBCI() != other.getBCI()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // Check locals
a61af66fc99e Initial load
duke
parents:
diff changeset
153 StackValueCollection locs = getLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
154 StackValueCollection otherLocs = other.getLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
155 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 Assert.that(locs.size() == otherLocs.size(), "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 for (int i = 0; i < locs.size(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // it might happen the compiler reports a conflict and
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // the interpreter reports a bogus int.
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if ( isCompiledFrame() && (locs.get(i)).getType() == BasicType.getTConflict()) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (other.isCompiledFrame() && (otherLocs.get(i)).getType() == BasicType.getTConflict()) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 if (!locs.get(i).equals(otherLocs.get(i))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Check expressions
a61af66fc99e Initial load
duke
parents:
diff changeset
170 StackValueCollection exprs = getExpressions();
a61af66fc99e Initial load
duke
parents:
diff changeset
171 StackValueCollection otherExprs = other.getExpressions();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 Assert.that(exprs.size() == otherExprs.size(), "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 for (int i = 0; i < exprs.size(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (!exprs.get(i).equals(otherExprs.get(i))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 //--------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
186 //
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 private void printStackValuesOn(PrintStream tty, String title, StackValueCollection values) {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if (values.isEmpty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 tty.println("\t" + title + ":");
a61af66fc99e Initial load
duke
parents:
diff changeset
193 for (int index = 0; index < values.size(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 tty.print("\t" + index + "\t");
a61af66fc99e Initial load
duke
parents:
diff changeset
195 values.get(index).printOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
196 tty.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }