Mercurial > hg > truffle
changeset 17376:b888ded3ee42
Be more aggressive about sharing of debug info
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 08 Oct 2014 11:52:00 -0700 |
parents | 44b83285b645 |
children | 21015ffe0a1e |
files | src/share/vm/code/debugInfoRec.cpp src/share/vm/code/debugInfoRec.hpp |
diffstat | 2 files changed, 43 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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<DIR_Chunk*>(300); +#ifndef GRAAL _shared_chunks = new GrowableArray<DIR_Chunk*>(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<DIR_Chunk::compare>(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 }
--- 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<DIR_Chunk*>* _all_chunks; +#ifndef GRAAL GrowableArray<DIR_Chunk*>* _shared_chunks; +#endif DIR_Chunk* _next_chunk; DIR_Chunk* _next_chunk_limit;