src/share/vm/gc_implementation/g1/concurrentMark.hpp
Print this page
rev 6802 : imported patch refactor-heapregionseq
rev 6804 : imported patch commit-uncommit-within-heap
rev 6806 : [mq]: bengt-suggestions
@@ -25,14 +25,16 @@
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_HPP
#define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_HPP
#include "classfile/javaClasses.hpp"
#include "gc_implementation/g1/heapRegionSet.hpp"
+#include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
#include "gc_implementation/shared/gcId.hpp"
#include "utilities/taskqueue.hpp"
class G1CollectedHeap;
+class CMBitMap;
class CMTask;
typedef GenericTaskQueue<oop, mtGC> CMTaskQueue;
typedef GenericTaskQueueSet<CMTaskQueue, mtGC> CMTaskQueueSet;
// Closure used by CM during concurrent reference discovery
@@ -55,11 +57,10 @@
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
- VirtualSpace _virtual_space; // underlying the bit map
BitMap _bm; // the bit map itself
public:
// constructor
CMBitMapRO(int shifter);
@@ -113,56 +114,58 @@
}
void print_on_error(outputStream* st, const char* prefix) const;
// debugging
- NOT_PRODUCT(bool covers(ReservedSpace rs) const;)
+ NOT_PRODUCT(bool covers(MemRegion rs) const;)
+};
+
+class CMBitMapMappingChangedListener : public G1MappingChangedListener {
+ private:
+ CMBitMap* _bm;
+ public:
+ CMBitMapMappingChangedListener() : _bm(NULL) {}
+
+ void set_bitmap(CMBitMap* bm) { _bm = bm; }
+
+ virtual void on_commit(uint start_idx, size_t num_regions);
};
class CMBitMap : public CMBitMapRO {
+ private:
+ CMBitMapMappingChangedListener _listener;
public:
- // constructor
- CMBitMap(int shifter) :
- CMBitMapRO(shifter) {}
+ 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();
+
+ 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);
- // Allocates the back store for the marking bitmap
- bool allocate(ReservedSpace heap_rs);
-
- // write marks
- void mark(HeapWord* addr) {
- assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
- "outside underlying space?");
- _bm.set_bit(heapWordToOffset(addr));
- }
- void clear(HeapWord* addr) {
- assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
- "outside underlying space?");
- _bm.clear_bit(heapWordToOffset(addr));
- }
- bool parMark(HeapWord* addr) {
- assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
- "outside underlying space?");
- return _bm.par_set_bit(heapWordToOffset(addr));
- }
- bool parClear(HeapWord* addr) {
- assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),
- "outside underlying space?");
- return _bm.par_clear_bit(heapWordToOffset(addr));
- }
void markRange(MemRegion mr);
- void clearAll();
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();
};
// Represents a marking stack used by ConcurrentMarking in the G1 collector.
class CMMarkStack VALUE_OBJ_CLASS_SPEC {
VirtualSpace _virtual_space; // Underlying backing store for actual stack
@@ -678,11 +681,11 @@
// Attempts to steal an object from the task queues of other tasks
bool try_stealing(uint worker_id, int* hash_seed, oop& obj) {
return _task_queues->steal(worker_id, hash_seed, obj);
}
- ConcurrentMark(G1CollectedHeap* g1h, ReservedSpace heap_rs);
+ ConcurrentMark(G1CollectedHeap* g1h, G1RegionToSpaceMapper* prev_bitmap_storage, G1RegionToSpaceMapper* next_bitmap_storage);
~ConcurrentMark();
ConcurrentMarkThread* cmThread() { return _cmThread; }
CMBitMapRO* prevMarkBitMap() const { return _prevMarkBitMap; }
@@ -734,11 +737,12 @@
VerifyOption vo, bool all) PRODUCT_RETURN;
// Clear the next marking bitmap (will be called concurrently).
void clearNextBitmap();
- // Return whether the next mark bitmap has no marks set.
+ // Return whether the next mark bitmap has no marks set. To be used for assertions
+ // only. Will not yield to pause requests.
bool nextMarkBitmapIsClear();
// These two do the work that needs to be done before and after the
// initial root checkpoint. Since this checkpoint can be done at two
// different points (i.e. an explicit pause or piggy-backed on a
@@ -792,16 +796,10 @@
void verify_no_cset_oops(bool verify_stacks,
bool verify_enqueued_buffers,
bool verify_thread_buffers,
bool verify_fingers) PRODUCT_RETURN;
- // It is called at the end of an evacuation pause during marking so
- // that CM is notified of where the new end of the heap is. It
- // doesn't do anything if concurrent_marking_in_progress() is false,
- // unless the force parameter is true.
- void update_heap_boundaries(MemRegion bounds, bool force = false);
-
bool isMarked(oop p) const {
assert(p != NULL && p->is_oop(), "expected an oop");
HeapWord* addr = (HeapWord*)p;
assert(addr >= _nextMarkBitMap->startWord() ||
addr < _nextMarkBitMap->endWord(), "in a region");