annotate src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp @ 17467:55fb97c4c58d hs25-b65

8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013 Summary: Copyright year updated for files modified during 2013 Reviewed-by: twisti, iveresov
author mikael
date Tue, 24 Dec 2013 11:48:39 -0800
parents 746b070f5022
children 63a4eb8bcd23 78bbf4d43a14
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 /*
17467
55fb97c4c58d 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 10161
diff changeset
2 * Copyright (c) 2001, 2013, 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: 1489
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1489
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: 1489
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 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
26 #include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
27 #include "memory/space.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
28 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1886
diff changeset
29 #include "runtime/java.hpp"
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2133
diff changeset
30 #include "services/memTracker.hpp"
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
31
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
32 //////////////////////////////////////////////////////////////////////
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
33 // G1BlockOffsetSharedArray
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
34 //////////////////////////////////////////////////////////////////////
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
35
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
36 G1BlockOffsetSharedArray::G1BlockOffsetSharedArray(MemRegion reserved,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
37 size_t init_word_size) :
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
38 _reserved(reserved), _end(NULL)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
39 {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
40 size_t size = compute_size(reserved.word_size());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
41 ReservedSpace rs(ReservedSpace::allocation_align_size_up(size));
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
42 if (!rs.is_reserved()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
43 vm_exit_during_initialization("Could not reserve enough space for heap offset array");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
44 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
45 if (!_vs.initialize(rs, 0)) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
46 vm_exit_during_initialization("Could not reserve enough space for heap offset array");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
47 }
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2133
diff changeset
48
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2133
diff changeset
49 MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 2133
diff changeset
50
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
51 _offset_array = (u_char*)_vs.low_boundary();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
52 resize(init_word_size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
53 if (TraceBlockOffsetTable) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
54 gclog_or_tty->print_cr("G1BlockOffsetSharedArray::G1BlockOffsetSharedArray: ");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
55 gclog_or_tty->print_cr(" "
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
56 " rs.base(): " INTPTR_FORMAT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
57 " rs.size(): " INTPTR_FORMAT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
58 " rs end(): " INTPTR_FORMAT,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
59 rs.base(), rs.size(), rs.base() + rs.size());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
60 gclog_or_tty->print_cr(" "
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
61 " _vs.low_boundary(): " INTPTR_FORMAT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
62 " _vs.high_boundary(): " INTPTR_FORMAT,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
63 _vs.low_boundary(),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
64 _vs.high_boundary());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
65 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
66 }
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 void G1BlockOffsetSharedArray::resize(size_t new_word_size) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
69 assert(new_word_size <= _reserved.word_size(), "Resize larger than reserved");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
70 size_t new_size = compute_size(new_word_size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
71 size_t old_size = _vs.committed_size();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
72 size_t delta;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
73 char* high = _vs.high();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
74 _end = _reserved.start() + new_word_size;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
75 if (new_size > old_size) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
76 delta = ReservedSpace::page_align_size_up(new_size - old_size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
77 assert(delta > 0, "just checking");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
78 if (!_vs.expand_by(delta)) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
79 // Do better than this for Merlin
10161
746b070f5022 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 7181
diff changeset
80 vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion");
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
81 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
82 assert(_vs.high() == high + delta, "invalid expansion");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
83 // Initialization of the contents is left to the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
84 // G1BlockOffsetArray that uses it.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
85 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
86 delta = ReservedSpace::page_align_size_down(old_size - new_size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
87 if (delta == 0) return;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
88 _vs.shrink_by(delta);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
89 assert(_vs.high() == high - delta, "invalid expansion");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
90 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
91 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
92
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
93 bool G1BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
94 assert(p >= _reserved.start(), "just checking");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
95 size_t delta = pointer_delta(p, _reserved.start());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
96 return (delta & right_n_bits(LogN_words)) == (size_t)NoBits;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
97 }
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
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
100 //////////////////////////////////////////////////////////////////////
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
101 // G1BlockOffsetArray
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
102 //////////////////////////////////////////////////////////////////////
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
103
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
104 G1BlockOffsetArray::G1BlockOffsetArray(G1BlockOffsetSharedArray* array,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
105 MemRegion mr, bool init_to_zero) :
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
106 G1BlockOffsetTable(mr.start(), mr.end()),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
107 _unallocated_block(_bottom),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
108 _array(array), _csp(NULL),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
109 _init_to_zero(init_to_zero) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
110 assert(_bottom <= _end, "arguments out of order");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
111 if (!_init_to_zero) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
112 // initialize cards to point back to mr.start()
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
113 set_remainder_to_point_to_start(mr.start() + N_words, mr.end());
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
114 _array->set_offset_array(0, 0); // set first card to 0
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
115 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
116 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
117
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
118 void G1BlockOffsetArray::set_space(Space* sp) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
119 _sp = sp;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
120 _csp = sp->toContiguousSpace();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
121 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
122
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
123 // The arguments follow the normal convention of denoting
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
124 // a right-open interval: [start, end)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
125 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
126 G1BlockOffsetArray:: set_remainder_to_point_to_start(HeapWord* start, HeapWord* end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
127
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
128 if (start >= end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
129 // The start address is equal to the end address (or to
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
130 // the right of the end address) so there are not cards
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
131 // that need to be updated..
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
132 return;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
133 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
134
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
135 // Write the backskip value for each region.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
136 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
137 // offset
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
138 // card 2nd 3rd
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
139 // | +- 1st | |
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
140 // v v v v
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
141 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
142 // |x|0|0|0|0|0|0|0|1|1|1|1|1|1| ... |1|1|1|1|2|2|2|2|2|2| ...
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
143 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
144 // 11 19 75
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
145 // 12
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
146 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
147 // offset card is the card that points to the start of an object
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
148 // x - offset value of offset card
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
149 // 1st - start of first logarithmic region
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
150 // 0 corresponds to logarithmic value N_words + 0 and 2**(3 * 0) = 1
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
151 // 2nd - start of second logarithmic region
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
152 // 1 corresponds to logarithmic value N_words + 1 and 2**(3 * 1) = 8
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
153 // 3rd - start of third logarithmic region
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
154 // 2 corresponds to logarithmic value N_words + 2 and 2**(3 * 2) = 64
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
155 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
156 // integer below the block offset entry is an example of
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
157 // the index of the entry
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
158 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
159 // Given an address,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
160 // Find the index for the address
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
161 // Find the block offset table entry
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
162 // Convert the entry to a back slide
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
163 // (e.g., with today's, offset = 0x81 =>
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
164 // back slip = 2**(3*(0x81 - N_words)) = 2**3) = 8
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
165 // Move back N (e.g., 8) entries and repeat with the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
166 // value of the new entry
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
167 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
168 size_t start_card = _array->index_for(start);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
169 size_t end_card = _array->index_for(end-1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
170 assert(start ==_array->address_for_index(start_card), "Precondition");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
171 assert(end ==_array->address_for_index(end_card)+N_words, "Precondition");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
172 set_remainder_to_point_to_start_incl(start_card, end_card); // closed interval
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
173 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
174
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
175 // Unlike the normal convention in this code, the argument here denotes
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
176 // a closed, inclusive interval: [start_card, end_card], cf set_remainder_to_point_to_start()
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
177 // above.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
178 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
179 G1BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
180 if (start_card > end_card) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
181 return;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
182 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
183 assert(start_card > _array->index_for(_bottom), "Cannot be first card");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
184 assert(_array->offset_array(start_card-1) <= N_words,
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1552
diff changeset
185 "Offset card has an unexpected value");
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
186 size_t start_card_for_region = start_card;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
187 u_char offset = max_jubyte;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
188 for (int i = 0; i < BlockOffsetArray::N_powers; i++) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
189 // -1 so that the the card with the actual offset is counted. Another -1
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
190 // so that the reach ends in this region and not at the start
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
191 // of the next.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
192 size_t reach = start_card - 1 + (BlockOffsetArray::power_to_cards_back(i+1) - 1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
193 offset = N_words + i;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
194 if (reach >= end_card) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
195 _array->set_offset_array(start_card_for_region, end_card, offset);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
196 start_card_for_region = reach + 1;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
197 break;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
198 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
199 _array->set_offset_array(start_card_for_region, reach, offset);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
200 start_card_for_region = reach + 1;
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 assert(start_card_for_region > end_card, "Sanity check");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
203 DEBUG_ONLY(check_all_cards(start_card, end_card);)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
204 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
205
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
206 // The block [blk_start, blk_end) has been allocated;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
207 // adjust the block offset table to represent this information;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
208 // right-open interval: [blk_start, blk_end)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
209 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
210 G1BlockOffsetArray::alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
211 mark_block(blk_start, blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
212 allocated(blk_start, blk_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
213 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
214
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
215 // Adjust BOT to show that a previously whole block has been split
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
216 // into two.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
217 void G1BlockOffsetArray::split_block(HeapWord* blk, size_t blk_size,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
218 size_t left_blk_size) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
219 // 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
220 verify_single_block(blk, blk_size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
221 // Update the BOT to indicate that [blk + left_blk_size, blk + blk_size)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
222 // is one single block.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
223 mark_block(blk + left_blk_size, blk + blk_size);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
224 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
225
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
226
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
227 // Action_mark - update the BOT for the block [blk_start, blk_end).
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
228 // Current typical use is for splitting a block.
2133
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
229 // Action_single - update the BOT for an allocation.
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
230 // Action_verify - BOT verification.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
231 void G1BlockOffsetArray::do_block_internal(HeapWord* blk_start,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
232 HeapWord* blk_end,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
233 Action action) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
234 assert(Universe::heap()->is_in_reserved(blk_start),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
235 "reference must be into the heap");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
236 assert(Universe::heap()->is_in_reserved(blk_end-1),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
237 "limit must be within the heap");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
238 // This is optimized to make the test fast, assuming we only rarely
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
239 // cross boundaries.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
240 uintptr_t end_ui = (uintptr_t)(blk_end - 1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
241 uintptr_t start_ui = (uintptr_t)blk_start;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
242 // Calculate the last card boundary preceding end of blk
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
243 intptr_t boundary_before_end = (intptr_t)end_ui;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
244 clear_bits(boundary_before_end, right_n_bits(LogN));
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
245 if (start_ui <= (uintptr_t)boundary_before_end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
246 // blk starts at or crosses a boundary
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
247 // Calculate index of card on which blk begins
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
248 size_t start_index = _array->index_for(blk_start);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
249 // Index of card on which blk ends
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
250 size_t end_index = _array->index_for(blk_end - 1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
251 // Start address of card on which blk begins
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
252 HeapWord* boundary = _array->address_for_index(start_index);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
253 assert(boundary <= blk_start, "blk should start at or after boundary");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
254 if (blk_start != boundary) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
255 // blk starts strictly after boundary
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
256 // adjust card boundary and start_index forward to next card
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
257 boundary += N_words;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
258 start_index++;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
259 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
260 assert(start_index <= end_index, "monotonicity of index_for()");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
261 assert(boundary <= (HeapWord*)boundary_before_end, "tautology");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
262 switch (action) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
263 case Action_mark: {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
264 if (init_to_zero()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
265 _array->set_offset_array(start_index, boundary, blk_start);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
266 break;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
267 } // Else fall through to the next case
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
268 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
269 case Action_single: {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
270 _array->set_offset_array(start_index, boundary, blk_start);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
271 // We have finished marking the "offset card". We need to now
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
272 // mark the subsequent cards that this blk spans.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
273 if (start_index < end_index) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
274 HeapWord* rem_st = _array->address_for_index(start_index) + N_words;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
275 HeapWord* rem_end = _array->address_for_index(end_index) + N_words;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
276 set_remainder_to_point_to_start(rem_st, rem_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
277 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
278 break;
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 case Action_check: {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
281 _array->check_offset_array(start_index, boundary, blk_start);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
282 // We have finished checking the "offset card". We need to now
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
283 // check the subsequent cards that this blk spans.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
284 check_all_cards(start_index + 1, end_index);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
285 break;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
286 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
287 default:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
288 ShouldNotReachHere();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
289 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
290 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
291 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
292
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
293 // The card-interval [start_card, end_card] is a closed interval; this
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
294 // is an expensive check -- use with care and only under protection of
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
295 // suitable flag.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
296 void G1BlockOffsetArray::check_all_cards(size_t start_card, size_t end_card) const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
297
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
298 if (end_card < start_card) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
299 return;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
300 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
301 guarantee(_array->offset_array(start_card) == N_words, "Wrong value in second card");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
302 for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
303 u_char entry = _array->offset_array(c);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
304 if (c - start_card > BlockOffsetArray::power_to_cards_back(1)) {
7181
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
305 guarantee(entry > N_words,
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
306 err_msg("Should be in logarithmic region - "
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
307 "entry: " UINT32_FORMAT ", "
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
308 "_array->offset_array(c): " UINT32_FORMAT ", "
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
309 "N_words: " UINT32_FORMAT,
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
310 entry, _array->offset_array(c), N_words));
342
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 size_t backskip = BlockOffsetArray::entry_to_cards_back(entry);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
313 size_t landing_card = c - backskip;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
314 guarantee(landing_card >= (start_card - 1), "Inv");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
315 if (landing_card >= start_card) {
7181
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
316 guarantee(_array->offset_array(landing_card) <= entry,
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
317 err_msg("Monotonicity - landing_card offset: " UINT32_FORMAT ", "
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
318 "entry: " UINT32_FORMAT,
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
319 _array->offset_array(landing_card), entry));
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
320 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
321 guarantee(landing_card == start_card - 1, "Tautology");
7181
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
322 // Note that N_words is the maximum offset value
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
323 guarantee(_array->offset_array(landing_card) <= N_words,
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
324 err_msg("landing card offset: " UINT32_FORMAT ", "
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
325 "N_words: " UINT32_FORMAT,
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
326 _array->offset_array(landing_card), N_words));
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
327 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
328 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
329 }
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 // The range [blk_start, blk_end) represents a single contiguous block
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
332 // of storage; modify the block offset table to represent this
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
333 // information; Right-open interval: [blk_start, blk_end)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
334 // NOTE: this method does _not_ adjust _unallocated_block.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
335 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
336 G1BlockOffsetArray::single_block(HeapWord* blk_start, HeapWord* blk_end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
337 do_block_internal(blk_start, blk_end, Action_single);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
338 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
339
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
340 // Mark the BOT such that if [blk_start, blk_end) straddles a card
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
341 // boundary, the card following the first such boundary is marked
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
342 // with the appropriate offset.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
343 // NOTE: this method does _not_ adjust _unallocated_block or
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
344 // any cards subsequent to the first one.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
345 void
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
346 G1BlockOffsetArray::mark_block(HeapWord* blk_start, HeapWord* blk_end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
347 do_block_internal(blk_start, blk_end, Action_mark);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
348 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
349
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
350 HeapWord* G1BlockOffsetArray::block_start_unsafe(const void* addr) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
351 assert(_bottom <= addr && addr < _end,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
352 "addr must be covered by this Array");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
353 // Must read this exactly once because it can be modified by parallel
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
354 // allocation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
355 HeapWord* ub = _unallocated_block;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
356 if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
357 assert(ub < _end, "tautology (see above)");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
358 return ub;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
359 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
360 // Otherwise, find the block start using the table.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
361 HeapWord* q = block_at_or_preceding(addr, false, 0);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
362 return forward_to_block_containing_addr(q, addr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
363 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
364
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
365 // This duplicates a little code from the above: unavoidable.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
366 HeapWord*
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
367 G1BlockOffsetArray::block_start_unsafe_const(const void* addr) const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
368 assert(_bottom <= addr && addr < _end,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
369 "addr must be covered by this Array");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
370 // Must read this exactly once because it can be modified by parallel
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
371 // allocation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
372 HeapWord* ub = _unallocated_block;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
373 if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
374 assert(ub < _end, "tautology (see above)");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
375 return ub;
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 // Otherwise, find the block start using the table.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
378 HeapWord* q = block_at_or_preceding(addr, false, 0);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
379 HeapWord* n = q + _sp->block_size(q);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
380 return forward_to_block_containing_addr_const(q, n, addr);
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
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
383
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
384 HeapWord*
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
385 G1BlockOffsetArray::forward_to_block_containing_addr_slow(HeapWord* q,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
386 HeapWord* n,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
387 const void* addr) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
388 // We're not in the normal case. We need to handle an important subcase
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
389 // here: LAB allocation. An allocation previously recorded in the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
390 // offset table was actually a lab allocation, and was divided into
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
391 // several objects subsequently. Fix this situation as we answer the
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
392 // query, by updating entries as we cross them.
352
e0c09f7ec5c4 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 342
diff changeset
393
e0c09f7ec5c4 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 342
diff changeset
394 // If the fist object's end q is at the card boundary. Start refining
e0c09f7ec5c4 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 342
diff changeset
395 // with the corresponding card (the value of the entry will be basically
e0c09f7ec5c4 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 342
diff changeset
396 // set to 0). If the object crosses the boundary -- start from the next card.
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
397 size_t n_index = _array->index_for(n);
352
e0c09f7ec5c4 6702387: G1: assertion failure: assert(p == current_top || oop(p)->is_oop(),"p is not a block start")
iveresov
parents: 342
diff changeset
398 size_t next_index = _array->index_for(n) + !_array->is_card_boundary(n);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
399 // Calculate a consistent next boundary. If "n" is not at the boundary
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
400 // already, step to the boundary.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
401 HeapWord* next_boundary = _array->address_for_index(n_index) +
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
402 (n_index == next_index ? 0 : N_words);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
403 assert(next_boundary <= _array->_end,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
404 err_msg("next_boundary is beyond the end of the covered region "
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
405 " next_boundary " PTR_FORMAT " _array->_end " PTR_FORMAT,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
406 next_boundary, _array->_end));
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
407 if (csp() != NULL) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
408 if (addr >= csp()->top()) return csp()->top();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
409 while (next_boundary < addr) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
410 while (n <= next_boundary) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
411 q = n;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
412 oop obj = oop(q);
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 470
diff changeset
413 if (obj->klass_or_null() == NULL) return q;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
414 n += obj->size();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
415 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
416 assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
417 // [q, n) is the block that crosses the boundary.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
418 alloc_block_work2(&next_boundary, &next_index, q, n);
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 } else {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
421 while (next_boundary < addr) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
422 while (n <= next_boundary) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
423 q = n;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
424 oop obj = oop(q);
845
df6caf649ff7 6700789: G1: Enable use of compressed oops with G1 heaps
ysr
parents: 470
diff changeset
425 if (obj->klass_or_null() == NULL) return q;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
426 n += _sp->block_size(q);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
427 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
428 assert(q <= next_boundary && n > next_boundary, "Consequence of loop");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
429 // [q, n) is the block that crosses the boundary.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
430 alloc_block_work2(&next_boundary, &next_index, q, n);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
431 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
432 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
433 return forward_to_block_containing_addr_const(q, n, addr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
434 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
435
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
436 HeapWord* G1BlockOffsetArray::block_start_careful(const void* addr) const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
437 assert(_array->offset_array(0) == 0, "objects can't cross covered areas");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
438
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
439 assert(_bottom <= addr && addr < _end,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
440 "addr must be covered by this Array");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
441 // Must read this exactly once because it can be modified by parallel
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
442 // allocation.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
443 HeapWord* ub = _unallocated_block;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
444 if (BlockOffsetArrayUseUnallocatedBlock && addr >= ub) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
445 assert(ub < _end, "tautology (see above)");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
446 return ub;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
447 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
448
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
449 // Otherwise, find the block start using the table, but taking
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
450 // care (cf block_start_unsafe() above) not to parse any objects/blocks
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
451 // on the cards themsleves.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
452 size_t index = _array->index_for(addr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
453 assert(_array->address_for_index(index) == addr,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
454 "arg should be start of card");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
455
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
456 HeapWord* q = (HeapWord*)addr;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
457 uint offset;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
458 do {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
459 offset = _array->offset_array(index--);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
460 q -= offset;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
461 } while (offset == N_words);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
462 assert(q <= addr, "block start should be to left of arg");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
463 return q;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
464 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
465
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
466 // 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
467 // so the table size might also wish to change.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
468 void G1BlockOffsetArray::resize(size_t new_word_size) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
469 HeapWord* new_end = _bottom + new_word_size;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
470 if (_end < new_end && !init_to_zero()) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
471 // verify that the old and new boundaries are also card boundaries
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
472 assert(_array->is_card_boundary(_end),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
473 "_end not a card boundary");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
474 assert(_array->is_card_boundary(new_end),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
475 "new _end would not be a card boundary");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
476 // set all the newly added cards
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
477 _array->set_offset_array(_end, new_end, N_words);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
478 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
479 _end = new_end; // update _end
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
480 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
481
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
482 void G1BlockOffsetArray::set_region(MemRegion mr) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
483 _bottom = mr.start();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
484 _end = mr.end();
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
485 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
486
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
487 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
488 // threshold_
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
489 // | _index_
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
490 // v v
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
491 // +-------+-------+-------+-------+-------+
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
492 // | i-1 | i | i+1 | i+2 | i+3 |
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
493 // +-------+-------+-------+-------+-------+
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
494 // ( ^ ]
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
495 // block-start
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
496 //
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
497 void G1BlockOffsetArray::alloc_block_work2(HeapWord** threshold_, size_t* index_,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
498 HeapWord* blk_start, HeapWord* blk_end) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
499 // For efficiency, do copy-in/copy-out.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
500 HeapWord* threshold = *threshold_;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
501 size_t index = *index_;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
502
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
503 assert(blk_start != NULL && blk_end > blk_start,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
504 "phantom block");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
505 assert(blk_end > threshold, "should be past threshold");
1489
cff162798819 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 845
diff changeset
506 assert(blk_start <= threshold, "blk_start should be at or before threshold");
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
507 assert(pointer_delta(threshold, blk_start) <= N_words,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
508 "offset should be <= BlockOffsetSharedArray::N");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
509 assert(Universe::heap()->is_in_reserved(blk_start),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
510 "reference must be into the heap");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
511 assert(Universe::heap()->is_in_reserved(blk_end-1),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
512 "limit must be within the heap");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
513 assert(threshold == _array->_reserved.start() + index*N_words,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
514 "index must agree with threshold");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
515
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
516 DEBUG_ONLY(size_t orig_index = index;)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
517
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
518 // Mark the card that holds the offset into the block. Note
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
519 // that _next_offset_index and _next_offset_threshold are not
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
520 // updated until the end of this method.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
521 _array->set_offset_array(index, threshold, blk_start);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
522
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
523 // We need to now mark the subsequent cards that this blk spans.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
524
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
525 // Index of card on which blk ends.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
526 size_t end_index = _array->index_for(blk_end - 1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
527
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
528 // Are there more cards left to be updated?
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
529 if (index + 1 <= end_index) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
530 HeapWord* rem_st = _array->address_for_index(index + 1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
531 // Calculate rem_end this way because end_index
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
532 // may be the last valid index in the covered region.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
533 HeapWord* rem_end = _array->address_for_index(end_index) + N_words;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
534 set_remainder_to_point_to_start(rem_st, rem_end);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
535 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
536
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
537 index = end_index + 1;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
538 // Calculate threshold_ this way because end_index
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
539 // may be the last valid index in the covered region.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
540 threshold = _array->address_for_index(end_index) + N_words;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
541 assert(threshold >= blk_end, "Incorrect offset threshold");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
542
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
543 // index_ and threshold_ updated here.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
544 *threshold_ = threshold;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
545 *index_ = index;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
546
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
547 #ifdef ASSERT
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
548 // The offset can be 0 if the block starts on a boundary. That
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
549 // is checked by an assertion above.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
550 size_t start_index = _array->index_for(blk_start);
7181
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
551 HeapWord* boundary = _array->address_for_index(start_index);
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
552 assert((_array->offset_array(orig_index) == 0 &&
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
553 blk_start == boundary) ||
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
554 (_array->offset_array(orig_index) > 0 &&
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
555 _array->offset_array(orig_index) <= N_words),
7181
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
556 err_msg("offset array should have been set - "
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
557 "orig_index offset: " UINT32_FORMAT ", "
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
558 "blk_start: " PTR_FORMAT ", "
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
559 "boundary: " PTR_FORMAT,
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
560 _array->offset_array(orig_index),
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
561 blk_start, boundary));
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
562 for (size_t j = orig_index + 1; j <= end_index; j++) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
563 assert(_array->offset_array(j) > 0 &&
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
564 _array->offset_array(j) <=
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
565 (u_char) (N_words+BlockOffsetArray::N_powers-1),
7181
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
566 err_msg("offset array should have been set - "
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
567 UINT32_FORMAT " not > 0 OR "
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
568 UINT32_FORMAT " not <= " UINT32_FORMAT,
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
569 _array->offset_array(j),
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
570 _array->offset_array(j),
2fc0334f613a 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 6725
diff changeset
571 (u_char) (N_words+BlockOffsetArray::N_powers-1)));
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
572 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
573 #endif
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
574 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
575
2133
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
576 bool
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
577 G1BlockOffsetArray::verify_for_object(HeapWord* obj_start,
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
578 size_t word_size) const {
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
579 size_t first_card = _array->index_for(obj_start);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
580 size_t last_card = _array->index_for(obj_start + word_size - 1);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
581 if (!_array->is_card_boundary(obj_start)) {
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
582 // If the object is not on a card boundary the BOT entry of the
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
583 // first card should point to another object so we should not
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
584 // check that one.
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
585 first_card += 1;
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
586 }
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
587 for (size_t card = first_card; card <= last_card; card += 1) {
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
588 HeapWord* card_addr = _array->address_for_index(card);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
589 HeapWord* block_start = block_start_const(card_addr);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
590 if (block_start != obj_start) {
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
591 gclog_or_tty->print_cr("block start: "PTR_FORMAT" is incorrect - "
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
592 "card index: "SIZE_FORMAT" "
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
593 "card addr: "PTR_FORMAT" BOT entry: %u "
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
594 "obj: "PTR_FORMAT" word size: "SIZE_FORMAT" "
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
595 "cards: ["SIZE_FORMAT","SIZE_FORMAT"]",
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
596 block_start, card, card_addr,
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
597 _array->offset_array(card),
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
598 obj_start, word_size, first_card, last_card);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
599 return false;
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
600 }
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
601 }
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
602 return true;
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
603 }
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1552
diff changeset
604
2133
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
605 #ifndef PRODUCT
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
606 void
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
607 G1BlockOffsetArray::print_on(outputStream* out) {
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
608 size_t from_index = _array->index_for(_bottom);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
609 size_t to_index = _array->index_for(_end);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
610 out->print_cr(">> BOT for area ["PTR_FORMAT","PTR_FORMAT") "
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
611 "cards ["SIZE_FORMAT","SIZE_FORMAT")",
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
612 _bottom, _end, from_index, to_index);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
613 for (size_t i = from_index; i < to_index; ++i) {
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
614 out->print_cr(" entry "SIZE_FORMAT_W(8)" | "PTR_FORMAT" : %3u",
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
615 i, _array->address_for_index(i),
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
616 (uint) _array->offset_array(i));
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
617 }
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1552
diff changeset
618 }
2133
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
619 #endif // !PRODUCT
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1552
diff changeset
620
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
621 //////////////////////////////////////////////////////////////////////
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
622 // G1BlockOffsetArrayContigSpace
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
623 //////////////////////////////////////////////////////////////////////
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
624
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
625 HeapWord*
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
626 G1BlockOffsetArrayContigSpace::block_start_unsafe(const void* addr) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
627 assert(_bottom <= addr && addr < _end,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
628 "addr must be covered by this Array");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
629 HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
630 return forward_to_block_containing_addr(q, addr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
631 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
632
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
633 HeapWord*
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
634 G1BlockOffsetArrayContigSpace::
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
635 block_start_unsafe_const(const void* addr) const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
636 assert(_bottom <= addr && addr < _end,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
637 "addr must be covered by this Array");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
638 HeapWord* q = block_at_or_preceding(addr, true, _next_offset_index-1);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
639 HeapWord* n = q + _sp->block_size(q);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
640 return forward_to_block_containing_addr_const(q, n, addr);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
641 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
642
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
643 G1BlockOffsetArrayContigSpace::
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
644 G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
645 MemRegion mr) :
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
646 G1BlockOffsetArray(array, mr, true)
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
647 {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
648 _next_offset_threshold = NULL;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
649 _next_offset_index = 0;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
650 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
651
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
652 HeapWord* G1BlockOffsetArrayContigSpace::initialize_threshold() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
653 assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
654 "just checking");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
655 _next_offset_index = _array->index_for(_bottom);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
656 _next_offset_index++;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
657 _next_offset_threshold =
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
658 _array->address_for_index(_next_offset_index);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
659 return _next_offset_threshold;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
660 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
661
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
662 void G1BlockOffsetArrayContigSpace::zero_bottom_entry() {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
663 assert(!Universe::heap()->is_in_reserved(_array->_offset_array),
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
664 "just checking");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
665 size_t bottom_index = _array->index_for(_bottom);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
666 assert(_array->address_for_index(bottom_index) == _bottom,
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
667 "Precondition of call");
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
668 _array->set_offset_array(bottom_index, 0);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
669 }
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1552
diff changeset
670
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1552
diff changeset
671 void
2133
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
672 G1BlockOffsetArrayContigSpace::set_for_starts_humongous(HeapWord* new_top) {
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
673 assert(new_top <= _end, "_end should have already been updated");
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
674
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
675 // The first BOT entry should have offset 0.
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
676 zero_bottom_entry();
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
677 initialize_threshold();
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
678 alloc_block(_bottom, new_top);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
679 }
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1552
diff changeset
680
2133
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
681 #ifndef PRODUCT
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
682 void
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
683 G1BlockOffsetArrayContigSpace::print_on(outputStream* out) {
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
684 G1BlockOffsetArray::print_on(out);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
685 out->print_cr(" next offset threshold: "PTR_FORMAT, _next_offset_threshold);
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
686 out->print_cr(" next offset index: "SIZE_FORMAT, _next_offset_index);
1886
72a161e62cc4 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 1552
diff changeset
687 }
2133
2250ee17e258 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 1972
diff changeset
688 #endif // !PRODUCT