564 ShouldNotReachHere(); |
564 ShouldNotReachHere(); |
565 return NULL; |
565 return NULL; |
566 } |
566 } |
567 |
567 |
568 void G1CollectedHeap::begin_archive_alloc_range(bool open) { |
568 void G1CollectedHeap::begin_archive_alloc_range(bool open) { |
569 assert_at_safepoint(true /* should_be_vm_thread */); |
569 assert_at_safepoint_on_vm_thread(); |
570 if (_archive_allocator == NULL) { |
570 if (_archive_allocator == NULL) { |
571 _archive_allocator = G1ArchiveAllocator::create_allocator(this, open); |
571 _archive_allocator = G1ArchiveAllocator::create_allocator(this, open); |
572 } |
572 } |
573 } |
573 } |
574 |
574 |
578 // may be different at archive-restore time. |
578 // may be different at archive-restore time. |
579 return word_size >= humongous_threshold_for(HeapRegion::min_region_size_in_words()); |
579 return word_size >= humongous_threshold_for(HeapRegion::min_region_size_in_words()); |
580 } |
580 } |
581 |
581 |
582 HeapWord* G1CollectedHeap::archive_mem_allocate(size_t word_size) { |
582 HeapWord* G1CollectedHeap::archive_mem_allocate(size_t word_size) { |
583 assert_at_safepoint(true /* should_be_vm_thread */); |
583 assert_at_safepoint_on_vm_thread(); |
584 assert(_archive_allocator != NULL, "_archive_allocator not initialized"); |
584 assert(_archive_allocator != NULL, "_archive_allocator not initialized"); |
585 if (is_archive_alloc_too_large(word_size)) { |
585 if (is_archive_alloc_too_large(word_size)) { |
586 return NULL; |
586 return NULL; |
587 } |
587 } |
588 return _archive_allocator->archive_mem_allocate(word_size); |
588 return _archive_allocator->archive_mem_allocate(word_size); |
589 } |
589 } |
590 |
590 |
591 void G1CollectedHeap::end_archive_alloc_range(GrowableArray<MemRegion>* ranges, |
591 void G1CollectedHeap::end_archive_alloc_range(GrowableArray<MemRegion>* ranges, |
592 size_t end_alignment_in_bytes) { |
592 size_t end_alignment_in_bytes) { |
593 assert_at_safepoint(true /* should_be_vm_thread */); |
593 assert_at_safepoint_on_vm_thread(); |
594 assert(_archive_allocator != NULL, "_archive_allocator not initialized"); |
594 assert(_archive_allocator != NULL, "_archive_allocator not initialized"); |
595 |
595 |
596 // Call complete_archive to do the real work, filling in the MemRegion |
596 // Call complete_archive to do the real work, filling in the MemRegion |
597 // array with the archive regions. |
597 // array with the archive regions. |
598 _archive_allocator->complete_archive(ranges, end_alignment_in_bytes); |
598 _archive_allocator->complete_archive(ranges, end_alignment_in_bytes); |
981 return NULL; |
981 return NULL; |
982 } |
982 } |
983 |
983 |
984 HeapWord* G1CollectedHeap::attempt_allocation_at_safepoint(size_t word_size, |
984 HeapWord* G1CollectedHeap::attempt_allocation_at_safepoint(size_t word_size, |
985 bool expect_null_mutator_alloc_region) { |
985 bool expect_null_mutator_alloc_region) { |
986 assert_at_safepoint(true /* should_be_vm_thread */); |
986 assert_at_safepoint_on_vm_thread(); |
987 assert(!_allocator->has_mutator_alloc_region() || !expect_null_mutator_alloc_region, |
987 assert(!_allocator->has_mutator_alloc_region() || !expect_null_mutator_alloc_region, |
988 "the current alloc region was unexpectedly found to be non-NULL"); |
988 "the current alloc region was unexpectedly found to be non-NULL"); |
989 |
989 |
990 if (!is_humongous(word_size)) { |
990 if (!is_humongous(word_size)) { |
991 return _allocator->attempt_allocation_locked(word_size); |
991 return _allocator->attempt_allocation_locked(word_size); |
1152 #endif |
1152 #endif |
1153 } |
1153 } |
1154 |
1154 |
1155 bool G1CollectedHeap::do_full_collection(bool explicit_gc, |
1155 bool G1CollectedHeap::do_full_collection(bool explicit_gc, |
1156 bool clear_all_soft_refs) { |
1156 bool clear_all_soft_refs) { |
1157 assert_at_safepoint(true /* should_be_vm_thread */); |
1157 assert_at_safepoint_on_vm_thread(); |
1158 |
1158 |
1159 if (GCLocker::check_active_before_gc()) { |
1159 if (GCLocker::check_active_before_gc()) { |
1160 // Full GC was not completed. |
1160 // Full GC was not completed. |
1161 return false; |
1161 return false; |
1162 } |
1162 } |
1293 return NULL; |
1293 return NULL; |
1294 } |
1294 } |
1295 |
1295 |
1296 HeapWord* G1CollectedHeap::satisfy_failed_allocation(size_t word_size, |
1296 HeapWord* G1CollectedHeap::satisfy_failed_allocation(size_t word_size, |
1297 bool* succeeded) { |
1297 bool* succeeded) { |
1298 assert_at_safepoint(true /* should_be_vm_thread */); |
1298 assert_at_safepoint_on_vm_thread(); |
1299 |
1299 |
1300 // Attempts to allocate followed by Full GC. |
1300 // Attempts to allocate followed by Full GC. |
1301 HeapWord* result = |
1301 HeapWord* result = |
1302 satisfy_failed_allocation_helper(word_size, |
1302 satisfy_failed_allocation_helper(word_size, |
1303 true, /* do_gc */ |
1303 true, /* do_gc */ |
1345 // to support an allocation of the given "word_size". If |
1345 // to support an allocation of the given "word_size". If |
1346 // successful, perform the allocation and return the address of the |
1346 // successful, perform the allocation and return the address of the |
1347 // allocated block, or else "NULL". |
1347 // allocated block, or else "NULL". |
1348 |
1348 |
1349 HeapWord* G1CollectedHeap::expand_and_allocate(size_t word_size) { |
1349 HeapWord* G1CollectedHeap::expand_and_allocate(size_t word_size) { |
1350 assert_at_safepoint(true /* should_be_vm_thread */); |
1350 assert_at_safepoint_on_vm_thread(); |
1351 |
1351 |
1352 _verifier->verify_region_sets_optional(); |
1352 _verifier->verify_region_sets_optional(); |
1353 |
1353 |
1354 size_t expand_bytes = MAX2(word_size * HeapWordSize, MinHeapDeltaBytes); |
1354 size_t expand_bytes = MAX2(word_size * HeapWordSize, MinHeapDeltaBytes); |
1355 log_debug(gc, ergo, heap)("Attempt heap expansion (allocation request failed). Allocation request: " SIZE_FORMAT "B", |
1355 log_debug(gc, ergo, heap)("Attempt heap expansion (allocation request failed). Allocation request: " SIZE_FORMAT "B", |
2815 g1_policy()->transfer_survivors_to_cset(survivor()); |
2815 g1_policy()->transfer_survivors_to_cset(survivor()); |
2816 } |
2816 } |
2817 |
2817 |
2818 bool |
2818 bool |
2819 G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { |
2819 G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { |
2820 assert_at_safepoint(true /* should_be_vm_thread */); |
2820 assert_at_safepoint_on_vm_thread(); |
2821 guarantee(!is_gc_active(), "collection is not reentrant"); |
2821 guarantee(!is_gc_active(), "collection is not reentrant"); |
2822 |
2822 |
2823 if (GCLocker::check_active_before_gc()) { |
2823 if (GCLocker::check_active_before_gc()) { |
2824 return false; |
2824 return false; |
2825 } |
2825 } |
4845 return _freed_bytes; |
4845 return _freed_bytes; |
4846 } |
4846 } |
4847 }; |
4847 }; |
4848 |
4848 |
4849 void G1CollectedHeap::eagerly_reclaim_humongous_regions() { |
4849 void G1CollectedHeap::eagerly_reclaim_humongous_regions() { |
4850 assert_at_safepoint(true); |
4850 assert_at_safepoint_on_vm_thread(); |
4851 |
4851 |
4852 if (!G1EagerReclaimHumongousObjects || |
4852 if (!G1EagerReclaimHumongousObjects || |
4853 (!_has_humongous_reclaim_candidates && !log_is_enabled(Debug, gc, humongous))) { |
4853 (!_has_humongous_reclaim_candidates && !log_is_enabled(Debug, gc, humongous))) { |
4854 g1_policy()->phase_times()->record_fast_reclaim_humongous_time_ms(0.0, 0); |
4854 g1_policy()->phase_times()->record_fast_reclaim_humongous_time_ms(0.0, 0); |
4855 return; |
4855 return; |
5001 assert(_old_set->is_empty(), "post-condition"); |
5001 assert(_old_set->is_empty(), "post-condition"); |
5002 } |
5002 } |
5003 }; |
5003 }; |
5004 |
5004 |
5005 void G1CollectedHeap::tear_down_region_sets(bool free_list_only) { |
5005 void G1CollectedHeap::tear_down_region_sets(bool free_list_only) { |
5006 assert_at_safepoint(true /* should_be_vm_thread */); |
5006 assert_at_safepoint_on_vm_thread(); |
5007 |
5007 |
5008 if (!free_list_only) { |
5008 if (!free_list_only) { |
5009 TearDownRegionSetsClosure cl(&_old_set); |
5009 TearDownRegionSetsClosure cl(&_old_set); |
5010 heap_region_iterate(&cl); |
5010 heap_region_iterate(&cl); |
5011 |
5011 |