Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/g1/g1CardCounts.hpp
38920 views
/*1* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1CARDCOUNTS_HPP25#define SHARE_VM_GC_IMPLEMENTATION_G1_G1CARDCOUNTS_HPP2627#include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"28#include "memory/allocation.hpp"29#include "runtime/virtualspace.hpp"30#include "utilities/globalDefinitions.hpp"3132class CardTableModRefBS;33class G1CardCounts;34class G1CollectedHeap;35class G1RegionToSpaceMapper;36class HeapRegion;3738class G1CardCountsMappingChangedListener : public G1MappingChangedListener {39private:40G1CardCounts* _counts;41public:42void set_cardcounts(G1CardCounts* counts) { _counts = counts; }4344virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);45};4647// Table to track the number of times a card has been refined. Once48// a card has been refined a certain number of times, it is49// considered 'hot' and its refinement is delayed by inserting the50// card into the hot card cache. The card will then be refined when51// it is evicted from the hot card cache, or when the hot card cache52// is 'drained' during the next evacuation pause.5354class G1CardCounts: public CHeapObj<mtGC> {55G1CardCountsMappingChangedListener _listener;5657G1CollectedHeap* _g1h;5859// The table of counts60jubyte* _card_counts;6162// Max capacity of the reserved space for the counts table63size_t _reserved_max_card_num;6465// CardTable bottom.66const jbyte* _ct_bot;6768// Barrier set69CardTableModRefBS* _ct_bs;7071// Returns true if the card counts table has been reserved.72bool has_reserved_count_table() { return _card_counts != NULL; }7374// Returns true if the card counts table has been reserved and committed.75bool has_count_table() {76return has_reserved_count_table();77}7879size_t ptr_2_card_num(const jbyte* card_ptr) {80assert(card_ptr >= _ct_bot,81err_msg("Invalid card pointer: "82"card_ptr: " PTR_FORMAT ", "83"_ct_bot: " PTR_FORMAT,84p2i(card_ptr), p2i(_ct_bot)));85size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(jbyte));86assert(card_num >= 0 && card_num < _reserved_max_card_num,87err_msg("card pointer out of range: " PTR_FORMAT, p2i(card_ptr)));88return card_num;89}9091jbyte* card_num_2_ptr(size_t card_num) {92assert(card_num >= 0 && card_num < _reserved_max_card_num,93err_msg("card num out of range: " SIZE_FORMAT, card_num));94return (jbyte*) (_ct_bot + card_num);95}9697// Clear the counts table for the given (exclusive) index range.98void clear_range(size_t from_card_num, size_t to_card_num);99100public:101G1CardCounts(G1CollectedHeap* g1h);102103void initialize(G1RegionToSpaceMapper* mapper);104105// Increments the refinement count for the given card.106// Returns the pre-increment count value.107uint add_card_count(jbyte* card_ptr);108109// Returns true if the given count is high enough to be considered110// 'hot'; false otherwise.111bool is_hot(uint count);112113// Clears the card counts for the cards spanned by the region114void clear_region(HeapRegion* hr);115116// Clears the card counts for the cards spanned by the MemRegion117void clear_range(MemRegion mr);118119// Clear the entire card counts table during GC.120void clear_all();121};122123#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1CARDCOUNTS_HPP124125126