annotate src/share/vm/memory/blockOffsetTable.hpp @ 1994:6cd6d394f280

7001033: assert(gch->gc_cause() == GCCause::_scavenge_alot || !gch->incremental_collection_failed()) 7002546: regression on SpecJbb2005 on 7b118 comparing to 7b117 on small heaps Summary: Relaxed assertion checking related to incremental_collection_failed flag to allow for ExplicitGCInvokesConcurrent behaviour where we do not want a failing scavenge to bail to a stop-world collection. Parameterized incremental_collection_will_fail() so we can selectively use, or not use, as appropriate, the statistical prediction at specific use sites. This essentially reverts the scavenge bail-out logic to what it was prior to some recent changes that had inadvertently started using the statistical prediction which can be noisy in the presence of bursty loads. Added some associated verbose non-product debugging messages. Reviewed-by: johnc, tonyp
author ysr
date Tue, 07 Dec 2010 21:55:53 -0800
parents f95d63e2154a
children d2a62e0f25eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1518
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1518
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1518
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1732
diff changeset
25 #ifndef SHARE_VM_MEMORY_BLOCKOFFSETTABLE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1732
diff changeset
26 #define SHARE_VM_MEMORY_BLOCKOFFSETTABLE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1732
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1732
diff changeset
28 #include "memory/memRegion.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1732
diff changeset
29 #include "runtime/virtualspace.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1732
diff changeset
30 #include "utilities/globalDefinitions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1732
diff changeset
31
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // The CollectedHeap type requires subtypes to implement a method
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // "block_start". For some subtypes, notably generational
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // systems using card-table-based write barriers, the efficiency of this
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // operation may be important. Implementations of the "BlockOffsetArray"
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // class may be useful in providing such efficient implementations.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // BlockOffsetTable (abstract)
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // - BlockOffsetArray (abstract)
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // - BlockOffsetArrayNonContigSpace
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // - BlockOffsetArrayContigSpace
a61af66fc99e Initial load
duke
parents:
diff changeset
42 //
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class ContiguousSpace;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 class SerializeOopClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 //////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // The BlockOffsetTable "interface"
a61af66fc99e Initial load
duke
parents:
diff changeset
49 //////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
50 class BlockOffsetTable VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // These members describe the region covered by the table.
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // The space this table is covering.
a61af66fc99e Initial load
duke
parents:
diff changeset
56 HeapWord* _bottom; // == reserved.start
a61af66fc99e Initial load
duke
parents:
diff changeset
57 HeapWord* _end; // End of currently allocated region.
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Initialize the table to cover the given space.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // The contents of the initial table are undefined.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 BlockOffsetTable(HeapWord* bottom, HeapWord* end):
a61af66fc99e Initial load
duke
parents:
diff changeset
63 _bottom(bottom), _end(end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 assert(_bottom <= _end, "arguments out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Note that the committed size of the covered space may have changed,
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // so the table size might also wish to change.
a61af66fc99e Initial load
duke
parents:
diff changeset
69 virtual void resize(size_t new_word_size) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 virtual void set_bottom(HeapWord* new_bottom) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 assert(new_bottom <= _end, "new_bottom > _end");
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _bottom = new_bottom;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 resize(pointer_delta(_end, _bottom));
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Requires "addr" to be contained by a block, and returns the address of
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // the start of that block.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 virtual HeapWord* block_start_unsafe(const void* addr) const = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // Returns the address of the start of the block containing "addr", or
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // else "null" if it is covered by no block.
a61af66fc99e Initial load
duke
parents:
diff changeset
83 HeapWord* block_start(const void* addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 };
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 //////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // One implementation of "BlockOffsetTable," the BlockOffsetArray,
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // divides the covered region into "N"-word subregions (where
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // "N" = 2^"LogN". An array with an entry for each such subregion
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // indicates how far back one must go to find the start of the
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // chunk that includes the first word of the subregion.
a61af66fc99e Initial load
duke
parents:
diff changeset
92 //
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Each BlockOffsetArray is owned by a Space. However, the actual array
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // may be shared by several BlockOffsetArrays; this is useful
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // when a single resizable area (such as a generation) is divided up into
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // several spaces in which contiguous allocation takes place. (Consider,
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // for example, the garbage-first generation.)
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // Here is the shared array type.
a61af66fc99e Initial load
duke
parents:
diff changeset
100 //////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // BlockOffsetSharedArray
a61af66fc99e Initial load
duke
parents:
diff changeset
102 //////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
103 class BlockOffsetSharedArray: public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 friend class BlockOffsetArray;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 friend class BlockOffsetArrayNonContigSpace;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 friend class BlockOffsetArrayContigSpace;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
110 enum SomePrivateConstants {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 LogN = 9,
a61af66fc99e Initial load
duke
parents:
diff changeset
112 LogN_words = LogN - LogHeapWordSize,
a61af66fc99e Initial load
duke
parents:
diff changeset
113 N_bytes = 1 << LogN,
a61af66fc99e Initial load
duke
parents:
diff changeset
114 N_words = 1 << LogN_words
a61af66fc99e Initial load
duke
parents:
diff changeset
115 };
a61af66fc99e Initial load
duke
parents:
diff changeset
116
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
117 bool _init_to_zero;
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
118
0
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // The reserved region covered by the shared array.
a61af66fc99e Initial load
duke
parents:
diff changeset
120 MemRegion _reserved;
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // End of the current committed region.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 HeapWord* _end;
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Array for keeping offsets for retrieving object start fast given an
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // address.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 VirtualSpace _vs;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 u_char* _offset_array; // byte array keeping backwards offsets
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // Bounds checking accessors:
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // For performance these have to devolve to array accesses in product builds.
a61af66fc99e Initial load
duke
parents:
diff changeset
133 u_char offset_array(size_t index) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
134 assert(index < _vs.committed_size(), "index out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
135 return _offset_array[index];
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
137 // An assertion-checking helper method for the set_offset_array() methods below.
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
138 void check_reducing_assertion(bool reducing);
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
139
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
140 void set_offset_array(size_t index, u_char offset, bool reducing = false) {
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
141 check_reducing_assertion(reducing);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
142 assert(index < _vs.committed_size(), "index out of range");
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
143 assert(!reducing || _offset_array[index] >= offset, "Not reducing");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
144 _offset_array[index] = offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
146
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
147 void set_offset_array(size_t index, HeapWord* high, HeapWord* low, bool reducing = false) {
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
148 check_reducing_assertion(reducing);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
149 assert(index < _vs.committed_size(), "index out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
150 assert(high >= low, "addresses out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
151 assert(pointer_delta(high, low) <= N_words, "offset too large");
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
152 assert(!reducing || _offset_array[index] >= (u_char)pointer_delta(high, low),
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
153 "Not reducing");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
154 _offset_array[index] = (u_char)pointer_delta(high, low);
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
156
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
157 void set_offset_array(HeapWord* left, HeapWord* right, u_char offset, bool reducing = false) {
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
158 check_reducing_assertion(reducing);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
159 assert(index_for(right - 1) < _vs.committed_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
160 "right address out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
161 assert(left < right, "Heap addresses out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
162 size_t num_cards = pointer_delta(right, left) >> LogN_words;
1518
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
163
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
164 // Below, we may use an explicit loop instead of memset()
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
165 // because on certain platforms memset() can give concurrent
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
166 // readers "out-of-thin-air," phantom zeros; see 6948537.
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
167 if (UseMemSetInBOT) {
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
168 memset(&_offset_array[index_for(left)], offset, num_cards);
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
169 } else {
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
170 size_t i = index_for(left);
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
171 const size_t end = i + num_cards;
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
172 for (; i < end; i++) {
1732
52f2bc645da5 6978533: CMS: Elide BOT update asserts until 6977974 is fixed correctly
ysr
parents: 1716
diff changeset
173 // Elided until CR 6977974 is fixed properly.
52f2bc645da5 6978533: CMS: Elide BOT update asserts until 6977974 is fixed correctly
ysr
parents: 1716
diff changeset
174 // assert(!reducing || _offset_array[i] >= offset, "Not reducing");
1518
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
175 _offset_array[i] = offset;
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
176 }
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
177 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
180 void set_offset_array(size_t left, size_t right, u_char offset, bool reducing = false) {
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
181 check_reducing_assertion(reducing);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
182 assert(right < _vs.committed_size(), "right address out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
183 assert(left <= right, "indexes out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
184 size_t num_cards = right - left + 1;
1518
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
185
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
186 // Below, we may use an explicit loop instead of memset
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
187 // because on certain platforms memset() can give concurrent
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
188 // readers "out-of-thin-air," phantom zeros; see 6948537.
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
189 if (UseMemSetInBOT) {
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
190 memset(&_offset_array[left], offset, num_cards);
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
191 } else {
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
192 size_t i = left;
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
193 const size_t end = i + num_cards;
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
194 for (; i < end; i++) {
1732
52f2bc645da5 6978533: CMS: Elide BOT update asserts until 6977974 is fixed correctly
ysr
parents: 1716
diff changeset
195 // Elided until CR 6977974 is fixed properly.
52f2bc645da5 6978533: CMS: Elide BOT update asserts until 6977974 is fixed correctly
ysr
parents: 1716
diff changeset
196 // assert(!reducing || _offset_array[i] >= offset, "Not reducing");
1518
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
197 _offset_array[i] = offset;
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
198 }
3bfae429e2cf 6948537: CMS: BOT walkers observe out-of-thin-air zeros on sun4v sparc/CMT
ysr
parents: 844
diff changeset
199 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 void check_offset_array(size_t index, HeapWord* high, HeapWord* low) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 assert(index < _vs.committed_size(), "index out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
204 assert(high >= low, "addresses out of order");
a61af66fc99e Initial load
duke
parents:
diff changeset
205 assert(pointer_delta(high, low) <= N_words, "offset too large");
a61af66fc99e Initial load
duke
parents:
diff changeset
206 assert(_offset_array[index] == pointer_delta(high, low),
a61af66fc99e Initial load
duke
parents:
diff changeset
207 "Wrong offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 bool is_card_boundary(HeapWord* p) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // Return the number of slots needed for an offset array
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // that covers mem_region_words words.
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // We always add an extra slot because if an object
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // ends on a card boundary we put a 0 in the next
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // offset array slot, so we want that slot always
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // to be reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 size_t compute_size(size_t mem_region_words) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 size_t number_of_slots = (mem_region_words / N_words) + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 return ReservedSpace::allocation_align_size_up(number_of_slots);
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // Initialize the table to cover from "base" to (at least)
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // "base + init_word_size". In the future, the table may be expanded
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // (see "resize" below) up to the size of "_reserved" (which must be at
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // least "init_word_size".) The contents of the initial table are
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // undefined; it is the responsibility of the constituent
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // BlockOffsetTable(s) to initialize cards.
a61af66fc99e Initial load
duke
parents:
diff changeset
231 BlockOffsetSharedArray(MemRegion reserved, size_t init_word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 // Notes a change in the committed size of the region covered by the
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // table. The "new_word_size" may not be larger than the size of the
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // reserved region this table covers.
a61af66fc99e Initial load
duke
parents:
diff changeset
236 void resize(size_t new_word_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 void set_bottom(HeapWord* new_bottom);
a61af66fc99e Initial load
duke
parents:
diff changeset
239
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
240 // Whether entries should be initialized to zero. Used currently only for
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
241 // error checking.
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
242 void set_init_to_zero(bool val) { _init_to_zero = val; }
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
243 bool init_to_zero() { return _init_to_zero; }
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
244
0
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // Updates all the BlockOffsetArray's sharing this shared array to
a61af66fc99e Initial load
duke
parents:
diff changeset
246 // reflect the current "top"'s of their spaces.
a61af66fc99e Initial load
duke
parents:
diff changeset
247 void update_offset_arrays(); // Not yet implemented!
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // Return the appropriate index into "_offset_array" for "p".
a61af66fc99e Initial load
duke
parents:
diff changeset
250 size_t index_for(const void* p) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // Return the address indicating the start of the region corresponding to
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // "index" in "_offset_array".
a61af66fc99e Initial load
duke
parents:
diff changeset
254 HeapWord* address_for_index(size_t index) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
255
301
387a62b4be60 6728478: Assertion at parallel promotion from young to old generation
jmasa
parents: 0
diff changeset
256 // Return the address "p" incremented by the size of
387a62b4be60 6728478: Assertion at parallel promotion from young to old generation
jmasa
parents: 0
diff changeset
257 // a region. This method does not align the address
387a62b4be60 6728478: Assertion at parallel promotion from young to old generation
jmasa
parents: 0
diff changeset
258 // returned to the start of a region. It is a simple
387a62b4be60 6728478: Assertion at parallel promotion from young to old generation
jmasa
parents: 0
diff changeset
259 // primitive.
387a62b4be60 6728478: Assertion at parallel promotion from young to old generation
jmasa
parents: 0
diff changeset
260 HeapWord* inc_by_region_size(HeapWord* p) const { return p + N_words; }
387a62b4be60 6728478: Assertion at parallel promotion from young to old generation
jmasa
parents: 0
diff changeset
261
0
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // Shared space support
a61af66fc99e Initial load
duke
parents:
diff changeset
263 void serialize(SerializeOopClosure* soc, HeapWord* start, HeapWord* end);
a61af66fc99e Initial load
duke
parents:
diff changeset
264 };
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 //////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
267 // The BlockOffsetArray whose subtypes use the BlockOffsetSharedArray.
a61af66fc99e Initial load
duke
parents:
diff changeset
268 //////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
269 class BlockOffsetArray: public BlockOffsetTable {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 friend class VMStructs;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
271 friend class G1BlockOffsetArray; // temp. until we restructure and cleanup
0
a61af66fc99e Initial load
duke
parents:
diff changeset
272 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
273 // The following enums are used by do_block_internal() below
a61af66fc99e Initial load
duke
parents:
diff changeset
274 enum Action {
a61af66fc99e Initial load
duke
parents:
diff changeset
275 Action_single, // BOT records a single block (see single_block())
a61af66fc99e Initial load
duke
parents:
diff changeset
276 Action_mark, // BOT marks the start of a block (see mark_block())
a61af66fc99e Initial load
duke
parents:
diff changeset
277 Action_check // Check that BOT records block correctly
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // (see verify_single_block()).
a61af66fc99e Initial load
duke
parents:
diff changeset
279 };
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 enum SomePrivateConstants {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 N_words = BlockOffsetSharedArray::N_words,
a61af66fc99e Initial load
duke
parents:
diff changeset
283 LogN = BlockOffsetSharedArray::LogN,
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // entries "e" of at least N_words mean "go back by Base^(e-N_words)."
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // All entries are less than "N_words + N_powers".
a61af66fc99e Initial load
duke
parents:
diff changeset
286 LogBase = 4,
a61af66fc99e Initial load
duke
parents:
diff changeset
287 Base = (1 << LogBase),
a61af66fc99e Initial load
duke
parents:
diff changeset
288 N_powers = 14
a61af66fc99e Initial load
duke
parents:
diff changeset
289 };
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 static size_t power_to_cards_back(uint i) {
645
c3a720eefe82 6816308: Changes to allow builds with latest Windows SDK 6.1 on 64bit Windows 2003
kvn
parents: 380
diff changeset
292 return (size_t)(1 << (LogBase * i));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294 static size_t power_to_words_back(uint i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
295 return power_to_cards_back(i) * N_words;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 static size_t entry_to_cards_back(u_char entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 assert(entry >= N_words, "Precondition");
a61af66fc99e Initial load
duke
parents:
diff changeset
299 return power_to_cards_back(entry - N_words);
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301 static size_t entry_to_words_back(u_char entry) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 assert(entry >= N_words, "Precondition");
a61af66fc99e Initial load
duke
parents:
diff changeset
303 return power_to_words_back(entry - N_words);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // The shared array, which is shared with other BlockOffsetArray's
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // corresponding to different spaces within a generation or span of
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // memory.
a61af66fc99e Initial load
duke
parents:
diff changeset
309 BlockOffsetSharedArray* _array;
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // The space that owns this subregion.
a61af66fc99e Initial load
duke
parents:
diff changeset
312 Space* _sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314 // If true, array entries are initialized to 0; otherwise, they are
a61af66fc99e Initial load
duke
parents:
diff changeset
315 // initialized to point backwards to the beginning of the covered region.
a61af66fc99e Initial load
duke
parents:
diff changeset
316 bool _init_to_zero;
a61af66fc99e Initial load
duke
parents:
diff changeset
317
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
318 // An assertion-checking helper method for the set_remainder*() methods below.
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
319 void check_reducing_assertion(bool reducing) { _array->check_reducing_assertion(reducing); }
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
320
0
a61af66fc99e Initial load
duke
parents:
diff changeset
321 // Sets the entries
a61af66fc99e Initial load
duke
parents:
diff changeset
322 // corresponding to the cards starting at "start" and ending at "end"
a61af66fc99e Initial load
duke
parents:
diff changeset
323 // to point back to the card before "start": the interval [start, end)
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
324 // is right-open. The last parameter, reducing, indicates whether the
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
325 // updates to individual entries always reduce the entry from a higher
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
326 // to a lower value. (For example this would hold true during a temporal
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
327 // regime during which only block splits were updating the BOT.
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
328 void set_remainder_to_point_to_start(HeapWord* start, HeapWord* end, bool reducing = false);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // Same as above, except that the args here are a card _index_ interval
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // that is closed: [start_index, end_index]
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
331 void set_remainder_to_point_to_start_incl(size_t start, size_t end, bool reducing = false);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // A helper function for BOT adjustment/verification work
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
334 void do_block_internal(HeapWord* blk_start, HeapWord* blk_end, Action action, bool reducing = false);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
337 // The space may not have its bottom and top set yet, which is why the
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // region is passed as a parameter. If "init_to_zero" is true, the
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // elements of the array are initialized to zero. Otherwise, they are
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // initialized to point backwards to the beginning.
a61af66fc99e Initial load
duke
parents:
diff changeset
341 BlockOffsetArray(BlockOffsetSharedArray* array, MemRegion mr,
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
342 bool init_to_zero_);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
343
a61af66fc99e Initial load
duke
parents:
diff changeset
344 // Note: this ought to be part of the constructor, but that would require
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // "this" to be passed as a parameter to a member constructor for
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // the containing concrete subtype of Space.
a61af66fc99e Initial load
duke
parents:
diff changeset
347 // This would be legal C++, but MS VC++ doesn't allow it.
a61af66fc99e Initial load
duke
parents:
diff changeset
348 void set_space(Space* sp) { _sp = sp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // Resets the covered region to the given "mr".
a61af66fc99e Initial load
duke
parents:
diff changeset
351 void set_region(MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
352 _bottom = mr.start();
a61af66fc99e Initial load
duke
parents:
diff changeset
353 _end = mr.end();
a61af66fc99e Initial load
duke
parents:
diff changeset
354 }
a61af66fc99e Initial load
duke
parents:
diff changeset
355
a61af66fc99e Initial load
duke
parents:
diff changeset
356 // Note that the committed size of the covered space may have changed,
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // so the table size might also wish to change.
a61af66fc99e Initial load
duke
parents:
diff changeset
358 virtual void resize(size_t new_word_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 HeapWord* new_end = _bottom + new_word_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
360 if (_end < new_end && !init_to_zero()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // verify that the old and new boundaries are also card boundaries
a61af66fc99e Initial load
duke
parents:
diff changeset
362 assert(_array->is_card_boundary(_end),
a61af66fc99e Initial load
duke
parents:
diff changeset
363 "_end not a card boundary");
a61af66fc99e Initial load
duke
parents:
diff changeset
364 assert(_array->is_card_boundary(new_end),
a61af66fc99e Initial load
duke
parents:
diff changeset
365 "new _end would not be a card boundary");
a61af66fc99e Initial load
duke
parents:
diff changeset
366 // set all the newly added cards
a61af66fc99e Initial load
duke
parents:
diff changeset
367 _array->set_offset_array(_end, new_end, N_words);
a61af66fc99e Initial load
duke
parents:
diff changeset
368 }
a61af66fc99e Initial load
duke
parents:
diff changeset
369 _end = new_end; // update _end
a61af66fc99e Initial load
duke
parents:
diff changeset
370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // Adjust the BOT to show that it has a single block in the
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // range [blk_start, blk_start + size). All necessary BOT
a61af66fc99e Initial load
duke
parents:
diff changeset
374 // cards are adjusted, but _unallocated_block isn't.
a61af66fc99e Initial load
duke
parents:
diff changeset
375 void single_block(HeapWord* blk_start, HeapWord* blk_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
376 void single_block(HeapWord* blk, size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
377 single_block(blk, blk + size);
a61af66fc99e Initial load
duke
parents:
diff changeset
378 }
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
380 // When the alloc_block() call returns, the block offset table should
a61af66fc99e Initial load
duke
parents:
diff changeset
381 // have enough information such that any subsequent block_start() call
a61af66fc99e Initial load
duke
parents:
diff changeset
382 // with an argument equal to an address that is within the range
a61af66fc99e Initial load
duke
parents:
diff changeset
383 // [blk_start, blk_end) would return the value blk_start, provided
a61af66fc99e Initial load
duke
parents:
diff changeset
384 // there have been no calls in between that reset this information
a61af66fc99e Initial load
duke
parents:
diff changeset
385 // (e.g. see BlockOffsetArrayNonContigSpace::single_block() call
a61af66fc99e Initial load
duke
parents:
diff changeset
386 // for an appropriate range covering the said interval).
a61af66fc99e Initial load
duke
parents:
diff changeset
387 // These methods expect to be called with [blk_start, blk_end)
a61af66fc99e Initial load
duke
parents:
diff changeset
388 // representing a block of memory in the heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
389 virtual void alloc_block(HeapWord* blk_start, HeapWord* blk_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
390 void alloc_block(HeapWord* blk, size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
391 alloc_block(blk, blk + size);
a61af66fc99e Initial load
duke
parents:
diff changeset
392 }
a61af66fc99e Initial load
duke
parents:
diff changeset
393
a61af66fc99e Initial load
duke
parents:
diff changeset
394 // If true, initialize array slots with no allocated blocks to zero.
a61af66fc99e Initial load
duke
parents:
diff changeset
395 // Otherwise, make them point back to the front.
a61af66fc99e Initial load
duke
parents:
diff changeset
396 bool init_to_zero() { return _init_to_zero; }
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
397 // Corresponding setter
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
398 void set_init_to_zero(bool val) {
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
399 _init_to_zero = val;
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
400 assert(_array != NULL, "_array should be non-NULL");
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
401 _array->set_init_to_zero(val);
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
402 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
403
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
405 // Return the index of the last entry in the "active" region.
a61af66fc99e Initial load
duke
parents:
diff changeset
406 virtual size_t last_active_index() const = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
407 // Verify the block offset table
a61af66fc99e Initial load
duke
parents:
diff changeset
408 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
409 void check_all_cards(size_t left_card, size_t right_card) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
410 };
a61af66fc99e Initial load
duke
parents:
diff changeset
411
a61af66fc99e Initial load
duke
parents:
diff changeset
412 ////////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
413 // A subtype of BlockOffsetArray that takes advantage of the fact
a61af66fc99e Initial load
duke
parents:
diff changeset
414 // that its underlying space is a NonContiguousSpace, so that some
a61af66fc99e Initial load
duke
parents:
diff changeset
415 // specialized interfaces can be made available for spaces that
a61af66fc99e Initial load
duke
parents:
diff changeset
416 // manipulate the table.
a61af66fc99e Initial load
duke
parents:
diff changeset
417 ////////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
418 class BlockOffsetArrayNonContigSpace: public BlockOffsetArray {
a61af66fc99e Initial load
duke
parents:
diff changeset
419 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
420 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
421 // The portion [_unallocated_block, _sp.end()) of the space that
a61af66fc99e Initial load
duke
parents:
diff changeset
422 // is a single block known not to contain any objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
423 // NOTE: See BlockOffsetArrayUseUnallocatedBlock flag.
a61af66fc99e Initial load
duke
parents:
diff changeset
424 HeapWord* _unallocated_block;
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
427 BlockOffsetArrayNonContigSpace(BlockOffsetSharedArray* array, MemRegion mr):
a61af66fc99e Initial load
duke
parents:
diff changeset
428 BlockOffsetArray(array, mr, false),
a61af66fc99e Initial load
duke
parents:
diff changeset
429 _unallocated_block(_bottom) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
430
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // accessor
a61af66fc99e Initial load
duke
parents:
diff changeset
432 HeapWord* unallocated_block() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 assert(BlockOffsetArrayUseUnallocatedBlock,
a61af66fc99e Initial load
duke
parents:
diff changeset
434 "_unallocated_block is not being maintained");
a61af66fc99e Initial load
duke
parents:
diff changeset
435 return _unallocated_block;
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437
a61af66fc99e Initial load
duke
parents:
diff changeset
438 void set_unallocated_block(HeapWord* block) {
a61af66fc99e Initial load
duke
parents:
diff changeset
439 assert(BlockOffsetArrayUseUnallocatedBlock,
a61af66fc99e Initial load
duke
parents:
diff changeset
440 "_unallocated_block is not being maintained");
a61af66fc99e Initial load
duke
parents:
diff changeset
441 assert(block >= _bottom && block <= _end, "out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
442 _unallocated_block = block;
a61af66fc99e Initial load
duke
parents:
diff changeset
443 }
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 // These methods expect to be called with [blk_start, blk_end)
a61af66fc99e Initial load
duke
parents:
diff changeset
446 // representing a block of memory in the heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
447 void alloc_block(HeapWord* blk_start, HeapWord* blk_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
448 void alloc_block(HeapWord* blk, size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
449 alloc_block(blk, blk + size);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 }
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 // The following methods are useful and optimized for a
a61af66fc99e Initial load
duke
parents:
diff changeset
453 // non-contiguous space.
a61af66fc99e Initial load
duke
parents:
diff changeset
454
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // Given a block [blk_start, blk_start + full_blk_size), and
a61af66fc99e Initial load
duke
parents:
diff changeset
456 // a left_blk_size < full_blk_size, adjust the BOT to show two
a61af66fc99e Initial load
duke
parents:
diff changeset
457 // blocks [blk_start, blk_start + left_blk_size) and
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // [blk_start + left_blk_size, blk_start + full_blk_size).
a61af66fc99e Initial load
duke
parents:
diff changeset
459 // It is assumed (and verified in the non-product VM) that the
a61af66fc99e Initial load
duke
parents:
diff changeset
460 // BOT was correct for the original block.
a61af66fc99e Initial load
duke
parents:
diff changeset
461 void split_block(HeapWord* blk_start, size_t full_blk_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
462 size_t left_blk_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
463
a61af66fc99e Initial load
duke
parents:
diff changeset
464 // Adjust BOT to show that it has a block in the range
a61af66fc99e Initial load
duke
parents:
diff changeset
465 // [blk_start, blk_start + size). Only the first card
a61af66fc99e Initial load
duke
parents:
diff changeset
466 // of BOT is touched. It is assumed (and verified in the
a61af66fc99e Initial load
duke
parents:
diff changeset
467 // non-product VM) that the remaining cards of the block
a61af66fc99e Initial load
duke
parents:
diff changeset
468 // are correct.
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
469 void mark_block(HeapWord* blk_start, HeapWord* blk_end, bool reducing = false);
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
470 void mark_block(HeapWord* blk, size_t size, bool reducing = false) {
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
471 mark_block(blk, blk + size, reducing);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
472 }
a61af66fc99e Initial load
duke
parents:
diff changeset
473
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // Adjust _unallocated_block to indicate that a particular
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // block has been newly allocated or freed. It is assumed (and
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // verified in the non-product VM) that the BOT is correct for
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // the given block.
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
478 void allocated(HeapWord* blk_start, HeapWord* blk_end, bool reducing = false) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
479 // Verify that the BOT shows [blk, blk + blk_size) to be one block.
a61af66fc99e Initial load
duke
parents:
diff changeset
480 verify_single_block(blk_start, blk_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
481 if (BlockOffsetArrayUseUnallocatedBlock) {
a61af66fc99e Initial load
duke
parents:
diff changeset
482 _unallocated_block = MAX2(_unallocated_block, blk_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
483 }
a61af66fc99e Initial load
duke
parents:
diff changeset
484 }
a61af66fc99e Initial load
duke
parents:
diff changeset
485
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
486 void allocated(HeapWord* blk, size_t size, bool reducing = false) {
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
487 allocated(blk, blk + size, reducing);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
488 }
a61af66fc99e Initial load
duke
parents:
diff changeset
489
a61af66fc99e Initial load
duke
parents:
diff changeset
490 void freed(HeapWord* blk_start, HeapWord* blk_end);
1716
be3f9c242c9d 6948538: CMS: BOT walkers can fall into object allocation and initialization cracks
ysr
parents: 1552
diff changeset
491 void freed(HeapWord* blk, size_t size);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
492
a61af66fc99e Initial load
duke
parents:
diff changeset
493 HeapWord* block_start_unsafe(const void* addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 // Requires "addr" to be the start of a card and returns the
a61af66fc99e Initial load
duke
parents:
diff changeset
496 // start of the block that contains the given address.
a61af66fc99e Initial load
duke
parents:
diff changeset
497 HeapWord* block_start_careful(const void* addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
498
a61af66fc99e Initial load
duke
parents:
diff changeset
499 // Verification & debugging: ensure that the offset table reflects
a61af66fc99e Initial load
duke
parents:
diff changeset
500 // the fact that the block [blk_start, blk_end) or [blk, blk + size)
a61af66fc99e Initial load
duke
parents:
diff changeset
501 // is a single block of storage. NOTE: can't const this because of
a61af66fc99e Initial load
duke
parents:
diff changeset
502 // call to non-const do_block_internal() below.
a61af66fc99e Initial load
duke
parents:
diff changeset
503 void verify_single_block(HeapWord* blk_start, HeapWord* blk_end)
a61af66fc99e Initial load
duke
parents:
diff changeset
504 PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
505 void verify_single_block(HeapWord* blk, size_t size) PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
506
a61af66fc99e Initial load
duke
parents:
diff changeset
507 // Verify that the given block is before _unallocated_block
a61af66fc99e Initial load
duke
parents:
diff changeset
508 void verify_not_unallocated(HeapWord* blk_start, HeapWord* blk_end)
a61af66fc99e Initial load
duke
parents:
diff changeset
509 const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
510 void verify_not_unallocated(HeapWord* blk, size_t size)
a61af66fc99e Initial load
duke
parents:
diff changeset
511 const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
512
a61af66fc99e Initial load
duke
parents:
diff changeset
513 // Debugging support
a61af66fc99e Initial load
duke
parents:
diff changeset
514 virtual size_t last_active_index() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
515 };
a61af66fc99e Initial load
duke
parents:
diff changeset
516
a61af66fc99e Initial load
duke
parents:
diff changeset
517 ////////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
518 // A subtype of BlockOffsetArray that takes advantage of the fact
a61af66fc99e Initial load
duke
parents:
diff changeset
519 // that its underlying space is a ContiguousSpace, so that its "active"
a61af66fc99e Initial load
duke
parents:
diff changeset
520 // region can be more efficiently tracked (than for a non-contiguous space).
a61af66fc99e Initial load
duke
parents:
diff changeset
521 ////////////////////////////////////////////////////////////////////////////
a61af66fc99e Initial load
duke
parents:
diff changeset
522 class BlockOffsetArrayContigSpace: public BlockOffsetArray {
a61af66fc99e Initial load
duke
parents:
diff changeset
523 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
524 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
525 // allocation boundary at which offset array must be updated
a61af66fc99e Initial load
duke
parents:
diff changeset
526 HeapWord* _next_offset_threshold;
a61af66fc99e Initial load
duke
parents:
diff changeset
527 size_t _next_offset_index; // index corresponding to that boundary
a61af66fc99e Initial load
duke
parents:
diff changeset
528
a61af66fc99e Initial load
duke
parents:
diff changeset
529 // Work function when allocation start crosses threshold.
a61af66fc99e Initial load
duke
parents:
diff changeset
530 void alloc_block_work(HeapWord* blk_start, HeapWord* blk_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
531
a61af66fc99e Initial load
duke
parents:
diff changeset
532 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
533 BlockOffsetArrayContigSpace(BlockOffsetSharedArray* array, MemRegion mr):
a61af66fc99e Initial load
duke
parents:
diff changeset
534 BlockOffsetArray(array, mr, true) {
a61af66fc99e Initial load
duke
parents:
diff changeset
535 _next_offset_threshold = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
536 _next_offset_index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
537 }
a61af66fc99e Initial load
duke
parents:
diff changeset
538
a61af66fc99e Initial load
duke
parents:
diff changeset
539 void set_contig_space(ContiguousSpace* sp) { set_space((Space*)sp); }
a61af66fc99e Initial load
duke
parents:
diff changeset
540
a61af66fc99e Initial load
duke
parents:
diff changeset
541 // Initialize the threshold for an empty heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
542 HeapWord* initialize_threshold();
a61af66fc99e Initial load
duke
parents:
diff changeset
543 // Zero out the entry for _bottom (offset will be zero)
a61af66fc99e Initial load
duke
parents:
diff changeset
544 void zero_bottom_entry();
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546 // Return the next threshold, the point at which the table should be
a61af66fc99e Initial load
duke
parents:
diff changeset
547 // updated.
a61af66fc99e Initial load
duke
parents:
diff changeset
548 HeapWord* threshold() const { return _next_offset_threshold; }
a61af66fc99e Initial load
duke
parents:
diff changeset
549
a61af66fc99e Initial load
duke
parents:
diff changeset
550 // In general, these methods expect to be called with
a61af66fc99e Initial load
duke
parents:
diff changeset
551 // [blk_start, blk_end) representing a block of memory in the heap.
a61af66fc99e Initial load
duke
parents:
diff changeset
552 // In this implementation, however, we are OK even if blk_start and/or
a61af66fc99e Initial load
duke
parents:
diff changeset
553 // blk_end are NULL because NULL is represented as 0, and thus
a61af66fc99e Initial load
duke
parents:
diff changeset
554 // never exceeds the "_next_offset_threshold".
a61af66fc99e Initial load
duke
parents:
diff changeset
555 void alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
556 if (blk_end > _next_offset_threshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
557 alloc_block_work(blk_start, blk_end);
a61af66fc99e Initial load
duke
parents:
diff changeset
558 }
a61af66fc99e Initial load
duke
parents:
diff changeset
559 }
a61af66fc99e Initial load
duke
parents:
diff changeset
560 void alloc_block(HeapWord* blk, size_t size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
561 alloc_block(blk, blk + size);
a61af66fc99e Initial load
duke
parents:
diff changeset
562 }
a61af66fc99e Initial load
duke
parents:
diff changeset
563
a61af66fc99e Initial load
duke
parents:
diff changeset
564 HeapWord* block_start_unsafe(const void* addr) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
565
a61af66fc99e Initial load
duke
parents:
diff changeset
566 void serialize(SerializeOopClosure* soc);
a61af66fc99e Initial load
duke
parents:
diff changeset
567
a61af66fc99e Initial load
duke
parents:
diff changeset
568 // Debugging support
a61af66fc99e Initial load
duke
parents:
diff changeset
569 virtual size_t last_active_index() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
570 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1732
diff changeset
571
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1732
diff changeset
572 #endif // SHARE_VM_MEMORY_BLOCKOFFSETTABLE_HPP