author | goetz |
Thu, 11 Jun 2015 10:50:27 +0200 | |
changeset 31406 | 4121166054b6 |
parent 24424 | 2658d7834c6e |
child 33160 | c59f1676d27e |
child 33148 | 68fa8b6c4340 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
31406
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
2 |
* Copyright (c) 1997, 2015, 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:
670
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
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:
670
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "code/debugInfo.hpp" |
|
27 |
#include "code/debugInfoRec.hpp" |
|
28 |
#include "code/nmethod.hpp" |
|
31406
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
29 |
#include "oops/oop.inline.hpp" |
7397 | 30 |
#include "runtime/handles.inline.hpp" |
1 | 31 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13728
diff
changeset
|
32 |
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13728
diff
changeset
|
33 |
|
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13728
diff
changeset
|
34 |
// Constructors |
1 | 35 |
|
36 |
DebugInfoWriteStream::DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size) |
|
37 |
: CompressedWriteStream(initial_size) { |
|
38 |
_recorder = recorder; |
|
39 |
} |
|
40 |
||
41 |
// Serializing oops |
|
42 |
||
43 |
void DebugInfoWriteStream::write_handle(jobject h) { |
|
44 |
write_int(recorder()->oop_recorder()->find_index(h)); |
|
45 |
} |
|
46 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
47 |
void DebugInfoWriteStream::write_metadata(Metadata* h) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
48 |
write_int(recorder()->oop_recorder()->find_index(h)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
49 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
50 |
|
31406
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
51 |
oop DebugInfoReadStream::read_oop() { |
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
52 |
oop o = code()->oop_at(read_int()); |
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
53 |
assert(o->is_oop_or_null(), "oop only"); |
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
54 |
return o; |
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
55 |
} |
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
56 |
|
1 | 57 |
ScopeValue* DebugInfoReadStream::read_object_value() { |
58 |
int id = read_int(); |
|
59 |
#ifdef ASSERT |
|
60 |
assert(_obj_pool != NULL, "object pool does not exist"); |
|
61 |
for (int i = _obj_pool->length() - 1; i >= 0; i--) { |
|
62 |
assert(((ObjectValue*) _obj_pool->at(i))->id() != id, "should not be read twice"); |
|
63 |
} |
|
64 |
#endif |
|
65 |
ObjectValue* result = new ObjectValue(id); |
|
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
66 |
// Cache the object since an object field could reference it. |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
67 |
_obj_pool->push(result); |
1 | 68 |
result->read_object(this); |
69 |
return result; |
|
70 |
} |
|
71 |
||
72 |
ScopeValue* DebugInfoReadStream::get_cached_object() { |
|
73 |
int id = read_int(); |
|
74 |
assert(_obj_pool != NULL, "object pool does not exist"); |
|
75 |
for (int i = _obj_pool->length() - 1; i >= 0; i--) { |
|
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
76 |
ObjectValue* ov = (ObjectValue*) _obj_pool->at(i); |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
77 |
if (ov->id() == id) { |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
78 |
return ov; |
1 | 79 |
} |
80 |
} |
|
81 |
ShouldNotReachHere(); |
|
82 |
return NULL; |
|
83 |
} |
|
84 |
||
85 |
// Serializing scope values |
|
86 |
||
87 |
enum { LOCATION_CODE = 0, CONSTANT_INT_CODE = 1, CONSTANT_OOP_CODE = 2, |
|
88 |
CONSTANT_LONG_CODE = 3, CONSTANT_DOUBLE_CODE = 4, |
|
89 |
OBJECT_CODE = 5, OBJECT_ID_CODE = 6 }; |
|
90 |
||
91 |
ScopeValue* ScopeValue::read_from(DebugInfoReadStream* stream) { |
|
92 |
ScopeValue* result = NULL; |
|
93 |
switch(stream->read_int()) { |
|
94 |
case LOCATION_CODE: result = new LocationValue(stream); break; |
|
95 |
case CONSTANT_INT_CODE: result = new ConstantIntValue(stream); break; |
|
96 |
case CONSTANT_OOP_CODE: result = new ConstantOopReadValue(stream); break; |
|
97 |
case CONSTANT_LONG_CODE: result = new ConstantLongValue(stream); break; |
|
98 |
case CONSTANT_DOUBLE_CODE: result = new ConstantDoubleValue(stream); break; |
|
99 |
case OBJECT_CODE: result = stream->read_object_value(); break; |
|
100 |
case OBJECT_ID_CODE: result = stream->get_cached_object(); break; |
|
101 |
default: ShouldNotReachHere(); |
|
102 |
} |
|
103 |
return result; |
|
104 |
} |
|
105 |
||
106 |
// LocationValue |
|
107 |
||
108 |
LocationValue::LocationValue(DebugInfoReadStream* stream) { |
|
109 |
_location = Location(stream); |
|
110 |
} |
|
111 |
||
112 |
void LocationValue::write_on(DebugInfoWriteStream* stream) { |
|
113 |
stream->write_int(LOCATION_CODE); |
|
114 |
location().write_on(stream); |
|
115 |
} |
|
116 |
||
117 |
void LocationValue::print_on(outputStream* st) const { |
|
118 |
location().print_on(st); |
|
119 |
} |
|
120 |
||
121 |
// ObjectValue |
|
122 |
||
123 |
void ObjectValue::read_object(DebugInfoReadStream* stream) { |
|
124 |
_klass = read_from(stream); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
125 |
assert(_klass->is_constant_oop(), "should be constant java mirror oop"); |
1 | 126 |
int length = stream->read_int(); |
127 |
for (int i = 0; i < length; i++) { |
|
128 |
ScopeValue* val = read_from(stream); |
|
129 |
_field_values.append(val); |
|
130 |
} |
|
131 |
} |
|
132 |
||
133 |
void ObjectValue::write_on(DebugInfoWriteStream* stream) { |
|
134 |
if (_visited) { |
|
135 |
stream->write_int(OBJECT_ID_CODE); |
|
136 |
stream->write_int(_id); |
|
137 |
} else { |
|
138 |
_visited = true; |
|
139 |
stream->write_int(OBJECT_CODE); |
|
140 |
stream->write_int(_id); |
|
141 |
_klass->write_on(stream); |
|
142 |
int length = _field_values.length(); |
|
143 |
stream->write_int(length); |
|
144 |
for (int i = 0; i < length; i++) { |
|
145 |
_field_values.at(i)->write_on(stream); |
|
146 |
} |
|
147 |
} |
|
148 |
} |
|
149 |
||
150 |
void ObjectValue::print_on(outputStream* st) const { |
|
151 |
st->print("obj[%d]", _id); |
|
152 |
} |
|
153 |
||
154 |
void ObjectValue::print_fields_on(outputStream* st) const { |
|
155 |
#ifndef PRODUCT |
|
156 |
if (_field_values.length() > 0) { |
|
157 |
_field_values.at(0)->print_on(st); |
|
158 |
} |
|
159 |
for (int i = 1; i < _field_values.length(); i++) { |
|
160 |
st->print(", "); |
|
161 |
_field_values.at(i)->print_on(st); |
|
162 |
} |
|
163 |
#endif |
|
164 |
} |
|
165 |
||
166 |
// ConstantIntValue |
|
167 |
||
168 |
ConstantIntValue::ConstantIntValue(DebugInfoReadStream* stream) { |
|
169 |
_value = stream->read_signed_int(); |
|
170 |
} |
|
171 |
||
172 |
void ConstantIntValue::write_on(DebugInfoWriteStream* stream) { |
|
173 |
stream->write_int(CONSTANT_INT_CODE); |
|
174 |
stream->write_signed_int(value()); |
|
175 |
} |
|
176 |
||
177 |
void ConstantIntValue::print_on(outputStream* st) const { |
|
178 |
st->print("%d", value()); |
|
179 |
} |
|
180 |
||
181 |
// ConstantLongValue |
|
182 |
||
183 |
ConstantLongValue::ConstantLongValue(DebugInfoReadStream* stream) { |
|
184 |
_value = stream->read_long(); |
|
185 |
} |
|
186 |
||
187 |
void ConstantLongValue::write_on(DebugInfoWriteStream* stream) { |
|
188 |
stream->write_int(CONSTANT_LONG_CODE); |
|
189 |
stream->write_long(value()); |
|
190 |
} |
|
191 |
||
192 |
void ConstantLongValue::print_on(outputStream* st) const { |
|
193 |
st->print(INT64_FORMAT, value()); |
|
194 |
} |
|
195 |
||
196 |
// ConstantDoubleValue |
|
197 |
||
198 |
ConstantDoubleValue::ConstantDoubleValue(DebugInfoReadStream* stream) { |
|
199 |
_value = stream->read_double(); |
|
200 |
} |
|
201 |
||
202 |
void ConstantDoubleValue::write_on(DebugInfoWriteStream* stream) { |
|
203 |
stream->write_int(CONSTANT_DOUBLE_CODE); |
|
204 |
stream->write_double(value()); |
|
205 |
} |
|
206 |
||
207 |
void ConstantDoubleValue::print_on(outputStream* st) const { |
|
208 |
st->print("%f", value()); |
|
209 |
} |
|
210 |
||
211 |
// ConstantOopWriteValue |
|
212 |
||
213 |
void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
214 |
assert(JNIHandles::resolve(value()) == NULL || |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
215 |
Universe::heap()->is_in_reserved(JNIHandles::resolve(value())), |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
216 |
"Should be in heap"); |
1 | 217 |
stream->write_int(CONSTANT_OOP_CODE); |
218 |
stream->write_handle(value()); |
|
219 |
} |
|
220 |
||
221 |
void ConstantOopWriteValue::print_on(outputStream* st) const { |
|
222 |
JNIHandles::resolve(value())->print_value_on(st); |
|
223 |
} |
|
224 |
||
225 |
||
226 |
// ConstantOopReadValue |
|
227 |
||
228 |
ConstantOopReadValue::ConstantOopReadValue(DebugInfoReadStream* stream) { |
|
229 |
_value = Handle(stream->read_oop()); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
230 |
assert(_value() == NULL || |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
231 |
Universe::heap()->is_in_reserved(_value()), "Should be in heap"); |
1 | 232 |
} |
233 |
||
234 |
void ConstantOopReadValue::write_on(DebugInfoWriteStream* stream) { |
|
235 |
ShouldNotReachHere(); |
|
236 |
} |
|
237 |
||
238 |
void ConstantOopReadValue::print_on(outputStream* st) const { |
|
239 |
value()()->print_value_on(st); |
|
240 |
} |
|
241 |
||
242 |
||
243 |
// MonitorValue |
|
244 |
||
245 |
MonitorValue::MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated) { |
|
246 |
_owner = owner; |
|
247 |
_basic_lock = basic_lock; |
|
248 |
_eliminated = eliminated; |
|
249 |
} |
|
250 |
||
251 |
MonitorValue::MonitorValue(DebugInfoReadStream* stream) { |
|
252 |
_basic_lock = Location(stream); |
|
253 |
_owner = ScopeValue::read_from(stream); |
|
254 |
_eliminated = (stream->read_bool() != 0); |
|
255 |
} |
|
256 |
||
257 |
void MonitorValue::write_on(DebugInfoWriteStream* stream) { |
|
258 |
_basic_lock.write_on(stream); |
|
259 |
_owner->write_on(stream); |
|
260 |
stream->write_bool(_eliminated); |
|
261 |
} |
|
262 |
||
263 |
#ifndef PRODUCT |
|
264 |
void MonitorValue::print_on(outputStream* st) const { |
|
265 |
st->print("monitor{"); |
|
266 |
owner()->print_on(st); |
|
267 |
st->print(","); |
|
268 |
basic_lock().print_on(st); |
|
269 |
st->print("}"); |
|
270 |
if (_eliminated) { |
|
271 |
st->print(" (eliminated)"); |
|
272 |
} |
|
273 |
} |
|
274 |
#endif |