--- old/src/share/vm/services/memPtr.hpp 2012-10-31 11:57:28.011797000 -0400 +++ new/src/share/vm/services/memPtr.hpp 2012-10-31 11:57:26.848933000 -0400 @@ -299,18 +299,29 @@ } // if this memory region fully contains another one - inline bool contains_region(const MemPointerRecord* other) const { - return contains_region(other->addr(), other->size()); + inline bool contain_region(const MemPointerRecord* other) const { + return contain_region(other->addr(), other->size()); } // if this memory region fully contains specified memory range - inline bool contains_region(address add, size_t sz) const { + inline bool contain_region(address add, size_t sz) const { return (addr() <= add && addr() + size() >= add + sz); } - inline bool contains_address(address add) const { + inline bool contain_address(address add) const { return (addr() <= add && addr() + size() > add); } + + // if this memory region overlaps another region + inline bool overlap_region(const MemPointerRecord* other) const { + assert(other != NULL, "Just check"); + assert(size() > 0 && other->size() > 0, "empty range"); + return contain_address(other->addr()) || + contain_address(other->addr() + other->size() - 1) || // exclude end address + other->contain_address(addr()) || + other->contain_address(addr() + size() - 1); // exclude end address + } + }; // MemPointerRecordEx also records callsite pc, from where