uint HeapRegionSeq::find_contiguous(uint num) { assert(num > 1, "use this only for sequences of length 2 or greater"); assert(_next_search_index <= length(), err_msg("_next_search_index: %u should be valid and <= than %u", _next_search_index, length())); uint start = _next_search_index; uint res = find_contiguous_from(start, num); if (res == G1_NULL_HRS_INDEX && start > 0) { // Try starting from the beginning. If _next_search_index was 0, // no point in doing this again. res = find_contiguous_from(0, num); } if (res != G1_NULL_HRS_INDEX) { assert(res < length(), err_msg("res: %u should be valid", res)); _next_search_index = res + num; assert(_next_search_index <= length(), err_msg("_next_search_index: %u should be valid and <= than %u", _next_search_index, length())); } return res; }
int HeapRegionSeq::find_contiguous(size_t num) { assert(num > 1, "otherwise we should not be calling this"); assert(0 <= _alloc_search_start && _alloc_search_start <= _regions.length(), err_msg("_alloc_search_start: %d should be valid and <= than %d", _alloc_search_start, _regions.length())); int start = _alloc_search_start; int res = find_contiguous_from(start, num); if (res == -1 && start != 0) { // Try starting from the beginning. If _alloc_search_start was 0, // no point in doing this again. res = find_contiguous_from(0, num); } if (res != -1) { assert(0 <= res && res < _regions.length(), err_msg("res: %d should be valid", res)); _alloc_search_start = res + (int) num; assert(0 < _alloc_search_start && _alloc_search_start <= _regions.length(), err_msg("_alloc_search_start: %d should be valid", _alloc_search_start)); } return res; }