Mercurial > hg > truffle
annotate src/share/vm/code/debugInfoRec.cpp @ 7788:dbbe8ce3bfa5
commands: accept 'server0' as a vm, accept version number which have '-...' suffix (-internal, -ea...)
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 13 Feb 2013 18:33:54 +0100 |
parents | 0b646334c5f7 |
children | 85bd81dba8fc |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
2 * Copyright (c) 1998, 2012, 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) | |
40 | |
41 void* operator new(size_t ignore, DebugInformationRecorder* dir) { | |
42 assert(ignore == sizeof(DIR_Chunk), ""); | |
43 if (dir->_next_chunk >= dir->_next_chunk_limit) { | |
44 const int CHUNK = 100; | |
45 dir->_next_chunk = NEW_RESOURCE_ARRAY(DIR_Chunk, CHUNK); | |
46 dir->_next_chunk_limit = dir->_next_chunk + CHUNK; | |
47 } | |
48 return dir->_next_chunk++; | |
49 } | |
50 | |
51 DIR_Chunk(int offset, int length, DebugInformationRecorder* dir) { | |
52 _offset = offset; | |
53 _length = length; | |
54 unsigned int hash = 0; | |
55 address p = dir->stream()->buffer() + _offset; | |
56 for (int i = 0; i < length; i++) { | |
57 if (i == 6) break; | |
58 hash *= 127; | |
59 hash += p[i]; | |
60 } | |
61 _hash = hash; | |
62 } | |
63 | |
64 DIR_Chunk* find_match(GrowableArray<DIR_Chunk*>* arr, | |
65 int start_index, | |
66 DebugInformationRecorder* dir) { | |
67 int end_index = arr->length(); | |
68 int hash = this->_hash, length = this->_length; | |
69 address buf = dir->stream()->buffer(); | |
70 for (int i = end_index; --i >= start_index; ) { | |
71 DIR_Chunk* that = arr->at(i); | |
72 if (hash == that->_hash && | |
73 length == that->_length && | |
74 0 == memcmp(buf + this->_offset, buf + that->_offset, length)) { | |
75 return that; | |
76 } | |
77 } | |
78 return NULL; | |
79 } | |
80 }; | |
81 | |
82 static inline bool compute_recording_non_safepoints() { | |
83 if (JvmtiExport::should_post_compiled_method_load() | |
84 && FLAG_IS_DEFAULT(DebugNonSafepoints)) { | |
85 // The default value of this flag is taken to be true, | |
86 // if JVMTI is looking at nmethod codes. | |
87 // We anticipate that JVMTI may wish to participate in profiling. | |
88 return true; | |
89 } | |
90 | |
91 // If the flag is set manually, use it, whether true or false. | |
92 // Otherwise, if JVMTI is not in the picture, use the default setting. | |
93 // (This is true in debug, just for the exercise, false in product mode.) | |
94 return DebugNonSafepoints; | |
95 } | |
96 | |
97 DebugInformationRecorder::DebugInformationRecorder(OopRecorder* oop_recorder) | |
98 : _recording_non_safepoints(compute_recording_non_safepoints()) | |
99 { | |
100 _pcs_size = 100; | |
101 _pcs = NEW_RESOURCE_ARRAY(PcDesc, _pcs_size); | |
102 _pcs_length = 0; | |
103 | |
104 _prev_safepoint_pc = PcDesc::lower_offset_limit; | |
105 | |
106 _stream = new DebugInfoWriteStream(this, 10 * K); | |
107 // make sure that there is no stream_decode_offset that is zero | |
108 _stream->write_byte((jbyte)0xFF); | |
109 | |
110 // make sure that we can distinguish the value "serialized_null" from offsets | |
111 assert(_stream->position() > serialized_null, "sanity"); | |
112 | |
113 _oop_recorder = oop_recorder; | |
114 | |
115 _all_chunks = new GrowableArray<DIR_Chunk*>(300); | |
116 _shared_chunks = new GrowableArray<DIR_Chunk*>(30); | |
117 _next_chunk = _next_chunk_limit = NULL; | |
118 | |
119 add_new_pc_offset(PcDesc::lower_offset_limit); // sentinel record | |
120 | |
121 debug_only(_recording_state = rs_null); | |
122 } | |
123 | |
124 | |
125 void DebugInformationRecorder::add_oopmap(int pc_offset, OopMap* map) { | |
126 // !!!!! Preserve old style handling of oopmaps for now | |
127 _oopmaps->add_gc_map(pc_offset, map); | |
128 } | |
129 | |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7046
diff
changeset
|
130 void DebugInformationRecorder::add_safepoint(int pc_offset, OopMap* map) { |
0 | 131 assert(!_oop_recorder->is_complete(), "not frozen yet"); |
132 // Store the new safepoint | |
133 | |
134 // Add the oop map | |
135 add_oopmap(pc_offset, map); | |
136 | |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7046
diff
changeset
|
137 add_new_pc_offset(pc_offset); |
0 | 138 |
139 assert(_recording_state == rs_null, "nesting of recording calls"); | |
140 debug_only(_recording_state = rs_safepoint); | |
141 } | |
142 | |
143 void DebugInformationRecorder::add_non_safepoint(int pc_offset) { | |
144 assert(!_oop_recorder->is_complete(), "not frozen yet"); | |
145 assert(_recording_non_safepoints, "must be recording non-safepoints"); | |
146 | |
147 add_new_pc_offset(pc_offset); | |
148 | |
149 assert(_recording_state == rs_null, "nesting of recording calls"); | |
150 debug_only(_recording_state = rs_non_safepoint); | |
151 } | |
152 | |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7046
diff
changeset
|
153 void DebugInformationRecorder::add_new_pc_offset(int pc_offset) { |
0 | 154 assert(_pcs_length == 0 || last_pc()->pc_offset() < pc_offset, |
155 "must specify a new, larger pc offset"); | |
156 | |
157 // add the pcdesc | |
158 if (_pcs_length == _pcs_size) { | |
159 // Expand | |
160 int new_pcs_size = _pcs_size * 2; | |
161 PcDesc* new_pcs = NEW_RESOURCE_ARRAY(PcDesc, new_pcs_size); | |
162 for (int index = 0; index < _pcs_length; index++) { | |
163 new_pcs[index] = _pcs[index]; | |
164 } | |
165 _pcs_size = new_pcs_size; | |
166 _pcs = new_pcs; | |
167 } | |
168 assert(_pcs_size > _pcs_length, "There must be room for after expanding"); | |
169 | |
170 _pcs[_pcs_length++] = PcDesc(pc_offset, DebugInformationRecorder::serialized_null, | |
7660
0b646334c5f7
keep track of leafGraphIds only at the StructuredGraph level (see GRAAL-60)
Lukas Stadler <lukas.stadler@jku.at>
parents:
7046
diff
changeset
|
171 DebugInformationRecorder::serialized_null); |
0 | 172 } |
173 | |
174 | |
175 int DebugInformationRecorder::serialize_monitor_values(GrowableArray<MonitorValue*>* monitors) { | |
176 if (monitors == NULL || monitors->is_empty()) return DebugInformationRecorder::serialized_null; | |
177 assert(_recording_state == rs_safepoint, "must be recording a safepoint"); | |
178 int result = stream()->position(); | |
179 stream()->write_int(monitors->length()); | |
180 for (int index = 0; index < monitors->length(); index++) { | |
181 monitors->at(index)->write_on(stream()); | |
182 } | |
183 assert(result != serialized_null, "sanity"); | |
184 | |
185 // (See comment below on DebugInformationRecorder::describe_scope.) | |
186 int shared_result = find_sharable_decode_offset(result); | |
187 if (shared_result != serialized_null) { | |
188 stream()->set_position(result); | |
189 result = shared_result; | |
190 } | |
191 | |
192 return result; | |
193 } | |
194 | |
195 | |
196 int DebugInformationRecorder::serialize_scope_values(GrowableArray<ScopeValue*>* values) { | |
197 if (values == NULL || values->is_empty()) return DebugInformationRecorder::serialized_null; | |
198 assert(_recording_state == rs_safepoint, "must be recording a safepoint"); | |
199 int result = stream()->position(); | |
200 assert(result != serialized_null, "sanity"); | |
201 stream()->write_int(values->length()); | |
202 for (int index = 0; index < values->length(); index++) { | |
203 values->at(index)->write_on(stream()); | |
204 } | |
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 | |
7046
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
216 #ifdef GRAAL |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
217 |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
218 int DebugInformationRecorder::serialize_deferred_writes(GrowableArray<DeferredWriteValue*>* deferred_writes) { |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
219 if (deferred_writes == NULL || deferred_writes->is_empty()) return DebugInformationRecorder::serialized_null; |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
220 assert(_recording_state == rs_safepoint, "must be recording a safepoint"); |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
221 int result = stream()->position(); |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
222 assert(result != serialized_null, "sanity"); |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
223 stream()->write_int(deferred_writes->length()); |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
224 for (int index = 0; index < deferred_writes->length(); index++) { |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
225 deferred_writes->at(index)->write_on(stream()); |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
226 } |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
227 |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
228 // (See comment below on DebugInformationRecorder::describe_scope.) |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
229 int shared_result = find_sharable_decode_offset(result); |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
230 if (shared_result != serialized_null) { |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
231 stream()->set_position(result); |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
232 result = shared_result; |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
233 } |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
234 |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
235 return result; |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
236 } |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
237 |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
238 #endif // GRAAL |
0 | 239 |
240 #ifndef PRODUCT | |
241 // These variables are put into one block to reduce relocations | |
242 // and make it simpler to print from the debugger. | |
243 static | |
244 struct dir_stats_struct { | |
245 int chunks_queried; | |
246 int chunks_shared; | |
247 int chunks_reshared; | |
248 int chunks_elided; | |
249 | |
250 void print() { | |
251 tty->print_cr("Debug Data Chunks: %d, shared %d+%d, non-SP's elided %d", | |
252 chunks_queried, | |
253 chunks_shared, chunks_reshared, | |
254 chunks_elided); | |
255 } | |
256 } dir_stats; | |
257 #endif //PRODUCT | |
258 | |
259 | |
260 int DebugInformationRecorder::find_sharable_decode_offset(int stream_offset) { | |
261 // Only pull this trick if non-safepoint recording | |
262 // is enabled, for now. | |
263 if (!recording_non_safepoints()) | |
264 return serialized_null; | |
265 | |
266 NOT_PRODUCT(++dir_stats.chunks_queried); | |
267 int stream_length = stream()->position() - stream_offset; | |
268 assert(stream_offset != serialized_null, "should not be null"); | |
269 assert(stream_length != 0, "should not be empty"); | |
270 | |
271 DIR_Chunk* ns = new(this) DIR_Chunk(stream_offset, stream_length, this); | |
272 | |
273 // Look in previously shared scopes first: | |
274 DIR_Chunk* ms = ns->find_match(_shared_chunks, 0, this); | |
275 if (ms != NULL) { | |
276 NOT_PRODUCT(++dir_stats.chunks_reshared); | |
277 assert(ns+1 == _next_chunk, ""); | |
278 _next_chunk = ns; | |
279 return ms->_offset; | |
280 } | |
281 | |
282 // Look in recently encountered scopes next: | |
283 const int MAX_RECENT = 50; | |
284 int start_index = _all_chunks->length() - MAX_RECENT; | |
285 if (start_index < 0) start_index = 0; | |
286 ms = ns->find_match(_all_chunks, start_index, this); | |
287 if (ms != NULL) { | |
288 NOT_PRODUCT(++dir_stats.chunks_shared); | |
289 // Searching in _all_chunks is limited to a window, | |
290 // but searching in _shared_chunks is unlimited. | |
291 _shared_chunks->append(ms); | |
292 assert(ns+1 == _next_chunk, ""); | |
293 _next_chunk = ns; | |
294 return ms->_offset; | |
295 } | |
296 | |
297 // No match. Add this guy to the list, in hopes of future shares. | |
298 _all_chunks->append(ns); | |
299 return serialized_null; | |
300 } | |
301 | |
302 | |
303 // must call add_safepoint before: it sets PcDesc and this routine uses | |
304 // the last PcDesc set | |
305 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
|
306 methodHandle methodH, |
0 | 307 ciMethod* method, |
308 int bci, | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
0
diff
changeset
|
309 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
|
310 bool rethrow_exception, |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1014
diff
changeset
|
311 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
|
312 bool return_oop, |
0 | 313 DebugToken* locals, |
314 DebugToken* expressions, | |
7046
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
315 DebugToken* monitors |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
316 #ifdef GRAAL |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
317 , DebugToken* deferred_writes |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
318 #endif // GRAAL |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
319 ) { |
0 | 320 assert(_recording_state != rs_null, "nesting of recording calls"); |
321 PcDesc* last_pd = last_pc(); | |
322 assert(last_pd->pc_offset() == pc_offset, "must be last pc"); | |
323 int sender_stream_offset = last_pd->scope_decode_offset(); | |
324 // update the stream offset of current pc desc | |
325 int stream_offset = stream()->position(); | |
326 last_pd->set_scope_decode_offset(stream_offset); | |
327 | |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1014
diff
changeset
|
328 // Record flags into pcDesc. |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
900
diff
changeset
|
329 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
|
330 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
|
331 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
|
332 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
|
333 |
0 | 334 // serialize sender stream offest |
335 stream()->write_int(sender_stream_offset); | |
336 | |
337 // 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
|
338 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
|
339 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
|
340 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
|
341 } 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
|
342 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
|
343 } 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
|
344 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
|
345 } |
0 | 346 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
|
347 stream()->write_bci(bci); |
0 | 348 assert(method == NULL || |
349 (method->is_native() && bci == 0) || | |
350 (!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
|
351 (method->is_compiled_lambda_form() && bci == -99) || // this might happen in C1 |
0 | 352 bci == -1, "illegal bci"); |
353 | |
354 // serialize the locals/expressions/monitors | |
355 stream()->write_int((intptr_t) locals); | |
356 stream()->write_int((intptr_t) expressions); | |
357 stream()->write_int((intptr_t) monitors); | |
7046
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
358 #ifdef GRAAL |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
359 stream()->write_int((intptr_t) deferred_writes); |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
360 #endif // GRAAL |
0 | 361 |
362 // Here's a tricky bit. We just wrote some bytes. | |
363 // Wouldn't it be nice to find that we had already | |
364 // written those same bytes somewhere else? | |
365 // If we get lucky this way, reset the stream | |
366 // and reuse the old bytes. By the way, this | |
367 // trick not only shares parent scopes, but also | |
368 // compresses equivalent non-safepoint PcDescs. | |
369 int shared_stream_offset = find_sharable_decode_offset(stream_offset); | |
370 if (shared_stream_offset != serialized_null) { | |
371 stream()->set_position(stream_offset); | |
372 last_pd->set_scope_decode_offset(shared_stream_offset); | |
373 } | |
374 } | |
375 | |
376 void DebugInformationRecorder::dump_object_pool(GrowableArray<ScopeValue*>* objects) { | |
377 guarantee( _pcs_length > 0, "safepoint must exist before describing scopes"); | |
378 PcDesc* last_pd = &_pcs[_pcs_length-1]; | |
379 if (objects != NULL) { | |
380 for (int i = objects->length() - 1; i >= 0; i--) { | |
381 ((ObjectValue*) objects->at(i))->set_visited(false); | |
382 } | |
383 } | |
384 int offset = serialize_scope_values(objects); | |
385 last_pd->set_obj_decode_offset(offset); | |
386 } | |
387 | |
388 void DebugInformationRecorder::end_scopes(int pc_offset, bool is_safepoint) { | |
389 assert(_recording_state == (is_safepoint? rs_safepoint: rs_non_safepoint), | |
390 "nesting of recording calls"); | |
391 debug_only(_recording_state = rs_null); | |
392 | |
393 // Try to compress away an equivalent non-safepoint predecessor. | |
394 // (This only works because we have previously recognized redundant | |
395 // scope trees and made them use a common scope_decode_offset.) | |
396 if (_pcs_length >= 2 && recording_non_safepoints()) { | |
397 PcDesc* last = last_pc(); | |
398 PcDesc* prev = prev_pc(); | |
399 // If prev is (a) not a safepoint and (b) has the same | |
400 // stream pointer, then it can be coalesced into the last. | |
401 // This is valid because non-safepoints are only sought | |
402 // with pc_desc_near, which (when it misses prev) will | |
403 // search forward until it finds last. | |
404 // In addition, it does not matter if the last PcDesc | |
405 // is for a safepoint or not. | |
1014
8e954aedbb81
6889869: assert(!Interpreter::bytecode_should_reexecute(code),"should not reexecute")
never
parents:
989
diff
changeset
|
406 if (_prev_safepoint_pc < prev->pc_offset() && prev->is_same_info(last)) { |
0 | 407 assert(prev == last-1, "sane"); |
408 prev->set_pc_offset(pc_offset); | |
409 _pcs_length -= 1; | |
410 NOT_PRODUCT(++dir_stats.chunks_elided); | |
411 } | |
412 } | |
413 | |
414 // We have just recorded this safepoint. | |
415 // Remember it in case the previous paragraph needs to know. | |
416 if (is_safepoint) { | |
417 _prev_safepoint_pc = pc_offset; | |
418 } | |
419 } | |
420 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
421 #ifdef ASSERT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
422 bool DebugInformationRecorder::recorders_frozen() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
423 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
|
424 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
425 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
426 void DebugInformationRecorder::mark_recorders_frozen() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
427 _oop_recorder->freeze(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
428 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
429 #endif // PRODUCT |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
430 |
0 | 431 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
|
432 assert(!recorders_frozen(), "not frozen yet"); |
0 | 433 return (DebugToken*) (intptr_t) serialize_scope_values(values); |
434 } | |
435 | |
436 | |
437 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
|
438 assert(!recorders_frozen(), "not frozen yet"); |
0 | 439 return (DebugToken*) (intptr_t) serialize_monitor_values(monitors); |
440 } | |
441 | |
7046
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
442 #ifdef GRAAL |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
443 |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
444 DebugToken* DebugInformationRecorder::create_deferred_writes(GrowableArray<DeferredWriteValue*>* deferred_writes) { |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
445 assert(!recorders_frozen(), "not frozen yet"); |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
446 return (DebugToken*) (intptr_t) serialize_deferred_writes(deferred_writes); |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
447 } |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
448 |
b6a8f2d23057
VM support for deferred reads and writes: ScopeDesc, DebugInfo, DebugInfoRecorder
Lukas Stadler <lukas.stadler@jku.at>
parents:
6948
diff
changeset
|
449 #endif // GRAAL |
0 | 450 |
451 int DebugInformationRecorder::data_size() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
452 debug_only(mark_recorders_frozen()); // mark it "frozen" for asserts |
0 | 453 return _stream->position(); |
454 } | |
455 | |
456 | |
457 int DebugInformationRecorder::pcs_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 if (last_pc()->pc_offset() != PcDesc::upper_offset_limit) |
460 add_new_pc_offset(PcDesc::upper_offset_limit); | |
461 return _pcs_length * sizeof(PcDesc); | |
462 } | |
463 | |
464 | |
465 void DebugInformationRecorder::copy_to(nmethod* nm) { | |
466 nm->copy_scopes_data(stream()->buffer(), stream()->position()); | |
467 nm->copy_scopes_pcs(_pcs, _pcs_length); | |
468 } | |
469 | |
470 | |
471 void DebugInformationRecorder::verify(const nmethod* code) { | |
472 Unimplemented(); | |
473 } | |
474 | |
475 #ifndef PRODUCT | |
476 void DebugInformationRecorder::print_statistics() { | |
477 dir_stats.print(); | |
478 } | |
479 #endif //PRODUCT |