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

Mon, 21 Jul 2014 09:41:04 +0200

author
tschatzl
date
Mon, 21 Jul 2014 09:41:04 +0200
changeset 6937
b0c374311c4e
parent 6680
78bbf4d43a14
child 6876
710a3c8b516e
child 7051
1f1d373cd044
permissions
-rw-r--r--

8035400: Move G1ParScanThreadState into its own files
Summary: Extract the G1ParScanThreadState class from G1CollectedHeap.?pp into its own files.
Reviewed-by: brutisso, mgerdin

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

mercurial