author | naoto |
Tue, 09 Jul 2019 08:05:38 -0700 | |
changeset 55627 | 9c1885fb2a42 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
2 |
* Copyright (c) 1998, 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:
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/scopeDesc.hpp" |
|
28 |
#include "prims/jvmtiExport.hpp" |
|
1 | 29 |
|
30 |
// Private definition. |
|
31 |
// There is one DIR_Chunk for each scope and values array. |
|
32 |
// A chunk can potentially be used more than once. |
|
33 |
// We keep track of these chunks in order to detect |
|
34 |
// repetition and enable sharing. |
|
35 |
class DIR_Chunk { |
|
34501
d914dfe7abf5
8142333: Build failure in debugInfoRec.cpp with SS12u4
never
parents:
33593
diff
changeset
|
36 |
private: |
1 | 37 |
int _offset; // location in the stream of this scope |
38 |
int _length; // number of bytes in the stream |
|
39 |
int _hash; // hash of stream bytes (for quicker reuse) |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
40 |
DebugInformationRecorder* _DIR; |
1 | 41 |
|
34501
d914dfe7abf5
8142333: Build failure in debugInfoRec.cpp with SS12u4
never
parents:
33593
diff
changeset
|
42 |
public: |
d914dfe7abf5
8142333: Build failure in debugInfoRec.cpp with SS12u4
never
parents:
33593
diff
changeset
|
43 |
int offset() { return _offset; } |
d914dfe7abf5
8142333: Build failure in debugInfoRec.cpp with SS12u4
never
parents:
33593
diff
changeset
|
44 |
|
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
13728
diff
changeset
|
45 |
void* operator new(size_t ignore, DebugInformationRecorder* dir) throw() { |
1 | 46 |
assert(ignore == sizeof(DIR_Chunk), ""); |
47 |
if (dir->_next_chunk >= dir->_next_chunk_limit) { |
|
48 |
const int CHUNK = 100; |
|
49 |
dir->_next_chunk = NEW_RESOURCE_ARRAY(DIR_Chunk, CHUNK); |
|
50 |
dir->_next_chunk_limit = dir->_next_chunk + CHUNK; |
|
51 |
} |
|
52 |
return dir->_next_chunk++; |
|
53 |
} |
|
54 |
||
55 |
DIR_Chunk(int offset, int length, DebugInformationRecorder* dir) { |
|
56 |
_offset = offset; |
|
57 |
_length = length; |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
58 |
_DIR = dir; |
1 | 59 |
unsigned int hash = 0; |
60 |
address p = dir->stream()->buffer() + _offset; |
|
61 |
for (int i = 0; i < length; i++) { |
|
62 |
if (i == 6) break; |
|
63 |
hash *= 127; |
|
64 |
hash += p[i]; |
|
65 |
} |
|
66 |
_hash = hash; |
|
67 |
} |
|
68 |
||
69 |
DIR_Chunk* find_match(GrowableArray<DIR_Chunk*>* arr, |
|
70 |
int start_index, |
|
71 |
DebugInformationRecorder* dir) { |
|
72 |
int end_index = arr->length(); |
|
73 |
int hash = this->_hash, length = this->_length; |
|
74 |
address buf = dir->stream()->buffer(); |
|
75 |
for (int i = end_index; --i >= start_index; ) { |
|
76 |
DIR_Chunk* that = arr->at(i); |
|
77 |
if (hash == that->_hash && |
|
78 |
length == that->_length && |
|
79 |
0 == memcmp(buf + this->_offset, buf + that->_offset, length)) { |
|
80 |
return that; |
|
81 |
} |
|
82 |
} |
|
83 |
return NULL; |
|
84 |
} |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
85 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
86 |
static int compare(DIR_Chunk* const & a, DIR_Chunk* const & b) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
87 |
if (b->_hash > a->_hash) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
88 |
return 1; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
89 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
90 |
if (b->_hash < a->_hash) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
91 |
return -1; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
92 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
93 |
if (b->_length > a->_length) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
94 |
return 1; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
95 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
96 |
if (b->_length < a->_length) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
97 |
return -1; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
98 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
99 |
address buf = a->_DIR->stream()->buffer(); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
100 |
return memcmp(buf + b->_offset, buf + a->_offset, a->_length); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
101 |
} |
1 | 102 |
}; |
103 |
||
104 |
static inline bool compute_recording_non_safepoints() { |
|
105 |
if (JvmtiExport::should_post_compiled_method_load() |
|
106 |
&& FLAG_IS_DEFAULT(DebugNonSafepoints)) { |
|
107 |
// The default value of this flag is taken to be true, |
|
108 |
// if JVMTI is looking at nmethod codes. |
|
109 |
// We anticipate that JVMTI may wish to participate in profiling. |
|
110 |
return true; |
|
111 |
} |
|
112 |
||
113 |
// If the flag is set manually, use it, whether true or false. |
|
114 |
// Otherwise, if JVMTI is not in the picture, use the default setting. |
|
115 |
// (This is true in debug, just for the exercise, false in product mode.) |
|
116 |
return DebugNonSafepoints; |
|
117 |
} |
|
118 |
||
119 |
DebugInformationRecorder::DebugInformationRecorder(OopRecorder* oop_recorder) |
|
120 |
: _recording_non_safepoints(compute_recording_non_safepoints()) |
|
121 |
{ |
|
122 |
_pcs_size = 100; |
|
123 |
_pcs = NEW_RESOURCE_ARRAY(PcDesc, _pcs_size); |
|
124 |
_pcs_length = 0; |
|
125 |
||
126 |
_prev_safepoint_pc = PcDesc::lower_offset_limit; |
|
127 |
||
128 |
_stream = new DebugInfoWriteStream(this, 10 * K); |
|
129 |
// make sure that there is no stream_decode_offset that is zero |
|
130 |
_stream->write_byte((jbyte)0xFF); |
|
131 |
||
132 |
// make sure that we can distinguish the value "serialized_null" from offsets |
|
133 |
assert(_stream->position() > serialized_null, "sanity"); |
|
134 |
||
135 |
_oop_recorder = oop_recorder; |
|
136 |
||
137 |
_all_chunks = new GrowableArray<DIR_Chunk*>(300); |
|
138 |
_next_chunk = _next_chunk_limit = NULL; |
|
139 |
||
140 |
add_new_pc_offset(PcDesc::lower_offset_limit); // sentinel record |
|
141 |
||
142 |
debug_only(_recording_state = rs_null); |
|
143 |
} |
|
144 |
||
145 |
||
146 |
void DebugInformationRecorder::add_oopmap(int pc_offset, OopMap* map) { |
|
147 |
// !!!!! Preserve old style handling of oopmaps for now |
|
148 |
_oopmaps->add_gc_map(pc_offset, map); |
|
149 |
} |
|
150 |
||
151 |
void DebugInformationRecorder::add_safepoint(int pc_offset, OopMap* map) { |
|
152 |
assert(!_oop_recorder->is_complete(), "not frozen yet"); |
|
153 |
// Store the new safepoint |
|
154 |
||
155 |
// Add the oop map |
|
156 |
add_oopmap(pc_offset, map); |
|
157 |
||
158 |
add_new_pc_offset(pc_offset); |
|
159 |
||
160 |
assert(_recording_state == rs_null, "nesting of recording calls"); |
|
161 |
debug_only(_recording_state = rs_safepoint); |
|
162 |
} |
|
163 |
||
164 |
void DebugInformationRecorder::add_non_safepoint(int pc_offset) { |
|
165 |
assert(!_oop_recorder->is_complete(), "not frozen yet"); |
|
166 |
assert(_recording_non_safepoints, "must be recording non-safepoints"); |
|
167 |
||
168 |
add_new_pc_offset(pc_offset); |
|
169 |
||
170 |
assert(_recording_state == rs_null, "nesting of recording calls"); |
|
171 |
debug_only(_recording_state = rs_non_safepoint); |
|
172 |
} |
|
173 |
||
174 |
void DebugInformationRecorder::add_new_pc_offset(int pc_offset) { |
|
175 |
assert(_pcs_length == 0 || last_pc()->pc_offset() < pc_offset, |
|
176 |
"must specify a new, larger pc offset"); |
|
177 |
||
178 |
// add the pcdesc |
|
179 |
if (_pcs_length == _pcs_size) { |
|
180 |
// Expand |
|
181 |
int new_pcs_size = _pcs_size * 2; |
|
182 |
PcDesc* new_pcs = NEW_RESOURCE_ARRAY(PcDesc, new_pcs_size); |
|
183 |
for (int index = 0; index < _pcs_length; index++) { |
|
184 |
new_pcs[index] = _pcs[index]; |
|
185 |
} |
|
186 |
_pcs_size = new_pcs_size; |
|
187 |
_pcs = new_pcs; |
|
188 |
} |
|
189 |
assert(_pcs_size > _pcs_length, "There must be room for after expanding"); |
|
190 |
||
191 |
_pcs[_pcs_length++] = PcDesc(pc_offset, DebugInformationRecorder::serialized_null, |
|
192 |
DebugInformationRecorder::serialized_null); |
|
193 |
} |
|
194 |
||
195 |
||
196 |
int DebugInformationRecorder::serialize_monitor_values(GrowableArray<MonitorValue*>* monitors) { |
|
197 |
if (monitors == NULL || monitors->is_empty()) return DebugInformationRecorder::serialized_null; |
|
198 |
assert(_recording_state == rs_safepoint, "must be recording a safepoint"); |
|
199 |
int result = stream()->position(); |
|
200 |
stream()->write_int(monitors->length()); |
|
201 |
for (int index = 0; index < monitors->length(); index++) { |
|
202 |
monitors->at(index)->write_on(stream()); |
|
203 |
} |
|
204 |
assert(result != serialized_null, "sanity"); |
|
205 |
||
206 |
// (See comment below on DebugInformationRecorder::describe_scope.) |
|
207 |
int shared_result = find_sharable_decode_offset(result); |
|
208 |
if (shared_result != serialized_null) { |
|
209 |
stream()->set_position(result); |
|
210 |
result = shared_result; |
|
211 |
} |
|
212 |
||
213 |
return result; |
|
214 |
} |
|
215 |
||
216 |
||
217 |
int DebugInformationRecorder::serialize_scope_values(GrowableArray<ScopeValue*>* values) { |
|
218 |
if (values == NULL || values->is_empty()) return DebugInformationRecorder::serialized_null; |
|
219 |
assert(_recording_state == rs_safepoint, "must be recording a safepoint"); |
|
220 |
int result = stream()->position(); |
|
221 |
assert(result != serialized_null, "sanity"); |
|
222 |
stream()->write_int(values->length()); |
|
223 |
for (int index = 0; index < values->length(); index++) { |
|
224 |
values->at(index)->write_on(stream()); |
|
225 |
} |
|
226 |
||
227 |
// (See comment below on DebugInformationRecorder::describe_scope.) |
|
228 |
int shared_result = find_sharable_decode_offset(result); |
|
229 |
if (shared_result != serialized_null) { |
|
230 |
stream()->set_position(result); |
|
231 |
result = shared_result; |
|
232 |
} |
|
233 |
||
234 |
return result; |
|
235 |
} |
|
236 |
||
237 |
||
238 |
#ifndef PRODUCT |
|
239 |
// These variables are put into one block to reduce relocations |
|
240 |
// and make it simpler to print from the debugger. |
|
241 |
static |
|
242 |
struct dir_stats_struct { |
|
243 |
int chunks_queried; |
|
244 |
int chunks_shared; |
|
245 |
int chunks_reshared; |
|
246 |
int chunks_elided; |
|
247 |
||
248 |
void print() { |
|
249 |
tty->print_cr("Debug Data Chunks: %d, shared %d+%d, non-SP's elided %d", |
|
250 |
chunks_queried, |
|
251 |
chunks_shared, chunks_reshared, |
|
252 |
chunks_elided); |
|
253 |
} |
|
254 |
} dir_stats; |
|
255 |
#endif //PRODUCT |
|
256 |
||
257 |
||
258 |
int DebugInformationRecorder::find_sharable_decode_offset(int stream_offset) { |
|
259 |
NOT_PRODUCT(++dir_stats.chunks_queried); |
|
260 |
int stream_length = stream()->position() - stream_offset; |
|
261 |
assert(stream_offset != serialized_null, "should not be null"); |
|
262 |
assert(stream_length != 0, "should not be empty"); |
|
263 |
||
264 |
DIR_Chunk* ns = new(this) DIR_Chunk(stream_offset, stream_length, this); |
|
265 |
||
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
266 |
DIR_Chunk* match = _all_chunks->insert_sorted<DIR_Chunk::compare>(ns); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
267 |
if (match != ns) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
268 |
// Found an existing chunk |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
269 |
NOT_PRODUCT(++dir_stats.chunks_shared); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
270 |
assert(ns+1 == _next_chunk, ""); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
271 |
_next_chunk = ns; |
34501
d914dfe7abf5
8142333: Build failure in debugInfoRec.cpp with SS12u4
never
parents:
33593
diff
changeset
|
272 |
return match->offset(); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
273 |
} else { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
274 |
// Inserted this chunk, so nothing to do |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
275 |
return serialized_null; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
276 |
} |
1 | 277 |
} |
278 |
||
279 |
||
280 |
// must call add_safepoint before: it sets PcDesc and this routine uses |
|
281 |
// the last PcDesc set |
|
282 |
void DebugInformationRecorder::describe_scope(int pc_offset, |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
33160
diff
changeset
|
283 |
const methodHandle& methodH, |
1 | 284 |
ciMethod* method, |
285 |
int bci, |
|
3600
27aa4477d039
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
1
diff
changeset
|
286 |
bool reexecute, |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
287 |
bool rethrow_exception, |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4017
diff
changeset
|
288 |
bool is_method_handle_invoke, |
4894
8a76fd3d098d
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
4564
diff
changeset
|
289 |
bool return_oop, |
1 | 290 |
DebugToken* locals, |
291 |
DebugToken* expressions, |
|
292 |
DebugToken* monitors) { |
|
293 |
assert(_recording_state != rs_null, "nesting of recording calls"); |
|
294 |
PcDesc* last_pd = last_pc(); |
|
295 |
assert(last_pd->pc_offset() == pc_offset, "must be last pc"); |
|
296 |
int sender_stream_offset = last_pd->scope_decode_offset(); |
|
297 |
// update the stream offset of current pc desc |
|
298 |
int stream_offset = stream()->position(); |
|
299 |
last_pd->set_scope_decode_offset(stream_offset); |
|
300 |
||
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4017
diff
changeset
|
301 |
// Record flags into pcDesc. |
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
302 |
last_pd->set_should_reexecute(reexecute); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
303 |
last_pd->set_rethrow_exception(rethrow_exception); |
4564
55dfb20908d0
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
4017
diff
changeset
|
304 |
last_pd->set_is_method_handle_invoke(is_method_handle_invoke); |
4894
8a76fd3d098d
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
4564
diff
changeset
|
305 |
last_pd->set_return_oop(return_oop); |
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
306 |
|
1 | 307 |
// serialize sender stream offest |
308 |
stream()->write_int(sender_stream_offset); |
|
309 |
||
310 |
// serialize scope |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
311 |
Metadata* method_enc; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
312 |
if (method != NULL) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
313 |
method_enc = method->constant_encoding(); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
314 |
} else if (methodH.not_null()) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
315 |
method_enc = methodH(); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
316 |
} else { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
317 |
method_enc = NULL; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
318 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
319 |
int method_enc_index = oop_recorder()->find_index(method_enc); |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
320 |
stream()->write_int(method_enc_index); |
3686
69c1b5228547
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
3600
diff
changeset
|
321 |
stream()->write_bci(bci); |
1 | 322 |
assert(method == NULL || |
323 |
(method->is_native() && bci == 0) || |
|
324 |
(!method->is_native() && 0 <= bci && bci < method->code_size()) || |
|
325 |
bci == -1, "illegal bci"); |
|
326 |
||
327 |
// serialize the locals/expressions/monitors |
|
328 |
stream()->write_int((intptr_t) locals); |
|
329 |
stream()->write_int((intptr_t) expressions); |
|
330 |
stream()->write_int((intptr_t) monitors); |
|
331 |
||
332 |
// Here's a tricky bit. We just wrote some bytes. |
|
333 |
// Wouldn't it be nice to find that we had already |
|
334 |
// written those same bytes somewhere else? |
|
335 |
// If we get lucky this way, reset the stream |
|
336 |
// and reuse the old bytes. By the way, this |
|
337 |
// trick not only shares parent scopes, but also |
|
338 |
// compresses equivalent non-safepoint PcDescs. |
|
339 |
int shared_stream_offset = find_sharable_decode_offset(stream_offset); |
|
340 |
if (shared_stream_offset != serialized_null) { |
|
341 |
stream()->set_position(stream_offset); |
|
342 |
last_pd->set_scope_decode_offset(shared_stream_offset); |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
void DebugInformationRecorder::dump_object_pool(GrowableArray<ScopeValue*>* objects) { |
|
347 |
guarantee( _pcs_length > 0, "safepoint must exist before describing scopes"); |
|
348 |
PcDesc* last_pd = &_pcs[_pcs_length-1]; |
|
349 |
if (objects != NULL) { |
|
350 |
for (int i = objects->length() - 1; i >= 0; i--) { |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
19696
diff
changeset
|
351 |
objects->at(i)->as_ObjectValue()->set_visited(false); |
1 | 352 |
} |
353 |
} |
|
354 |
int offset = serialize_scope_values(objects); |
|
355 |
last_pd->set_obj_decode_offset(offset); |
|
356 |
} |
|
357 |
||
358 |
void DebugInformationRecorder::end_scopes(int pc_offset, bool is_safepoint) { |
|
359 |
assert(_recording_state == (is_safepoint? rs_safepoint: rs_non_safepoint), |
|
360 |
"nesting of recording calls"); |
|
361 |
debug_only(_recording_state = rs_null); |
|
362 |
||
363 |
// Try to compress away an equivalent non-safepoint predecessor. |
|
364 |
// (This only works because we have previously recognized redundant |
|
365 |
// scope trees and made them use a common scope_decode_offset.) |
|
366 |
if (_pcs_length >= 2 && recording_non_safepoints()) { |
|
367 |
PcDesc* last = last_pc(); |
|
368 |
PcDesc* prev = prev_pc(); |
|
369 |
// If prev is (a) not a safepoint and (b) has the same |
|
370 |
// stream pointer, then it can be coalesced into the last. |
|
371 |
// This is valid because non-safepoints are only sought |
|
372 |
// with pc_desc_near, which (when it misses prev) will |
|
373 |
// search forward until it finds last. |
|
374 |
// In addition, it does not matter if the last PcDesc |
|
375 |
// is for a safepoint or not. |
|
4017
0cb087a2b9a9
6889869: assert(!Interpreter::bytecode_should_reexecute(code),"should not reexecute")
never
parents:
3908
diff
changeset
|
376 |
if (_prev_safepoint_pc < prev->pc_offset() && prev->is_same_info(last)) { |
1 | 377 |
assert(prev == last-1, "sane"); |
378 |
prev->set_pc_offset(pc_offset); |
|
379 |
_pcs_length -= 1; |
|
380 |
NOT_PRODUCT(++dir_stats.chunks_elided); |
|
381 |
} |
|
382 |
} |
|
383 |
||
384 |
// We have just recorded this safepoint. |
|
385 |
// Remember it in case the previous paragraph needs to know. |
|
386 |
if (is_safepoint) { |
|
387 |
_prev_safepoint_pc = pc_offset; |
|
388 |
} |
|
389 |
} |
|
390 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
391 |
#ifdef ASSERT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
392 |
bool DebugInformationRecorder::recorders_frozen() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
393 |
return _oop_recorder->is_complete() || _oop_recorder->is_complete(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
394 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
395 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
396 |
void DebugInformationRecorder::mark_recorders_frozen() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
397 |
_oop_recorder->freeze(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
398 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
399 |
#endif // PRODUCT |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
400 |
|
1 | 401 |
DebugToken* DebugInformationRecorder::create_scope_values(GrowableArray<ScopeValue*>* values) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
402 |
assert(!recorders_frozen(), "not frozen yet"); |
1 | 403 |
return (DebugToken*) (intptr_t) serialize_scope_values(values); |
404 |
} |
|
405 |
||
406 |
||
407 |
DebugToken* DebugInformationRecorder::create_monitor_values(GrowableArray<MonitorValue*>* monitors) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
408 |
assert(!recorders_frozen(), "not frozen yet"); |
1 | 409 |
return (DebugToken*) (intptr_t) serialize_monitor_values(monitors); |
410 |
} |
|
411 |
||
412 |
||
413 |
int DebugInformationRecorder::data_size() { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
414 |
debug_only(mark_recorders_frozen()); // mark it "frozen" for asserts |
1 | 415 |
return _stream->position(); |
416 |
} |
|
417 |
||
418 |
||
419 |
int DebugInformationRecorder::pcs_size() { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
420 |
debug_only(mark_recorders_frozen()); // mark it "frozen" for asserts |
1 | 421 |
if (last_pc()->pc_offset() != PcDesc::upper_offset_limit) |
422 |
add_new_pc_offset(PcDesc::upper_offset_limit); |
|
423 |
return _pcs_length * sizeof(PcDesc); |
|
424 |
} |
|
425 |
||
426 |
||
427 |
void DebugInformationRecorder::copy_to(nmethod* nm) { |
|
428 |
nm->copy_scopes_data(stream()->buffer(), stream()->position()); |
|
429 |
nm->copy_scopes_pcs(_pcs, _pcs_length); |
|
430 |
} |
|
431 |
||
432 |
||
433 |
void DebugInformationRecorder::verify(const nmethod* code) { |
|
434 |
Unimplemented(); |
|
435 |
} |
|
436 |
||
437 |
#ifndef PRODUCT |
|
438 |
void DebugInformationRecorder::print_statistics() { |
|
439 |
dir_stats.print(); |
|
440 |
} |
|
441 |
#endif //PRODUCT |