--- old/src/share/vm/gc/shenandoah/shenandoahConnectionMatrix.cpp 2017-03-24 18:44:29.334390285 +0100 +++ new/src/share/vm/gc/shenandoah/shenandoahConnectionMatrix.cpp 2017-03-24 18:44:29.278390436 +0100 @@ -36,7 +36,9 @@ _magic_offset( ((uintptr_t) _matrix) - ( ((uintptr_t) ShenandoahHeap::heap()->first_region_bottom()) >> _region_shift) * (_stride + 1)) { - clear_all(); + if (UseShenandoahMatrix) { + clear_all(); + } } ShenandoahConnectionMatrix::~ShenandoahConnectionMatrix() { @@ -44,18 +46,22 @@ } size_t ShenandoahConnectionMatrix::index_of(size_t from_idx, size_t to_idx) const { + assert (UseShenandoahMatrix, "call only when matrix is enabled"); return from_idx * _stride + to_idx; } bool ShenandoahConnectionMatrix::is_connected(size_t from_idx, size_t to_idx) const { + assert (UseShenandoahMatrix, "call only when matrix is enabled"); return _matrix[index_of(from_idx, to_idx)] > 0; } void ShenandoahConnectionMatrix::clear_connected(size_t from_idx, size_t to_idx) { + assert (UseShenandoahMatrix, "call only when matrix is enabled"); _matrix[index_of(from_idx, to_idx)] = 0; } void ShenandoahConnectionMatrix::clear_region(size_t idx) { + assert (UseShenandoahMatrix, "call only when matrix is enabled"); for (uint i = 0; i < _stride; i++) { clear_connected(i, idx); clear_connected(idx, i); @@ -63,17 +69,20 @@ } void ShenandoahConnectionMatrix::clear_region_outbound(size_t idx) { + assert (UseShenandoahMatrix, "call only when matrix is enabled"); for (uint i = 0; i < _stride; i++) { clear_connected(idx, i); } } void ShenandoahConnectionMatrix::clear_all() { + assert (UseShenandoahMatrix, "call only when matrix is enabled"); size_t count = sizeof(char) * _stride * _stride; Copy::fill_to_bytes(_matrix, count, 0); } void ShenandoahConnectionMatrix::print_on(outputStream* st) const { + assert (UseShenandoahMatrix, "call only when matrix is enabled"); st->print_cr("Connection Matrix:"); st->print_cr("%8s, %10s, %10s, %10s, %8s, %s", "Region", "Live", "Used", "Garbage", "Refcnt", "Referenced by"); --- old/src/share/vm/gc/shenandoah/shenandoahHeap.cpp 2017-03-24 18:44:29.538389736 +0100 +++ new/src/share/vm/gc/shenandoah/shenandoahHeap.cpp 2017-03-24 18:44:29.482389887 +0100 @@ -1149,11 +1149,9 @@ ensure_parsability(true); - if (UseShenandoahMatrix) { - if (PrintShenandoahMatrix) { - outputStream* log = Log(gc)::info_stream(); - connection_matrix()->print_on(log); - } + if (UseShenandoahMatrix && PrintShenandoahMatrix) { + outputStream* log = Log(gc)::info_stream(); + connection_matrix()->print_on(log); } if (ShenandoahVerify || (UseShenandoahMatrix && VerifyShenandoahMatrix)) { --- old/src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp 2017-03-24 18:44:29.754389155 +0100 +++ new/src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp 2017-03-24 18:44:29.698389306 +0100 @@ -351,8 +351,10 @@ assert(p->klass() == return_val->klass(), "Should have the same class p: "PTR_FORMAT", copy: "PTR_FORMAT, p2i((HeapWord*) p), p2i((HeapWord*) copy)); - UpdateMatrixClosure cl; - copy_val->oop_iterate(&cl); + if (UseShenandoahMatrix) { + UpdateMatrixClosure cl; + copy_val->oop_iterate(&cl); + } #endif } else { if (alloc_from_gclab) { --- old/src/share/vm/gc/shenandoah/shenandoahHeapRegion.cpp 2017-03-24 18:44:29.958388604 +0100 +++ new/src/share/vm/gc/shenandoah/shenandoahHeapRegion.cpp 2017-03-24 18:44:29.902388756 +0100 @@ -291,7 +291,10 @@ _heap->set_complete_top_at_mark_start(bottom(), bottom()); // We can only safely reset the C-TAMS pointer if the bitmap is clear for that region. assert(_heap->is_complete_bitmap_clear_range(bottom(), end()), "must be clear"); - _heap->connection_matrix()->clear_region(region_number()); + + if (UseShenandoahMatrix) { + _heap->connection_matrix()->clear_region(region_number()); + } } HeapWord* ShenandoahHeapRegion::block_start_const(const void* p) const { --- old/src/share/vm/gc/shenandoah/shenandoahMarkCompact.cpp 2017-03-24 18:44:30.162388054 +0100 +++ new/src/share/vm/gc/shenandoah/shenandoahMarkCompact.cpp 2017-03-24 18:44:30.106388205 +0100 @@ -231,11 +231,9 @@ oopDesc::set_bs(old_bs); - if (UseShenandoahMatrix) { - if (PrintShenandoahMatrix) { - outputStream* log = Log(gc)::info_stream(); - _heap->connection_matrix()->print_on(log); - } + if (UseShenandoahMatrix && PrintShenandoahMatrix) { + outputStream* log = Log(gc)::info_stream(); + _heap->connection_matrix()->print_on(log); } } @@ -315,11 +313,9 @@ _heap->swap_mark_bitmaps(); - if (UseShenandoahMatrix) { - if (PrintShenandoahMatrix) { - outputStream* log = Log(gc)::info_stream(); - _heap->connection_matrix()->print_on(log); - } + if (UseShenandoahMatrix && PrintShenandoahMatrix) { + outputStream* log = Log(gc)::info_stream(); + _heap->connection_matrix()->print_on(log); } if (ShenandoahVerify || (UseShenandoahMatrix && VerifyShenandoahMatrix)) {