Mercurial > hg > truffle
annotate src/share/vm/code/debugInfoRec.cpp @ 19177:1a7b33c96c0d
Fixes for TruffleGraphBuilderPluginsProvider.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 06 Feb 2015 16:49:34 +0100 |
parents | b888ded3ee42 |
children | 15ef24874df7 |
rev | line source |
---|---|
0 | 1 /* |
12146
9758d9f36299
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
6725
diff
changeset
|
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1253
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1253
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1253
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "code/debugInfoRec.hpp" | |
27 #include "code/scopeDesc.hpp" | |
28 #include "prims/jvmtiExport.hpp" | |
0 | 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 { | |
36 friend class DebugInformationRecorder; | |
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) | |
17376
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
40 #ifdef GRAAL |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
41 DebugInformationRecorder* _DIR; |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
42 #endif |
0 | 43 |
12146
9758d9f36299
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
6725
diff
changeset
|
44 void* operator new(size_t ignore, DebugInformationRecorder* dir) throw() { |
0 | 45 assert(ignore == sizeof(DIR_Chunk), ""); |
46 if (dir->_next_chunk >= dir->_next_chunk_limit) { | |
47 const int CHUNK = 100; | |
48 dir->_next_chunk = NEW_RESOURCE_ARRAY(DIR_Chunk, CHUNK); | |
49 dir->_next_chunk_limit = dir->_next_chunk + CHUNK; | |
50 } | |
51 return dir->_next_chunk++; | |
52 } | |
53 | |
54 DIR_Chunk(int offset, int length, DebugInformationRecorder* dir) { | |
55 _offset = offset; | |
56 _length = length; | |
17376
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
57 #ifdef GRAAL |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
58 _DIR = dir; |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
59 #endif |
0 | 60 unsigned int hash = 0; |
61 address p = dir->stream()->buffer() + _offset; | |
62 for (int i = 0; i < length; i++) { | |
63 if (i == 6) break; | |
64 hash *= 127; | |
65 hash += p[i]; | |
66 } | |
67 _hash = hash; | |
68 } | |
69 | |
70 DIR_Chunk* find_match(GrowableArray<DIR_Chunk*>* arr, | |
71 int start_index, | |
72 DebugInformationRecorder* dir) { | |
73 int end_index = arr->length(); | |
74 int hash = this->_hash, length = this->_length; | |
75 address buf = dir->stream()->buffer(); | |
76 for (int i = end_index; --i >= start_index; ) { | |
77 DIR_Chunk* that = arr->at(i); | |
78 if (hash == that->_hash && | |
79 length == that->_length && | |
80 0 == memcmp(buf + this->_offset, buf + that->_offset, length)) { | |
81 return that; | |
82 } | |
83 } | |
84 return NULL; | |
85 } | |
17376
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
86 |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
87 #ifdef GRAAL |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
88 static int compare(DIR_Chunk* a, DIR_Chunk* b) { |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
89 if (b->_hash > a->_hash) { |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
90 return 1; |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
91 } |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
92 if (b->_hash < a->_hash) { |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
93 return -1; |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
94 } |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
95 if (b->_length > a->_length) { |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
96 return 1; |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
97 } |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
98 if (b->_length < a->_length) { |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
99 return -1; |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
100 } |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
101 address buf = a->_DIR->stream()->buffer(); |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
102 return memcmp(buf + b->_offset, buf + a->_offset, a->_length); |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
103 } |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
104 #endif |
0 | 105 }; |
106 | |
107 static inline bool compute_recording_non_safepoints() { | |
108 if (JvmtiExport::should_post_compiled_method_load() | |
109 && FLAG_IS_DEFAULT(DebugNonSafepoints)) { | |
110 // The default value of this flag is taken to be true, | |
111 // if JVMTI is looking at nmethod codes. | |
112 // We anticipate that JVMTI may wish to participate in profiling. | |
113 return true; | |
114 } | |
115 | |
116 // If the flag is set manually, use it, whether true or false. | |
117 // Otherwise, if JVMTI is not in the picture, use the default setting. | |
118 // (This is true in debug, just for the exercise, false in product mode.) | |
119 return DebugNonSafepoints; | |
120 } | |
121 | |
122 DebugInformationRecorder::DebugInformationRecorder(OopRecorder* oop_recorder) | |
123 : _recording_non_safepoints(compute_recording_non_safepoints()) | |
124 { | |
125 _pcs_size = 100; | |
126 _pcs = NEW_RESOURCE_ARRAY(PcDesc, _pcs_size); | |
127 _pcs_length = 0; | |
128 | |
129 _prev_safepoint_pc = PcDesc::lower_offset_limit; | |
130 | |
131 _stream = new DebugInfoWriteStream(this, 10 * K); | |
132 // make sure that there is no stream_decode_offset that is zero | |
133 _stream->write_byte((jbyte)0xFF); | |
134 | |
135 // make sure that we can distinguish the value "serialized_null" from offsets | |
136 assert(_stream->position() > serialized_null, "sanity"); | |
137 | |
138 _oop_recorder = oop_recorder; | |
139 | |
140 _all_chunks = new GrowableArray<DIR_Chunk*>(300); | |
17376
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
141 #ifndef GRAAL |
0 | 142 _shared_chunks = new GrowableArray<DIR_Chunk*>(30); |
17376
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
143 #endif |
0 | 144 _next_chunk = _next_chunk_limit = NULL; |
145 | |
146 add_new_pc_offset(PcDesc::lower_offset_limit); // sentinel record | |
147 | |
148 debug_only(_recording_state = rs_null); | |
149 } | |
150 | |
151 | |
152 void DebugInformationRecorder::add_oopmap(int pc_offset, OopMap* map) { | |
153 // !!!!! Preserve old style handling of oopmaps for now | |
154 _oopmaps->add_gc_map(pc_offset, map); | |
155 } | |
156 | |
157 void DebugInformationRecorder::add_safepoint(int pc_offset, OopMap* map) { | |
158 assert(!_oop_recorder->is_complete(), "not frozen yet"); | |
159 // Store the new safepoint | |
160 | |
161 // Add the oop map | |
162 add_oopmap(pc_offset, map); | |
163 | |
164 add_new_pc_offset(pc_offset); | |
165 | |
166 assert(_recording_state == rs_null, "nesting of recording calls"); | |
167 debug_only(_recording_state = rs_safepoint); | |
168 } | |
169 | |
170 void DebugInformationRecorder::add_non_safepoint(int pc_offset) { | |
171 assert(!_oop_recorder->is_complete(), "not frozen yet"); | |
172 assert(_recording_non_safepoints, "must be recording non-safepoints"); | |
173 | |
174 add_new_pc_offset(pc_offset); | |
175 | |
176 assert(_recording_state == rs_null, "nesting of recording calls"); | |
177 debug_only(_recording_state = rs_non_safepoint); | |
178 } | |
179 | |
180 void DebugInformationRecorder::add_new_pc_offset(int pc_offset) { | |
181 assert(_pcs_length == 0 || last_pc()->pc_offset() < pc_offset, | |
182 "must specify a new, larger pc offset"); | |
183 | |
184 // add the pcdesc | |
185 if (_pcs_length == _pcs_size) { | |
186 // Expand | |
187 int new_pcs_size = _pcs_size * 2; | |
188 PcDesc* new_pcs = NEW_RESOURCE_ARRAY(PcDesc, new_pcs_size); | |
189 for (int index = 0; index < _pcs_length; index++) { | |
190 new_pcs[index] = _pcs[index]; | |
191 } | |
192 _pcs_size = new_pcs_size; | |
193 _pcs = new_pcs; | |
194 } | |
195 assert(_pcs_size > _pcs_length, "There must be room for after expanding"); | |
196 | |
197 _pcs[_pcs_length++] = PcDesc(pc_offset, DebugInformationRecorder::serialized_null, | |
198 DebugInformationRecorder::serialized_null); | |
199 } | |
200 | |
201 | |
202 int DebugInformationRecorder::serialize_monitor_values(GrowableArray<MonitorValue*>* monitors) { | |
203 if (monitors == NULL || monitors->is_empty()) return DebugInformationRecorder::serialized_null; | |
204 assert(_recording_state == rs_safepoint, "must be recording a safepoint"); | |
205 int result = stream()->position(); | |
206 stream()->write_int(monitors->length()); | |
207 for (int index = 0; index < monitors->length(); index++) { | |
208 monitors->at(index)->write_on(stream()); | |
209 } | |
210 assert(result != serialized_null, "sanity"); | |
211 | |
212 // (See comment below on DebugInformationRecorder::describe_scope.) | |
213 int shared_result = find_sharable_decode_offset(result); | |
214 if (shared_result != serialized_null) { | |
215 stream()->set_position(result); | |
216 result = shared_result; | |
217 } | |
218 | |
219 return result; | |
220 } | |
221 | |
222 | |
223 int DebugInformationRecorder::serialize_scope_values(GrowableArray<ScopeValue*>* values) { | |
224 if (values == NULL || values->is_empty()) return DebugInformationRecorder::serialized_null; | |
225 assert(_recording_state == rs_safepoint, "must be recording a safepoint"); | |
226 int result = stream()->position(); | |
227 assert(result != serialized_null, "sanity"); | |
228 stream()->write_int(values->length()); | |
229 for (int index = 0; index < values->length(); index++) { | |
230 values->at(index)->write_on(stream()); | |
231 } | |
232 | |
233 // (See comment below on DebugInformationRecorder::describe_scope.) | |
234 int shared_result = find_sharable_decode_offset(result); | |
235 if (shared_result != serialized_null) { | |
236 stream()->set_position(result); | |
237 result = shared_result; | |
238 } | |
239 | |
240 return result; | |
241 } | |
242 | |
243 | |
244 #ifndef PRODUCT | |
245 // These variables are put into one block to reduce relocations | |
246 // and make it simpler to print from the debugger. | |
247 static | |
248 struct dir_stats_struct { | |
249 int chunks_queried; | |
250 int chunks_shared; | |
251 int chunks_reshared; | |
252 int chunks_elided; | |
253 | |
254 void print() { | |
255 tty->print_cr("Debug Data Chunks: %d, shared %d+%d, non-SP's elided %d", | |
256 chunks_queried, | |
257 chunks_shared, chunks_reshared, | |
258 chunks_elided); | |
259 } | |
260 } dir_stats; | |
261 #endif //PRODUCT | |
262 | |
263 | |
264 int DebugInformationRecorder::find_sharable_decode_offset(int stream_offset) { | |
15433
8638307944be
Add flag to always enable debug info sharing (true ifdef GRAAL)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15100
diff
changeset
|
265 if (FLAG_IS_DEFAULT(ShareDebugInfo)) { |
8638307944be
Add flag to always enable debug info sharing (true ifdef GRAAL)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15100
diff
changeset
|
266 if (!ShareDebugInfo && !recording_non_safepoints()) { |
8638307944be
Add flag to always enable debug info sharing (true ifdef GRAAL)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15100
diff
changeset
|
267 return serialized_null; |
8638307944be
Add flag to always enable debug info sharing (true ifdef GRAAL)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15100
diff
changeset
|
268 } |
8638307944be
Add flag to always enable debug info sharing (true ifdef GRAAL)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15100
diff
changeset
|
269 } else if (!ShareDebugInfo) { |
0 | 270 return serialized_null; |
15433
8638307944be
Add flag to always enable debug info sharing (true ifdef GRAAL)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15100
diff
changeset
|
271 } |
0 | 272 |
273 NOT_PRODUCT(++dir_stats.chunks_queried); | |
274 int stream_length = stream()->position() - stream_offset; | |
275 assert(stream_offset != serialized_null, "should not be null"); | |
276 assert(stream_length != 0, "should not be empty"); | |
277 | |
278 DIR_Chunk* ns = new(this) DIR_Chunk(stream_offset, stream_length, this); | |
279 | |
17376
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
280 #ifdef GRAAL |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
281 DIR_Chunk* match = _all_chunks->find_insert_binary<DIR_Chunk::compare>(ns); |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
282 if (match != ns) { |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
283 // Found an existing chunk |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
284 NOT_PRODUCT(++dir_stats.chunks_shared); |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
285 assert(ns+1 == _next_chunk, ""); |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
286 _next_chunk = ns; |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
287 return match->_offset; |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
288 } else { |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
289 // Inserted this chunk, so nothing to do |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
290 return serialized_null; |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
291 } |
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
292 #else |
0 | 293 // Look in previously shared scopes first: |
294 DIR_Chunk* ms = ns->find_match(_shared_chunks, 0, this); | |
295 if (ms != NULL) { | |
296 NOT_PRODUCT(++dir_stats.chunks_reshared); | |
297 assert(ns+1 == _next_chunk, ""); | |
298 _next_chunk = ns; | |
299 return ms->_offset; | |
300 } | |
301 | |
302 // Look in recently encountered scopes next: | |
303 const int MAX_RECENT = 50; | |
304 int start_index = _all_chunks->length() - MAX_RECENT; | |
305 if (start_index < 0) start_index = 0; | |
306 ms = ns->find_match(_all_chunks, start_index, this); | |
307 if (ms != NULL) { | |
308 NOT_PRODUCT(++dir_stats.chunks_shared); | |
309 // Searching in _all_chunks is limited to a window, | |
310 // but searching in _shared_chunks is unlimited. | |
311 _shared_chunks->append(ms); | |
312 assert(ns+1 == _next_chunk, ""); | |
313 _next_chunk = ns; | |
314 return ms->_offset; | |
315 } | |
316 | |
317 // No match. Add this guy to the list, in hopes of future shares. | |
318 _all_chunks->append(ns); | |
319 return serialized_null; | |
17376
b888ded3ee42
Be more aggressive about sharing of debug info
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15433
diff
changeset
|
320 #endif |
0 | 321 } |
322 | |
323 | |
324 // must call add_safepoint before: it sets PcDesc and this routine uses | |
325 // the last PcDesc set | |
326 void DebugInformationRecorder::describe_scope(int pc_offset, | |
4583
597bc897257d
Made DebugInformationRecorder::describe_scope() take both a methodHandle _and_ a ciMethod* parameter to avoid creating handles in scopes where it is not allowed.
Doug Simon <doug.simon@oracle.com>
parents:
3650
diff
changeset
|
327 methodHandle methodH, |
0 | 328 ciMethod* method, |
329 int bci, | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
0
diff
changeset
|
330 bool reexecute, |
3018
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
1972
diff
changeset
|
331 bool rethrow_exception, |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1014
diff
changeset
|
332 bool is_method_handle_invoke, |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1135
diff
changeset
|
333 bool return_oop, |
0 | 334 DebugToken* locals, |
335 DebugToken* expressions, | |
336 DebugToken* monitors) { | |
337 assert(_recording_state != rs_null, "nesting of recording calls"); | |
338 PcDesc* last_pd = last_pc(); | |
339 assert(last_pd->pc_offset() == pc_offset, "must be last pc"); | |
340 int sender_stream_offset = last_pd->scope_decode_offset(); | |
341 // update the stream offset of current pc desc | |
342 int stream_offset = stream()->position(); | |
343 last_pd->set_scope_decode_offset(stream_offset); | |
344 | |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1014
diff
changeset
|
345 // Record flags into pcDesc. |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
900
diff
changeset
|
346 last_pd->set_should_reexecute(reexecute); |
3018
5857923e563c
Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
1972
diff
changeset
|
347 last_pd->set_rethrow_exception(rethrow_exception); |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1014
diff
changeset
|
348 last_pd->set_is_method_handle_invoke(is_method_handle_invoke); |
1253
f70b0d9ab095
6910618: C2: Error: assert(d->is_oop(),"JVM_ArrayCopy: dst not an oop")
kvn
parents:
1135
diff
changeset
|
349 last_pd->set_return_oop(return_oop); |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
900
diff
changeset
|
350 |
0 | 351 // serialize sender stream offest |
352 stream()->write_int(sender_stream_offset); | |
353 | |
354 // serialize scope | |
6948
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
355 Metadata* method_enc; |
4583
597bc897257d
Made DebugInformationRecorder::describe_scope() take both a methodHandle _and_ a ciMethod* parameter to avoid creating handles in scopes where it is not allowed.
Doug Simon <doug.simon@oracle.com>
parents:
3650
diff
changeset
|
356 if (method != NULL) { |
597bc897257d
Made DebugInformationRecorder::describe_scope() take both a methodHandle _and_ a ciMethod* parameter to avoid creating handles in scopes where it is not allowed.
Doug Simon <doug.simon@oracle.com>
parents:
3650
diff
changeset
|
357 method_enc = method->constant_encoding(); |
597bc897257d
Made DebugInformationRecorder::describe_scope() take both a methodHandle _and_ a ciMethod* parameter to avoid creating handles in scopes where it is not allowed.
Doug Simon <doug.simon@oracle.com>
parents:
3650
diff
changeset
|
358 } else if (methodH.not_null()) { |
6948
e522a00b91aa
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
diff
changeset
|
359 method_enc = methodH(); |
4583
597bc897257d
Made DebugInformationRecorder::describe_scope() take both a methodHandle _and_ a ciMethod* parameter to avoid creating handles in scopes where it is not allowed.
Doug Simon <doug.simon@oracle.com>
parents:
3650
diff
changeset
|
360 } else { |
597bc897257d
Made DebugInformationRecorder::describe_scope() take both a methodHandle _and_ a ciMethod* parameter to avoid creating handles in scopes where it is not allowed.
Doug Simon <doug.simon@oracle.com>
parents:
3650
diff
changeset
|
361 method_enc = NULL; |
597bc897257d
Made DebugInformationRecorder::describe_scope() take both a methodHandle _and_ a ciMethod* parameter to avoid creating handles in scopes where it is not allowed.
Doug Simon <doug.simon@oracle.com>
parents:
3650
diff
changeset
|
362 } |
0 | 363 stream()->write_int(oop_recorder()->find_index(method_enc)); |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
900
diff
changeset
|
364 stream()->write_bci(bci); |
0 | 365 assert(method == NULL || |
366 (method->is_native() && bci == 0) || | |
367 (!method->is_native() && 0 <= bci && bci < method->code_size()) || | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
1972
diff
changeset
|
368 (method->is_compiled_lambda_form() && bci == -99) || // this might happen in C1 |
0 | 369 bci == -1, "illegal bci"); |
370 | |
371 // serialize the locals/expressions/monitors | |
372 stream()->write_int((intptr_t) locals); | |
373 stream()->write_int((intptr_t) expressions); | |
374 stream()->write_int((intptr_t) monitors); | |
375 | |
376 // Here's a tricky bit. We just wrote some bytes. | |
377 // Wouldn't it be nice to find that we had already | |
378 // written those same bytes somewhere else? | |
379 // If we get lucky this way, reset the stream | |
380 // and reuse the old bytes. By the way, this | |
381 // trick not only shares parent scopes, but also | |
382 // compresses equivalent non-safepoint PcDescs. | |
383 int shared_stream_offset = find_sharable_decode_offset(stream_offset); | |
384 if (shared_stream_offset != serialized_null) { | |
385 stream()->set_position(stream_offset); | |
386 last_pd->set_scope_decode_offset(shared_stream_offset); | |
387 } | |
388 } | |
389 | |
390 void DebugInformationRecorder::dump_object_pool(GrowableArray<ScopeValue*>* objects) { | |
391 guarantee( _pcs_length > 0, "safepoint must exist before describing scopes"); | |
392 PcDesc* last_pd = &_pcs[_pcs_length-1]; | |
393 if (objects != NULL) { | |
394 for (int i = objects->length() - 1; i >= 0; i--) { | |
395 ((ObjectValue*) objects->at(i))->set_visited(false); | |
396 } | |
397 } | |
398 int offset = serialize_scope_values(objects); | |
399 last_pd->set_obj_decode_offset(offset); | |
400 } | |
401 | |
402 void DebugInformationRecorder::end_scopes(int pc_offset, bool is_safepoint) { | |
403 assert(_recording_state == (is_safepoint? rs_safepoint: rs_non_safepoint), | |
404 "nesting of recording calls"); | |
405 debug_only(_recording_state = rs_null); | |
406 | |
407 // Try to compress away an equivalent non-safepoint predecessor. | |
408 // (This only works because we have previously recognized redundant | |
409 // scope trees and made them use a common scope_decode_offset.) | |
410 if (_pcs_length >= 2 && recording_non_safepoints()) { | |
411 PcDesc* last = last_pc(); | |
412 PcDesc* prev = prev_pc(); | |
413 // If prev is (a) not a safepoint and (b) has the same | |
414 // stream pointer, then it can be coalesced into the last. | |
415 // This is valid because non-safepoints are only sought | |
416 // with pc_desc_near, which (when it misses prev) will | |
417 // search forward until it finds last. | |
418 // In addition, it does not matter if the last PcDesc | |
419 // is for a safepoint or not. | |
1014
8e954aedbb81
6889869: assert(!Interpreter::bytecode_should_reexecute(code),"should not reexecute")
never
parents:
989
diff
changeset
|
420 if (_prev_safepoint_pc < prev->pc_offset() && prev->is_same_info(last)) { |
0 | 421 assert(prev == last-1, "sane"); |
422 prev->set_pc_offset(pc_offset); | |
423 _pcs_length -= 1; | |
424 NOT_PRODUCT(++dir_stats.chunks_elided); | |
425 } | |
426 } | |
427 | |
428 // We have just recorded this safepoint. | |
429 // Remember it in case the previous paragraph needs to know. | |
430 if (is_safepoint) { | |
431 _prev_safepoint_pc = pc_offset; | |
432 } | |
433 } | |
434 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
435 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
436 bool DebugInformationRecorder::recorders_frozen() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
437 return _oop_recorder->is_complete() || _oop_recorder->is_complete(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
438 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
439 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
440 void DebugInformationRecorder::mark_recorders_frozen() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
441 _oop_recorder->freeze(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
442 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
443 #endif // PRODUCT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
444 |
0 | 445 DebugToken* DebugInformationRecorder::create_scope_values(GrowableArray<ScopeValue*>* values) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
446 assert(!recorders_frozen(), "not frozen yet"); |
0 | 447 return (DebugToken*) (intptr_t) serialize_scope_values(values); |
448 } | |
449 | |
450 | |
451 DebugToken* DebugInformationRecorder::create_monitor_values(GrowableArray<MonitorValue*>* monitors) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
452 assert(!recorders_frozen(), "not frozen yet"); |
0 | 453 return (DebugToken*) (intptr_t) serialize_monitor_values(monitors); |
454 } | |
455 | |
456 | |
457 int DebugInformationRecorder::data_size() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
458 debug_only(mark_recorders_frozen()); // mark it "frozen" for asserts |
0 | 459 return _stream->position(); |
460 } | |
461 | |
462 | |
463 int DebugInformationRecorder::pcs_size() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
464 debug_only(mark_recorders_frozen()); // mark it "frozen" for asserts |
0 | 465 if (last_pc()->pc_offset() != PcDesc::upper_offset_limit) |
466 add_new_pc_offset(PcDesc::upper_offset_limit); | |
467 return _pcs_length * sizeof(PcDesc); | |
468 } | |
469 | |
470 | |
471 void DebugInformationRecorder::copy_to(nmethod* nm) { | |
472 nm->copy_scopes_data(stream()->buffer(), stream()->position()); | |
473 nm->copy_scopes_pcs(_pcs, _pcs_length); | |
474 } | |
475 | |
476 | |
477 void DebugInformationRecorder::verify(const nmethod* code) { | |
478 Unimplemented(); | |
479 } | |
480 | |
481 #ifndef PRODUCT | |
482 void DebugInformationRecorder::print_statistics() { | |
483 dir_stats.print(); | |
484 } | |
485 #endif //PRODUCT |