author | coleenp |
Fri, 16 Mar 2018 09:12:13 -0400 | |
changeset 49449 | ef5d5d343e2a |
parent 49192 | 6734eeef4283 |
child 51268 | 4ac20e5f96ce |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49192
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
48120
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, 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" |
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49192
diff
changeset
|
31 |
#include "runtime/interfaceSupport.inline.hpp" |
49192
6734eeef4283
8198474: Move JNIHandles::resolve into jniHandles.inline.hpp
kbarrett
parents:
48120
diff
changeset
|
32 |
#include "runtime/jniHandles.inline.hpp" |
48120 | 33 |
#include "runtime/thread.hpp" |
1 | 34 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
13728
diff
changeset
|
35 |
// Constructors |
1 | 36 |
|
37 |
DebugInfoWriteStream::DebugInfoWriteStream(DebugInformationRecorder* recorder, int initial_size) |
|
38 |
: CompressedWriteStream(initial_size) { |
|
39 |
_recorder = recorder; |
|
40 |
} |
|
41 |
||
42 |
// Serializing oops |
|
43 |
||
44 |
void DebugInfoWriteStream::write_handle(jobject h) { |
|
45 |
write_int(recorder()->oop_recorder()->find_index(h)); |
|
46 |
} |
|
47 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
48 |
void DebugInfoWriteStream::write_metadata(Metadata* h) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
49 |
write_int(recorder()->oop_recorder()->find_index(h)); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
50 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
51 |
|
31406
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
52 |
oop DebugInfoReadStream::read_oop() { |
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
53 |
oop o = code()->oop_at(read_int()); |
46968
9119841280f4
8160399: is_oop_or_null involves undefined behavior
coleenp
parents:
46630
diff
changeset
|
54 |
assert(oopDesc::is_oop_or_null(o), "oop only"); |
31406
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
55 |
return o; |
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
56 |
} |
4121166054b6
8087183: Fix call to inline function is_oop in header debugInfo.hpp.
goetz
parents:
24424
diff
changeset
|
57 |
|
1 | 58 |
ScopeValue* DebugInfoReadStream::read_object_value() { |
59 |
int id = read_int(); |
|
60 |
#ifdef ASSERT |
|
61 |
assert(_obj_pool != NULL, "object pool does not exist"); |
|
62 |
for (int i = _obj_pool->length() - 1; i >= 0; i--) { |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31406
diff
changeset
|
63 |
assert(_obj_pool->at(i)->as_ObjectValue()->id() != id, "should not be read twice"); |
1 | 64 |
} |
65 |
#endif |
|
66 |
ObjectValue* result = new ObjectValue(id); |
|
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
67 |
// 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
|
68 |
_obj_pool->push(result); |
1 | 69 |
result->read_object(this); |
70 |
return result; |
|
71 |
} |
|
72 |
||
73 |
ScopeValue* DebugInfoReadStream::get_cached_object() { |
|
74 |
int id = read_int(); |
|
75 |
assert(_obj_pool != NULL, "object pool does not exist"); |
|
76 |
for (int i = _obj_pool->length() - 1; i >= 0; i--) { |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
31406
diff
changeset
|
77 |
ObjectValue* ov = _obj_pool->at(i)->as_ObjectValue(); |
217
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
78 |
if (ov->id() == id) { |
c646ef2f5d58
6667620: (Escape Analysis) fix deoptimization for scalar replaced objects
kvn
parents:
1
diff
changeset
|
79 |
return ov; |
1 | 80 |
} |
81 |
} |
|
82 |
ShouldNotReachHere(); |
|
83 |
return NULL; |
|
84 |
} |
|
85 |
||
86 |
// Serializing scope values |
|
87 |
||
88 |
enum { LOCATION_CODE = 0, CONSTANT_INT_CODE = 1, CONSTANT_OOP_CODE = 2, |
|
89 |
CONSTANT_LONG_CODE = 3, CONSTANT_DOUBLE_CODE = 4, |
|
90 |
OBJECT_CODE = 5, OBJECT_ID_CODE = 6 }; |
|
91 |
||
92 |
ScopeValue* ScopeValue::read_from(DebugInfoReadStream* stream) { |
|
93 |
ScopeValue* result = NULL; |
|
94 |
switch(stream->read_int()) { |
|
95 |
case LOCATION_CODE: result = new LocationValue(stream); break; |
|
96 |
case CONSTANT_INT_CODE: result = new ConstantIntValue(stream); break; |
|
97 |
case CONSTANT_OOP_CODE: result = new ConstantOopReadValue(stream); break; |
|
98 |
case CONSTANT_LONG_CODE: result = new ConstantLongValue(stream); break; |
|
99 |
case CONSTANT_DOUBLE_CODE: result = new ConstantDoubleValue(stream); break; |
|
100 |
case OBJECT_CODE: result = stream->read_object_value(); break; |
|
101 |
case OBJECT_ID_CODE: result = stream->get_cached_object(); break; |
|
102 |
default: ShouldNotReachHere(); |
|
103 |
} |
|
104 |
return result; |
|
105 |
} |
|
106 |
||
107 |
// LocationValue |
|
108 |
||
109 |
LocationValue::LocationValue(DebugInfoReadStream* stream) { |
|
110 |
_location = Location(stream); |
|
111 |
} |
|
112 |
||
113 |
void LocationValue::write_on(DebugInfoWriteStream* stream) { |
|
114 |
stream->write_int(LOCATION_CODE); |
|
115 |
location().write_on(stream); |
|
116 |
} |
|
117 |
||
118 |
void LocationValue::print_on(outputStream* st) const { |
|
119 |
location().print_on(st); |
|
120 |
} |
|
121 |
||
122 |
// ObjectValue |
|
123 |
||
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49192
diff
changeset
|
124 |
void ObjectValue::set_value(oop value) { |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49192
diff
changeset
|
125 |
_value = Handle(Thread::current(), value); |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49192
diff
changeset
|
126 |
} |
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
49192
diff
changeset
|
127 |
|
1 | 128 |
void ObjectValue::read_object(DebugInfoReadStream* stream) { |
129 |
_klass = read_from(stream); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
130 |
assert(_klass->is_constant_oop(), "should be constant java mirror oop"); |
1 | 131 |
int length = stream->read_int(); |
132 |
for (int i = 0; i < length; i++) { |
|
133 |
ScopeValue* val = read_from(stream); |
|
134 |
_field_values.append(val); |
|
135 |
} |
|
136 |
} |
|
137 |
||
138 |
void ObjectValue::write_on(DebugInfoWriteStream* stream) { |
|
139 |
if (_visited) { |
|
140 |
stream->write_int(OBJECT_ID_CODE); |
|
141 |
stream->write_int(_id); |
|
142 |
} else { |
|
143 |
_visited = true; |
|
144 |
stream->write_int(OBJECT_CODE); |
|
145 |
stream->write_int(_id); |
|
146 |
_klass->write_on(stream); |
|
147 |
int length = _field_values.length(); |
|
148 |
stream->write_int(length); |
|
149 |
for (int i = 0; i < length; i++) { |
|
150 |
_field_values.at(i)->write_on(stream); |
|
151 |
} |
|
152 |
} |
|
153 |
} |
|
154 |
||
155 |
void ObjectValue::print_on(outputStream* st) const { |
|
156 |
st->print("obj[%d]", _id); |
|
157 |
} |
|
158 |
||
159 |
void ObjectValue::print_fields_on(outputStream* st) const { |
|
160 |
#ifndef PRODUCT |
|
161 |
if (_field_values.length() > 0) { |
|
162 |
_field_values.at(0)->print_on(st); |
|
163 |
} |
|
164 |
for (int i = 1; i < _field_values.length(); i++) { |
|
165 |
st->print(", "); |
|
166 |
_field_values.at(i)->print_on(st); |
|
167 |
} |
|
168 |
#endif |
|
169 |
} |
|
170 |
||
171 |
// ConstantIntValue |
|
172 |
||
173 |
ConstantIntValue::ConstantIntValue(DebugInfoReadStream* stream) { |
|
174 |
_value = stream->read_signed_int(); |
|
175 |
} |
|
176 |
||
177 |
void ConstantIntValue::write_on(DebugInfoWriteStream* stream) { |
|
178 |
stream->write_int(CONSTANT_INT_CODE); |
|
179 |
stream->write_signed_int(value()); |
|
180 |
} |
|
181 |
||
182 |
void ConstantIntValue::print_on(outputStream* st) const { |
|
183 |
st->print("%d", value()); |
|
184 |
} |
|
185 |
||
186 |
// ConstantLongValue |
|
187 |
||
188 |
ConstantLongValue::ConstantLongValue(DebugInfoReadStream* stream) { |
|
189 |
_value = stream->read_long(); |
|
190 |
} |
|
191 |
||
192 |
void ConstantLongValue::write_on(DebugInfoWriteStream* stream) { |
|
193 |
stream->write_int(CONSTANT_LONG_CODE); |
|
194 |
stream->write_long(value()); |
|
195 |
} |
|
196 |
||
197 |
void ConstantLongValue::print_on(outputStream* st) const { |
|
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46271
diff
changeset
|
198 |
st->print(JLONG_FORMAT, value()); |
1 | 199 |
} |
200 |
||
201 |
// ConstantDoubleValue |
|
202 |
||
203 |
ConstantDoubleValue::ConstantDoubleValue(DebugInfoReadStream* stream) { |
|
204 |
_value = stream->read_double(); |
|
205 |
} |
|
206 |
||
207 |
void ConstantDoubleValue::write_on(DebugInfoWriteStream* stream) { |
|
208 |
stream->write_int(CONSTANT_DOUBLE_CODE); |
|
209 |
stream->write_double(value()); |
|
210 |
} |
|
211 |
||
212 |
void ConstantDoubleValue::print_on(outputStream* st) const { |
|
213 |
st->print("%f", value()); |
|
214 |
} |
|
215 |
||
216 |
// ConstantOopWriteValue |
|
217 |
||
218 |
void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) { |
|
48120 | 219 |
#ifdef ASSERT |
220 |
{ |
|
221 |
// cannot use ThreadInVMfromNative here since in case of JVMCI compiler, |
|
222 |
// thread is already in VM state. |
|
223 |
ThreadInVMfromUnknown tiv; |
|
224 |
assert(JNIHandles::resolve(value()) == NULL || |
|
225 |
Universe::heap()->is_in_reserved(JNIHandles::resolve(value())), |
|
226 |
"Should be in heap"); |
|
227 |
} |
|
228 |
#endif |
|
1 | 229 |
stream->write_int(CONSTANT_OOP_CODE); |
230 |
stream->write_handle(value()); |
|
231 |
} |
|
232 |
||
233 |
void ConstantOopWriteValue::print_on(outputStream* st) const { |
|
48120 | 234 |
// using ThreadInVMfromUnknown here since in case of JVMCI compiler, |
235 |
// thread is already in VM state. |
|
236 |
ThreadInVMfromUnknown tiv; |
|
1 | 237 |
JNIHandles::resolve(value())->print_value_on(st); |
238 |
} |
|
239 |
||
240 |
||
241 |
// ConstantOopReadValue |
|
242 |
||
243 |
ConstantOopReadValue::ConstantOopReadValue(DebugInfoReadStream* stream) { |
|
46271
979ebd346ecf
8169881: Remove implicit Handle conversions oop->Handle
coleenp
parents:
33198
diff
changeset
|
244 |
_value = Handle(Thread::current(), stream->read_oop()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
245 |
assert(_value() == NULL || |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
7397
diff
changeset
|
246 |
Universe::heap()->is_in_reserved(_value()), "Should be in heap"); |
1 | 247 |
} |
248 |
||
249 |
void ConstantOopReadValue::write_on(DebugInfoWriteStream* stream) { |
|
250 |
ShouldNotReachHere(); |
|
251 |
} |
|
252 |
||
253 |
void ConstantOopReadValue::print_on(outputStream* st) const { |
|
254 |
value()()->print_value_on(st); |
|
255 |
} |
|
256 |
||
257 |
||
258 |
// MonitorValue |
|
259 |
||
260 |
MonitorValue::MonitorValue(ScopeValue* owner, Location basic_lock, bool eliminated) { |
|
261 |
_owner = owner; |
|
262 |
_basic_lock = basic_lock; |
|
263 |
_eliminated = eliminated; |
|
264 |
} |
|
265 |
||
266 |
MonitorValue::MonitorValue(DebugInfoReadStream* stream) { |
|
267 |
_basic_lock = Location(stream); |
|
268 |
_owner = ScopeValue::read_from(stream); |
|
269 |
_eliminated = (stream->read_bool() != 0); |
|
270 |
} |
|
271 |
||
272 |
void MonitorValue::write_on(DebugInfoWriteStream* stream) { |
|
273 |
_basic_lock.write_on(stream); |
|
274 |
_owner->write_on(stream); |
|
275 |
stream->write_bool(_eliminated); |
|
276 |
} |
|
277 |
||
278 |
#ifndef PRODUCT |
|
279 |
void MonitorValue::print_on(outputStream* st) const { |
|
280 |
st->print("monitor{"); |
|
281 |
owner()->print_on(st); |
|
282 |
st->print(","); |
|
283 |
basic_lock().print_on(st); |
|
284 |
st->print("}"); |
|
285 |
if (_eliminated) { |
|
286 |
st->print(" (eliminated)"); |
|
287 |
} |
|
288 |
} |
|
289 |
#endif |