annotate src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp @ 20504:6948da6d7c13

8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set Summary: Remove -XX:-G1DeferredRSUpdate functionality as it is racy. During evacuation failure handling, threads where evacuation failure handling occurred may try to add remembered sets to regions which remembered sets are currently being scanned. The iterator to handle the remembered set scan does not support addition of entries during scan and so may skip valid references. Reviewed-by: iveresov, brutisso, mgerdin
author tschatzl
date Tue, 30 Sep 2014 09:44:36 +0200
parents 1f1d373cd044
children 0fcaab91d485
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
1 /*
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 7181
diff changeset
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
4 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
7 * published by the Free Software Foundation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
8 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
13 * accompanied this code).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
14 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 342
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 342
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: 342
diff changeset
21 * questions.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
22 *
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
23 */
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
27
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
28 #include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
29 #include "memory/memRegion.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
30 #include "runtime/virtualspace.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
31 #include "utilities/globalDefinitions.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
32
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
33 // The CollectedHeap type requires subtypes to implement a method
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
34 // "block_start". For some subtypes, notably generational
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
35 // systems using card-table-based write barriers, the efficiency of this
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
36 // operation may be important. Implementations of the "BlockOffsetArray"
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
37 // class may be useful in providing such efficient implementations.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
38 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
39 // While generally mirroring the structure of the BOT for GenCollectedHeap,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
40 // the following types are tailored more towards G1's uses; these should,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
41 // however, be merged back into a common BOT to avoid code duplication
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
42 // and reduce maintenance overhead.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
43 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
44 // G1BlockOffsetTable (abstract)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
45 // -- G1BlockOffsetArray (uses G1BlockOffsetSharedArray)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
46 // -- G1BlockOffsetArrayContigSpace
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
47 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
48 // A main impediment to the consolidation of this code might be the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
49 // effect of making some of the block_start*() calls non-const as
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
50 // below. Whether that might adversely affect performance optimizations
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
51 // that compilers might normally perform in the case of non-G1
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
52 // collectors needs to be carefully investigated prior to any such
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
53 // consolidation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
54
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
55 // Forward declarations
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
56 class G1BlockOffsetSharedArray;
20273
9441d22e429a 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 17937
diff changeset
57 class G1OffsetTableContigSpace;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
58
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
59 class G1BlockOffsetTable VALUE_OBJ_CLASS_SPEC {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
60 friend class VMStructs;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
61 protected:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
62 // These members describe the region covered by the table.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
63
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
64 // The space this table is covering.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
65 HeapWord* _bottom; // == reserved.start
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
66 HeapWord* _end; // End of currently allocated region.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
67
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
68 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
69 // Initialize the table to cover the given space.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
70 // The contents of the initial table are undefined.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
71 G1BlockOffsetTable(HeapWord* bottom, HeapWord* end) :
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
72 _bottom(bottom), _end(end)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
73 {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
74 assert(_bottom <= _end, "arguments out of order");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
75 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
76
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
77 // Note that the committed size of the covered space may have changed,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
78 // so the table size might also wish to change.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
79 virtual void resize(size_t new_word_size) = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
80
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
81 virtual void set_bottom(HeapWord* new_bottom) {
7181
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6610
diff changeset
82 assert(new_bottom <= _end,
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6610
diff changeset
83 err_msg("new_bottom (" PTR_FORMAT ") > _end (" PTR_FORMAT ")",
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 7181
diff changeset
84 p2i(new_bottom), p2i(_end)));
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
85 _bottom = new_bottom;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
86 resize(pointer_delta(_end, _bottom));
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
87 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
88
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
89 // Requires "addr" to be contained by a block, and returns the address of
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
90 // the start of that block. (May have side effects, namely updating of
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
91 // shared array entries that "point" too far backwards. This can occur,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
92 // for example, when LAB allocation is used in a space covered by the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
93 // table.)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
94 virtual HeapWord* block_start_unsafe(const void* addr) = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
95 // Same as above, but does not have any of the possible side effects
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
96 // discussed above.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
97 virtual HeapWord* block_start_unsafe_const(const void* addr) const = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
98
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
99 // Returns the address of the start of the block containing "addr", or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
100 // else "null" if it is covered by no block. (May have side effects,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
101 // namely updating of shared array entries that "point" too far
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
102 // backwards. This can occur, for example, when lab allocation is used
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
103 // in a space covered by the table.)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
104 inline HeapWord* block_start(const void* addr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
105 // Same as above, but does not have any of the possible side effects
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
106 // discussed above.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
107 inline HeapWord* block_start_const(const void* addr) const;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
108 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
109
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
110 class G1BlockOffsetSharedArrayMappingChangedListener : public G1MappingChangedListener {
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
111 public:
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
112 virtual void on_commit(uint start_idx, size_t num_regions);
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
113 };
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
114
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
115 // This implementation of "G1BlockOffsetTable" divides the covered region
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
116 // into "N"-word subregions (where "N" = 2^"LogN". An array with an entry
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
117 // for each such subregion indicates how far back one must go to find the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
118 // start of the chunk that includes the first word of the subregion.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
119 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
120 // Each BlockOffsetArray is owned by a Space. However, the actual array
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
121 // may be shared by several BlockOffsetArrays; this is useful
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
122 // when a single resizable area (such as a generation) is divided up into
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
123 // several spaces in which contiguous allocation takes place,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
124 // such as, for example, in G1 or in the train generation.)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
125
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
126 // Here is the shared array type.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
127
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2133
diff changeset
128 class G1BlockOffsetSharedArray: public CHeapObj<mtGC> {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
129 friend class G1BlockOffsetArray;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
130 friend class G1BlockOffsetArrayContigSpace;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
131 friend class VMStructs;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
132
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
133 private:
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
134 G1BlockOffsetSharedArrayMappingChangedListener _listener;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
135 // The reserved region covered by the shared array.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
136 MemRegion _reserved;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
137
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
138 // End of the current committed region.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
139 HeapWord* _end;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
140
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
141 // Array for keeping offsets for retrieving object start fast given an
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
142 // address.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
143 u_char* _offset_array; // byte array keeping backwards offsets
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
144
7181
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6610
diff changeset
145 void check_offset(size_t offset, const char* msg) const {
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6610
diff changeset
146 assert(offset <= N_words,
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6610
diff changeset
147 err_msg("%s - "
17937
78bbf4d43a14 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 7181
diff changeset
148 "offset: " SIZE_FORMAT ", N_words: " UINT32_FORMAT,
7181
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6610
diff changeset
149 msg, offset, N_words));
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6610
diff changeset
150 }
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6610
diff changeset
151
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
152 // Bounds checking accessors:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
153 // For performance these have to devolve to array accesses in product builds.
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
154 inline u_char offset_array(size_t index) const;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
155
20273
9441d22e429a 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 17937
diff changeset
156 void set_offset_array(HeapWord* left, HeapWord* right, u_char offset);
9441d22e429a 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 17937
diff changeset
157
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
158 void set_offset_array_raw(size_t index, u_char offset) {
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
159 _offset_array[index] = offset;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
160 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
161
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
162 inline void set_offset_array(size_t index, u_char offset);
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
163
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
164 inline void set_offset_array(size_t index, HeapWord* high, HeapWord* low);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
165
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
166 inline void set_offset_array(size_t left, size_t right, u_char offset);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
167
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
168 inline void check_offset_array(size_t index, HeapWord* high, HeapWord* low) const;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
169
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
170 bool is_card_boundary(HeapWord* p) const;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
171
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
172 public:
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
173
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
174 // Return the number of slots needed for an offset array
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
175 // that covers mem_region_words words.
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
176 static size_t compute_size(size_t mem_region_words) {
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
177 size_t number_of_slots = (mem_region_words / N_words);
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
178 return ReservedSpace::allocation_align_size_up(number_of_slots);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
179 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
180
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
181 enum SomePublicConstants {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
182 LogN = 9,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
183 LogN_words = LogN - LogHeapWordSize,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
184 N_bytes = 1 << LogN,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
185 N_words = 1 << LogN_words
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
186 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
187
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
188 // Initialize the table to cover from "base" to (at least)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
189 // "base + init_word_size". In the future, the table may be expanded
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
190 // (see "resize" below) up to the size of "_reserved" (which must be at
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
191 // least "init_word_size".) The contents of the initial table are
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
192 // undefined; it is the responsibility of the constituent
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
193 // G1BlockOffsetTable(s) to initialize cards.
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
194 G1BlockOffsetSharedArray(MemRegion heap, G1RegionToSpaceMapper* storage);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
195
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
196 void set_bottom(HeapWord* new_bottom);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
197
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
198 // Return the appropriate index into "_offset_array" for "p".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
199 inline size_t index_for(const void* p) const;
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
200 inline size_t index_for_raw(const void* p) const;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
201
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
202 // Return the address indicating the start of the region corresponding to
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
203 // "index" in "_offset_array".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
204 inline HeapWord* address_for_index(size_t index) const;
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
205 // Variant of address_for_index that does not check the index for validity.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
206 inline HeapWord* address_for_index_raw(size_t index) const {
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
207 return _reserved.start() + (index << LogN_words);
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
208 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
209 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
210
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
211 // And here is the G1BlockOffsetTable subtype that uses the array.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
212
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
213 class G1BlockOffsetArray: public G1BlockOffsetTable {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
214 friend class G1BlockOffsetSharedArray;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
215 friend class G1BlockOffsetArrayContigSpace;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
216 friend class VMStructs;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
217 private:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
218 enum SomePrivateConstants {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
219 N_words = G1BlockOffsetSharedArray::N_words,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
220 LogN = G1BlockOffsetSharedArray::LogN
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
221 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
222
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
223 // The following enums are used by do_block_helper
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
224 enum Action {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
225 Action_single, // BOT records a single block (see single_block())
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
226 Action_mark, // BOT marks the start of a block (see mark_block())
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
227 Action_check // Check that BOT records block correctly
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
228 // (see verify_single_block()).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
229 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
230
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
231 // This is the array, which can be shared by several BlockOffsetArray's
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
232 // servicing different
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
233 G1BlockOffsetSharedArray* _array;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
234
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
235 // The space that owns this subregion.
20273
9441d22e429a 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 17937
diff changeset
236 G1OffsetTableContigSpace* _gsp;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
237
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
238 // If true, array entries are initialized to 0; otherwise, they are
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
239 // initialized to point backwards to the beginning of the covered region.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
240 bool _init_to_zero;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
241
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
242 // The portion [_unallocated_block, _sp.end()) of the space that
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
243 // is a single block known not to contain any objects.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
244 // NOTE: See BlockOffsetArrayUseUnallocatedBlock flag.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
245 HeapWord* _unallocated_block;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
246
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
247 // Sets the entries
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
248 // corresponding to the cards starting at "start" and ending at "end"
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
249 // to point back to the card before "start": the interval [start, end)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
250 // is right-open.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
251 void set_remainder_to_point_to_start(HeapWord* start, HeapWord* end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
252 // Same as above, except that the args here are a card _index_ interval
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
253 // that is closed: [start_index, end_index]
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
254 void set_remainder_to_point_to_start_incl(size_t start, size_t end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
255
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
256 // A helper function for BOT adjustment/verification work
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
257 void do_block_internal(HeapWord* blk_start, HeapWord* blk_end, Action action);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
258
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
259 protected:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
260
20273
9441d22e429a 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 17937
diff changeset
261 G1OffsetTableContigSpace* gsp() const { return _gsp; }
9441d22e429a 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 17937
diff changeset
262
9441d22e429a 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 17937
diff changeset
263 inline size_t block_size(const HeapWord* p) const;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
264
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
265 // Returns the address of a block whose start is at most "addr".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
266 // If "has_max_index" is true, "assumes "max_index" is the last valid one
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
267 // in the array.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
268 inline HeapWord* block_at_or_preceding(const void* addr,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
269 bool has_max_index,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
270 size_t max_index) const;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
271
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
272 // "q" is a block boundary that is <= "addr"; "n" is the address of the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
273 // next block (or the end of the space.) Return the address of the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
274 // beginning of the block that contains "addr". Does so without side
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
275 // effects (see, e.g., spec of block_start.)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
276 inline HeapWord*
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
277 forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
278 const void* addr) const;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
279
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
280 // "q" is a block boundary that is <= "addr"; return the address of the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
281 // beginning of the block that contains "addr". May have side effects
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
282 // on "this", by updating imprecise entries.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
283 inline HeapWord* forward_to_block_containing_addr(HeapWord* q,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
284 const void* addr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
285
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
286 // "q" is a block boundary that is <= "addr"; "n" is the address of the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
287 // next block (or the end of the space.) Return the address of the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
288 // beginning of the block that contains "addr". May have side effects
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
289 // on "this", by updating imprecise entries.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
290 HeapWord* forward_to_block_containing_addr_slow(HeapWord* q,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
291 HeapWord* n,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
292 const void* addr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
293
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
294 // Requires that "*threshold_" be the first array entry boundary at or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
295 // above "blk_start", and that "*index_" be the corresponding array
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
296 // index. If the block starts at or crosses "*threshold_", records
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
297 // "blk_start" as the appropriate block start for the array index
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
298 // starting at "*threshold_", and for any other indices crossed by the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
299 // block. Updates "*threshold_" and "*index_" to correspond to the first
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
300 // index after the block end.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
301 void alloc_block_work2(HeapWord** threshold_, size_t* index_,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
302 HeapWord* blk_start, HeapWord* blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
303
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
304 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
305 // The space may not have it's bottom and top set yet, which is why the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
306 // region is passed as a parameter. If "init_to_zero" is true, the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
307 // elements of the array are initialized to zero. Otherwise, they are
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
308 // initialized to point backwards to the beginning.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
309 G1BlockOffsetArray(G1BlockOffsetSharedArray* array, MemRegion mr,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
310 bool init_to_zero);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
311
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
312 // Note: this ought to be part of the constructor, but that would require
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
313 // "this" to be passed as a parameter to a member constructor for
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
314 // the containing concrete subtype of Space.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
315 // This would be legal C++, but MS VC++ doesn't allow it.
20273
9441d22e429a 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 17937
diff changeset
316 void set_space(G1OffsetTableContigSpace* sp);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
317
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
318 // Resets the covered region to the given "mr".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
319 void set_region(MemRegion mr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
320
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
321 // Resets the covered region to one with the same _bottom as before but
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
322 // the "new_word_size".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
323 void resize(size_t new_word_size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
324
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
325 // These must be guaranteed to work properly (i.e., do nothing)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
326 // when "blk_start" ("blk" for second version) is "NULL".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
327 virtual void alloc_block(HeapWord* blk_start, HeapWord* blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
328 virtual void alloc_block(HeapWord* blk, size_t size) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
329 alloc_block(blk, blk + size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
330 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
331
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
332 // The following methods are useful and optimized for a
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
333 // general, non-contiguous space.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
334
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
335 // Given a block [blk_start, blk_start + full_blk_size), and
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
336 // a left_blk_size < full_blk_size, adjust the BOT to show two
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
337 // blocks [blk_start, blk_start + left_blk_size) and
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
338 // [blk_start + left_blk_size, blk_start + full_blk_size).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
339 // It is assumed (and verified in the non-product VM) that the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
340 // BOT was correct for the original block.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
341 void split_block(HeapWord* blk_start, size_t full_blk_size,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
342 size_t left_blk_size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
343
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
344 // Adjust the BOT to show that it has a single block in the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
345 // range [blk_start, blk_start + size). All necessary BOT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
346 // cards are adjusted, but _unallocated_block isn't.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
347 void single_block(HeapWord* blk_start, HeapWord* blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
348 void single_block(HeapWord* blk, size_t size) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
349 single_block(blk, blk + size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
350 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
351
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
352 // Adjust BOT to show that it has a block in the range
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
353 // [blk_start, blk_start + size). Only the first card
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
354 // of BOT is touched. It is assumed (and verified in the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
355 // non-product VM) that the remaining cards of the block
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
356 // are correct.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
357 void mark_block(HeapWord* blk_start, HeapWord* blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
358 void mark_block(HeapWord* blk, size_t size) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
359 mark_block(blk, blk + size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
360 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
361
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
362 // Adjust _unallocated_block to indicate that a particular
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
363 // block has been newly allocated or freed. It is assumed (and
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
364 // verified in the non-product VM) that the BOT is correct for
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
365 // the given block.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
366 inline void allocated(HeapWord* blk_start, HeapWord* blk_end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
367 // Verify that the BOT shows [blk, blk + blk_size) to be one block.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
368 verify_single_block(blk_start, blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
369 if (BlockOffsetArrayUseUnallocatedBlock) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
370 _unallocated_block = MAX2(_unallocated_block, blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
371 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
372 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
373
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
374 inline void allocated(HeapWord* blk, size_t size) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
375 allocated(blk, blk + size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
376 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
377
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
378 inline void freed(HeapWord* blk_start, HeapWord* blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
379
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
380 inline void freed(HeapWord* blk, size_t size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
381
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
382 virtual HeapWord* block_start_unsafe(const void* addr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
383 virtual HeapWord* block_start_unsafe_const(const void* addr) const;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
384
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
385 // Requires "addr" to be the start of a card and returns the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
386 // start of the block that contains the given address.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
387 HeapWord* block_start_careful(const void* addr) const;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
388
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
389 // If true, initialize array slots with no allocated blocks to zero.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
390 // Otherwise, make them point back to the front.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
391 bool init_to_zero() { return _init_to_zero; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
392
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
393 // Verification & debugging - ensure that the offset table reflects the fact
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
394 // that the block [blk_start, blk_end) or [blk, blk + size) is a
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
395 // single block of storage. NOTE: can;t const this because of
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
396 // call to non-const do_block_internal() below.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
397 inline void verify_single_block(HeapWord* blk_start, HeapWord* blk_end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
398 if (VerifyBlockOffsetArray) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
399 do_block_internal(blk_start, blk_end, Action_check);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
400 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
401 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
402
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
403 inline void verify_single_block(HeapWord* blk, size_t size) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
404 verify_single_block(blk, blk + size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
405 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
406
2133
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
407 // Used by region verification. Checks that the contents of the
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
408 // BOT reflect that there's a single object that spans the address
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
409 // range [obj_start, obj_start + word_size); returns true if this is
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
410 // the case, returns false if it's not.
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
411 bool verify_for_object(HeapWord* obj_start, size_t word_size) const;
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
412
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
413 // Verify that the given block is before _unallocated_block
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
414 inline void verify_not_unallocated(HeapWord* blk_start,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
415 HeapWord* blk_end) const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
416 if (BlockOffsetArrayUseUnallocatedBlock) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
417 assert(blk_start < blk_end, "Block inconsistency?");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
418 assert(blk_end <= _unallocated_block, "_unallocated_block problem");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
419 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
420 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
421
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
422 inline void verify_not_unallocated(HeapWord* blk, size_t size) const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
423 verify_not_unallocated(blk, blk + size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
424 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
425
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
426 void check_all_cards(size_t left_card, size_t right_card) const;
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1552
diff changeset
427
2133
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
428 virtual void print_on(outputStream* out) PRODUCT_RETURN;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
429 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
430
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
431 // A subtype of BlockOffsetArray that takes advantage of the fact
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
432 // that its underlying space is a ContiguousSpace, so that its "active"
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
433 // region can be more efficiently tracked (than for a non-contiguous space).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
434 class G1BlockOffsetArrayContigSpace: public G1BlockOffsetArray {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
435 friend class VMStructs;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
436
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
437 // allocation boundary at which offset array must be updated
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
438 HeapWord* _next_offset_threshold;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
439 size_t _next_offset_index; // index corresponding to that boundary
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
440
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
441 // Work function to be called when allocation start crosses the next
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
442 // threshold in the contig space.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
443 void alloc_block_work1(HeapWord* blk_start, HeapWord* blk_end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
444 alloc_block_work2(&_next_offset_threshold, &_next_offset_index,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
445 blk_start, blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
446 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
447
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
448 // Variant of zero_bottom_entry that does not check for availability of the
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
449 // memory first.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
450 void zero_bottom_entry_raw();
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
451 // Variant of initialize_threshold that does not check for availability of the
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
452 // memory first.
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
453 HeapWord* initialize_threshold_raw();
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20273
diff changeset
454 // Zero out the entry for _bottom (offset will be zero).
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20273
diff changeset
455 void zero_bottom_entry();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
456 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
457 G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array, MemRegion mr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
458
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
459 // Initialize the threshold to reflect the first boundary after the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
460 // bottom of the covered region.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
461 HeapWord* initialize_threshold();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
462
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20273
diff changeset
463 void reset_bot() {
20337
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
464 zero_bottom_entry_raw();
1f1d373cd044 8038423: G1: Decommit memory within heap
tschatzl
parents: 20336
diff changeset
465 initialize_threshold_raw();
20336
6701abbc4441 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 20273
diff changeset
466 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
467
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
468 // Return the next threshold, the point at which the table should be
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
469 // updated.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
470 HeapWord* threshold() const { return _next_offset_threshold; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
471
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
472 // These must be guaranteed to work properly (i.e., do nothing)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
473 // when "blk_start" ("blk" for second version) is "NULL". In this
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
474 // implementation, that's true because NULL is represented as 0, and thus
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
475 // never exceeds the "_next_offset_threshold".
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
476 void alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
477 if (blk_end > _next_offset_threshold)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
478 alloc_block_work1(blk_start, blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
479 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
480 void alloc_block(HeapWord* blk, size_t size) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
481 alloc_block(blk, blk+size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
482 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
483
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
484 HeapWord* block_start_unsafe(const void* addr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
485 HeapWord* block_start_unsafe_const(const void* addr) const;
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1552
diff changeset
486
2133
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
487 void set_for_starts_humongous(HeapWord* new_top);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
488
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
489 virtual void print_on(outputStream* out) PRODUCT_RETURN;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
490 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
491
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
492 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP