/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc_implementation/g1/heapRegion.hpp"
#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
#include "gc_implementation/g1/heapRegionSets.hpp"
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
#include "memory/allocation.hpp"
// Private
if (first == G1_NULL_HRS_INDEX) {
num_so_far = 1;
} else {
num_so_far += 1;
}
} else {
num_so_far = 0;
}
curr += 1;
}
if (num_so_far == num) {
// we found enough space for the humongous object
}
return first;
} else {
// we failed to find enough space for the humongous object
return G1_NULL_HRS_INDEX;
}
}
// Public
uint max_length) {
"bottom should be heap region aligned");
"end should be heap region aligned");
_length = 0;
_next_search_index = 0;
_allocated_length = 0;
"bottom should be included in the region with index 0");
}
FreeRegionList* list) {
while (next_bottom < new_end) {
if (index == 0) {
// We have not allocated any regions so far
} else {
}
if (index == _allocated_length) {
// We have to allocate a new HeapRegion.
// allocation failed, we bail out and return what we have done so far
}
}
// Have to increment the length first, otherwise we will get an
// assert failure at(index) below.
}
}
while (index > 0) {
index -= 1;
break;
}
res += 1;
}
return res;
}
err_msg("_next_search_index: %u should be valid and <= than %u",
_next_search_index, length()));
// Try starting from the beginning. If _next_search_index was 0,
// no point in doing this again.
}
if (res != G1_NULL_HRS_INDEX) {
err_msg("_next_search_index: %u should be valid and <= than %u",
_next_search_index, length()));
}
return res;
}
}
}
if (res) {
blk->incomplete();
return;
}
}
if (res) {
blk->incomplete();
return;
}
}
}
// Reset this in case it's currently pointing into the regions that
// we just removed.
_next_search_index = 0;
// around the loop, i will be the next region to be removed
assert(i > 0, "we should never remove all regions");
// [last_start, end) is the MemRegion that covers the regions we will remove.
*num_regions_deleted = 0;
while (shrink_bytes > 0) {
// We should leave the humongous regions where they are.
if (cur->isHumongous()) break;
// We should stop shrinking if we come across a non-empty region.
i -= 1;
*num_regions_deleted += 1;
// We will reclaim the HeapRegion. _allocated_length should be
// covering this index. So, even though we removed the region from
// the active set by decreasing _length, we still have it
// available in the future if we need to re-use it.
assert(i > 0, "we should never remove all regions");
}
}
#ifndef PRODUCT
err_msg("invariant: _length: %u _allocated_length: %u",
err_msg("invariant: _allocated_length: %u _max_length: %u",
err_msg("invariant: _next_search_index: %u _length: %u",
if (i < _length) {
// Asserts will fire if i is >= _length
} else {
// using assert instead of guarantee here since containing_set()
// is only available in non-product builds.
}
if (hr->startsHumongous()) {
} else {
}
}
}
}
#endif // PRODUCT