Mercurial > hg > truffle
annotate src/share/vm/code/scopeDesc.cpp @ 5073:2db1ad9dd385
rename PiNode.value to PiNode.object and UnsafeCastNode.x to UnsafeCastNode.object
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Wed, 14 Mar 2012 16:57:18 +0100 |
parents | 5857923e563c |
children | e522a00b91aa |
rev | line source |
---|---|
0 | 1 /* |
1748 | 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1253
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1253
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:
1253
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "code/debugInfoRec.hpp" | |
27 #include "code/pcDesc.hpp" | |
28 #include "code/scopeDesc.hpp" | |
29 #include "memory/resourceArea.hpp" | |
30 #include "oops/oop.inline.hpp" | |
31 #include "runtime/handles.inline.hpp" | |
0 | 32 |
33 | |
3018
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
1972
diff
changeset
|
34 ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) { |
0 | 35 _code = code; |
36 _decode_offset = decode_offset; | |
37 _objects = decode_object_values(obj_decode_offset); | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
900
diff
changeset
|
38 _reexecute = reexecute; |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
931
diff
changeset
|
39 _return_oop = return_oop; |
3018
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
1972
diff
changeset
|
40 _rethrow_exception = rethrow_exception; |
0 | 41 decode_body(); |
42 } | |
43 | |
3018
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
1972
diff
changeset
|
44 ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) { |
0 | 45 _code = code; |
46 _decode_offset = decode_offset; | |
47 _objects = decode_object_values(DebugInformationRecorder::serialized_null); | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
900
diff
changeset
|
48 _reexecute = reexecute; |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
931
diff
changeset
|
49 _return_oop = return_oop; |
3018
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
1972
diff
changeset
|
50 _rethrow_exception = rethrow_exception; |
0 | 51 decode_body(); |
52 } | |
53 | |
54 | |
55 ScopeDesc::ScopeDesc(const ScopeDesc* parent) { | |
56 _code = parent->_code; | |
57 _decode_offset = parent->_sender_decode_offset; | |
58 _objects = parent->_objects; | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
900
diff
changeset
|
59 _reexecute = false; //reexecute only applies to the first scope |
3018
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
1972
diff
changeset
|
60 _rethrow_exception = false; |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
931
diff
changeset
|
61 _return_oop = false; |
0 | 62 decode_body(); |
63 } | |
64 | |
65 | |
66 void ScopeDesc::decode_body() { | |
67 if (decode_offset() == DebugInformationRecorder::serialized_null) { | |
68 // This is a sentinel record, which is only relevant to | |
69 // approximate queries. Decode a reasonable frame. | |
70 _sender_decode_offset = DebugInformationRecorder::serialized_null; | |
71 _method = methodHandle(_code->method()); | |
72 _bci = InvocationEntryBci; | |
73 _locals_decode_offset = DebugInformationRecorder::serialized_null; | |
74 _expressions_decode_offset = DebugInformationRecorder::serialized_null; | |
75 _monitors_decode_offset = DebugInformationRecorder::serialized_null; | |
76 } else { | |
77 // decode header | |
78 DebugInfoReadStream* stream = stream_at(decode_offset()); | |
79 | |
80 _sender_decode_offset = stream->read_int(); | |
81 _method = methodHandle((methodOop) stream->read_oop()); | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
900
diff
changeset
|
82 _bci = stream->read_bci(); |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
196
diff
changeset
|
83 |
0 | 84 // decode offsets for body and sender |
85 _locals_decode_offset = stream->read_int(); | |
86 _expressions_decode_offset = stream->read_int(); | |
87 _monitors_decode_offset = stream->read_int(); | |
88 } | |
89 } | |
90 | |
91 | |
92 GrowableArray<ScopeValue*>* ScopeDesc::decode_scope_values(int decode_offset) { | |
93 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; | |
94 DebugInfoReadStream* stream = stream_at(decode_offset); | |
95 int length = stream->read_int(); | |
96 GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*> (length); | |
97 for (int index = 0; index < length; index++) { | |
98 result->push(ScopeValue::read_from(stream)); | |
99 } | |
100 return result; | |
101 } | |
102 | |
103 GrowableArray<ScopeValue*>* ScopeDesc::decode_object_values(int decode_offset) { | |
104 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; | |
105 GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*>(); | |
106 DebugInfoReadStream* stream = new DebugInfoReadStream(_code, decode_offset, result); | |
107 int length = stream->read_int(); | |
108 for (int index = 0; index < length; index++) { | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
109 // Objects values are pushed to 'result' array during read so that |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
110 // object's fields could reference it (OBJECT_ID_CODE). |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
111 (void)ScopeValue::read_from(stream); |
0 | 112 } |
113 assert(result->length() == length, "inconsistent debug information"); | |
114 return result; | |
115 } | |
116 | |
117 | |
118 GrowableArray<MonitorValue*>* ScopeDesc::decode_monitor_values(int decode_offset) { | |
119 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; | |
120 DebugInfoReadStream* stream = stream_at(decode_offset); | |
121 int length = stream->read_int(); | |
122 GrowableArray<MonitorValue*>* result = new GrowableArray<MonitorValue*> (length); | |
123 for (int index = 0; index < length; index++) { | |
124 result->push(new MonitorValue(stream)); | |
125 } | |
126 return result; | |
127 } | |
128 | |
129 DebugInfoReadStream* ScopeDesc::stream_at(int decode_offset) const { | |
130 return new DebugInfoReadStream(_code, decode_offset, _objects); | |
131 } | |
132 | |
133 GrowableArray<ScopeValue*>* ScopeDesc::locals() { | |
134 return decode_scope_values(_locals_decode_offset); | |
135 } | |
136 | |
137 GrowableArray<ScopeValue*>* ScopeDesc::expressions() { | |
138 return decode_scope_values(_expressions_decode_offset); | |
139 } | |
140 | |
141 GrowableArray<MonitorValue*>* ScopeDesc::monitors() { | |
142 return decode_monitor_values(_monitors_decode_offset); | |
143 } | |
144 | |
145 GrowableArray<ScopeValue*>* ScopeDesc::objects() { | |
146 return _objects; | |
147 } | |
148 | |
149 bool ScopeDesc::is_top() const { | |
150 return _sender_decode_offset == DebugInformationRecorder::serialized_null; | |
151 } | |
152 | |
153 ScopeDesc* ScopeDesc::sender() const { | |
154 if (is_top()) return NULL; | |
155 return new ScopeDesc(this); | |
156 } | |
157 | |
158 | |
159 #ifndef PRODUCT | |
160 | |
161 void ScopeDesc::print_value_on(outputStream* st) const { | |
162 tty->print(" "); | |
163 method()()->print_short_name(st); | |
164 int lineno = method()->line_number_from_bci(bci()); | |
165 if (lineno != -1) { | |
166 st->print_cr("@%d (line %d)", bci(), lineno); | |
167 } else { | |
168 st->print_cr("@%d", bci()); | |
169 } | |
170 } | |
171 | |
172 void ScopeDesc::print_on(outputStream* st) const { | |
173 print_on(st, NULL); | |
174 } | |
175 | |
176 void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const { | |
177 // header | |
178 if (pd != NULL) { | |
179 tty->print_cr("ScopeDesc(pc=" PTR_FORMAT " offset=%x):", pd->real_pc(_code), pd->pc_offset()); | |
180 } | |
181 | |
182 print_value_on(st); | |
183 // decode offsets | |
184 if (WizardMode) { | |
1748 | 185 st->print("ScopeDesc[%d]@" PTR_FORMAT " ", _decode_offset, _code->content_begin()); |
0 | 186 st->print_cr(" offset: %d", _decode_offset); |
187 st->print_cr(" bci: %d", bci()); | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
196
diff
changeset
|
188 st->print_cr(" reexecute: %s", should_reexecute() ? "true" : "false"); |
0 | 189 st->print_cr(" locals: %d", _locals_decode_offset); |
190 st->print_cr(" stack: %d", _expressions_decode_offset); | |
191 st->print_cr(" monitor: %d", _monitors_decode_offset); | |
192 st->print_cr(" sender: %d", _sender_decode_offset); | |
193 } | |
194 // locals | |
195 { GrowableArray<ScopeValue*>* l = ((ScopeDesc*) this)->locals(); | |
196 if (l != NULL) { | |
197 tty->print_cr(" Locals"); | |
198 for (int index = 0; index < l->length(); index++) { | |
199 st->print(" - l%d: ", index); | |
200 l->at(index)->print_on(st); | |
201 st->cr(); | |
202 } | |
203 } | |
204 } | |
205 // expressions | |
206 { GrowableArray<ScopeValue*>* l = ((ScopeDesc*) this)->expressions(); | |
207 if (l != NULL) { | |
208 st->print_cr(" Expression stack"); | |
209 for (int index = 0; index < l->length(); index++) { | |
210 st->print(" - @%d: ", index); | |
211 l->at(index)->print_on(st); | |
212 st->cr(); | |
213 } | |
214 } | |
215 } | |
216 // monitors | |
217 { GrowableArray<MonitorValue*>* l = ((ScopeDesc*) this)->monitors(); | |
218 if (l != NULL) { | |
219 st->print_cr(" Monitor stack"); | |
220 for (int index = 0; index < l->length(); index++) { | |
221 st->print(" - @%d: ", index); | |
222 l->at(index)->print_on(st); | |
223 st->cr(); | |
224 } | |
225 } | |
226 } | |
227 | |
228 #ifdef COMPILER2 | |
229 if (DoEscapeAnalysis && is_top() && _objects != NULL) { | |
230 tty->print_cr("Objects"); | |
231 for (int i = 0; i < _objects->length(); i++) { | |
232 ObjectValue* sv = (ObjectValue*) _objects->at(i); | |
233 tty->print(" - %d: ", sv->id()); | |
234 sv->print_fields_on(tty); | |
235 tty->cr(); | |
236 } | |
237 } | |
238 #endif // COMPILER2 | |
239 } | |
240 | |
241 #endif | |
242 | |
243 void ScopeDesc::verify() { | |
244 ResourceMark rm; | |
245 guarantee(method()->is_method(), "type check"); | |
246 | |
247 // check if we have any illegal elements on the expression stack | |
248 { GrowableArray<ScopeValue*>* l = expressions(); | |
249 if (l != NULL) { | |
250 for (int index = 0; index < l->length(); index++) { | |
251 //guarantee(!l->at(index)->is_illegal(), "expression element cannot be illegal"); | |
252 } | |
253 } | |
254 } | |
255 } |