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