annotate src/share/vm/gc_implementation/g1/g1CardCounts.hpp @ 12233:40136aa2cdb1

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