# HG changeset patch # User Tom Rodriguez # Date 1412794320 25200 # Node ID b888ded3ee422164bac2166a9232506922097474 # Parent 44b83285b64534af9df97df6bc123d17eae482d0 Be more aggressive about sharing of debug info diff -r 44b83285b645 -r b888ded3ee42 src/share/vm/code/debugInfoRec.cpp --- a/src/share/vm/code/debugInfoRec.cpp Wed Oct 08 11:50:00 2014 -0700 +++ b/src/share/vm/code/debugInfoRec.cpp Wed Oct 08 11:52:00 2014 -0700 @@ -37,6 +37,9 @@ int _offset; // location in the stream of this scope int _length; // number of bytes in the stream int _hash; // hash of stream bytes (for quicker reuse) +#ifdef GRAAL + DebugInformationRecorder* _DIR; +#endif void* operator new(size_t ignore, DebugInformationRecorder* dir) throw() { assert(ignore == sizeof(DIR_Chunk), ""); @@ -51,6 +54,9 @@ DIR_Chunk(int offset, int length, DebugInformationRecorder* dir) { _offset = offset; _length = length; +#ifdef GRAAL + _DIR = dir; +#endif unsigned int hash = 0; address p = dir->stream()->buffer() + _offset; for (int i = 0; i < length; i++) { @@ -77,6 +83,25 @@ } return NULL; } + +#ifdef GRAAL + static int compare(DIR_Chunk* a, DIR_Chunk* b) { + if (b->_hash > a->_hash) { + return 1; + } + if (b->_hash < a->_hash) { + return -1; + } + if (b->_length > a->_length) { + return 1; + } + if (b->_length < a->_length) { + return -1; + } + address buf = a->_DIR->stream()->buffer(); + return memcmp(buf + b->_offset, buf + a->_offset, a->_length); + } +#endif }; static inline bool compute_recording_non_safepoints() { @@ -113,7 +138,9 @@ _oop_recorder = oop_recorder; _all_chunks = new GrowableArray(300); +#ifndef GRAAL _shared_chunks = new GrowableArray(30); +#endif _next_chunk = _next_chunk_limit = NULL; add_new_pc_offset(PcDesc::lower_offset_limit); // sentinel record @@ -250,6 +277,19 @@ DIR_Chunk* ns = new(this) DIR_Chunk(stream_offset, stream_length, this); +#ifdef GRAAL + DIR_Chunk* match = _all_chunks->find_insert_binary(ns); + if (match != ns) { + // Found an existing chunk + NOT_PRODUCT(++dir_stats.chunks_shared); + assert(ns+1 == _next_chunk, ""); + _next_chunk = ns; + return match->_offset; + } else { + // Inserted this chunk, so nothing to do + return serialized_null; + } +#else // Look in previously shared scopes first: DIR_Chunk* ms = ns->find_match(_shared_chunks, 0, this); if (ms != NULL) { @@ -277,6 +317,7 @@ // No match. Add this guy to the list, in hopes of future shares. _all_chunks->append(ns); return serialized_null; +#endif } diff -r 44b83285b645 -r b888ded3ee42 src/share/vm/code/debugInfoRec.hpp --- a/src/share/vm/code/debugInfoRec.hpp Wed Oct 08 11:50:00 2014 -0700 +++ b/src/share/vm/code/debugInfoRec.hpp Wed Oct 08 11:52:00 2014 -0700 @@ -163,7 +163,9 @@ // Scopes that have been described so far. GrowableArray* _all_chunks; +#ifndef GRAAL GrowableArray* _shared_chunks; +#endif DIR_Chunk* _next_chunk; DIR_Chunk* _next_chunk_limit;