author | rkennke |
Mon, 10 Dec 2018 15:47:44 +0100 | |
changeset 52925 | 9c18c9d839d3 |
parent 47799 | 1772ebf07d1f |
child 53065 | 2f41e4935c34 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33198
diff
changeset
|
2 |
* Copyright (c) 1997, 2016, 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 |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33198
diff
changeset
|
33 |
ScopeDesc::ScopeDesc(const CompiledMethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, 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; |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
30186
diff
changeset
|
38 |
_rethrow_exception = rethrow_exception; |
4894
8a76fd3d098d
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
3686
diff
changeset
|
39 |
_return_oop = return_oop; |
1 | 40 |
decode_body(); |
41 |
} |
|
42 |
||
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
33198
diff
changeset
|
43 |
ScopeDesc::ScopeDesc(const CompiledMethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) { |
1 | 44 |
_code = code; |
45 |
_decode_offset = decode_offset; |
|
46 |
_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
|
47 |
_reexecute = reexecute; |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
30186
diff
changeset
|
48 |
_rethrow_exception = rethrow_exception; |
4894
8a76fd3d098d
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
3686
diff
changeset
|
49 |
_return_oop = return_oop; |
1 | 50 |
decode_body(); |
51 |
} |
|
52 |
||
53 |
||
54 |
ScopeDesc::ScopeDesc(const ScopeDesc* parent) { |
|
55 |
_code = parent->_code; |
|
56 |
_decode_offset = parent->_sender_decode_offset; |
|
57 |
_objects = parent->_objects; |
|
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
58 |
_reexecute = false; //reexecute only applies to the first scope |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
30186
diff
changeset
|
59 |
_rethrow_exception = false; |
4894
8a76fd3d098d
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
3686
diff
changeset
|
60 |
_return_oop = false; |
1 | 61 |
decode_body(); |
62 |
} |
|
63 |
||
64 |
||
65 |
void ScopeDesc::decode_body() { |
|
66 |
if (decode_offset() == DebugInformationRecorder::serialized_null) { |
|
67 |
// This is a sentinel record, which is only relevant to |
|
68 |
// approximate queries. Decode a reasonable frame. |
|
69 |
_sender_decode_offset = DebugInformationRecorder::serialized_null; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
70 |
_method = _code->method(); |
1 | 71 |
_bci = InvocationEntryBci; |
72 |
_locals_decode_offset = DebugInformationRecorder::serialized_null; |
|
73 |
_expressions_decode_offset = DebugInformationRecorder::serialized_null; |
|
74 |
_monitors_decode_offset = DebugInformationRecorder::serialized_null; |
|
75 |
} else { |
|
76 |
// decode header |
|
77 |
DebugInfoReadStream* stream = stream_at(decode_offset()); |
|
78 |
||
79 |
_sender_decode_offset = stream->read_int(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
80 |
_method = stream->read_method(); |
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
81 |
_bci = stream->read_bci(); |
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
670
diff
changeset
|
82 |
|
1 | 83 |
// decode offsets for body and sender |
84 |
_locals_decode_offset = stream->read_int(); |
|
85 |
_expressions_decode_offset = stream->read_int(); |
|
86 |
_monitors_decode_offset = stream->read_int(); |
|
87 |
} |
|
88 |
} |
|
89 |
||
90 |
||
91 |
GrowableArray<ScopeValue*>* ScopeDesc::decode_scope_values(int decode_offset) { |
|
92 |
if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; |
|
93 |
DebugInfoReadStream* stream = stream_at(decode_offset); |
|
94 |
int length = stream->read_int(); |
|
95 |
GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*> (length); |
|
96 |
for (int index = 0; index < length; index++) { |
|
97 |
result->push(ScopeValue::read_from(stream)); |
|
98 |
} |
|
99 |
return result; |
|
100 |
} |
|
101 |
||
102 |
GrowableArray<ScopeValue*>* ScopeDesc::decode_object_values(int decode_offset) { |
|
103 |
if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; |
|
104 |
GrowableArray<ScopeValue*>* result = new GrowableArray<ScopeValue*>(); |
|
105 |
DebugInfoReadStream* stream = new DebugInfoReadStream(_code, decode_offset, result); |
|
106 |
int length = stream->read_int(); |
|
107 |
for (int index = 0; index < length; index++) { |
|
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
108 |
// 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
|
109 |
// object's fields could reference it (OBJECT_ID_CODE). |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
110 |
(void)ScopeValue::read_from(stream); |
1 | 111 |
} |
112 |
assert(result->length() == length, "inconsistent debug information"); |
|
113 |
return result; |
|
114 |
} |
|
115 |
||
116 |
||
117 |
GrowableArray<MonitorValue*>* ScopeDesc::decode_monitor_values(int decode_offset) { |
|
118 |
if (decode_offset == DebugInformationRecorder::serialized_null) return NULL; |
|
119 |
DebugInfoReadStream* stream = stream_at(decode_offset); |
|
120 |
int length = stream->read_int(); |
|
121 |
GrowableArray<MonitorValue*>* result = new GrowableArray<MonitorValue*> (length); |
|
122 |
for (int index = 0; index < length; index++) { |
|
123 |
result->push(new MonitorValue(stream)); |
|
124 |
} |
|
125 |
return result; |
|
126 |
} |
|
127 |
||
128 |
DebugInfoReadStream* ScopeDesc::stream_at(int decode_offset) const { |
|
129 |
return new DebugInfoReadStream(_code, decode_offset, _objects); |
|
130 |
} |
|
131 |
||
132 |
GrowableArray<ScopeValue*>* ScopeDesc::locals() { |
|
133 |
return decode_scope_values(_locals_decode_offset); |
|
134 |
} |
|
135 |
||
136 |
GrowableArray<ScopeValue*>* ScopeDesc::expressions() { |
|
137 |
return decode_scope_values(_expressions_decode_offset); |
|
138 |
} |
|
139 |
||
140 |
GrowableArray<MonitorValue*>* ScopeDesc::monitors() { |
|
141 |
return decode_monitor_values(_monitors_decode_offset); |
|
142 |
} |
|
143 |
||
144 |
GrowableArray<ScopeValue*>* ScopeDesc::objects() { |
|
145 |
return _objects; |
|
146 |
} |
|
147 |
||
148 |
bool ScopeDesc::is_top() const { |
|
149 |
return _sender_decode_offset == DebugInformationRecorder::serialized_null; |
|
150 |
} |
|
151 |
||
152 |
ScopeDesc* ScopeDesc::sender() const { |
|
153 |
if (is_top()) return NULL; |
|
154 |
return new ScopeDesc(this); |
|
155 |
} |
|
156 |
||
157 |
||
158 |
#ifndef PRODUCT |
|
159 |
||
160 |
void ScopeDesc::print_value_on(outputStream* st) const { |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
161 |
st->print(" "); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
162 |
method()->print_short_name(st); |
1 | 163 |
int lineno = method()->line_number_from_bci(bci()); |
164 |
if (lineno != -1) { |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
165 |
st->print("@%d (line %d)", bci(), lineno); |
1 | 166 |
} else { |
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
167 |
st->print("@%d", bci()); |
1 | 168 |
} |
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
169 |
if (should_reexecute()) { |
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
170 |
st->print(" reexecute=true"); |
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
171 |
} |
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
172 |
st->cr(); |
1 | 173 |
} |
174 |
||
175 |
void ScopeDesc::print_on(outputStream* st) const { |
|
176 |
print_on(st, NULL); |
|
177 |
} |
|
178 |
||
179 |
void ScopeDesc::print_on(outputStream* st, PcDesc* pd) const { |
|
180 |
// header |
|
181 |
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
|
182 |
st->print_cr("ScopeDesc(pc=" PTR_FORMAT " offset=%x):", p2i(pd->real_pc(_code)), pd->pc_offset()); |
1 | 183 |
} |
184 |
||
185 |
print_value_on(st); |
|
186 |
// decode offsets |
|
187 |
if (WizardMode) { |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
30186
diff
changeset
|
188 |
st->print("ScopeDesc[%d]@" PTR_FORMAT " ", _decode_offset, p2i(_code->content_begin())); |
1 | 189 |
st->print_cr(" offset: %d", _decode_offset); |
190 |
st->print_cr(" bci: %d", bci()); |
|
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
670
diff
changeset
|
191 |
st->print_cr(" reexecute: %s", should_reexecute() ? "true" : "false"); |
1 | 192 |
st->print_cr(" locals: %d", _locals_decode_offset); |
193 |
st->print_cr(" stack: %d", _expressions_decode_offset); |
|
194 |
st->print_cr(" monitor: %d", _monitors_decode_offset); |
|
195 |
st->print_cr(" sender: %d", _sender_decode_offset); |
|
196 |
} |
|
197 |
// locals |
|
198 |
{ GrowableArray<ScopeValue*>* l = ((ScopeDesc*) this)->locals(); |
|
199 |
if (l != NULL) { |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
200 |
st->print_cr(" Locals"); |
1 | 201 |
for (int index = 0; index < l->length(); index++) { |
202 |
st->print(" - l%d: ", index); |
|
203 |
l->at(index)->print_on(st); |
|
204 |
st->cr(); |
|
205 |
} |
|
206 |
} |
|
207 |
} |
|
208 |
// expressions |
|
209 |
{ GrowableArray<ScopeValue*>* l = ((ScopeDesc*) this)->expressions(); |
|
210 |
if (l != NULL) { |
|
211 |
st->print_cr(" Expression stack"); |
|
212 |
for (int index = 0; index < l->length(); index++) { |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
213 |
st->print(" - @%d: ", index); |
1 | 214 |
l->at(index)->print_on(st); |
215 |
st->cr(); |
|
216 |
} |
|
217 |
} |
|
218 |
} |
|
219 |
// monitors |
|
220 |
{ GrowableArray<MonitorValue*>* l = ((ScopeDesc*) this)->monitors(); |
|
221 |
if (l != NULL) { |
|
222 |
st->print_cr(" Monitor stack"); |
|
223 |
for (int index = 0; index < l->length(); index++) { |
|
224 |
st->print(" - @%d: ", index); |
|
225 |
l->at(index)->print_on(st); |
|
226 |
st->cr(); |
|
227 |
} |
|
228 |
} |
|
229 |
} |
|
230 |
||
47799 | 231 |
#if COMPILER2_OR_JVMCI |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
30186
diff
changeset
|
232 |
if (NOT_JVMCI(DoEscapeAnalysis &&) is_top() && _objects != NULL) { |
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
233 |
st->print_cr(" Objects"); |
1 | 234 |
for (int i = 0; i < _objects->length(); i++) { |
235 |
ObjectValue* sv = (ObjectValue*) _objects->at(i); |
|
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
236 |
st->print(" - %d: ", sv->id()); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
30186
diff
changeset
|
237 |
st->print("%s ", java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()())->external_name()); |
30186
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
238 |
sv->print_fields_on(st); |
a416fa6a0fe7
8075270: Print locals & stack slots location for PcDescs
vlivanov
parents:
24424
diff
changeset
|
239 |
st->cr(); |
1 | 240 |
} |
241 |
} |
|
47799 | 242 |
#endif // COMPILER2_OR_JVMCI |
1 | 243 |
} |
244 |
||
245 |
#endif |
|
246 |
||
247 |
void ScopeDesc::verify() { |
|
248 |
ResourceMark rm; |
|
249 |
guarantee(method()->is_method(), "type check"); |
|
250 |
||
251 |
// check if we have any illegal elements on the expression stack |
|
252 |
{ GrowableArray<ScopeValue*>* l = expressions(); |
|
253 |
if (l != NULL) { |
|
254 |
for (int index = 0; index < l->length(); index++) { |
|
255 |
//guarantee(!l->at(index)->is_illegal(), "expression element cannot be illegal"); |
|
256 |
} |
|
257 |
} |
|
258 |
} |
|
259 |
} |