src/share/vm/utilities/bitMap.inline.hpp

changeset 3454
2e966d967c5c
parent 2314
f95d63e2154a
child 5713
17deed6716af
equal deleted inserted replaced
3417:9d4f4a1825e4 3454:2e966d967c5c
1 /* 1 /*
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
176 if (res != (uintptr_t)NoBits) { 176 if (res != (uintptr_t)NoBits) {
177 // find the position of the 1-bit 177 // find the position of the 1-bit
178 for (; !(res & 1); res_offset++) { 178 for (; !(res & 1); res_offset++) {
179 res = res >> 1; 179 res = res >> 1;
180 } 180 }
181 assert(res_offset >= l_offset && 181
182 res_offset < r_offset, "just checking"); 182 #ifdef ASSERT
183 // In the following assert, if r_offset is not bitamp word aligned,
184 // checking that res_offset is strictly less than r_offset is too
185 // strong and will trip the assert.
186 //
187 // Consider the case where l_offset is bit 15 and r_offset is bit 17
188 // of the same map word, and where bits [15:16:17:18] == [00:00:00:01].
189 // All the bits in the range [l_offset:r_offset) are 0.
190 // The loop that calculates res_offset, above, would yield the offset
191 // of bit 18 because it's in the same map word as l_offset and there
192 // is a set bit in that map word above l_offset (i.e. res != NoBits).
193 //
194 // In this case, however, we can assert is that res_offset is strictly
195 // less than size() since we know that there is at least one set bit
196 // at an offset above, but in the same map word as, r_offset.
197 // Otherwise, if r_offset is word aligned then it will not be in the
198 // same map word as l_offset (unless it equals l_offset). So either
199 // there won't be a set bit between l_offset and the end of it's map
200 // word (i.e. res == NoBits), or res_offset will be less than r_offset.
201
202 idx_t limit = is_word_aligned(r_offset) ? r_offset : size();
203 assert(res_offset >= l_offset && res_offset < limit, "just checking");
204 #endif // ASSERT
183 return MIN2(res_offset, r_offset); 205 return MIN2(res_offset, r_offset);
184 } 206 }
185 // skip over all word length 0-bit runs 207 // skip over all word length 0-bit runs
186 for (index++; index < r_index; index++) { 208 for (index++; index < r_index; index++) {
187 res = map(index); 209 res = map(index);

mercurial