Bug Summary

File:jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp
Warning:line 360, column 5
Value stored to 'last_p' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name blockOffsetTable.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mthread-model posix -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -fno-rounding-math -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib/llvm-10/lib/clang/10.0.0 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/libjvm/objs/precompiled -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -D _GNU_SOURCE -D _REENTRANT -D LIBC=gnu -D LINUX -D VM_LITTLE_ENDIAN -D _LP64=1 -D ASSERT -D CHECK_UNHANDLED_OOPS -D TARGET_ARCH_x86 -D INCLUDE_SUFFIX_OS=_linux -D INCLUDE_SUFFIX_CPU=_x86 -D INCLUDE_SUFFIX_COMPILER=_gcc -D TARGET_COMPILER_gcc -D AMD64 -D HOTSPOT_LIB_ARCH="amd64" -D COMPILER1 -D COMPILER2 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -I /home/daniel/Projects/java/jdk/src/hotspot/share/precompiled -I /home/daniel/Projects/java/jdk/src/hotspot/share/include -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix/include -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/support/modules_include/java.base/linux -I /home/daniel/Projects/java/jdk/src/java.base/share/native/libjimage -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc/adfiles -I /home/daniel/Projects/java/jdk/src/hotspot/share -I /home/daniel/Projects/java/jdk/src/hotspot/os/linux -I /home/daniel/Projects/java/jdk/src/hotspot/os/posix -I /home/daniel/Projects/java/jdk/src/hotspot/cpu/x86 -I /home/daniel/Projects/java/jdk/src/hotspot/os_cpu/linux_x86 -I /home/daniel/Projects/java/jdk/build/linux-x86_64-server-fastdebug/hotspot/variant-server/gensrc -D _FORTIFY_SOURCE=2 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/x86_64-linux-gnu/c++/7.5.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-10/lib/clang/10.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-format-zero-length -Wno-unused-parameter -Wno-unused -Wno-parentheses -Wno-comment -Wno-unknown-pragmas -Wno-address -Wno-delete-non-virtual-dtor -Wno-char-subscripts -Wno-array-bounds -Wno-int-in-bool-context -Wno-ignored-qualifiers -Wno-missing-field-initializers -Wno-implicit-fallthrough -Wno-empty-body -Wno-strict-overflow -Wno-sequence-point -Wno-maybe-uninitialized -Wno-misleading-indentation -Wno-cast-function-type -Wno-shift-negative-value -std=c++14 -fdeprecated-macro -fdebug-compilation-dir /home/daniel/Projects/java/jdk/make/hotspot -ferror-limit 19 -fmessage-length 0 -fvisibility hidden -stack-protector 1 -fno-rtti -fgnuc-version=4.2.1 -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -o /home/daniel/Projects/java/scan/2021-12-21-193737-8510-1 -x c++ /home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp
1/*
2 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25#include "precompiled.hpp"
26#include "gc/shared/blockOffsetTable.inline.hpp"
27#include "gc/shared/collectedHeap.inline.hpp"
28#include "gc/shared/space.inline.hpp"
29#include "memory/iterator.hpp"
30#include "memory/universe.hpp"
31#include "logging/log.hpp"
32#include "oops/oop.inline.hpp"
33#include "runtime/java.hpp"
34#include "services/memTracker.hpp"
35
36uint BOTConstants::_log_card_size = 0;
37uint BOTConstants::_log_card_size_in_words = 0;
38uint BOTConstants::_card_size = 0;
39uint BOTConstants::_card_size_in_words = 0;
40
41void BOTConstants::initialize_bot_size(uint card_shift) {
42 _log_card_size = card_shift;
43 _log_card_size_in_words = _log_card_size - LogHeapWordSize;
44 _card_size = 1 << _log_card_size;
45 _card_size_in_words = 1 << _log_card_size_in_words;
46}
47
48//////////////////////////////////////////////////////////////////////
49// BlockOffsetSharedArray
50//////////////////////////////////////////////////////////////////////
51
52BlockOffsetSharedArray::BlockOffsetSharedArray(MemRegion reserved,
53 size_t init_word_size):
54 _reserved(reserved), _end(NULL__null)
55{
56 size_t size = compute_size(reserved.word_size());
57 ReservedSpace rs(size);
58 if (!rs.is_reserved()) {
59 vm_exit_during_initialization("Could not reserve enough space for heap offset array");
60 }
61
62 MemTracker::record_virtual_memory_type((address)rs.base(), mtGC);
63
64 if (!_vs.initialize(rs, 0)) {
65 vm_exit_during_initialization("Could not reserve enough space for heap offset array");
66 }
67 _offset_array = (u_char*)_vs.low_boundary();
68 resize(init_word_size);
69 log_trace(gc, bot)(!(LogImpl<(LogTag::_gc), (LogTag::_bot), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_bot), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Trace>
("BlockOffsetSharedArray::BlockOffsetSharedArray: ");
70 log_trace(gc, bot)(!(LogImpl<(LogTag::_gc), (LogTag::_bot), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_bot), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Trace>
(" rs.base(): " INTPTR_FORMAT"0x%016" "l" "x" " rs.size(): " INTPTR_FORMAT"0x%016" "l" "x" " rs end(): " INTPTR_FORMAT"0x%016" "l" "x",
71 p2i(rs.base()), rs.size(), p2i(rs.base() + rs.size()));
72 log_trace(gc, bot)(!(LogImpl<(LogTag::_gc), (LogTag::_bot), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG), (LogTag::__NO_TAG)
>::is_level(LogLevel::Trace))) ? (void)0 : LogImpl<(LogTag
::_gc), (LogTag::_bot), (LogTag::__NO_TAG), (LogTag::__NO_TAG
), (LogTag::__NO_TAG), (LogTag::__NO_TAG)>::write<LogLevel
::Trace>
(" _vs.low_boundary(): " INTPTR_FORMAT"0x%016" "l" "x" " _vs.high_boundary(): " INTPTR_FORMAT"0x%016" "l" "x",
73 p2i(_vs.low_boundary()), p2i(_vs.high_boundary()));
74}
75
76void BlockOffsetSharedArray::resize(size_t new_word_size) {
77 assert(new_word_size <= _reserved.word_size(), "Resize larger than reserved")do { if (!(new_word_size <= _reserved.word_size())) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 77, "assert(" "new_word_size <= _reserved.word_size()" ") failed"
, "Resize larger than reserved"); ::breakpoint(); } } while (
0)
;
78 size_t new_size = compute_size(new_word_size);
79 size_t old_size = _vs.committed_size();
80 size_t delta;
81 char* high = _vs.high();
82 _end = _reserved.start() + new_word_size;
83 if (new_size > old_size) {
84 delta = ReservedSpace::page_align_size_up(new_size - old_size);
85 assert(delta > 0, "just checking")do { if (!(delta > 0)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 85, "assert(" "delta > 0" ") failed", "just checking"); ::
breakpoint(); } } while (0)
;
86 if (!_vs.expand_by(delta)) {
87 // Do better than this for Merlin
88 vm_exit_out_of_memory(delta, OOM_MMAP_ERROR, "offset table expansion")do { report_vm_out_of_memory("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 88, delta, OOM_MMAP_ERROR, "offset table expansion"); ::breakpoint
(); } while (0)
;
89 }
90 assert(_vs.high() == high + delta, "invalid expansion")do { if (!(_vs.high() == high + delta)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 90, "assert(" "_vs.high() == high + delta" ") failed", "invalid expansion"
); ::breakpoint(); } } while (0)
;
91 } else {
92 delta = ReservedSpace::page_align_size_down(old_size - new_size);
93 if (delta == 0) return;
94 _vs.shrink_by(delta);
95 assert(_vs.high() == high - delta, "invalid expansion")do { if (!(_vs.high() == high - delta)) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 95, "assert(" "_vs.high() == high - delta" ") failed", "invalid expansion"
); ::breakpoint(); } } while (0)
;
96 }
97}
98
99bool BlockOffsetSharedArray::is_card_boundary(HeapWord* p) const {
100 assert(p >= _reserved.start(), "just checking")do { if (!(p >= _reserved.start())) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 100, "assert(" "p >= _reserved.start()" ") failed", "just checking"
); ::breakpoint(); } } while (0)
;
101 size_t delta = pointer_delta(p, _reserved.start());
102 return (delta & right_n_bits((int)BOTConstants::log_card_size_in_words())(((((int)BOTConstants::log_card_size_in_words()) >= BitsPerWord
) ? 0 : (OneBit << ((int)BOTConstants::log_card_size_in_words
()))) - 1)
) == (size_t)NoBits;
103}
104
105
106//////////////////////////////////////////////////////////////////////
107// BlockOffsetArray
108//////////////////////////////////////////////////////////////////////
109
110BlockOffsetArray::BlockOffsetArray(BlockOffsetSharedArray* array,
111 MemRegion mr, bool init_to_zero_) :
112 BlockOffsetTable(mr.start(), mr.end()),
113 _array(array)
114{
115 assert(_bottom <= _end, "arguments out of order")do { if (!(_bottom <= _end)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 115, "assert(" "_bottom <= _end" ") failed", "arguments out of order"
); ::breakpoint(); } } while (0)
;
116 set_init_to_zero(init_to_zero_);
117 if (!init_to_zero_) {
118 // initialize cards to point back to mr.start()
119 set_remainder_to_point_to_start(mr.start() + BOTConstants::card_size_in_words(), mr.end());
120 _array->set_offset_array(0, 0); // set first card to 0
121 }
122}
123
124
125// The arguments follow the normal convention of denoting
126// a right-open interval: [start, end)
127void
128BlockOffsetArray::
129set_remainder_to_point_to_start(HeapWord* start, HeapWord* end, bool reducing) {
130
131 check_reducing_assertion(reducing);
132 if (start >= end) {
133 // The start address is equal to the end address (or to
134 // the right of the end address) so there are not cards
135 // that need to be updated..
136 return;
137 }
138
139 // Write the backskip value for each region.
140 //
141 // offset
142 // card 2nd 3rd
143 // | +- 1st | |
144 // v v v v
145 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-
146 // |x|0|0|0|0|0|0|0|1|1|1|1|1|1| ... |1|1|1|1|2|2|2|2|2|2| ...
147 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-
148 // 11 19 75
149 // 12
150 //
151 // offset card is the card that points to the start of an object
152 // x - offset value of offset card
153 // 1st - start of first logarithmic region
154 // 0 corresponds to logarithmic value N_words + 0 and 2**(3 * 0) = 1
155 // 2nd - start of second logarithmic region
156 // 1 corresponds to logarithmic value N_words + 1 and 2**(3 * 1) = 8
157 // 3rd - start of third logarithmic region
158 // 2 corresponds to logarithmic value N_words + 2 and 2**(3 * 2) = 64
159 //
160 // integer below the block offset entry is an example of
161 // the index of the entry
162 //
163 // Given an address,
164 // Find the index for the address
165 // Find the block offset table entry
166 // Convert the entry to a back slide
167 // (e.g., with today's, offset = 0x81 =>
168 // back slip = 2**(3*(0x81 - N_words)) = 2**3) = 8
169 // Move back N (e.g., 8) entries and repeat with the
170 // value of the new entry
171 //
172 size_t start_card = _array->index_for(start);
173 size_t end_card = _array->index_for(end-1);
174 assert(start ==_array->address_for_index(start_card), "Precondition")do { if (!(start ==_array->address_for_index(start_card)))
{ (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 174, "assert(" "start ==_array->address_for_index(start_card)"
") failed", "Precondition"); ::breakpoint(); } } while (0)
;
175 assert(end ==_array->address_for_index(end_card)+BOTConstants::card_size_in_words(), "Precondition")do { if (!(end ==_array->address_for_index(end_card)+BOTConstants
::card_size_in_words())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 175, "assert(" "end ==_array->address_for_index(end_card)+BOTConstants::card_size_in_words()"
") failed", "Precondition"); ::breakpoint(); } } while (0)
;
176 set_remainder_to_point_to_start_incl(start_card, end_card, reducing); // closed interval
177}
178
179
180// Unlike the normal convention in this code, the argument here denotes
181// a closed, inclusive interval: [start_card, end_card], cf set_remainder_to_point_to_start()
182// above.
183void
184BlockOffsetArray::set_remainder_to_point_to_start_incl(size_t start_card, size_t end_card, bool reducing) {
185
186 check_reducing_assertion(reducing);
187 if (start_card > end_card) {
188 return;
189 }
190 assert(start_card > _array->index_for(_bottom), "Cannot be first card")do { if (!(start_card > _array->index_for(_bottom))) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 190, "assert(" "start_card > _array->index_for(_bottom)"
") failed", "Cannot be first card"); ::breakpoint(); } } while
(0)
;
191 assert(_array->offset_array(start_card-1) <= BOTConstants::card_size_in_words(),do { if (!(_array->offset_array(start_card-1) <= BOTConstants
::card_size_in_words())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 192, "assert(" "_array->offset_array(start_card-1) <= BOTConstants::card_size_in_words()"
") failed", "Offset card has an unexpected value"); ::breakpoint
(); } } while (0)
192 "Offset card has an unexpected value")do { if (!(_array->offset_array(start_card-1) <= BOTConstants
::card_size_in_words())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 192, "assert(" "_array->offset_array(start_card-1) <= BOTConstants::card_size_in_words()"
") failed", "Offset card has an unexpected value"); ::breakpoint
(); } } while (0)
;
193 size_t start_card_for_region = start_card;
194 u_char offset = max_jubyte;
195 for (uint i = 0; i < BOTConstants::N_powers; i++) {
196 // -1 so that the the card with the actual offset is counted. Another -1
197 // so that the reach ends in this region and not at the start
198 // of the next.
199 size_t reach = start_card - 1 + (BOTConstants::power_to_cards_back(i+1) - 1);
200 offset = BOTConstants::card_size_in_words() + i;
201 if (reach >= end_card) {
202 _array->set_offset_array(start_card_for_region, end_card, offset, reducing);
203 start_card_for_region = reach + 1;
204 break;
205 }
206 _array->set_offset_array(start_card_for_region, reach, offset, reducing);
207 start_card_for_region = reach + 1;
208 }
209 assert(start_card_for_region > end_card, "Sanity check")do { if (!(start_card_for_region > end_card)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 209, "assert(" "start_card_for_region > end_card" ") failed"
, "Sanity check"); ::breakpoint(); } } while (0)
;
210 DEBUG_ONLY(check_all_cards(start_card, end_card);)check_all_cards(start_card, end_card);
211}
212
213// The card-interval [start_card, end_card] is a closed interval; this
214// is an expensive check -- use with care and only under protection of
215// suitable flag.
216void BlockOffsetArray::check_all_cards(size_t start_card, size_t end_card) const {
217
218 if (end_card < start_card) {
219 return;
220 }
221 guarantee(_array->offset_array(start_card) == BOTConstants::card_size_in_words(), "Wrong value in second card")do { if (!(_array->offset_array(start_card) == BOTConstants
::card_size_in_words())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 221, "guarantee(" "_array->offset_array(start_card) == BOTConstants::card_size_in_words()"
") failed", "Wrong value in second card"); ::breakpoint(); }
} while (0)
;
222 u_char last_entry = BOTConstants::card_size_in_words();
223 for (size_t c = start_card + 1; c <= end_card; c++ /* yeah! */) {
224 u_char entry = _array->offset_array(c);
225 guarantee(entry >= last_entry, "Monotonicity")do { if (!(entry >= last_entry)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 225, "guarantee(" "entry >= last_entry" ") failed", "Monotonicity"
); ::breakpoint(); } } while (0)
;
226 if (c - start_card > BOTConstants::power_to_cards_back(1)) {
227 guarantee(entry > BOTConstants::card_size_in_words(), "Should be in logarithmic region")do { if (!(entry > BOTConstants::card_size_in_words())) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 227, "guarantee(" "entry > BOTConstants::card_size_in_words()"
") failed", "Should be in logarithmic region"); ::breakpoint
(); } } while (0)
;
228 }
229 size_t backskip = BOTConstants::entry_to_cards_back(entry);
230 size_t landing_card = c - backskip;
231 guarantee(landing_card >= (start_card - 1), "Inv")do { if (!(landing_card >= (start_card - 1))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 231, "guarantee(" "landing_card >= (start_card - 1)" ") failed"
, "Inv"); ::breakpoint(); } } while (0)
;
232 if (landing_card >= start_card) {
233 guarantee(_array->offset_array(landing_card) <= entry, "Monotonicity")do { if (!(_array->offset_array(landing_card) <= entry)
) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 233, "guarantee(" "_array->offset_array(landing_card) <= entry"
") failed", "Monotonicity"); ::breakpoint(); } } while (0)
;
234 } else {
235 guarantee(landing_card == (start_card - 1), "Tautology")do { if (!(landing_card == (start_card - 1))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 235, "guarantee(" "landing_card == (start_card - 1)" ") failed"
, "Tautology"); ::breakpoint(); } } while (0)
;
236 // Note that N_words is the maximum offset value
237 guarantee(_array->offset_array(landing_card) <= BOTConstants::card_size_in_words(), "Offset value")do { if (!(_array->offset_array(landing_card) <= BOTConstants
::card_size_in_words())) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 237, "guarantee(" "_array->offset_array(landing_card) <= BOTConstants::card_size_in_words()"
") failed", "Offset value"); ::breakpoint(); } } while (0)
;
238 }
239 last_entry = entry; // remember for monotonicity test
240 }
241}
242
243
244void
245BlockOffsetArray::alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
246 assert(blk_start != NULL && blk_end > blk_start,do { if (!(blk_start != __null && blk_end > blk_start
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 247, "assert(" "blk_start != __null && blk_end > blk_start"
") failed", "phantom block"); ::breakpoint(); } } while (0)
247 "phantom block")do { if (!(blk_start != __null && blk_end > blk_start
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 247, "assert(" "blk_start != __null && blk_end > blk_start"
") failed", "phantom block"); ::breakpoint(); } } while (0)
;
248 single_block(blk_start, blk_end);
249}
250
251// Action_mark - update the BOT for the block [blk_start, blk_end).
252// Current typical use is for splitting a block.
253// Action_single - udpate the BOT for an allocation.
254// Action_verify - BOT verification.
255void
256BlockOffsetArray::do_block_internal(HeapWord* blk_start,
257 HeapWord* blk_end,
258 Action action, bool reducing) {
259 assert(_sp->is_in_reserved(blk_start),do { if (!(_sp->is_in_reserved(blk_start))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 260, "assert(" "_sp->is_in_reserved(blk_start)" ") failed"
, "reference must be into the space"); ::breakpoint(); } } while
(0)
260 "reference must be into the space")do { if (!(_sp->is_in_reserved(blk_start))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 260, "assert(" "_sp->is_in_reserved(blk_start)" ") failed"
, "reference must be into the space"); ::breakpoint(); } } while
(0)
;
261 assert(_sp->is_in_reserved(blk_end-1),do { if (!(_sp->is_in_reserved(blk_end-1))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 262, "assert(" "_sp->is_in_reserved(blk_end-1)" ") failed"
, "limit must be within the space"); ::breakpoint(); } } while
(0)
262 "limit must be within the space")do { if (!(_sp->is_in_reserved(blk_end-1))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 262, "assert(" "_sp->is_in_reserved(blk_end-1)" ") failed"
, "limit must be within the space"); ::breakpoint(); } } while
(0)
;
263 // This is optimized to make the test fast, assuming we only rarely
264 // cross boundaries.
265 uintptr_t end_ui = (uintptr_t)(blk_end - 1);
266 uintptr_t start_ui = (uintptr_t)blk_start;
267 // Calculate the last card boundary preceding end of blk
268 intptr_t boundary_before_end = (intptr_t)end_ui;
269 clear_bits(boundary_before_end, right_n_bits((int)BOTConstants::log_card_size())(((((int)BOTConstants::log_card_size()) >= BitsPerWord) ? 0
: (OneBit << ((int)BOTConstants::log_card_size()))) - 1
)
);
270 if (start_ui <= (uintptr_t)boundary_before_end) {
271 // blk starts at or crosses a boundary
272 // Calculate index of card on which blk begins
273 size_t start_index = _array->index_for(blk_start);
274 // Index of card on which blk ends
275 size_t end_index = _array->index_for(blk_end - 1);
276 // Start address of card on which blk begins
277 HeapWord* boundary = _array->address_for_index(start_index);
278 assert(boundary <= blk_start, "blk should start at or after boundary")do { if (!(boundary <= blk_start)) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 278, "assert(" "boundary <= blk_start" ") failed", "blk should start at or after boundary"
); ::breakpoint(); } } while (0)
;
279 if (blk_start != boundary) {
280 // blk starts strictly after boundary
281 // adjust card boundary and start_index forward to next card
282 boundary += BOTConstants::card_size_in_words();
283 start_index++;
284 }
285 assert(start_index <= end_index, "monotonicity of index_for()")do { if (!(start_index <= end_index)) { (*g_assert_poison)
= 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 285, "assert(" "start_index <= end_index" ") failed", "monotonicity of index_for()"
); ::breakpoint(); } } while (0)
;
286 assert(boundary <= (HeapWord*)boundary_before_end, "tautology")do { if (!(boundary <= (HeapWord*)boundary_before_end)) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 286, "assert(" "boundary <= (HeapWord*)boundary_before_end"
") failed", "tautology"); ::breakpoint(); } } while (0)
;
287 switch (action) {
288 case Action_mark: {
289 if (init_to_zero()) {
290 _array->set_offset_array(start_index, boundary, blk_start, reducing);
291 break;
292 } // Else fall through to the next case
293 }
294 case Action_single: {
295 _array->set_offset_array(start_index, boundary, blk_start, reducing);
296 // We have finished marking the "offset card". We need to now
297 // mark the subsequent cards that this blk spans.
298 if (start_index < end_index) {
299 HeapWord* rem_st = _array->address_for_index(start_index) + BOTConstants::card_size_in_words();
300 HeapWord* rem_end = _array->address_for_index(end_index) + BOTConstants::card_size_in_words();
301 set_remainder_to_point_to_start(rem_st, rem_end, reducing);
302 }
303 break;
304 }
305 case Action_check: {
306 _array->check_offset_array(start_index, boundary, blk_start);
307 // We have finished checking the "offset card". We need to now
308 // check the subsequent cards that this blk spans.
309 check_all_cards(start_index + 1, end_index);
310 break;
311 }
312 default:
313 ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here(
"/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 313); ::breakpoint(); } while (0)
;
314 }
315 }
316}
317
318// The range [blk_start, blk_end) represents a single contiguous block
319// of storage; modify the block offset table to represent this
320// information; Right-open interval: [blk_start, blk_end)
321// NOTE: this method does _not_ adjust _unallocated_block.
322void
323BlockOffsetArray::single_block(HeapWord* blk_start,
324 HeapWord* blk_end) {
325 do_block_internal(blk_start, blk_end, Action_single);
326}
327
328void BlockOffsetArray::verify() const {
329 // For each entry in the block offset table, verify that
330 // the entry correctly finds the start of an object at the
331 // first address covered by the block or to the left of that
332 // first address.
333
334 size_t next_index = 1;
335 size_t last_index = last_active_index();
336
337 // Use for debugging. Initialize to NULL to distinguish the
338 // first iteration through the while loop.
339 HeapWord* last_p = NULL__null;
340 HeapWord* last_start = NULL__null;
341 oop last_o = NULL__null;
342
343 while (next_index <= last_index) {
344 // Use an address past the start of the address for
345 // the entry.
346 HeapWord* p = _array->address_for_index(next_index) + 1;
347 if (p >= _end) {
348 // That's all of the allocated block table.
349 return;
350 }
351 // block_start() asserts that start <= p.
352 HeapWord* start = block_start(p);
353 // First check if the start is an allocated block and only
354 // then if it is a valid object.
355 oop o = cast_to_oop(start);
356 assert(!Universe::is_fully_initialized() ||do { if (!(!Universe::is_fully_initialized() || _sp->is_free_block
(start) || oopDesc::is_oop_or_null(o))) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 358, "assert(" "!Universe::is_fully_initialized() || _sp->is_free_block(start) || oopDesc::is_oop_or_null(o)"
") failed", "Bad object was found"); ::breakpoint(); } } while
(0)
357 _sp->is_free_block(start) ||do { if (!(!Universe::is_fully_initialized() || _sp->is_free_block
(start) || oopDesc::is_oop_or_null(o))) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 358, "assert(" "!Universe::is_fully_initialized() || _sp->is_free_block(start) || oopDesc::is_oop_or_null(o)"
") failed", "Bad object was found"); ::breakpoint(); } } while
(0)
358 oopDesc::is_oop_or_null(o), "Bad object was found")do { if (!(!Universe::is_fully_initialized() || _sp->is_free_block
(start) || oopDesc::is_oop_or_null(o))) { (*g_assert_poison) =
'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 358, "assert(" "!Universe::is_fully_initialized() || _sp->is_free_block(start) || oopDesc::is_oop_or_null(o)"
") failed", "Bad object was found"); ::breakpoint(); } } while
(0)
;
359 next_index++;
360 last_p = p;
Value stored to 'last_p' is never read
361 last_start = start;
362 last_o = o;
363 }
364}
365
366//////////////////////////////////////////////////////////////////////
367// BlockOffsetArrayContigSpace
368//////////////////////////////////////////////////////////////////////
369
370HeapWord* BlockOffsetArrayContigSpace::block_start_unsafe(const void* addr) const {
371 assert(_array->offset_array(0) == 0, "objects can't cross covered areas")do { if (!(_array->offset_array(0) == 0)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 371, "assert(" "_array->offset_array(0) == 0" ") failed"
, "objects can't cross covered areas"); ::breakpoint(); } } while
(0)
;
372
373 // Otherwise, find the block start using the table.
374 assert(_bottom <= addr && addr < _end,do { if (!(_bottom <= addr && addr < _end)) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 375, "assert(" "_bottom <= addr && addr < _end"
") failed", "addr must be covered by this Array"); ::breakpoint
(); } } while (0)
375 "addr must be covered by this Array")do { if (!(_bottom <= addr && addr < _end)) { (
*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 375, "assert(" "_bottom <= addr && addr < _end"
") failed", "addr must be covered by this Array"); ::breakpoint
(); } } while (0)
;
376 size_t index = _array->index_for(addr);
377 // We must make sure that the offset table entry we use is valid. If
378 // "addr" is past the end, start at the last known one and go forward.
379 index = MIN2(index, _next_offset_index-1);
380 HeapWord* q = _array->address_for_index(index);
381
382 uint offset = _array->offset_array(index); // Extend u_char to uint.
383 while (offset > BOTConstants::card_size_in_words()) {
384 // The excess of the offset from N_words indicates a power of Base
385 // to go back by.
386 size_t n_cards_back = BOTConstants::entry_to_cards_back(offset);
387 q -= (BOTConstants::card_size_in_words() * n_cards_back);
388 assert(q >= _sp->bottom(), "Went below bottom!")do { if (!(q >= _sp->bottom())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 388, "assert(" "q >= _sp->bottom()" ") failed", "Went below bottom!"
); ::breakpoint(); } } while (0)
;
389 index -= n_cards_back;
390 offset = _array->offset_array(index);
391 }
392 while (offset == BOTConstants::card_size_in_words()) {
393 assert(q >= _sp->bottom(), "Went below bottom!")do { if (!(q >= _sp->bottom())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 393, "assert(" "q >= _sp->bottom()" ") failed", "Went below bottom!"
); ::breakpoint(); } } while (0)
;
394 q -= BOTConstants::card_size_in_words();
395 index--;
396 offset = _array->offset_array(index);
397 }
398 assert(offset < BOTConstants::card_size_in_words(), "offset too large")do { if (!(offset < BOTConstants::card_size_in_words())) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 398, "assert(" "offset < BOTConstants::card_size_in_words()"
") failed", "offset too large"); ::breakpoint(); } } while (
0)
;
399 q -= offset;
400 HeapWord* n = q;
401
402 while (n <= addr) {
403 debug_only(HeapWord* last = q)HeapWord* last = q; // for debugging
404 q = n;
405 n += _sp->block_size(n);
406 }
407 assert(q <= addr, "wrong order for current and arg")do { if (!(q <= addr)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 407, "assert(" "q <= addr" ") failed", "wrong order for current and arg"
); ::breakpoint(); } } while (0)
;
408 assert(addr <= n, "wrong order for arg and next")do { if (!(addr <= n)) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 408, "assert(" "addr <= n" ") failed", "wrong order for arg and next"
); ::breakpoint(); } } while (0)
;
409 return q;
410}
411
412//
413// _next_offset_threshold
414// | _next_offset_index
415// v v
416// +-------+-------+-------+-------+-------+
417// | i-1 | i | i+1 | i+2 | i+3 |
418// +-------+-------+-------+-------+-------+
419// ( ^ ]
420// block-start
421//
422
423void BlockOffsetArrayContigSpace::alloc_block_work(HeapWord* blk_start,
424 HeapWord* blk_end) {
425 assert(blk_start != NULL && blk_end > blk_start,do { if (!(blk_start != __null && blk_end > blk_start
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 426, "assert(" "blk_start != __null && blk_end > blk_start"
") failed", "phantom block"); ::breakpoint(); } } while (0)
426 "phantom block")do { if (!(blk_start != __null && blk_end > blk_start
)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 426, "assert(" "blk_start != __null && blk_end > blk_start"
") failed", "phantom block"); ::breakpoint(); } } while (0)
;
427 assert(blk_end > _next_offset_threshold,do { if (!(blk_end > _next_offset_threshold)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 428, "assert(" "blk_end > _next_offset_threshold" ") failed"
, "should be past threshold"); ::breakpoint(); } } while (0)
428 "should be past threshold")do { if (!(blk_end > _next_offset_threshold)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 428, "assert(" "blk_end > _next_offset_threshold" ") failed"
, "should be past threshold"); ::breakpoint(); } } while (0)
;
429 assert(blk_start <= _next_offset_threshold,do { if (!(blk_start <= _next_offset_threshold)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 430, "assert(" "blk_start <= _next_offset_threshold" ") failed"
, "blk_start should be at or before threshold"); ::breakpoint
(); } } while (0)
430 "blk_start should be at or before threshold")do { if (!(blk_start <= _next_offset_threshold)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 430, "assert(" "blk_start <= _next_offset_threshold" ") failed"
, "blk_start should be at or before threshold"); ::breakpoint
(); } } while (0)
;
431 assert(pointer_delta(_next_offset_threshold, blk_start) <= BOTConstants::card_size_in_words(),do { if (!(pointer_delta(_next_offset_threshold, blk_start) <=
BOTConstants::card_size_in_words())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 432, "assert(" "pointer_delta(_next_offset_threshold, blk_start) <= BOTConstants::card_size_in_words()"
") failed", "offset should be <= BlockOffsetSharedArray::N"
); ::breakpoint(); } } while (0)
432 "offset should be <= BlockOffsetSharedArray::N")do { if (!(pointer_delta(_next_offset_threshold, blk_start) <=
BOTConstants::card_size_in_words())) { (*g_assert_poison) = 'X'
;; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 432, "assert(" "pointer_delta(_next_offset_threshold, blk_start) <= BOTConstants::card_size_in_words()"
") failed", "offset should be <= BlockOffsetSharedArray::N"
); ::breakpoint(); } } while (0)
;
433 assert(_sp->is_in_reserved(blk_start),do { if (!(_sp->is_in_reserved(blk_start))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 434, "assert(" "_sp->is_in_reserved(blk_start)" ") failed"
, "reference must be into the space"); ::breakpoint(); } } while
(0)
434 "reference must be into the space")do { if (!(_sp->is_in_reserved(blk_start))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 434, "assert(" "_sp->is_in_reserved(blk_start)" ") failed"
, "reference must be into the space"); ::breakpoint(); } } while
(0)
;
435 assert(_sp->is_in_reserved(blk_end-1),do { if (!(_sp->is_in_reserved(blk_end-1))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 436, "assert(" "_sp->is_in_reserved(blk_end-1)" ") failed"
, "limit must be within the space"); ::breakpoint(); } } while
(0)
436 "limit must be within the space")do { if (!(_sp->is_in_reserved(blk_end-1))) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 436, "assert(" "_sp->is_in_reserved(blk_end-1)" ") failed"
, "limit must be within the space"); ::breakpoint(); } } while
(0)
;
437 assert(_next_offset_threshold ==do { if (!(_next_offset_threshold == _array->_reserved.start
() + _next_offset_index*BOTConstants::card_size_in_words())) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 439, "assert(" "_next_offset_threshold == _array->_reserved.start() + _next_offset_index*BOTConstants::card_size_in_words()"
") failed", "index must agree with threshold"); ::breakpoint
(); } } while (0)
438 _array->_reserved.start() + _next_offset_index*BOTConstants::card_size_in_words(),do { if (!(_next_offset_threshold == _array->_reserved.start
() + _next_offset_index*BOTConstants::card_size_in_words())) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 439, "assert(" "_next_offset_threshold == _array->_reserved.start() + _next_offset_index*BOTConstants::card_size_in_words()"
") failed", "index must agree with threshold"); ::breakpoint
(); } } while (0)
439 "index must agree with threshold")do { if (!(_next_offset_threshold == _array->_reserved.start
() + _next_offset_index*BOTConstants::card_size_in_words())) {
(*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 439, "assert(" "_next_offset_threshold == _array->_reserved.start() + _next_offset_index*BOTConstants::card_size_in_words()"
") failed", "index must agree with threshold"); ::breakpoint
(); } } while (0)
;
440
441 debug_only(size_t orig_next_offset_index = _next_offset_index;)size_t orig_next_offset_index = _next_offset_index;
442
443 // Mark the card that holds the offset into the block. Note
444 // that _next_offset_index and _next_offset_threshold are not
445 // updated until the end of this method.
446 _array->set_offset_array(_next_offset_index,
447 _next_offset_threshold,
448 blk_start);
449
450 // We need to now mark the subsequent cards that this blk spans.
451
452 // Index of card on which blk ends.
453 size_t end_index = _array->index_for(blk_end - 1);
454
455 // Are there more cards left to be updated?
456 if (_next_offset_index + 1 <= end_index) {
457 HeapWord* rem_st = _array->address_for_index(_next_offset_index + 1);
458 // Calculate rem_end this way because end_index
459 // may be the last valid index in the covered region.
460 HeapWord* rem_end = _array->address_for_index(end_index) + BOTConstants::card_size_in_words();
461 set_remainder_to_point_to_start(rem_st, rem_end);
462 }
463
464 // _next_offset_index and _next_offset_threshold updated here.
465 _next_offset_index = end_index + 1;
466 // Calculate _next_offset_threshold this way because end_index
467 // may be the last valid index in the covered region.
468 _next_offset_threshold = _array->address_for_index(end_index) + BOTConstants::card_size_in_words();
469 assert(_next_offset_threshold >= blk_end, "Incorrect offset threshold")do { if (!(_next_offset_threshold >= blk_end)) { (*g_assert_poison
) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 469, "assert(" "_next_offset_threshold >= blk_end" ") failed"
, "Incorrect offset threshold"); ::breakpoint(); } } while (0
)
;
470
471#ifdef ASSERT1
472 // The offset can be 0 if the block starts on a boundary. That
473 // is checked by an assertion above.
474 size_t start_index = _array->index_for(blk_start);
475 HeapWord* boundary = _array->address_for_index(start_index);
476 assert((_array->offset_array(orig_next_offset_index) == 0 &&do { if (!((_array->offset_array(orig_next_offset_index) ==
0 && blk_start == boundary) || (_array->offset_array
(orig_next_offset_index) > 0 && _array->offset_array
(orig_next_offset_index) <= BOTConstants::card_size_in_words
()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 480, "assert(" "(_array->offset_array(orig_next_offset_index) == 0 && blk_start == boundary) || (_array->offset_array(orig_next_offset_index) > 0 && _array->offset_array(orig_next_offset_index) <= BOTConstants::card_size_in_words())"
") failed", "offset array should have been set"); ::breakpoint
(); } } while (0)
477 blk_start == boundary) ||do { if (!((_array->offset_array(orig_next_offset_index) ==
0 && blk_start == boundary) || (_array->offset_array
(orig_next_offset_index) > 0 && _array->offset_array
(orig_next_offset_index) <= BOTConstants::card_size_in_words
()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 480, "assert(" "(_array->offset_array(orig_next_offset_index) == 0 && blk_start == boundary) || (_array->offset_array(orig_next_offset_index) > 0 && _array->offset_array(orig_next_offset_index) <= BOTConstants::card_size_in_words())"
") failed", "offset array should have been set"); ::breakpoint
(); } } while (0)
478 (_array->offset_array(orig_next_offset_index) > 0 &&do { if (!((_array->offset_array(orig_next_offset_index) ==
0 && blk_start == boundary) || (_array->offset_array
(orig_next_offset_index) > 0 && _array->offset_array
(orig_next_offset_index) <= BOTConstants::card_size_in_words
()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 480, "assert(" "(_array->offset_array(orig_next_offset_index) == 0 && blk_start == boundary) || (_array->offset_array(orig_next_offset_index) > 0 && _array->offset_array(orig_next_offset_index) <= BOTConstants::card_size_in_words())"
") failed", "offset array should have been set"); ::breakpoint
(); } } while (0)
479 _array->offset_array(orig_next_offset_index) <= BOTConstants::card_size_in_words()),do { if (!((_array->offset_array(orig_next_offset_index) ==
0 && blk_start == boundary) || (_array->offset_array
(orig_next_offset_index) > 0 && _array->offset_array
(orig_next_offset_index) <= BOTConstants::card_size_in_words
()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 480, "assert(" "(_array->offset_array(orig_next_offset_index) == 0 && blk_start == boundary) || (_array->offset_array(orig_next_offset_index) > 0 && _array->offset_array(orig_next_offset_index) <= BOTConstants::card_size_in_words())"
") failed", "offset array should have been set"); ::breakpoint
(); } } while (0)
480 "offset array should have been set")do { if (!((_array->offset_array(orig_next_offset_index) ==
0 && blk_start == boundary) || (_array->offset_array
(orig_next_offset_index) > 0 && _array->offset_array
(orig_next_offset_index) <= BOTConstants::card_size_in_words
()))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 480, "assert(" "(_array->offset_array(orig_next_offset_index) == 0 && blk_start == boundary) || (_array->offset_array(orig_next_offset_index) > 0 && _array->offset_array(orig_next_offset_index) <= BOTConstants::card_size_in_words())"
") failed", "offset array should have been set"); ::breakpoint
(); } } while (0)
;
481 for (size_t j = orig_next_offset_index + 1; j <= end_index; j++) {
482 assert(_array->offset_array(j) > 0 &&do { if (!(_array->offset_array(j) > 0 && _array
->offset_array(j) <= (u_char) (BOTConstants::card_size_in_words
()+BOTConstants::N_powers-1))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 484, "assert(" "_array->offset_array(j) > 0 && _array->offset_array(j) <= (u_char) (BOTConstants::card_size_in_words()+BOTConstants::N_powers-1)"
") failed", "offset array should have been set"); ::breakpoint
(); } } while (0)
483 _array->offset_array(j) <= (u_char) (BOTConstants::card_size_in_words()+BOTConstants::N_powers-1),do { if (!(_array->offset_array(j) > 0 && _array
->offset_array(j) <= (u_char) (BOTConstants::card_size_in_words
()+BOTConstants::N_powers-1))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 484, "assert(" "_array->offset_array(j) > 0 && _array->offset_array(j) <= (u_char) (BOTConstants::card_size_in_words()+BOTConstants::N_powers-1)"
") failed", "offset array should have been set"); ::breakpoint
(); } } while (0)
484 "offset array should have been set")do { if (!(_array->offset_array(j) > 0 && _array
->offset_array(j) <= (u_char) (BOTConstants::card_size_in_words
()+BOTConstants::N_powers-1))) { (*g_assert_poison) = 'X';; report_vm_error
("/home/daniel/Projects/java/jdk/src/hotspot/share/gc/shared/blockOffsetTable.cpp"
, 484, "assert(" "_array->offset_array(j) > 0 && _array->offset_array(j) <= (u_char) (BOTConstants::card_size_in_words()+BOTConstants::N_powers-1)"
") failed", "offset array should have been set"); ::breakpoint
(); } } while (0)
;
485 }
486#endif
487}
488
489void BlockOffsetArrayContigSpace::initialize_threshold() {
490 _next_offset_index = _array->index_for(_bottom);
491 _next_offset_index++;
492 _next_offset_threshold =
493 _array->address_for_index(_next_offset_index);
494}
495
496void BlockOffsetArrayContigSpace::zero_bottom_entry() {
497 size_t bottom_index = _array->index_for(_bottom);
498 _array->set_offset_array(bottom_index, 0);
499}
500
501size_t BlockOffsetArrayContigSpace::last_active_index() const {
502 return _next_offset_index == 0 ? 0 : _next_offset_index - 1;
503}