src/hotspot/share/gc/g1/g1RemSet.cpp
changeset 48969 7eb296a8ce2c
parent 48890 f9884e190f2b
parent 48955 e22914003cf0
child 49075 1fd4d6068f54
child 49164 7e958a8ebcd3
equal deleted inserted replaced
48893:454518b338b0 48969:7eb296a8ce2c
     1 /*
     1 /*
     2  * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   125   private:
   125   private:
   126     HeapWord** _scan_top;
   126     HeapWord** _scan_top;
   127   public:
   127   public:
   128     G1ResetScanTopClosure(HeapWord** scan_top) : _scan_top(scan_top) { }
   128     G1ResetScanTopClosure(HeapWord** scan_top) : _scan_top(scan_top) { }
   129 
   129 
   130     virtual bool doHeapRegion(HeapRegion* r) {
   130     virtual bool do_heap_region(HeapRegion* r) {
   131       uint hrm_index = r->hrm_index();
   131       uint hrm_index = r->hrm_index();
   132       if (!r->in_collection_set() && r->is_old_or_humongous()) {
   132       if (!r->in_collection_set() && r->is_old_or_humongous()) {
   133         _scan_top[hrm_index] = r->top();
   133         _scan_top[hrm_index] = r->top();
   134       } else {
   134       } else {
   135         _scan_top[hrm_index] = r->bottom();
   135         _scan_top[hrm_index] = r->bottom();
   202   inline bool claim_iter(uint region) {
   202   inline bool claim_iter(uint region) {
   203     assert(region < _max_regions, "Tried to access invalid region %u", region);
   203     assert(region < _max_regions, "Tried to access invalid region %u", region);
   204     if (_iter_states[region] != Unclaimed) {
   204     if (_iter_states[region] != Unclaimed) {
   205       return false;
   205       return false;
   206     }
   206     }
   207     jint res = Atomic::cmpxchg(Claimed, (jint*)(&_iter_states[region]), Unclaimed);
   207     G1RemsetIterState res = Atomic::cmpxchg(Claimed, &_iter_states[region], Unclaimed);
   208     return (res == Unclaimed);
   208     return (res == Unclaimed);
   209   }
   209   }
   210 
   210 
   211   // Try to atomically sets the iteration state to "complete". Returns true for the
   211   // Try to atomically sets the iteration state to "complete". Returns true for the
   212   // thread that caused the transition.
   212   // thread that caused the transition.
   213   inline bool set_iter_complete(uint region) {
   213   inline bool set_iter_complete(uint region) {
   214     if (iter_is_complete(region)) {
   214     if (iter_is_complete(region)) {
   215       return false;
   215       return false;
   216     }
   216     }
   217     jint res = Atomic::cmpxchg(Complete, (jint*)(&_iter_states[region]), Claimed);
   217     G1RemsetIterState res = Atomic::cmpxchg(Complete, &_iter_states[region], Claimed);
   218     return (res == Claimed);
   218     return (res == Claimed);
   219   }
   219   }
   220 
   220 
   221   // Returns true if the region's iteration is complete.
   221   // Returns true if the region's iteration is complete.
   222   inline bool iter_is_complete(uint region) const {
   222   inline bool iter_is_complete(uint region) const {
   347 void G1ScanRSForRegionClosure::claim_card(size_t card_index, const uint region_idx_for_card){
   347 void G1ScanRSForRegionClosure::claim_card(size_t card_index, const uint region_idx_for_card){
   348   _ct_bs->set_card_claimed(card_index);
   348   _ct_bs->set_card_claimed(card_index);
   349   _scan_state->add_dirty_region(region_idx_for_card);
   349   _scan_state->add_dirty_region(region_idx_for_card);
   350 }
   350 }
   351 
   351 
   352 bool G1ScanRSForRegionClosure::doHeapRegion(HeapRegion* r) {
   352 bool G1ScanRSForRegionClosure::do_heap_region(HeapRegion* r) {
   353   assert(r->in_collection_set(), "should only be called on elements of CS.");
   353   assert(r->in_collection_set(), "should only be called on elements of CS.");
   354   uint region_idx = r->hrm_index();
   354   uint region_idx = r->hrm_index();
   355 
   355 
   356   if (_scan_state->iter_is_complete(region_idx)) {
   356   if (_scan_state->iter_is_complete(region_idx)) {
   357     return false;
   357     return false;
   520 public:
   520 public:
   521   G1ScrubRSClosure(G1CardLiveData* live_data) :
   521   G1ScrubRSClosure(G1CardLiveData* live_data) :
   522     _g1h(G1CollectedHeap::heap()),
   522     _g1h(G1CollectedHeap::heap()),
   523     _live_data(live_data) { }
   523     _live_data(live_data) { }
   524 
   524 
   525   bool doHeapRegion(HeapRegion* r) {
   525   bool do_heap_region(HeapRegion* r) {
   526     if (!r->is_continues_humongous()) {
   526     if (!r->is_continues_humongous()) {
   527       r->rem_set()->scrub(_live_data);
   527       r->rem_set()->scrub(_live_data);
   528     }
   528     }
   529     return false;
   529     return false;
   530   }
   530   }