< prev index next >

src/share/vm/code/debugInfoRec.cpp

Print this page




  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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/debugInfoRec.hpp"
  27 #include "code/scopeDesc.hpp"
  28 #include "prims/jvmtiExport.hpp"
  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 #if INCLUDE_JVMCI
  41   DebugInformationRecorder* _DIR;
  42 #endif
  43 



  44   void* operator new(size_t ignore, DebugInformationRecorder* dir) throw() {
  45     assert(ignore == sizeof(DIR_Chunk), "");
  46     if (dir->_next_chunk >= dir->_next_chunk_limit) {
  47       const int CHUNK = 100;
  48       dir->_next_chunk = NEW_RESOURCE_ARRAY(DIR_Chunk, CHUNK);
  49       dir->_next_chunk_limit = dir->_next_chunk + CHUNK;
  50     }
  51     return dir->_next_chunk++;
  52   }
  53 
  54   DIR_Chunk(int offset, int length, DebugInformationRecorder* dir) {
  55     _offset = offset;
  56     _length = length;
  57 #if INCLUDE_JVMCI
  58     _DIR = dir;
  59 #endif
  60     unsigned int hash = 0;
  61     address p = dir->stream()->buffer() + _offset;
  62     for (int i = 0; i < length; i++) {
  63       if (i == 6)  break;


 267   // is enabled, for now.
 268   if (!recording_non_safepoints()) {
 269     return serialized_null;
 270   }
 271 #endif // INCLUDE_JVMCI
 272 
 273   NOT_PRODUCT(++dir_stats.chunks_queried);
 274   int stream_length = stream()->position() - stream_offset;
 275   assert(stream_offset != serialized_null, "should not be null");
 276   assert(stream_length != 0, "should not be empty");
 277 
 278   DIR_Chunk* ns = new(this) DIR_Chunk(stream_offset, stream_length, this);
 279 
 280 #if INCLUDE_JVMCI
 281   DIR_Chunk* match = _all_chunks->insert_sorted<DIR_Chunk::compare>(ns);
 282   if (match != ns) {
 283     // Found an existing chunk
 284     NOT_PRODUCT(++dir_stats.chunks_shared);
 285     assert(ns+1 == _next_chunk, "");
 286     _next_chunk = ns;
 287     return match->_offset;
 288   } else {
 289     // Inserted this chunk, so nothing to do
 290     return serialized_null;
 291   }
 292 #else // INCLUDE_JVMCI
 293   // Look in previously shared scopes first:
 294   DIR_Chunk* ms = ns->find_match(_shared_chunks, 0, this);
 295   if (ms != NULL) {
 296     NOT_PRODUCT(++dir_stats.chunks_reshared);
 297     assert(ns+1 == _next_chunk, "");
 298     _next_chunk = ns;
 299     return ms->_offset;
 300   }
 301 
 302   // Look in recently encountered scopes next:
 303   const int MAX_RECENT = 50;
 304   int start_index = _all_chunks->length() - MAX_RECENT;
 305   if (start_index < 0)  start_index = 0;
 306   ms = ns->find_match(_all_chunks, start_index, this);
 307   if (ms != NULL) {
 308     NOT_PRODUCT(++dir_stats.chunks_shared);
 309     // Searching in _all_chunks is limited to a window,
 310     // but searching in _shared_chunks is unlimited.
 311     _shared_chunks->append(ms);
 312     assert(ns+1 == _next_chunk, "");
 313     _next_chunk = ns;
 314     return ms->_offset;
 315   }
 316 
 317   // No match.  Add this guy to the list, in hopes of future shares.
 318   _all_chunks->append(ns);
 319   return serialized_null;
 320 #endif // INCLUDE_JVMCI
 321 }
 322 
 323 
 324 // must call add_safepoint before: it sets PcDesc and this routine uses
 325 // the last PcDesc set
 326 void DebugInformationRecorder::describe_scope(int         pc_offset,
 327                                               const methodHandle& methodH,
 328                                               ciMethod*   method,
 329                                               int         bci,
 330                                               bool        reexecute,
 331                                               bool        rethrow_exception,
 332                                               bool        is_method_handle_invoke,
 333                                               bool        return_oop,
 334                                               DebugToken* locals,




  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  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/debugInfoRec.hpp"
  27 #include "code/scopeDesc.hpp"
  28 #include "prims/jvmtiExport.hpp"
  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 private:
  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 #if INCLUDE_JVMCI
  41   DebugInformationRecorder* _DIR;
  42 #endif
  43 
  44 public:
  45   int offset() { return _offset; }
  46 
  47   void* operator new(size_t ignore, DebugInformationRecorder* dir) throw() {
  48     assert(ignore == sizeof(DIR_Chunk), "");
  49     if (dir->_next_chunk >= dir->_next_chunk_limit) {
  50       const int CHUNK = 100;
  51       dir->_next_chunk = NEW_RESOURCE_ARRAY(DIR_Chunk, CHUNK);
  52       dir->_next_chunk_limit = dir->_next_chunk + CHUNK;
  53     }
  54     return dir->_next_chunk++;
  55   }
  56 
  57   DIR_Chunk(int offset, int length, DebugInformationRecorder* dir) {
  58     _offset = offset;
  59     _length = length;
  60 #if INCLUDE_JVMCI
  61     _DIR = dir;
  62 #endif
  63     unsigned int hash = 0;
  64     address p = dir->stream()->buffer() + _offset;
  65     for (int i = 0; i < length; i++) {
  66       if (i == 6)  break;


 270   // is enabled, for now.
 271   if (!recording_non_safepoints()) {
 272     return serialized_null;
 273   }
 274 #endif // INCLUDE_JVMCI
 275 
 276   NOT_PRODUCT(++dir_stats.chunks_queried);
 277   int stream_length = stream()->position() - stream_offset;
 278   assert(stream_offset != serialized_null, "should not be null");
 279   assert(stream_length != 0, "should not be empty");
 280 
 281   DIR_Chunk* ns = new(this) DIR_Chunk(stream_offset, stream_length, this);
 282 
 283 #if INCLUDE_JVMCI
 284   DIR_Chunk* match = _all_chunks->insert_sorted<DIR_Chunk::compare>(ns);
 285   if (match != ns) {
 286     // Found an existing chunk
 287     NOT_PRODUCT(++dir_stats.chunks_shared);
 288     assert(ns+1 == _next_chunk, "");
 289     _next_chunk = ns;
 290     return match->offset();
 291   } else {
 292     // Inserted this chunk, so nothing to do
 293     return serialized_null;
 294   }
 295 #else // INCLUDE_JVMCI
 296   // Look in previously shared scopes first:
 297   DIR_Chunk* ms = ns->find_match(_shared_chunks, 0, this);
 298   if (ms != NULL) {
 299     NOT_PRODUCT(++dir_stats.chunks_reshared);
 300     assert(ns+1 == _next_chunk, "");
 301     _next_chunk = ns;
 302     return ms->offset();
 303   }
 304 
 305   // Look in recently encountered scopes next:
 306   const int MAX_RECENT = 50;
 307   int start_index = _all_chunks->length() - MAX_RECENT;
 308   if (start_index < 0)  start_index = 0;
 309   ms = ns->find_match(_all_chunks, start_index, this);
 310   if (ms != NULL) {
 311     NOT_PRODUCT(++dir_stats.chunks_shared);
 312     // Searching in _all_chunks is limited to a window,
 313     // but searching in _shared_chunks is unlimited.
 314     _shared_chunks->append(ms);
 315     assert(ns+1 == _next_chunk, "");
 316     _next_chunk = ns;
 317     return ms->offset();
 318   }
 319 
 320   // No match.  Add this guy to the list, in hopes of future shares.
 321   _all_chunks->append(ns);
 322   return serialized_null;
 323 #endif // INCLUDE_JVMCI
 324 }
 325 
 326 
 327 // must call add_safepoint before: it sets PcDesc and this routine uses
 328 // the last PcDesc set
 329 void DebugInformationRecorder::describe_scope(int         pc_offset,
 330                                               const methodHandle& methodH,
 331                                               ciMethod*   method,
 332                                               int         bci,
 333                                               bool        reexecute,
 334                                               bool        rethrow_exception,
 335                                               bool        is_method_handle_invoke,
 336                                               bool        return_oop,
 337                                               DebugToken* locals,


< prev index next >