--- old/src/share/vm/gc/g1/concurrentMark.hpp 2015-10-08 22:15:41.649447743 +0200 +++ new/src/share/vm/gc/g1/concurrentMark.hpp 2015-10-08 22:15:41.556449964 +0200 @@ -28,6 +28,7 @@ #include "classfile/javaClasses.hpp" #include "gc/g1/g1RegionToSpaceMapper.hpp" #include "gc/g1/heapRegionSet.hpp" +#include "gc/shared/cmBitMap.inline.hpp" #include "gc/shared/gcId.hpp" #include "gc/shared/taskqueue.hpp" @@ -52,74 +53,6 @@ bool do_object_b(oop obj); }; -// A generic CM bit map. This is essentially a wrapper around the BitMap -// class, with one bit per (1<<_shifter) HeapWords. - -class CMBitMapRO VALUE_OBJ_CLASS_SPEC { - protected: - HeapWord* _bmStartWord; // base address of range covered by map - size_t _bmWordSize; // map size (in #HeapWords covered) - const int _shifter; // map to char or bit - BitMap _bm; // the bit map itself - - public: - // constructor - CMBitMapRO(int shifter); - - enum { do_yield = true }; - - // inquiries - HeapWord* startWord() const { return _bmStartWord; } - size_t sizeInWords() const { return _bmWordSize; } - // the following is one past the last word in space - HeapWord* endWord() const { return _bmStartWord + _bmWordSize; } - - // read marks - - bool isMarked(HeapWord* addr) const { - assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize), - "outside underlying space?"); - return _bm.at(heapWordToOffset(addr)); - } - - // iteration - inline bool iterate(BitMapClosure* cl, MemRegion mr); - inline bool iterate(BitMapClosure* cl); - - // Return the address corresponding to the next marked bit at or after - // "addr", and before "limit", if "limit" is non-NULL. If there is no - // such bit, returns "limit" if that is non-NULL, or else "endWord()". - HeapWord* getNextMarkedWordAddress(const HeapWord* addr, - const HeapWord* limit = NULL) const; - // Return the address corresponding to the next unmarked bit at or after - // "addr", and before "limit", if "limit" is non-NULL. If there is no - // such bit, returns "limit" if that is non-NULL, or else "endWord()". - HeapWord* getNextUnmarkedWordAddress(const HeapWord* addr, - const HeapWord* limit = NULL) const; - - // conversion utilities - HeapWord* offsetToHeapWord(size_t offset) const { - return _bmStartWord + (offset << _shifter); - } - size_t heapWordToOffset(const HeapWord* addr) const { - return pointer_delta(addr, _bmStartWord) >> _shifter; - } - int heapWordDiffToOffsetDiff(size_t diff) const; - - // The argument addr should be the start address of a valid object - HeapWord* nextObject(HeapWord* addr) { - oop obj = (oop) addr; - HeapWord* res = addr + obj->size(); - assert(offsetToHeapWord(heapWordToOffset(res)) == res, "sanity"); - return res; - } - - void print_on_error(outputStream* st, const char* prefix) const; - - // debugging - NOT_PRODUCT(bool covers(MemRegion rs) const;) -}; - class CMBitMapMappingChangedListener : public G1MappingChangedListener { private: CMBitMap* _bm; @@ -131,11 +64,12 @@ virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled); }; -class CMBitMap : public CMBitMapRO { +class G1CMBitMap : public CMBitMap { private: CMBitMapMappingChangedListener _listener; public: + G1CMBitMap() : CMBitMap(), _listener() { _listener.set_bitmap(this); } static size_t compute_size(size_t heap_size); // Returns the amount of bytes on the heap between two marks in the bitmap. static size_t mark_distance(); @@ -145,29 +79,9 @@ return mark_distance(); } - CMBitMap() : CMBitMapRO(LogMinObjAlignment), _listener() { _listener.set_bitmap(this); } - // Initializes the underlying BitMap to cover the given area. void initialize(MemRegion heap, G1RegionToSpaceMapper* storage); - // Write marks. - inline void mark(HeapWord* addr); - inline void clear(HeapWord* addr); - inline bool parMark(HeapWord* addr); - inline bool parClear(HeapWord* addr); - - void markRange(MemRegion mr); - void clearRange(MemRegion mr); - - // Starting at the bit corresponding to "addr" (inclusive), find the next - // "1" bit, if any. This bit starts some run of consecutive "1"'s; find - // the end of this run (stopping at "end_addr"). Return the MemRegion - // covering from the start of the region corresponding to the first bit - // of the run to the end of the region corresponding to the last bit of - // the run. If there is no "1" bit at or after "addr", return an empty - // MemRegion. - MemRegion getAndClearMarkedRegion(HeapWord* addr, HeapWord* end_addr); - // Clear the whole mark bitmap. void clearAll(); }; @@ -378,8 +292,8 @@ FreeRegionList _cleanup_list; // Concurrent marking support structures - CMBitMap _markBitMap1; - CMBitMap _markBitMap2; + G1CMBitMap _markBitMap1; + G1CMBitMap _markBitMap2; CMBitMapRO* _prevMarkBitMap; // Completed mark bitmap CMBitMap* _nextMarkBitMap; // Under-construction mark bitmap