src/share/vm/memory/collectorPolicy.cpp
Print this page
rev 4327 : [mq]: JDK-8008677
@@ -537,11 +537,11 @@
// First allocation attempt is lock-free.
Generation *gen0 = gch->get_gen(0);
assert(gen0->supports_inline_contig_alloc(),
"Otherwise, must do alloc within heap lock");
- if (gen0->should_allocate(size, is_tlab)) {
+ if (gen0 != NULL && gen0->should_allocate(size, is_tlab)) {
result = gen0->par_allocate(size, is_tlab);
if (result != NULL) {
assert(gch->is_in_reserved(result), "result not in heap");
return result;
}
@@ -647,11 +647,11 @@
bool is_tlab) {
GenCollectedHeap *gch = GenCollectedHeap::heap();
HeapWord* result = NULL;
for (int i = number_of_generations() - 1; i >= 0 && result == NULL; i--) {
Generation *gen = gch->get_gen(i);
- if (gen->should_allocate(size, is_tlab)) {
+ if (gen != NULL && gen->should_allocate(size, is_tlab)) {
result = gen->expand_and_allocate(size, is_tlab);
}
}
assert(result == NULL || gch->is_in_reserved(result), "result not in heap");
return result;
@@ -819,11 +819,14 @@
// was a full collection because a partial collection (would
// have) failed and is likely to fail again
bool GenCollectorPolicy::should_try_older_generation_allocation(
size_t word_size) const {
GenCollectedHeap* gch = GenCollectedHeap::heap();
- size_t gen0_capacity = gch->get_gen(0)->capacity_before_gc();
+ Generation* gen = gch->get_gen(0);
+ guarantee(gen != NULL, "need generation");
+
+ size_t gen0_capacity = gen->capacity_before_gc();
return (word_size > heap_word_size(gen0_capacity))
|| GC_locker::is_active_and_needs_gc()
|| gch->incremental_collection_failed();
}