< prev index next >

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Print this page
rev 56323 : imported patch 8220310.mut.0
rev 56324 : imported patch 8220310.mut.1_thomas
rev 56326 : [mq]: 8220310.mut.1-3_kim

*** 167,182 **** return new HeapRegion(hrs_index, bot(), mr); } // Private methods. ! HeapRegion* G1CollectedHeap::new_region(size_t word_size, HeapRegionType type, bool do_expand) { assert(!is_humongous(word_size) || word_size <= HeapRegion::GrainWords, "the only time we use this to allocate a humongous region is " "when we are allocating a single humongous region"); ! HeapRegion* res = _hrm->allocate_free_region(type); if (res == NULL && do_expand && _expand_heap_after_alloc_failure) { // Currently, only attempts to allocate GC alloc regions set // do_expand to true. So, we should only reach here during a // safepoint. If this assumption changes we might have to --- 167,185 ---- return new HeapRegion(hrs_index, bot(), mr); } // Private methods. ! HeapRegion* G1CollectedHeap::new_region(size_t word_size, ! HeapRegionType type, ! bool do_expand, ! uint node_index) { assert(!is_humongous(word_size) || word_size <= HeapRegion::GrainWords, "the only time we use this to allocate a humongous region is " "when we are allocating a single humongous region"); ! HeapRegion* res = _hrm->allocate_free_region(type, node_index); if (res == NULL && do_expand && _expand_heap_after_alloc_failure) { // Currently, only attempts to allocate GC alloc regions set // do_expand to true. So, we should only reach here during a // safepoint. If this assumption changes we might have to
*** 184,199 **** assert(SafepointSynchronize::is_at_safepoint(), "invariant"); log_debug(gc, ergo, heap)("Attempt heap expansion (region allocation request failed). Allocation request: " SIZE_FORMAT "B", word_size * HeapWordSize); ! if (expand(word_size * HeapWordSize)) { // Given that expand() succeeded in expanding the heap, and we // always expand the heap by an amount aligned to the heap // region size, the free list should in theory not be empty. // In either case allocate_free_region() will check for NULL. ! res = _hrm->allocate_free_region(type); } else { _expand_heap_after_alloc_failure = false; } } return res; --- 187,202 ---- assert(SafepointSynchronize::is_at_safepoint(), "invariant"); log_debug(gc, ergo, heap)("Attempt heap expansion (region allocation request failed). Allocation request: " SIZE_FORMAT "B", word_size * HeapWordSize); ! if (expand(word_size * HeapWordSize, node_index)) { // Given that expand() succeeded in expanding the heap, and we // always expand the heap by an amount aligned to the heap // region size, the free list should in theory not be empty. // In either case allocate_free_region() will check for NULL. ! res = _hrm->allocate_free_region(type, node_index); } else { _expand_heap_after_alloc_failure = false; } } return res;
*** 360,370 **** // We found something. Make sure these regions are committed, i.e. expand // the heap. Alternatively we could do a defragmentation GC. log_debug(gc, ergo, heap)("Attempt heap expansion (humongous allocation request failed). Allocation request: " SIZE_FORMAT "B", word_size * HeapWordSize); ! _hrm->expand_at(first, obj_regions, workers()); policy()->record_new_heap_size(num_regions()); #ifdef ASSERT for (uint i = first; i < first + obj_regions; ++i) { HeapRegion* hr = region_at(i); --- 363,373 ---- // We found something. Make sure these regions are committed, i.e. expand // the heap. Alternatively we could do a defragmentation GC. log_debug(gc, ergo, heap)("Attempt heap expansion (humongous allocation request failed). Allocation request: " SIZE_FORMAT "B", word_size * HeapWordSize); ! _hrm->expand_at(first, obj_regions, G1MemoryNodeManager::AnyNodeIndex, workers()); policy()->record_new_heap_size(num_regions()); #ifdef ASSERT for (uint i = first; i < first + obj_regions; ++i) { HeapRegion* hr = region_at(i);
*** 1221,1231 **** log_debug(gc, ergo, heap)("Attempt heap expansion (capacity lower than min desired capacity). " "Capacity: " SIZE_FORMAT "B occupancy: " SIZE_FORMAT "B live: " SIZE_FORMAT "B " "min_desired_capacity: " SIZE_FORMAT "B (" UINTX_FORMAT " %%)", capacity_after_gc, used_after_gc, used(), minimum_desired_capacity, MinHeapFreeRatio); ! expand(expand_bytes, _workers); // No expansion, now see if we want to shrink } else if (capacity_after_gc > maximum_desired_capacity) { // Capacity too large, compute shrinking size size_t shrink_bytes = capacity_after_gc - maximum_desired_capacity; --- 1224,1234 ---- log_debug(gc, ergo, heap)("Attempt heap expansion (capacity lower than min desired capacity). " "Capacity: " SIZE_FORMAT "B occupancy: " SIZE_FORMAT "B live: " SIZE_FORMAT "B " "min_desired_capacity: " SIZE_FORMAT "B (" UINTX_FORMAT " %%)", capacity_after_gc, used_after_gc, used(), minimum_desired_capacity, MinHeapFreeRatio); ! expand(expand_bytes, G1MemoryNodeManager::AnyNodeIndex, _workers); // No expansion, now see if we want to shrink } else if (capacity_after_gc > maximum_desired_capacity) { // Capacity too large, compute shrinking size size_t shrink_bytes = capacity_after_gc - maximum_desired_capacity;
*** 1332,1351 **** size_t expand_bytes = MAX2(word_size * HeapWordSize, MinHeapDeltaBytes); log_debug(gc, ergo, heap)("Attempt heap expansion (allocation request failed). Allocation request: " SIZE_FORMAT "B", word_size * HeapWordSize); ! if (expand(expand_bytes, _workers)) { _hrm->verify_optional(); _verifier->verify_region_sets_optional(); return attempt_allocation_at_safepoint(word_size, false /* expect_null_mutator_alloc_region */); } return NULL; } ! bool G1CollectedHeap::expand(size_t expand_bytes, WorkGang* pretouch_workers, double* expand_time_ms) { size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes); aligned_expand_bytes = align_up(aligned_expand_bytes, HeapRegion::GrainBytes); log_debug(gc, ergo, heap)("Expand the heap. requested expansion amount: " SIZE_FORMAT "B expansion amount: " SIZE_FORMAT "B", --- 1335,1354 ---- size_t expand_bytes = MAX2(word_size * HeapWordSize, MinHeapDeltaBytes); log_debug(gc, ergo, heap)("Attempt heap expansion (allocation request failed). Allocation request: " SIZE_FORMAT "B", word_size * HeapWordSize); ! if (expand(expand_bytes, G1MemoryNodeManager::AnyNodeIndex, _workers)) { _hrm->verify_optional(); _verifier->verify_region_sets_optional(); return attempt_allocation_at_safepoint(word_size, false /* expect_null_mutator_alloc_region */); } return NULL; } ! bool G1CollectedHeap::expand(size_t expand_bytes, uint node_index, WorkGang* pretouch_workers, double* expand_time_ms) { size_t aligned_expand_bytes = ReservedSpace::page_align_size_up(expand_bytes); aligned_expand_bytes = align_up(aligned_expand_bytes, HeapRegion::GrainBytes); log_debug(gc, ergo, heap)("Expand the heap. requested expansion amount: " SIZE_FORMAT "B expansion amount: " SIZE_FORMAT "B",
*** 1358,1368 **** double expand_heap_start_time_sec = os::elapsedTime(); uint regions_to_expand = (uint)(aligned_expand_bytes / HeapRegion::GrainBytes); assert(regions_to_expand > 0, "Must expand by at least one region"); ! uint expanded_by = _hrm->expand_by(regions_to_expand, pretouch_workers); if (expand_time_ms != NULL) { *expand_time_ms = (os::elapsedTime() - expand_heap_start_time_sec) * MILLIUNITS; } if (expanded_by > 0) { --- 1361,1371 ---- double expand_heap_start_time_sec = os::elapsedTime(); uint regions_to_expand = (uint)(aligned_expand_bytes / HeapRegion::GrainBytes); assert(regions_to_expand > 0, "Must expand by at least one region"); ! uint expanded_by = _hrm->expand_by(regions_to_expand, node_index, pretouch_workers); if (expand_time_ms != NULL) { *expand_time_ms = (os::elapsedTime() - expand_heap_start_time_sec) * MILLIUNITS; } if (expanded_by > 0) {
*** 1391,1401 **** uint num_regions_to_remove = (uint)(shrink_bytes / HeapRegion::GrainBytes); uint num_regions_removed = _hrm->shrink_by(num_regions_to_remove); size_t shrunk_bytes = num_regions_removed * HeapRegion::GrainBytes; - log_debug(gc, ergo, heap)("Shrink the heap. requested shrinking amount: " SIZE_FORMAT "B aligned shrinking amount: " SIZE_FORMAT "B attempted shrinking amount: " SIZE_FORMAT "B", shrink_bytes, aligned_shrink_bytes, shrunk_bytes); if (num_regions_removed > 0) { policy()->record_new_heap_size(num_regions()); } else { --- 1394,1403 ----
*** 1493,1502 **** --- 1495,1505 ---- _old_set("Old Region Set", new OldRegionSetChecker()), _archive_set("Archive Region Set", new ArchiveRegionSetChecker()), _humongous_set("Humongous Region Set", new HumongousRegionSetChecker()), _bot(NULL), _listener(), + _mem_node_mgr(G1MemoryNodeManager::create()), _hrm(NULL), _allocator(NULL), _verifier(NULL), _summary_bytes_used(0), _archive_allocator(NULL),
*** 1776,1796 **** if (_workers == NULL) { return JNI_ENOMEM; } _workers->initialize_workers(); // Create the G1ConcurrentMark data structure and thread. // (Must do this late, so that "max_regions" is defined.) _cm = new G1ConcurrentMark(this, prev_bitmap_storage, next_bitmap_storage); if (_cm == NULL || !_cm->completed_initialization()) { vm_shutdown_during_initialization("Could not create/initialize G1ConcurrentMark"); return JNI_ENOMEM; } _cm_thread = _cm->cm_thread(); // Now expand into the initial heap size. ! if (!expand(init_byte_size, _workers)) { vm_shutdown_during_initialization("Failed to allocate initial heap."); return JNI_ENOMEM; } // Perform any initialization actions delegated to the policy. --- 1779,1801 ---- if (_workers == NULL) { return JNI_ENOMEM; } _workers->initialize_workers(); + _mem_node_mgr->set_page_size(page_size); + // Create the G1ConcurrentMark data structure and thread. // (Must do this late, so that "max_regions" is defined.) _cm = new G1ConcurrentMark(this, prev_bitmap_storage, next_bitmap_storage); if (_cm == NULL || !_cm->completed_initialization()) { vm_shutdown_during_initialization("Could not create/initialize G1ConcurrentMark"); return JNI_ENOMEM; } _cm_thread = _cm->cm_thread(); // Now expand into the initial heap size. ! if (!expand(init_byte_size, G1MemoryNodeManager::AnyNodeIndex, _workers)) { vm_shutdown_during_initialization("Failed to allocate initial heap."); return JNI_ENOMEM; } // Perform any initialization actions delegated to the policy.
*** 2884,2894 **** size_t expand_bytes = _heap_sizing_policy->expansion_amount(); if (expand_bytes > 0) { // No need for an ergo logging here, // expansion_amount() does this when it returns a value > 0. double expand_ms; ! if (!expand(expand_bytes, _workers, &expand_ms)) { // We failed to expand the heap. Cannot do anything about it. } phase_times()->record_expand_heap_time(expand_ms); } } --- 2889,2899 ---- size_t expand_bytes = _heap_sizing_policy->expansion_amount(); if (expand_bytes > 0) { // No need for an ergo logging here, // expansion_amount() does this when it returns a value > 0. double expand_ms; ! if (!expand(expand_bytes, G1MemoryNodeManager::AnyNodeIndex, _workers, &expand_ms)) { // We failed to expand the heap. Cannot do anything about it. } phase_times()->record_expand_heap_time(expand_ms); } }
*** 4545,4561 **** } // Methods for the mutator alloc region HeapRegion* G1CollectedHeap::new_mutator_alloc_region(size_t word_size, ! bool force) { assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); bool should_allocate = policy()->should_allocate_mutator_region(); if (force || should_allocate) { HeapRegion* new_alloc_region = new_region(word_size, HeapRegionType::Eden, ! false /* do_expand */); if (new_alloc_region != NULL) { set_region_short_lived_locked(new_alloc_region); _hr_printer.alloc(new_alloc_region, !should_allocate); _verifier->check_bitmaps("Mutator Region Allocation", new_alloc_region); _policy->remset_tracker()->update_at_allocate(new_alloc_region); --- 4550,4568 ---- } // Methods for the mutator alloc region HeapRegion* G1CollectedHeap::new_mutator_alloc_region(size_t word_size, ! bool force, ! uint node_index) { assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); bool should_allocate = policy()->should_allocate_mutator_region(); if (force || should_allocate) { HeapRegion* new_alloc_region = new_region(word_size, HeapRegionType::Eden, ! false /* do_expand */, ! node_index); if (new_alloc_region != NULL) { set_region_short_lived_locked(new_alloc_region); _hr_printer.alloc(new_alloc_region, !should_allocate); _verifier->check_bitmaps("Mutator Region Allocation", new_alloc_region); _policy->remset_tracker()->update_at_allocate(new_alloc_region);
< prev index next >