< prev index next >
src/share/vm/gc/shenandoah/shenandoahHeap.cpp
Print this page
rev 13055 : Implement barriers for maintaining connection matrix.
*** 261,270 ****
--- 261,272 ----
_complete_mark_bit_map = &_mark_bit_map0;
_mark_bit_map1.initialize(heap_region, bitmap_region1);
_next_mark_bit_map = &_mark_bit_map1;
+ _connection_matrix = new ShenandoahConnectionMatrix(_max_regions);
+
_monitoring_support = new ShenandoahMonitoringSupport(this);
_concurrent_gc_thread = new ShenandoahConcurrentThread();
ShenandoahMarkCompact::initialize();
*** 293,302 ****
--- 295,305 ----
_next_top_at_mark_starts_base(NULL),
_complete_top_at_mark_starts(NULL),
_complete_top_at_mark_starts_base(NULL),
_mark_bit_map0(),
_mark_bit_map1(),
+ _connection_matrix(NULL),
_cancelled_concgc(false),
_need_update_refs(false),
_need_reset_bitmaps(false),
_heap_lock(0),
#ifdef ASSERT
*** 1133,1142 ****
--- 1136,1154 ----
#ifdef ASSERT
if (ShenandoahVerify) {
verify_heap_after_marking();
}
+
+ if (UseShenandoahMatrix) {
+ if (PrintShenandoahMatrix) {
+ connection_matrix()->print_on(tty);
+ }
+ if (VerifyShenandoahMatrix) {
+ verify_matrix();
+ }
+ }
#endif
// NOTE: This needs to be done during a stop the world pause, because
// putting regions into the collection set concurrently with Java threads
// will create a race. In particular, acmp could fail because when we
*** 1157,1184 ****
#ifdef ASSERT
CheckCollectionSetClosure ccsc;
_ordered_regions->heap_region_iterate(&ccsc);
#endif
- if (UseShenandoahMatrix) {
- int num = num_regions();
- int *connections = NEW_C_HEAP_ARRAY(int, num * num, mtGC);
- calculate_matrix(connections);
- print_matrix(connections);
- _shenandoah_policy->choose_collection_set(_collection_set, connections);
- FREE_C_HEAP_ARRAY(int,connections);
- } else {
_shenandoah_policy->choose_collection_set(_collection_set);
- }
_shenandoah_policy->choose_free_set(_free_regions);
}
- if (UseShenandoahMatrix) {
- _collection_set->print();
- }
-
_bytes_allocated_since_cm = 0;
Universe::update_heap_info_at_gc();
}
}
--- 1169,1183 ----
*** 1786,1796 ****
sh->set_next_top_at_mark_start(r->bottom(), r->top());
return false;
}
};
-
void ShenandoahHeap::start_concurrent_marking() {
shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::accumulate_stats);
accumulate_statistics_all_tlabs();
shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::accumulate_stats);
--- 1785,1794 ----
*** 1816,1825 ****
--- 1814,1826 ----
shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::clear_liveness);
ClearLivenessClosure clc(this);
heap_region_iterate(&clc);
shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::clear_liveness);
+ if (UseShenandoahMatrix) {
+ connection_matrix()->clear_all();
+ }
// print_all_refs("pre -mark");
// oopDesc::_debug = true;
// Make above changes visible to worker threads
*** 1898,1907 ****
--- 1899,1987 ----
HeapWord** tmp3 = _complete_top_at_mark_starts_base;
_complete_top_at_mark_starts_base = _next_top_at_mark_starts_base;
_next_top_at_mark_starts_base = tmp3;
}
+ class ShenandoahVerifyMatrixOopClosure : public ExtendedOopClosure {
+ private:
+ oop _obj;
+
+ template <class T>
+ inline void do_oop_nv(T* p) {
+ T o = oopDesc::load_heap_oop(p);
+ if (! oopDesc::is_null(o)) {
+ oop obj = oopDesc::decode_heap_oop_not_null(o);
+ ShenandoahHeap* heap = ShenandoahHeap::heap();
+ guarantee(heap->is_marked_complete(obj), "must be marked");
+
+ uint from_idx = heap->heap_region_index_containing(p);
+ uint to_idx = heap->heap_region_index_containing(obj);
+ if (!heap->connection_matrix()->is_connected(from_idx, to_idx)) {
+ tty->print_cr("from-obj: ");
+ _obj->print_on(tty);
+ tty->print_cr("to-obj:");
+ obj->print_on(tty);
+ tty->print_cr("from-obj allocated after mark: %s", BOOL_TO_STR(heap->allocated_after_complete_mark_start((HeapWord*) _obj)));
+ tty->print_cr("to-obj allocated after mark: %s", BOOL_TO_STR(heap->allocated_after_complete_mark_start((HeapWord*) obj)));
+ tty->print_cr("from-obj marked: %s", BOOL_TO_STR(heap->is_marked_complete(_obj)));
+ tty->print_cr("to-obj marked: %s", BOOL_TO_STR(heap->is_marked_complete(obj)));
+ tty->print_cr("from-idx: %u, to-idx: %u", from_idx, to_idx);
+
+ oop fwd_from = BrooksPointer::forwardee(_obj);
+ oop fwd_to = BrooksPointer::forwardee(obj);
+ tty->print_cr("from-obj forwardee: " PTR_FORMAT, p2i(fwd_from));
+ tty->print_cr("to-obj forwardee: " PTR_FORMAT, p2i(fwd_to));
+ tty->print_cr("forward(from-obj) marked: %s", BOOL_TO_STR(heap->is_marked_complete(fwd_from)));
+ tty->print_cr("forward(to-obj) marked: %s", BOOL_TO_STR(heap->is_marked_complete(fwd_to)));
+ uint fwd_from_idx = heap->heap_region_index_containing(fwd_from);
+ uint fwd_to_idx = heap->heap_region_index_containing(fwd_to);
+ tty->print_cr("forward(from-idx): %u, forward(to-idx): %u", fwd_from_idx, fwd_to_idx);
+ tty->print_cr("forward(from) connected with forward(to)? %s", BOOL_TO_STR(heap->connection_matrix()->is_connected(fwd_from_idx, fwd_to_idx)));
+ tty->print_cr("sizeof(bool): %lu", sizeof(bool));
+ }
+ guarantee(oopDesc::unsafe_equals(ShenandoahBarrierSet::resolve_oop_static_not_null(obj), obj), "polizeilich verboten");
+ guarantee(heap->connection_matrix()->is_connected(from_idx, to_idx), "must be connected");
+ }
+ }
+
+ public:
+ ShenandoahVerifyMatrixOopClosure(oop obj) : _obj(obj) {}
+
+ void do_oop(oop* o) {
+ do_oop_nv(o);
+ }
+
+ void do_oop(narrowOop* o) {
+ do_oop_nv(o);
+ }
+ };
+
+ class ShenandoahVerifyMatrixObjectClosure : public ObjectClosure {
+ public:
+ void do_object(oop obj) {
+ guarantee(ShenandoahHeap::heap()->is_marked_complete(obj), "must be marked");
+ ShenandoahVerifyMatrixOopClosure cl(obj);
+ obj->oop_iterate(&cl);
+ }
+
+ };
+
+ class ShenandoahVerifyMatrixRegionClosure : public ShenandoahHeapRegionClosure {
+ bool doHeapRegion(ShenandoahHeapRegion* r) {
+ ShenandoahVerifyMatrixObjectClosure cl;
+ ShenandoahHeap::heap()->marked_object_iterate(r, &cl);
+ return false;
+ }
+ };
+
+ void ShenandoahHeap::verify_matrix() {
+ OrderAccess::fence();
+ ensure_parsability(false);
+ ShenandoahVerifyMatrixRegionClosure cl;
+ heap_region_iterate(&cl, true, true);
+ }
+
void ShenandoahHeap::stop_concurrent_marking() {
assert(concurrent_mark_in_progress(), "How else could we get here?");
if (! cancelled_concgc()) {
// If we needed to update refs, and concurrent marking has been cancelled,
// we need to finish updating references.
*** 2440,2449 ****
--- 2520,2533 ----
ShenandoahCountGarbageClosure cl;
heap_region_iterate(&cl);
return cl.garbage();
}
+ ShenandoahConnectionMatrix* ShenandoahHeap::connection_matrix() {
+ return _connection_matrix;
+ }
+
#ifdef ASSERT
void ShenandoahHeap::assert_heaplock_owned_by_current_thread() {
assert(_heap_lock == locked, "must be locked");
assert(_heap_lock_owner == Thread::current(), "must be owned by current thread");
}
< prev index next >