src/share/vm/gc_implementation/g1/g1CardCounts.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1CARDCOUNTS_HPP
aoqi@0 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1CARDCOUNTS_HPP
aoqi@0 27
aoqi@0 28 #include "memory/allocation.hpp"
aoqi@0 29 #include "runtime/virtualspace.hpp"
aoqi@0 30 #include "utilities/globalDefinitions.hpp"
aoqi@0 31
aoqi@0 32 class CardTableModRefBS;
aoqi@0 33 class G1CollectedHeap;
aoqi@0 34 class HeapRegion;
aoqi@0 35
aoqi@0 36 // Table to track the number of times a card has been refined. Once
aoqi@0 37 // a card has been refined a certain number of times, it is
aoqi@0 38 // considered 'hot' and its refinement is delayed by inserting the
aoqi@0 39 // card into the hot card cache. The card will then be refined when
aoqi@0 40 // it is evicted from the hot card cache, or when the hot card cache
aoqi@0 41 // is 'drained' during the next evacuation pause.
aoqi@0 42
aoqi@0 43 class G1CardCounts: public CHeapObj<mtGC> {
aoqi@0 44 G1CollectedHeap* _g1h;
aoqi@0 45
aoqi@0 46 // The table of counts
aoqi@0 47 jubyte* _card_counts;
aoqi@0 48
aoqi@0 49 // Max capacity of the reserved space for the counts table
aoqi@0 50 size_t _reserved_max_card_num;
aoqi@0 51
aoqi@0 52 // Max capacity of the committed space for the counts table
aoqi@0 53 size_t _committed_max_card_num;
aoqi@0 54
aoqi@0 55 // Size of committed space for the counts table
aoqi@0 56 size_t _committed_size;
aoqi@0 57
aoqi@0 58 // CardTable bottom.
aoqi@0 59 const jbyte* _ct_bot;
aoqi@0 60
aoqi@0 61 // Barrier set
aoqi@0 62 CardTableModRefBS* _ct_bs;
aoqi@0 63
aoqi@0 64 // The virtual memory backing the counts table
aoqi@0 65 VirtualSpace _card_counts_storage;
aoqi@0 66
aoqi@0 67 // Returns true if the card counts table has been reserved.
aoqi@0 68 bool has_reserved_count_table() { return _card_counts != NULL; }
aoqi@0 69
aoqi@0 70 // Returns true if the card counts table has been reserved and committed.
aoqi@0 71 bool has_count_table() {
aoqi@0 72 return has_reserved_count_table() && _committed_max_card_num > 0;
aoqi@0 73 }
aoqi@0 74
aoqi@0 75 size_t ptr_2_card_num(const jbyte* card_ptr) {
aoqi@0 76 assert(card_ptr >= _ct_bot,
aoqi@0 77 err_msg("Invalid card pointer: "
aoqi@0 78 "card_ptr: " PTR_FORMAT ", "
aoqi@0 79 "_ct_bot: " PTR_FORMAT,
aoqi@0 80 p2i(card_ptr), p2i(_ct_bot)));
aoqi@0 81 size_t card_num = pointer_delta(card_ptr, _ct_bot, sizeof(jbyte));
aoqi@0 82 assert(card_num >= 0 && card_num < _committed_max_card_num,
aoqi@0 83 err_msg("card pointer out of range: " PTR_FORMAT, p2i(card_ptr)));
aoqi@0 84 return card_num;
aoqi@0 85 }
aoqi@0 86
aoqi@0 87 jbyte* card_num_2_ptr(size_t card_num) {
aoqi@0 88 assert(card_num >= 0 && card_num < _committed_max_card_num,
aoqi@0 89 err_msg("card num out of range: "SIZE_FORMAT, card_num));
aoqi@0 90 return (jbyte*) (_ct_bot + card_num);
aoqi@0 91 }
aoqi@0 92
aoqi@0 93 // Helper routine.
aoqi@0 94 // Returns the number of cards that can be counted by the given committed
aoqi@0 95 // table size, with a maximum of the number of cards spanned by the max
aoqi@0 96 // capacity of the heap.
aoqi@0 97 size_t committed_to_card_num(size_t committed_size) {
aoqi@0 98 return MIN2(_reserved_max_card_num, committed_size / sizeof(jbyte));
aoqi@0 99 }
aoqi@0 100
aoqi@0 101 // Clear the counts table for the given (exclusive) index range.
aoqi@0 102 void clear_range(size_t from_card_num, size_t to_card_num);
aoqi@0 103
aoqi@0 104 public:
aoqi@0 105 G1CardCounts(G1CollectedHeap* g1h);
aoqi@0 106 ~G1CardCounts();
aoqi@0 107
aoqi@0 108 void initialize();
aoqi@0 109
aoqi@0 110 // Resize the committed space for the card counts table in
aoqi@0 111 // response to a resize of the committed space for the heap.
aoqi@0 112 void resize(size_t heap_capacity);
aoqi@0 113
aoqi@0 114 // Increments the refinement count for the given card.
aoqi@0 115 // Returns the pre-increment count value.
aoqi@0 116 uint add_card_count(jbyte* card_ptr);
aoqi@0 117
aoqi@0 118 // Returns true if the given count is high enough to be considered
aoqi@0 119 // 'hot'; false otherwise.
aoqi@0 120 bool is_hot(uint count);
aoqi@0 121
aoqi@0 122 // Clears the card counts for the cards spanned by the region
aoqi@0 123 void clear_region(HeapRegion* hr);
aoqi@0 124
aoqi@0 125 // Clear the entire card counts table during GC.
aoqi@0 126 // Updates the policy stats with the duration.
aoqi@0 127 void clear_all();
aoqi@0 128 };
aoqi@0 129
aoqi@0 130 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1CARDCOUNTS_HPP

mercurial