During review of JDK-8137099 we found some code in G1CollectedHeap::attempt_allocation_slow() that could be cleaned up a little:
[...]
0 if (GCLocker::is_active_and_needs_gc() && g1_policy()->can_expand_young_list()) {
1 // No need for an ergo message here, can_expand_young_list() does this when it returns true
2 result = _allocator_attempt_allocation_force(word_size, context);
3 if (result != NULL) {
4 return result;
5 }
6 }
The issues are:
- The comment in line 1 is wrong, there is no ergo message anywhere.
- the result of attempt_allocation_force() must always be non-NULL as a successful can_expand_list() always indicates that another region can be allocated.
Clean this up.