/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "gc_implementation/g1/heapRegion.hpp"
#include "utilities/growableArray.hpp"
// Unfortunately, GrowableArray uses ints for length and indexes. To
// avoid excessive casting in the rest of the class the following
// wrapper methods are provided that use uints.
}
}
// The index of the next candidate old region to be considered for
// addition to the CSet.
// The number of candidate old regions added to the CSet chooser.
// Note: this is not updated when removing a region using
// remove_and_move_to_next() below.
// Keeps track of the start of the next array chunk to be claimed by
// parallel GC workers.
// If a region has more live bytes than this threshold, it will not
// be added to the CSet chooser and will not be a candidate for
// collection.
// The sum of reclaimable bytes over all the regions in the CSet chooser.
public:
// Return the current candidate region to be considered for
// collection without removing it from the CSet chooser.
if (_curr_index < _length) {
err_msg("Unexpected NULL hr in _regions at index %u",
_curr_index));
}
return res;
}
// Remove the given region from the CSet chooser and move to the
// next one. The given region should be the current candidate region
// in the CSet chooser.
err_msg("remaining reclaimable bytes inconsistent "
_curr_index += 1;
}
void sort_regions();
// Determine whether to add the given region to the CSet chooser or
// not. Currently, we skip humongous regions (we never add them to
// the CSet, we only reclaim them during cleanup) and regions whose
// live bytes are over the threshold.
return !hr->isHumongous() &&
}
// Returns the number candidate old regions added
// Serial version.
// Must be called before calls to claim_array_chunk().
// n_regions is the number of regions, chunk_size the chunk size.
// Returns the first index in a contiguous chunk of chunk_size indexes
// that the calling thread has reserved. These must be set by the
// calling thread using set_region() (to NULL if necessary).
// Set the marked array entry at index to hr. Careful to claim the index
// first if in parallel.
// Atomically increment the number of added regions by region_num
// and the amount of reclaimable bytes by reclaimable_bytes.
void clear();
// Return the number of candidate regions that remain to be collected.
// Determine whether the CSet chooser has more candidate regions or not.
// Return the reclaimable bytes that remain to be collected on
// all the candidate regions in the CSet chooser.
// Returns true if the used portion of "_regions" is properly
// sorted, otherwise asserts false.
};
private:
bool _parallel;
public:
_cur_chunk_idx(0), _cur_chunk_end(0),
_regions_added(0), _reclaimable_bytes_added(0) { }
if (_parallel && _regions_added > 0) {
}
}
if (_parallel) {
if (_cur_chunk_idx == _cur_chunk_end) {
}
_cur_chunk_idx += 1;
} else {
}
_regions_added += 1;
}
};
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_COLLECTIONSETCHOOSER_HPP