annotate src/share/vm/code/scopeDesc.cpp @ 30:65a06b4a51b8

6610906: inexplicable IncompatibleClassChangeError Summary: dependency check must treat polymorphic interfaces consistently Reviewed-by: kvn, never, sgoldman
author jrose
date Wed, 27 Feb 2008 00:23:37 -0800
parents a61af66fc99e
children 52fed2ec0afb
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 1997-2006 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 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_scopeDesc.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29 ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
30 _code = code;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 _decode_offset = decode_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 _objects = decode_object_values(obj_decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
33 decode_body();
a61af66fc99e Initial load
duke
parents:
diff changeset
34 }
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 _code = code;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 _decode_offset = decode_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 _objects = decode_object_values(DebugInformationRecorder::serialized_null);
a61af66fc99e Initial load
duke
parents:
diff changeset
40 decode_body();
a61af66fc99e Initial load
duke
parents:
diff changeset
41 }
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 ScopeDesc::ScopeDesc(const ScopeDesc* parent) {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 _code = parent->_code;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 _decode_offset = parent->_sender_decode_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _objects = parent->_objects;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 decode_body();
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 void ScopeDesc::decode_body() {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 if (decode_offset() == DebugInformationRecorder::serialized_null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // This is a sentinel record, which is only relevant to
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // approximate queries. Decode a reasonable frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
56 _sender_decode_offset = DebugInformationRecorder::serialized_null;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 _method = methodHandle(_code->method());
a61af66fc99e Initial load
duke
parents:
diff changeset
58 _bci = InvocationEntryBci;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 _locals_decode_offset = DebugInformationRecorder::serialized_null;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 _expressions_decode_offset = DebugInformationRecorder::serialized_null;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 _monitors_decode_offset = DebugInformationRecorder::serialized_null;
a61af66fc99e Initial load
duke
parents:
diff changeset
62 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // decode header
a61af66fc99e Initial load
duke
parents:
diff changeset
64 DebugInfoReadStream* stream = stream_at(decode_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _sender_decode_offset = stream->read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _method = methodHandle((methodOop) stream->read_oop());
a61af66fc99e Initial load
duke
parents:
diff changeset
68 _bci = stream->read_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // decode offsets for body and sender
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _locals_decode_offset = stream->read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
71 _expressions_decode_offset = stream->read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _monitors_decode_offset = stream->read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 GrowableArray<ScopeValue*>* ScopeDesc::decode_scope_values(int decode_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 DebugInfoReadStream* stream = stream_at(decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 int length = stream->read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*> (length);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 for (int index = 0; index < length; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 result->push(ScopeValue::read_from(stream));
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 GrowableArray<ScopeValue*>* ScopeDesc::decode_object_values(int decode_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*>();
a61af66fc99e Initial load
duke
parents:
diff changeset
91 DebugInfoReadStream* stream = new DebugInfoReadStream(_code, decode_offset, result);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 int length = stream->read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 for (int index = 0; index < length; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 result->push(ScopeValue::read_from(stream));
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 assert(result->length() == length, "inconsistent debug information");
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 GrowableArray<MonitorValue*>* ScopeDesc::decode_monitor_values(int decode_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 DebugInfoReadStream* stream = stream_at(decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 int length = stream->read_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
105 GrowableArray<MonitorValue*>* result = new GrowableArray<MonitorValue*> (length);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 for (int index = 0; index < length; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 result->push(new MonitorValue(stream));
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 DebugInfoReadStream* ScopeDesc::stream_at(int decode_offset) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 return new DebugInfoReadStream(_code, decode_offset, _objects);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 GrowableArray<ScopeValue*>* ScopeDesc::locals() {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 return decode_scope_values(_locals_decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 GrowableArray<ScopeValue*>* ScopeDesc::expressions() {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 return decode_scope_values(_expressions_decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 GrowableArray<MonitorValue*>* ScopeDesc::monitors() {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 return decode_monitor_values(_monitors_decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 GrowableArray<ScopeValue*>* ScopeDesc::objects() {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 return _objects;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 bool ScopeDesc::is_top() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 return _sender_decode_offset == DebugInformationRecorder::serialized_null;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 ScopeDesc* ScopeDesc::sender() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if (is_top()) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 return new ScopeDesc(this);
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 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 void ScopeDesc::print_value_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
146 method()()->print_short_name(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 int lineno = method()->line_number_from_bci(bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
148 if (lineno != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 st->print_cr("@%d (line %d)", bci(), lineno);
a61af66fc99e Initial load
duke
parents:
diff changeset
150 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 st->print_cr("@%d", bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 void ScopeDesc::print_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 print_on(st, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // header
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if (pd != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 tty->print_cr("ScopeDesc(pc=" PTR_FORMAT " offset=%x):", pd->real_pc(_code), pd->pc_offset());
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 print_value_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // decode offsets
a61af66fc99e Initial load
duke
parents:
diff changeset
167 if (WizardMode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 st->print("ScopeDesc[%d]@" PTR_FORMAT " ", _decode_offset, _code->instructions_begin());
a61af66fc99e Initial load
duke
parents:
diff changeset
169 st->print_cr(" offset: %d", _decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
170 st->print_cr(" bci: %d", bci());
a61af66fc99e Initial load
duke
parents:
diff changeset
171 st->print_cr(" locals: %d", _locals_decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 st->print_cr(" stack: %d", _expressions_decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 st->print_cr(" monitor: %d", _monitors_decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 st->print_cr(" sender: %d", _sender_decode_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // locals
a61af66fc99e Initial load
duke
parents:
diff changeset
177 { GrowableArray<ScopeValue*>* l = ((ScopeDesc*) this)->locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
178 if (l != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 tty->print_cr(" Locals");
a61af66fc99e Initial load
duke
parents:
diff changeset
180 for (int index = 0; index < l->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 st->print(" - l%d: ", index);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 l->at(index)->print_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // expressions
a61af66fc99e Initial load
duke
parents:
diff changeset
188 { GrowableArray<ScopeValue*>* l = ((ScopeDesc*) this)->expressions();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if (l != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 st->print_cr(" Expression stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
191 for (int index = 0; index < l->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 st->print(" - @%d: ", index);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 l->at(index)->print_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // monitors
a61af66fc99e Initial load
duke
parents:
diff changeset
199 { GrowableArray<MonitorValue*>* l = ((ScopeDesc*) this)->monitors();
a61af66fc99e Initial load
duke
parents:
diff changeset
200 if (l != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 st->print_cr(" Monitor stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
202 for (int index = 0; index < l->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 st->print(" - @%d: ", index);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 l->at(index)->print_on(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 #ifdef COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
211 if (DoEscapeAnalysis && is_top() && _objects != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 tty->print_cr("Objects");
a61af66fc99e Initial load
duke
parents:
diff changeset
213 for (int i = 0; i < _objects->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
214 ObjectValue* sv = (ObjectValue*) _objects->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 tty->print(" - %d: ", sv->id());
a61af66fc99e Initial load
duke
parents:
diff changeset
216 sv->print_fields_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 #endif // COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
221 }
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
224
a61af66fc99e Initial load
duke
parents:
diff changeset
225 void ScopeDesc::verify() {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 guarantee(method()->is_method(), "type check");
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // check if we have any illegal elements on the expression stack
a61af66fc99e Initial load
duke
parents:
diff changeset
230 { GrowableArray<ScopeValue*>* l = expressions();
a61af66fc99e Initial load
duke
parents:
diff changeset
231 if (l != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 for (int index = 0; index < l->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 //guarantee(!l->at(index)->is_illegal(), "expression element cannot be illegal");
a61af66fc99e Initial load
duke
parents:
diff changeset
234 }
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }