263 NOT_PRODUCT(++dir_stats.chunks_shared);
264 // Searching in _all_chunks is limited to a window,
265 // but searching in _shared_chunks is unlimited.
266 _shared_chunks->append(ms);
267 assert(ns+1 == _next_chunk, "");
268 _next_chunk = ns;
269 return ms->_offset;
270 }
271
272 // No match. Add this guy to the list, in hopes of future shares.
273 _all_chunks->append(ns);
274 return serialized_null;
275 }
276
277
278 // must call add_safepoint before: it sets PcDesc and this routine uses
279 // the last PcDesc set
280 void DebugInformationRecorder::describe_scope(int pc_offset,
281 ciMethod* method,
282 int bci,
283 DebugToken* locals,
284 DebugToken* expressions,
285 DebugToken* monitors) {
286 assert(_recording_state != rs_null, "nesting of recording calls");
287 PcDesc* last_pd = last_pc();
288 assert(last_pd->pc_offset() == pc_offset, "must be last pc");
289 int sender_stream_offset = last_pd->scope_decode_offset();
290 // update the stream offset of current pc desc
291 int stream_offset = stream()->position();
292 last_pd->set_scope_decode_offset(stream_offset);
293
294 // serialize sender stream offest
295 stream()->write_int(sender_stream_offset);
296
297 // serialize scope
298 jobject method_enc = (method == NULL)? NULL: method->encoding();
299 stream()->write_int(oop_recorder()->find_index(method_enc));
300 stream()->write_bci(bci);
301 assert(method == NULL ||
302 (method->is_native() && bci == 0) ||
303 (!method->is_native() && 0 <= bci && bci < method->code_size()) ||
304 bci == -1, "illegal bci");
305
306 // serialize the locals/expressions/monitors
307 stream()->write_int((intptr_t) locals);
308 stream()->write_int((intptr_t) expressions);
309 stream()->write_int((intptr_t) monitors);
310
311 // Here's a tricky bit. We just wrote some bytes.
312 // Wouldn't it be nice to find that we had already
313 // written those same bytes somewhere else?
314 // If we get lucky this way, reset the stream
315 // and reuse the old bytes. By the way, this
316 // trick not only shares parent scopes, but also
317 // compresses equivalent non-safepoint PcDescs.
318 int shared_stream_offset = find_sharable_decode_offset(stream_offset);
319 if (shared_stream_offset != serialized_null) {
320 stream()->set_position(stream_offset);
|
263 NOT_PRODUCT(++dir_stats.chunks_shared);
264 // Searching in _all_chunks is limited to a window,
265 // but searching in _shared_chunks is unlimited.
266 _shared_chunks->append(ms);
267 assert(ns+1 == _next_chunk, "");
268 _next_chunk = ns;
269 return ms->_offset;
270 }
271
272 // No match. Add this guy to the list, in hopes of future shares.
273 _all_chunks->append(ns);
274 return serialized_null;
275 }
276
277
278 // must call add_safepoint before: it sets PcDesc and this routine uses
279 // the last PcDesc set
280 void DebugInformationRecorder::describe_scope(int pc_offset,
281 ciMethod* method,
282 int bci,
283 bool reexecute,
284 DebugToken* locals,
285 DebugToken* expressions,
286 DebugToken* monitors) {
287 assert(_recording_state != rs_null, "nesting of recording calls");
288 PcDesc* last_pd = last_pc();
289 assert(last_pd->pc_offset() == pc_offset, "must be last pc");
290 int sender_stream_offset = last_pd->scope_decode_offset();
291 // update the stream offset of current pc desc
292 int stream_offset = stream()->position();
293 last_pd->set_scope_decode_offset(stream_offset);
294
295 // serialize sender stream offest
296 stream()->write_int(sender_stream_offset);
297
298 // serialize scope
299 jobject method_enc = (method == NULL)? NULL: method->encoding();
300 stream()->write_int(oop_recorder()->find_index(method_enc));
301 stream()->write_bci_and_reexecute(bci, reexecute);
302 assert(method == NULL ||
303 (method->is_native() && bci == 0) ||
304 (!method->is_native() && 0 <= bci && bci < method->code_size()) ||
305 bci == -1, "illegal bci");
306
307 // serialize the locals/expressions/monitors
308 stream()->write_int((intptr_t) locals);
309 stream()->write_int((intptr_t) expressions);
310 stream()->write_int((intptr_t) monitors);
311
312 // Here's a tricky bit. We just wrote some bytes.
313 // Wouldn't it be nice to find that we had already
314 // written those same bytes somewhere else?
315 // If we get lucky this way, reset the stream
316 // and reuse the old bytes. By the way, this
317 // trick not only shares parent scopes, but also
318 // compresses equivalent non-safepoint PcDescs.
319 int shared_stream_offset = find_sharable_decode_offset(stream_offset);
320 if (shared_stream_offset != serialized_null) {
321 stream()->set_position(stream_offset);
|