# HG changeset patch # User drwhite # Date 1447879871 18000 # Wed Nov 18 15:51:11 2015 -0500 # Node ID 12207103966186d8446a54461fd0e852019d4bbf # Parent 4da64841abd7f1ffb6217c6b23bb160d5633cdc0 [mq]: rev.01 diff --git a/src/share/vm/gc/g1/g1CollectedHeap.cpp b/src/share/vm/gc/g1/g1CollectedHeap.cpp --- a/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -1201,9 +1201,8 @@ heap_region_iterate(&cl); } -bool G1CollectedHeap::do_collection(bool explicit_gc, - bool clear_all_soft_refs, - size_t word_size) { +bool G1CollectedHeap::do_full_collection(bool explicit_gc, + bool clear_all_soft_refs) { assert_at_safepoint(true /* should_be_vm_thread */); if (GC_locker::check_active_before_gc()) { @@ -1361,8 +1360,7 @@ clear_rsets_post_compaction(); check_gc_time_stamps(); - // Resize the heap if necessary. - resize_if_necessary_after_full_collection(explicit_gc ? 0 : word_size); + resize_if_necessary_after_full_collection(); if (_hr_printer.is_active()) { // We should do this after we potentially resize the heap so @@ -1470,22 +1468,18 @@ } void G1CollectedHeap::do_full_collection(bool clear_all_soft_refs) { - // do_collection() will return whether it succeeded in performing - // the GC. Currently, there is no facility on the - // do_full_collection() API to notify the caller than the collection - // did not succeed (e.g., because it was locked out by the GC - // locker). So, right now, we'll ignore the return value. - bool dummy = do_collection(true, /* explicit_gc */ - clear_all_soft_refs, - 0 /* word_size */); -} - -// This code is mostly copied from TenuredGeneration. + // Currently, there is no facility in the do_full_collection(bool) API to notify + // the caller that the collection did not succeed (e.g., because it was locked + // out by the GC locker). So, right now, we'll ignore the return value. + bool dummy = do_full_collection(true, /* explicit_gc */ + clear_all_soft_refs); +} + +// This code is mostly copied from CardGeneration::compute_new_size. void G1CollectedHeap:: -resize_if_necessary_after_full_collection(size_t word_size) { - // Include the current allocation, if any, and bytes that will be - // pre-allocated to support collections, as "used". +resize_if_necessary_after_full_collection() { + // Include bytes that will be pre-allocated to support collections, as "used". const size_t used_after_gc = used(); const size_t capacity_after_gc = capacity(); const size_t free_after_gc = capacity_after_gc - used_after_gc; @@ -1597,9 +1591,8 @@ if (do_gc) { // Expansion didn't work, we'll try to do a Full GC. - *gc_succeeded = do_collection(false, /* explicit_gc */ - clear_all_soft_refs, - word_size); + *gc_succeeded = do_full_collection(false, /* explicit_gc */ + clear_all_soft_refs); } return NULL; diff --git a/src/share/vm/gc/g1/g1CollectedHeap.hpp b/src/share/vm/gc/g1/g1CollectedHeap.hpp --- a/src/share/vm/gc/g1/g1CollectedHeap.hpp +++ b/src/share/vm/gc/g1/g1CollectedHeap.hpp @@ -471,26 +471,20 @@ void retire_gc_alloc_region(HeapRegion* alloc_region, size_t allocated_bytes, InCSetState dest); - // - if explicit_gc is true, the GC is for a System.gc() or a heap - // inspection request and should collect the entire heap + // - if explicit_gc is true, the GC is for a System.gc() etc, + // otherwise it's for a failed allocation. // - if clear_all_soft_refs is true, all soft references should be - // cleared during the GC - // - if explicit_gc is false, word_size describes the allocation that - // the GC should attempt (at least) to satisfy + // cleared during the GC. // - it returns false if it is unable to do the collection due to the - // GC locker being active, true otherwise - bool do_collection(bool explicit_gc, - bool clear_all_soft_refs, - size_t word_size); + // GC locker being active, true otherwise. + bool do_full_collection(bool explicit_gc, + bool clear_all_soft_refs); - // Callback from VM_G1CollectFull operation. - // Perform a full collection. + // Callback from VM_G1CollectFull operation, or collect_as_vm_thread. virtual void do_full_collection(bool clear_all_soft_refs); - // Resize the heap if necessary after a full collection. If this is - // after a collect-for allocation, "word_size" is the allocation size, - // and will be considered part of the used portion of the heap. - void resize_if_necessary_after_full_collection(size_t word_size); + // Resize the heap if necessary after a full collection. + void resize_if_necessary_after_full_collection(); // Callback from VM_G1CollectForAllocation operation. // This function does everything necessary/possible to satisfy a @@ -1150,9 +1144,6 @@ // "CollectedHeap" supports. virtual void collect(GCCause::Cause cause); - // The same as above but assume that the caller holds the Heap_lock. - void collect_locked(GCCause::Cause cause); - virtual bool copy_allocation_context_stats(const jint* contexts, jlong* totals, jbyte* accuracy,