/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc_implementation/g1/collectionSetChooser.hpp"
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
#include "gc_implementation/g1/g1CollectorPolicy.hpp"
#include "gc_implementation/g1/g1ErgoVerbose.hpp"
#include "memory/space.inline.hpp"
// Even though we don't use the GC efficiency in our heuristics as
// much as we used to, we still order according to GC efficiency. This
// will cause regions with a lot of live objects and large RSets to
// end up at the end of the array. Given that we might skip collecting
// the last few old regions, if after a few mixed GCs the remaining
// have reclaimable bytes under a certain threshold, the hope is that
// the ones we'll skip are ones with both large RSets and a lot of
// live objects, not the ones with just a lot of live objects if we
// ordered according to the amount of reclaimable bytes per region.
return 0;
} else {
return 1;
}
return -1;
}
return -1;
return 1;
} else {
return 0;
}
}
}
// The line below is the worst bit of C++ hackery I've ever written
// (Detlefs, 11/23). You should think of it as equivalent to
// "_regions(100, true)": initialize the growable array and inform it
// that it should allocate its elem array(s) on the C heap.
//
// The first argument, however, is actually a comma expression
// (set_allocation_type(this, C_HEAP), 100). The purpose of the
// set_allocation_type() call is to replace the default allocation
// type for embedded objects STACK_OR_EMBEDDED with C_HEAP. It will
// allow to pass the assert in GenericGrowableArray() which checks
// that a growable array object must be on C heap if elements are.
//
// Note: containing object is allocated on C heap since it is CHeapObj.
//
100), true /* C_Heap */),
}
#ifndef PRODUCT
while (index < _curr_index) {
"all entries before _curr_index should be NULL");
index += 1;
}
err_msg("GC eff prev: %1.4f GC eff curr: %1.4f",
}
}
err_msg("reclaimable bytes inconsistent, "
}
#endif // !PRODUCT
// First trim any unused portion of the top in the parallel case.
if (_first_par_unreserved_idx > 0) {
"Or we didn't reserved enough length");
}
#ifdef ASSERT
}
#endif // ASSERT
if (G1PrintRegionLivenessInfo) {
HeapRegion* r = regions_at(i);
cl.doHeapRegion(r);
}
}
verify();
}
"Humongous regions shouldn't be added to the collection set");
_length++;
hr->calc_gc_efficiency();
}
uint chunk_size) {
if (UseDynamicNumberOfGCThreads) {
"Should have been set earlier");
// This is defensive code. As the assertion above says, the number
// of active threads should be > 0, but in case there is some path
// or some improperly initialized variable with leads to no
// active threads, protect against that in a product build.
1U);
}
// it should be aligned with respect to chunk_size
}
(volatile jint*) &_first_par_unreserved_idx);
"Should already have been expanded");
return res - chunk_size;
}
hr->calc_gc_efficiency();
}
// Only take the lock if we actually need to update the totals.
if (region_num > 0) {
// We could have just used atomics instead of taking the
// lock. However, we currently don't have an atomic add for size_t.
_length += region_num;
} else {
}
}
_curr_index = 0;
_length = 0;
};