1595 size_t expand_bytes = MAX2(word_size * HeapWordSize, MinHeapDeltaBytes);
1596 log_debug(gc, ergo, heap)("Attempt heap expansion (allocation request failed). Allocation request: " SIZE_FORMAT "B",
1597 word_size * HeapWordSize);
1598
1599
1600 if (expand(expand_bytes, _workers)) {
1601 _hrm.verify_optional();
1602 _verifier->verify_region_sets_optional();
1603 return attempt_allocation_at_safepoint(word_size,
1604 context,
1605 false /* expect_null_mutator_alloc_region */);
1606 }
1607 return NULL;
1608 }
1609
1610 bool G1CollectedHeap::expand(size_t expand_bytes, WorkGang* pretouch_workers, double* expand_time_ms) {
1611 size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
1612 aligned_expand_bytes = align_size_up(aligned_expand_bytes,
1613 HeapRegion::GrainBytes);
1614
1615 log_debug(gc, ergo, heap)("Expand the heap. requested expansion amount:" SIZE_FORMAT "B expansion amount:" SIZE_FORMAT "B",
1616 expand_bytes, aligned_expand_bytes);
1617
1618 if (is_maximal_no_gc()) {
1619 log_debug(gc, ergo, heap)("Did not expand the heap (heap already fully expanded)");
1620 return false;
1621 }
1622
1623 double expand_heap_start_time_sec = os::elapsedTime();
1624 uint regions_to_expand = (uint)(aligned_expand_bytes / HeapRegion::GrainBytes);
1625 assert(regions_to_expand > 0, "Must expand by at least one region");
1626
1627 uint expanded_by = _hrm.expand_by(regions_to_expand, pretouch_workers);
1628 if (expand_time_ms != NULL) {
1629 *expand_time_ms = (os::elapsedTime() - expand_heap_start_time_sec) * MILLIUNITS;
1630 }
1631
1632 if (expanded_by > 0) {
1633 size_t actual_expand_bytes = expanded_by * HeapRegion::GrainBytes;
1634 assert(actual_expand_bytes <= aligned_expand_bytes, "post-condition");
1635 g1_policy()->record_new_heap_size(num_regions());
|
1595 size_t expand_bytes = MAX2(word_size * HeapWordSize, MinHeapDeltaBytes);
1596 log_debug(gc, ergo, heap)("Attempt heap expansion (allocation request failed). Allocation request: " SIZE_FORMAT "B",
1597 word_size * HeapWordSize);
1598
1599
1600 if (expand(expand_bytes, _workers)) {
1601 _hrm.verify_optional();
1602 _verifier->verify_region_sets_optional();
1603 return attempt_allocation_at_safepoint(word_size,
1604 context,
1605 false /* expect_null_mutator_alloc_region */);
1606 }
1607 return NULL;
1608 }
1609
1610 bool G1CollectedHeap::expand(size_t expand_bytes, WorkGang* pretouch_workers, double* expand_time_ms) {
1611 size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes);
1612 aligned_expand_bytes = align_size_up(aligned_expand_bytes,
1613 HeapRegion::GrainBytes);
1614
1615 log_debug(gc, ergo, heap)("Expand the heap. requested expansion amount: " SIZE_FORMAT "B expansion amount: " SIZE_FORMAT "B",
1616 expand_bytes, aligned_expand_bytes);
1617
1618 if (is_maximal_no_gc()) {
1619 log_debug(gc, ergo, heap)("Did not expand the heap (heap already fully expanded)");
1620 return false;
1621 }
1622
1623 double expand_heap_start_time_sec = os::elapsedTime();
1624 uint regions_to_expand = (uint)(aligned_expand_bytes / HeapRegion::GrainBytes);
1625 assert(regions_to_expand > 0, "Must expand by at least one region");
1626
1627 uint expanded_by = _hrm.expand_by(regions_to_expand, pretouch_workers);
1628 if (expand_time_ms != NULL) {
1629 *expand_time_ms = (os::elapsedTime() - expand_heap_start_time_sec) * MILLIUNITS;
1630 }
1631
1632 if (expanded_by > 0) {
1633 size_t actual_expand_bytes = expanded_by * HeapRegion::GrainBytes;
1634 assert(actual_expand_bytes <= aligned_expand_bytes, "post-condition");
1635 g1_policy()->record_new_heap_size(num_regions());
|