--- old/src/share/vm/gc/g1/g1CollectedHeap.cpp 2017-04-25 16:44:32.775175270 +0200 +++ new/src/share/vm/gc/g1/g1CollectedHeap.cpp 2017-04-25 16:44:32.627175275 +0200 @@ -122,10 +122,10 @@ private: size_t _num_dirtied; G1CollectedHeap* _g1h; - G1SATBCardTableLoggingModRefBS* _g1_bs; + G1CardTable* _g1_ct; HeapRegion* region_for_card(jbyte* card_ptr) const { - return _g1h->heap_region_containing(_g1_bs->addr_for(card_ptr)); + return _g1h->heap_region_containing(_g1_ct->addr_for(card_ptr)); } bool will_become_free(HeapRegion* hr) const { @@ -136,14 +136,14 @@ public: RedirtyLoggedCardTableEntryClosure(G1CollectedHeap* g1h) : CardTableEntryClosure(), - _num_dirtied(0), _g1h(g1h), _g1_bs(g1h->g1_barrier_set()) { } + _num_dirtied(0), _g1h(g1h), _g1_ct(g1h->g1_card_table()) { } bool do_card_ptr(jbyte* card_ptr, uint worker_i) { HeapRegion* hr = region_for_card(card_ptr); // Should only dirty cards in regions that won't be freed. if (!will_become_free(hr)) { - *card_ptr = CardTableModRefBS::dirty_card_val(); + *card_ptr = G1CardTable::dirty_card_val(); _num_dirtied++; } @@ -1076,10 +1076,10 @@ class PostMCRemSetClearClosure: public HeapRegionClosure { G1CollectedHeap* _g1h; - ModRefBarrierSet* _mr_bs; + G1CardTable* _ct; public: - PostMCRemSetClearClosure(G1CollectedHeap* g1h, ModRefBarrierSet* mr_bs) : - _g1h(g1h), _mr_bs(mr_bs) {} + PostMCRemSetClearClosure(G1CollectedHeap* g1h, G1CardTable* ct) : + _g1h(g1h), _ct(ct) {} bool doHeapRegion(HeapRegion* r) { HeapRegionRemSet* hrrs = r->rem_set(); @@ -1098,14 +1098,14 @@ // in a region we might allocate into, then it would prevent that card // from being enqueued, and cause it to be missed. // Re: the performance cost: we shouldn't be doing full GC anyway! - _mr_bs->clear(MemRegion(r->bottom(), r->end())); + _ct->clear(MemRegion(r->bottom(), r->end())); return false; } }; void G1CollectedHeap::clear_rsets_post_compaction() { - PostMCRemSetClearClosure rs_clear(this, g1_barrier_set()); + PostMCRemSetClearClosure rs_clear(this, g1_card_table()); heap_region_iterate(&rs_clear); } @@ -1350,7 +1350,7 @@ #endif // Discard all rset updates - JavaThread::dirty_card_queue_set().abandon_logs(); + G1BarrierSet::dirty_card_queue_set().abandon_logs(); assert(dirty_card_queue_set().completed_buffers_num() == 0, "DCQS should be empty"); // At this point there should be no regions in the @@ -1832,17 +1832,18 @@ initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size())); // Create the barrier set for the entire reserved region. - G1SATBCardTableLoggingModRefBS* bs - = new G1SATBCardTableLoggingModRefBS(reserved_region()); + G1CardTable* ct = new G1CardTable(reserved_region()); + ct->initialize(); + G1BarrierSet* bs = new G1BarrierSet(ct); bs->initialize(); - assert(bs->is_a(BarrierSet::G1SATBCTLogging), "sanity"); + assert(bs->is_a(BarrierSet::G1BarrierSet), "sanity"); set_barrier_set(bs); // Create the hot card cache. _hot_card_cache = new G1HotCardCache(this); // Also create a G1 rem set. - _g1_rem_set = new G1RemSet(this, g1_barrier_set(), _hot_card_cache); + _g1_rem_set = new G1RemSet(this, ct, _hot_card_cache); // Carve out the G1 part of the heap. ReservedSpace g1_rs = heap_rs.first_part(max_byte_size); @@ -1868,11 +1869,11 @@ G1BlockOffsetTable::compute_size(g1_rs.size() / HeapWordSize), G1BlockOffsetTable::heap_map_factor()); - ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize)); + ReservedSpace cardtable_rs(G1CardTable::compute_size(g1_rs.size() / HeapWordSize)); G1RegionToSpaceMapper* cardtable_storage = create_aux_memory_mapper("Card Table", - G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize), - G1SATBCardTableLoggingModRefBS::heap_map_factor()); + G1CardTable::compute_size(g1_rs.size() / HeapWordSize), + G1CardTable::heap_map_factor()); G1RegionToSpaceMapper* card_counts_storage = create_aux_memory_mapper("Card Counts Table", @@ -1886,7 +1887,7 @@ create_aux_memory_mapper("Next Bitmap", bitmap_size, G1CMBitMap::heap_map_factor()); _hrm.initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage); - g1_barrier_set()->initialize(cardtable_storage); + g1_card_table()->initialize(cardtable_storage); // Do later initialization work for concurrent refinement. _hot_card_cache->initialize(card_counts_storage); @@ -1933,19 +1934,19 @@ // Perform any initialization actions delegated to the policy. g1_policy()->init(this, &_collection_set); - JavaThread::satb_mark_queue_set().initialize(SATB_Q_CBL_mon, - SATB_Q_FL_lock, - G1SATBProcessCompletedThreshold, - Shared_SATB_Q_lock); - - JavaThread::dirty_card_queue_set().initialize(_refine_cte_cl, - DirtyCardQ_CBL_mon, - DirtyCardQ_FL_lock, - (int)concurrent_g1_refine()->yellow_zone(), - (int)concurrent_g1_refine()->red_zone(), - Shared_DirtyCardQ_lock, - NULL, // fl_owner - true); // init_free_ids + G1BarrierSet::satb_mark_queue_set().initialize(SATB_Q_CBL_mon, + SATB_Q_FL_lock, + G1SATBProcessCompletedThreshold, + Shared_SATB_Q_lock); + + G1BarrierSet::dirty_card_queue_set().initialize(_refine_cte_cl, + DirtyCardQ_CBL_mon, + DirtyCardQ_FL_lock, + (int)concurrent_g1_refine()->yellow_zone(), + (int)concurrent_g1_refine()->red_zone(), + Shared_DirtyCardQ_lock, + NULL, // fl_owner + true); // init_free_ids dirty_card_queue_set().initialize(NULL, // Should never be called by the Java code DirtyCardQ_CBL_mon, @@ -1953,7 +1954,7 @@ -1, // never trigger processing -1, // no limit on length Shared_DirtyCardQ_lock, - &JavaThread::dirty_card_queue_set()); + &G1BarrierSet::dirty_card_queue_set()); // Here we allocate the dummy HeapRegion that is required by the // G1AllocRegion class. @@ -1994,6 +1995,14 @@ } } +void G1CollectedHeap::safepoint_synchronize_begin() { + SuspendibleThreadSet::synchronize(); +} + +void G1CollectedHeap::safepoint_synchronize_end() { + SuspendibleThreadSet::desynchronize(); +} + size_t G1CollectedHeap::conservative_max_heap_alignment() { return HeapRegion::max_region_size(); } @@ -2123,7 +2132,7 @@ } void G1CollectedHeap::iterate_dirty_card_closure(CardTableEntryClosure* cl, uint worker_i) { - DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); + DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); size_t n_completed_buffers = 0; while (dcqs.apply_closure_to_completed_buffer(cl, worker_i, 0, true)) { n_completed_buffers++; @@ -2499,6 +2508,10 @@ return _cmThread->request_concurrent_phase(phase); } +void G1CollectedHeap::verify_nmethod_roots(nmethod* nmethod) { + +} + class PrintRegionClosure: public HeapRegionClosure { outputStream* _st; public: @@ -2777,7 +2790,7 @@ extra_cards += dcq.size(); curr = curr->next(); } - DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); + DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set(); size_t buffer_size = dcqs.buffer_size(); size_t buffer_num = dcqs.completed_buffers_num(); @@ -2857,7 +2870,7 @@ RegisterHumongousWithInCSetFastTestClosure() : _total_humongous(0), _candidate_humongous(0), - _dcq(&JavaThread::dirty_card_queue_set()) { + _dcq(&G1BarrierSet::dirty_card_queue_set()) { } virtual bool doHeapRegion(HeapRegion* r) { @@ -2880,17 +2893,17 @@ if (!r->rem_set()->is_empty()) { guarantee(r->rem_set()->occupancy_less_or_equal_than(G1RSetSparseRegionEntries), "Found a not-small remembered set here. This is inconsistent with previous assumptions."); - G1SATBCardTableLoggingModRefBS* bs = g1h->g1_barrier_set(); + G1CardTable* ct = g1h->g1_card_table(); HeapRegionRemSetIterator hrrs(r->rem_set()); size_t card_index; while (hrrs.has_next(card_index)) { - jbyte* card_ptr = (jbyte*)bs->byte_for_index(card_index); + jbyte* card_ptr = (jbyte*)ct->byte_for_index(card_index); // The remembered set might contain references to already freed // regions. Filter out such entries to avoid failing card table // verification. - if (g1h->is_in_closed_subset(bs->addr_for(card_ptr))) { - if (*card_ptr != CardTableModRefBS::dirty_card_val()) { - *card_ptr = CardTableModRefBS::dirty_card_val(); + if (g1h->is_in_closed_subset(ct->addr_for(card_ptr))) { + if (*card_ptr != G1CardTable::dirty_card_val()) { + *card_ptr = G1CardTable::dirty_card_val(); _dcq.enqueue(card_ptr); } } @@ -3934,7 +3947,7 @@ dirty_card_queue_set().reset_for_par_iteration(); workers()->run_task(&redirty_task); - DirtyCardQueueSet& dcq = JavaThread::dirty_card_queue_set(); + DirtyCardQueueSet& dcq = G1BarrierSet::dirty_card_queue_set(); dcq.merge_bufferlists(&dirty_card_queue_set()); assert(dirty_card_queue_set().completed_buffers_num() == 0, "All should be consumed"); @@ -5460,16 +5473,14 @@ }; void G1CollectedHeap::register_nmethod(nmethod* nm) { - CollectedHeap::register_nmethod(nm); - + assert_locked_or_safepoint(CodeCache_lock); guarantee(nm != NULL, "sanity"); RegisterNMethodOopClosure reg_cl(this, nm); nm->oops_do(®_cl); } void G1CollectedHeap::unregister_nmethod(nmethod* nm) { - CollectedHeap::unregister_nmethod(nm); - + assert_locked_or_safepoint(CodeCache_lock); guarantee(nm != NULL, "sanity"); UnregisterNMethodOopClosure reg_cl(this, nm); nm->oops_do(®_cl, true);