Mercurial > hg > graal-compiler
annotate src/share/vm/code/scopeDesc.cpp @ 20096:3844fb65016c
SL: repeating node should implement SLStatementNode for a proper toString implementation.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 30 Mar 2015 22:52:03 +0200 |
parents | c1f116cd4b67 |
children | be896a1983c0 |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
6725
diff
changeset
|
2 * Copyright (c) 1997, 2014, 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 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
6725
diff
changeset
|
33 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
0 | 34 |
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
|
35 ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) { |
0 | 36 _code = code; |
37 _decode_offset = decode_offset; | |
38 _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
|
39 _reexecute = reexecute; |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
931
diff
changeset
|
40 _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
|
41 _rethrow_exception = rethrow_exception; |
0 | 42 decode_body(); |
43 } | |
44 | |
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
|
45 ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) { |
0 | 46 _code = code; |
47 _decode_offset = decode_offset; | |
48 _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
|
49 _reexecute = reexecute; |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
931
diff
changeset
|
50 _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
|
51 _rethrow_exception = rethrow_exception; |
0 | 52 decode_body(); |
53 } | |
54 | |
55 | |
56 ScopeDesc::ScopeDesc(const ScopeDesc* parent) { | |
57 _code = parent->_code; | |
58 _decode_offset = parent->_sender_decode_offset; | |
59 _objects = parent->_objects; | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
900
diff
changeset
|
60 _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
|
61 _rethrow_exception = false; |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
931
diff
changeset
|
62 _return_oop = false; |
0 | 63 decode_body(); |
64 } | |
65 | |
66 | |
67 void ScopeDesc::decode_body() { | |
68 if (decode_offset() == DebugInformationRecorder::serialized_null) { | |
69 // This is a sentinel record, which is only relevant to | |
70 // approximate queries. Decode a reasonable frame. | |
71 _sender_decode_offset = DebugInformationRecorder::serialized_null; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
72 _method = _code->method(); |
0 | 73 _bci = InvocationEntryBci; |
74 _locals_decode_offset = DebugInformationRecorder::serialized_null; | |
75 _expressions_decode_offset = DebugInformationRecorder::serialized_null; | |
76 _monitors_decode_offset = DebugInformationRecorder::serialized_null; | |
77 } else { | |
78 // decode header | |
79 DebugInfoReadStream* stream = stream_at(decode_offset()); | |
80 | |
81 _sender_decode_offset = stream->read_int(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
82 _method = stream->read_method(); |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
900
diff
changeset
|
83 _bci = stream->read_bci(); |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
196
diff
changeset
|
84 |
0 | 85 // decode offsets for body and sender |
86 _locals_decode_offset = stream->read_int(); | |
87 _expressions_decode_offset = stream->read_int(); | |
88 _monitors_decode_offset = stream->read_int(); | |
89 } | |
90 } | |
91 | |
92 | |
93 GrowableArray<ScopeValue*>* ScopeDesc::decode_scope_values(int decode_offset) { | |
94 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; | |
95 DebugInfoReadStream* stream = stream_at(decode_offset); | |
96 int length = stream->read_int(); | |
97 GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*> (length); | |
98 for (int index = 0; index < length; index++) { | |
99 result->push(ScopeValue::read_from(stream)); | |
100 } | |
101 return result; | |
102 } | |
103 | |
104 GrowableArray<ScopeValue*>* ScopeDesc::decode_object_values(int decode_offset) { | |
105 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; | |
106 GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*>(); | |
107 DebugInfoReadStream* stream = new DebugInfoReadStream(_code, decode_offset, result); | |
108 int length = stream->read_int(); | |
109 for (int index = 0; index < length; index++) { | |
44
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
110 // 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
|
111 // object's fields could reference it (OBJECT_ID_CODE). |
52fed2ec0afb
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
0
diff
changeset
|
112 (void)ScopeValue::read_from(stream); |
0 | 113 } |
114 assert(result->length() == length, "inconsistent debug information"); | |
115 return result; | |
116 } | |
117 | |
118 | |
119 GrowableArray<MonitorValue*>* ScopeDesc::decode_monitor_values(int decode_offset) { | |
120 if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; | |
121 DebugInfoReadStream* stream = stream_at(decode_offset); | |
122 int length = stream->read_int(); | |
123 GrowableArray<MonitorValue*>* result = new GrowableArray<MonitorValue*> (length); | |
124 for (int index = 0; index < length; index++) { | |
125 result->push(new MonitorValue(stream)); | |
126 } | |
127 return result; | |
128 } | |
129 | |
130 DebugInfoReadStream* ScopeDesc::stream_at(int decode_offset) const { | |
131 return new DebugInfoReadStream(_code, decode_offset, _objects); | |
132 } | |
133 | |
134 GrowableArray<ScopeValue*>* ScopeDesc::locals() { | |
135 return decode_scope_values(_locals_decode_offset); | |
136 } | |
137 | |
138 GrowableArray<ScopeValue*>* ScopeDesc::expressions() { | |
139 return decode_scope_values(_expressions_decode_offset); | |
140 } | |
141 | |
142 GrowableArray<MonitorValue*>* ScopeDesc::monitors() { | |
143 return decode_monitor_values(_monitors_decode_offset); | |
144 } | |
145 | |
146 GrowableArray<ScopeValue*>* ScopeDesc::objects() { | |
147 return _objects; | |
148 } | |
149 | |
150 bool ScopeDesc::is_top() const { | |
151 return _sender_decode_offset == DebugInformationRecorder::serialized_null; | |
152 } | |
153 | |
154 ScopeDesc* ScopeDesc::sender() const { | |
155 if (is_top()) return NULL; | |
156 return new ScopeDesc(this); | |
157 } | |
158 | |
159 | |
160 #ifndef PRODUCT | |
161 | |
162 void ScopeDesc::print_value_on(outputStream* st) const { | |
163 tty->print(" "); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
164 method()->print_short_name(st); |
0 | 165 int lineno = method()->line_number_from_bci(bci()); |
166 if (lineno != -1) { | |
167 st->print_cr("@%d (line %d)", bci(), lineno); | |
168 } else { | |
169 st->print_cr("@%d", bci()); | |
170 } | |
171 } | |
172 | |
173 void ScopeDesc::print_on(outputStream* st) const { | |
174 print_on(st, NULL); | |
175 } | |
176 | |
177 void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const { | |
178 // header | |
179 if (pd != NULL) { | |
180 tty->print_cr("ScopeDesc(pc=" PTR_FORMAT " offset=%x):", pd->real_pc(_code), pd->pc_offset()); | |
181 } | |
182 | |
183 print_value_on(st); | |
184 // decode offsets | |
185 if (WizardMode) { | |
1748 | 186 st->print("ScopeDesc[%d]@" PTR_FORMAT " ", _decode_offset, _code->content_begin()); |
0 | 187 st->print_cr(" offset: %d", _decode_offset); |
188 st->print_cr(" bci: %d", bci()); | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
196
diff
changeset
|
189 st->print_cr(" reexecute: %s", should_reexecute() ? "true" : "false"); |
0 | 190 st->print_cr(" locals: %d", _locals_decode_offset); |
191 st->print_cr(" stack: %d", _expressions_decode_offset); | |
192 st->print_cr(" monitor: %d", _monitors_decode_offset); | |
193 st->print_cr(" sender: %d", _sender_decode_offset); | |
194 } | |
195 // locals | |
196 { GrowableArray<ScopeValue*>* l = ((ScopeDesc*) this)->locals(); | |
197 if (l != NULL) { | |
198 tty->print_cr(" Locals"); | |
199 for (int index = 0; index < l->length(); index++) { | |
200 st->print(" - l%d: ", index); | |
201 l->at(index)->print_on(st); | |
202 st->cr(); | |
203 } | |
204 } | |
205 } | |
206 // expressions | |
207 { GrowableArray<ScopeValue*>* l = ((ScopeDesc*) this)->expressions(); | |
208 if (l != NULL) { | |
209 st->print_cr(" Expression stack"); | |
210 for (int index = 0; index < l->length(); index++) { | |
211 st->print(" - @%d: ", index); | |
212 l->at(index)->print_on(st); | |
213 st->cr(); | |
214 } | |
215 } | |
216 } | |
217 // monitors | |
218 { GrowableArray<MonitorValue*>* l = ((ScopeDesc*) this)->monitors(); | |
219 if (l != NULL) { | |
220 st->print_cr(" Monitor stack"); | |
221 for (int index = 0; index < l->length(); index++) { | |
222 st->print(" - @%d: ", index); | |
223 l->at(index)->print_on(st); | |
224 st->cr(); | |
225 } | |
226 } | |
227 } | |
228 | |
7046
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
229 #if defined(COMPILER2) || defined(GRAAL) |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
230 if (NOT_GRAAL(DoEscapeAnalysis &&) is_top() && _objects != NULL) { |
0 | 231 tty->print_cr("Objects"); |
232 for (int i = 0; i < _objects->length(); i++) { | |
19605
15ef24874df7
Add assertion to ObjectValue conversion
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18041
diff
changeset
|
233 ObjectValue* sv = _objects->at(i)->as_ObjectValue(); |
0 | 234 tty->print(" - %d: ", sv->id()); |
20044
c1f116cd4b67
Speed up debug info generation for virtual objects
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
19605
diff
changeset
|
235 tty->print("%s ", java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())->external_name()); |
0 | 236 sv->print_fields_on(tty); |
237 tty->cr(); | |
238 } | |
239 } | |
7046
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
240 #endif // COMPILER2 || GRAAL |
0 | 241 } |
242 | |
243 #endif | |
244 | |
245 void ScopeDesc::verify() { | |
246 ResourceMark rm; | |
247 guarantee(method()->is_method(), "type check"); | |
248 | |
249 // check if we have any illegal elements on the expression stack | |
250 { GrowableArray<ScopeValue*>* l = expressions(); | |
251 if (l != NULL) { | |
252 for (int index = 0; index < l->length(); index++) { | |
253 //guarantee(!l->at(index)->is_illegal(), "expression element cannot be illegal"); | |
254 } | |
255 } | |
256 } | |
257 } |