Beispiel #1
0
void DebugInformationRecorder::end_scopes(int pc_offset, bool is_safepoint) {
  assert(_recording_state == (is_safepoint? rs_safepoint: rs_non_safepoint),
         "nesting of recording calls");
  debug_only(_recording_state = rs_null);

  // Try to compress away an equivalent non-safepoint predecessor.
  // (This only works because we have previously recognized redundant
  // scope trees and made them use a common scope_decode_offset.)
  if (_pcs_length >= 2 && recording_non_safepoints()) {
    PcDesc* last = last_pc();
    PcDesc* prev = prev_pc();
    // If prev is (a) not a safepoint and (b) has the same
    // stream pointer, then it can be coalesced into the last.
    // This is valid because non-safepoints are only sought
    // with pc_desc_near, which (when it misses prev) will
    // search forward until it finds last.
    // In addition, it does not matter if the last PcDesc
    // is for a safepoint or not.
    if (_prev_safepoint_pc < prev->pc_offset() && prev->is_same_info(last)) {
      assert(prev == last-1, "sane");
      prev->set_pc_offset(pc_offset);
      _pcs_length -= 1;
      NOT_PRODUCT(++dir_stats.chunks_elided);
    }
  }

  // We have just recorded this safepoint.
  // Remember it in case the previous paragraph needs to know.
  if (is_safepoint) {
    _prev_safepoint_pc = pc_offset;
  }
}
Beispiel #2
0
// must call add_safepoint before: it sets PcDesc and this routine uses
// the last PcDesc set
void DebugInformationRecorder::describe_scope(int         pc_offset,
        ciMethod*   method,
        int         bci,
        bool        reexecute,
        bool        is_method_handle_invoke,
        bool        return_oop,
        DebugToken* locals,
        DebugToken* expressions,
        DebugToken* monitors) {
    assert(_recording_state != rs_null, "nesting of recording calls");
    PcDesc* last_pd = last_pc();
    assert(last_pd->pc_offset() == pc_offset, "must be last pc");
    int sender_stream_offset = last_pd->scope_decode_offset();
    // update the stream offset of current pc desc
    int stream_offset = stream()->position();
    last_pd->set_scope_decode_offset(stream_offset);

    // Record flags into pcDesc.
    last_pd->set_should_reexecute(reexecute);
    last_pd->set_is_method_handle_invoke(is_method_handle_invoke);
    last_pd->set_return_oop(return_oop);

    // serialize sender stream offest
    stream()->write_int(sender_stream_offset);

    // serialize scope
    Metadata* method_enc = (method == NULL)? NULL: method->constant_encoding();
    stream()->write_int(oop_recorder()->find_index(method_enc));
    stream()->write_bci(bci);
    assert(method == NULL ||
           (method->is_native() && bci == 0) ||
           (!method->is_native() && 0 <= bci && bci < method->code_size()) ||
           (method->is_compiled_lambda_form() && bci == -99) ||  // this might happen in C1
           bci == -1, "illegal bci");

    // serialize the locals/expressions/monitors
    stream()->write_int((intptr_t) locals);
    stream()->write_int((intptr_t) expressions);
    stream()->write_int((intptr_t) monitors);

    // Here's a tricky bit.  We just wrote some bytes.
    // Wouldn't it be nice to find that we had already
    // written those same bytes somewhere else?
    // If we get lucky this way, reset the stream
    // and reuse the old bytes.  By the way, this
    // trick not only shares parent scopes, but also
    // compresses equivalent non-safepoint PcDescs.
    int shared_stream_offset = find_sharable_decode_offset(stream_offset);
    if (shared_stream_offset != serialized_null) {
        stream()->set_position(stream_offset);
        last_pd->set_scope_decode_offset(shared_stream_offset);
    }
}
Beispiel #3
0
void DebugInformationRecorder::add_new_pc_offset(int pc_offset) {
  assert(_pcs_length == 0 || last_pc()->pc_offset() < pc_offset,
         "must specify a new, larger pc offset");

  // add the pcdesc
  if (_pcs_length == _pcs_size) {
    // Expand
    int     new_pcs_size = _pcs_size * 2;
    PcDesc* new_pcs      = NEW_RESOURCE_ARRAY(PcDesc, new_pcs_size);
    for (int index = 0; index < _pcs_length; index++) {
      new_pcs[index] = _pcs[index];
    }
    _pcs_size = new_pcs_size;
    _pcs      = new_pcs;
  }
  assert(_pcs_size > _pcs_length, "There must be room for after expanding");

  _pcs[_pcs_length++] = PcDesc(pc_offset, DebugInformationRecorder::serialized_null,
                               DebugInformationRecorder::serialized_null);
}
Beispiel #4
0
int DebugInformationRecorder::pcs_size() {
  debug_only(_oop_recorder->oop_size());  // mark it "frozen" for asserts
  if (last_pc()->pc_offset() != PcDesc::upper_offset_limit)
    add_new_pc_offset(PcDesc::upper_offset_limit);
  return _pcs_length * sizeof(PcDesc);
}
 int last_pc_offset() { return last_pc()->pc_offset(); }