author | david |
Fri, 09 Oct 2015 09:42:33 +0200 | |
changeset 33148 | 68fa8b6c4340 |
parent 30186 | a416fa6a0fe7 |
child 33198 | b37ad9fbf681 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13728
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4894
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4894
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4894
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 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" |
|
1 | 32 |
|
4894
8a76fd3d098d
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
3686
diff
changeset
|
33 |
ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool return_oop) { |
1 | 34 |
_code = code; |
35 |
_decode_offset = decode_offset; |
|
36 |
_objects = decode_object_values(obj_decode_offset); |
|
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
37 |
_reexecute = reexecute; |
4894
8a76fd3d098d
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
3686
diff
changeset
|
38 |
_return_oop = return_oop; |
1 | 39 |
decode_body(); |
40 |
} |
|
41 |
||
4894
8a76fd3d098d
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
3686
diff
changeset
|
42 |
ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, bool reexecute, bool return_oop) { |
1 | 43 |
_code = code; |
44 |
_decode_offset = decode_offset; |
|
45 |
_objects = decode_object_values(DebugInformationRecorder::serialized_null); |
|
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
46 |
_reexecute = reexecute; |
4894
8a76fd3d098d
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
3686
diff
changeset
|
47 |
_return_oop = return_oop; |
1 | 48 |
decode_body(); |
49 |
} |
|
50 |
||
51 |
||
52 |
ScopeDesc::ScopeDesc(const ScopeDesc* parent) { |
|
53 |
_code = parent->_code; |
|
54 |
_decode_offset = parent->_sender_decode_offset; |
|
55 |
_objects = parent->_objects; |
|
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
56 |
_reexecute = false; //reexecute only applies to the first scope |
4894
8a76fd3d098d
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
3686
diff
changeset
|
57 |
_return_oop = false; |
1 | 58 |
decode_body(); |
59 |
} |
|
60 |
||
61 |
||
62 |
void ScopeDesc::decode_body() { |
|
63 |
if (decode_offset() == DebugInformationRecorder::serialized_null) { |
|
64 |
// This is a sentinel record, which is only relevant to |
|
65 |
// approximate queries. Decode a reasonable frame. |
|
66 |
_sender_decode_offset = DebugInformationRecorder::serialized_null; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
67 |
_method = _code->method(); |
1 | 68 |
_bci = InvocationEntryBci; |
69 |
_locals_decode_offset = DebugInformationRecorder::serialized_null; |
|
70 |
_expressions_decode_offset = DebugInformationRecorder::serialized_null; |
|
71 |
_monitors_decode_offset = DebugInformationRecorder::serialized_null; |
|
72 |
} else { |
|
73 |
// decode header |
|
74 |
DebugInfoReadStream* stream = stream_at(decode_offset()); |
|
75 |
||
76 |
_sender_decode_offset = stream->read_int(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
77 |
_method = stream->read_method(); |
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
78 |
_bci = stream->read_bci(); |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
670
diff
changeset
|
79 |
|
1 | 80 |
// decode offsets for body and sender |
81 |
_locals_decode_offset = stream->read_int(); |
|
82 |
_expressions_decode_offset = stream->read_int(); |
|
83 |
_monitors_decode_offset = stream->read_int(); |
|
84 |
} |
|
85 |
} |
|
86 |
||
87 |
||
88 |
GrowableArray<ScopeValue*>* ScopeDesc::decode_scope_values(int decode_offset) { |
|
89 |
if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; |
|
90 |
DebugInfoReadStream* stream = stream_at(decode_offset); |
|
91 |
int length = stream->read_int(); |
|
92 |
GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*> (length); |
|
93 |
for (int index = 0; index < length; index++) { |
|
94 |
result->push(ScopeValue::read_from(stream)); |
|
95 |
} |
|
96 |
return result; |
|
97 |
} |
|
98 |
||
99 |
GrowableArray<ScopeValue*>* ScopeDesc::decode_object_values(int decode_offset) { |
|
100 |
if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; |
|
101 |
GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*>(); |
|
102 |
DebugInfoReadStream* stream = new DebugInfoReadStream(_code, decode_offset, result); |
|
103 |
int length = stream->read_int(); |
|
104 |
for (int index = 0; index < length; index++) { |
|
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
105 |
// Objects values are pushed to 'result' array during read so that |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
106 |
// object's fields could reference it (OBJECT_ID_CODE). |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
107 |
(void)ScopeValue::read_from(stream); |
1 | 108 |
} |
109 |
assert(result->length() == length, "inconsistent debug information"); |
|
110 |
return result; |
|
111 |
} |
|
112 |
||
113 |
||
114 |
GrowableArray<MonitorValue*>* ScopeDesc::decode_monitor_values(int decode_offset) { |
|
115 |
if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; |
|
116 |
DebugInfoReadStream* stream = stream_at(decode_offset); |
|
117 |
int length = stream->read_int(); |
|
118 |
GrowableArray<MonitorValue*>* result = new GrowableArray<MonitorValue*> (length); |
|
119 |
for (int index = 0; index < length; index++) { |
|
120 |
result->push(new MonitorValue(stream)); |
|
121 |
} |
|
122 |
return result; |
|
123 |
} |
|
124 |
||
125 |
DebugInfoReadStream* ScopeDesc::stream_at(int decode_offset) const { |
|
126 |
return new DebugInfoReadStream(_code, decode_offset, _objects); |
|
127 |
} |
|
128 |
||
129 |
GrowableArray<ScopeValue*>* ScopeDesc::locals() { |
|
130 |
return decode_scope_values(_locals_decode_offset); |
|
131 |
} |
|
132 |
||
133 |
GrowableArray<ScopeValue*>* ScopeDesc::expressions() { |
|
134 |
return decode_scope_values(_expressions_decode_offset); |
|
135 |
} |
|
136 |
||
137 |
GrowableArray<MonitorValue*>* ScopeDesc::monitors() { |
|
138 |
return decode_monitor_values(_monitors_decode_offset); |
|
139 |
} |
|
140 |
||
141 |
GrowableArray<ScopeValue*>* ScopeDesc::objects() { |
|
142 |
return _objects; |
|
143 |
} |
|
144 |
||
145 |
bool ScopeDesc::is_top() const { |
|
146 |
return _sender_decode_offset == DebugInformationRecorder::serialized_null; |
|
147 |
} |
|
148 |
||
149 |
ScopeDesc* ScopeDesc::sender() const { |
|
150 |
if (is_top()) return NULL; |
|
151 |
return new ScopeDesc(this); |
|
152 |
} |
|
153 |
||
154 |
||
155 |
#ifndef PRODUCT |
|
156 |
||
157 |
void ScopeDesc::print_value_on(outputStream* st) const { |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
158 |
st->print(" "); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
159 |
method()->print_short_name(st); |
1 | 160 |
int lineno = method()->line_number_from_bci(bci()); |
161 |
if (lineno != -1) { |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
162 |
st->print("@%d (line %d)", bci(), lineno); |
1 | 163 |
} else { |
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
164 |
st->print("@%d", bci()); |
1 | 165 |
} |
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
166 |
if (should_reexecute()) { |
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
167 |
st->print(" reexecute=true"); |
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
168 |
} |
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
169 |
st->cr(); |
1 | 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) { |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
30186
diff
changeset
|
179 |
st->print_cr("ScopeDesc(pc=" PTR_FORMAT " offset=%x):", p2i(pd->real_pc(_code)), pd->pc_offset()); |
1 | 180 |
} |
181 |
||
182 |
print_value_on(st); |
|
183 |
// decode offsets |
|
184 |
if (WizardMode) { |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
30186
diff
changeset
|
185 |
st->print("ScopeDesc[%d]@" PTR_FORMAT " ", _decode_offset, p2i(_code->content_begin())); |
1 | 186 |
st->print_cr(" offset: %d", _decode_offset); |
187 |
st->print_cr(" bci: %d", bci()); |
|
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
670
diff
changeset
|
188 |
st->print_cr(" reexecute: %s", should_reexecute() ? "true" : "false"); |
1 | 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) { |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
197 |
st->print_cr(" Locals"); |
1 | 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++) { |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
210 |
st->print(" - @%d: ", index); |
1 | 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) { |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
230 |
st->print_cr(" Objects"); |
1 | 231 |
for (int i = 0; i < _objects->length(); i++) { |
232 |
ObjectValue* sv = (ObjectValue*) _objects->at(i); |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
233 |
st->print(" - %d: ", sv->id()); |
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
234 |
sv->print_fields_on(st); |
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
235 |
st->cr(); |
1 | 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 |
} |