Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp
38922 views
/*1* Copyright (c) 2018, Red Hat, Inc. All rights reserved.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation.6*7* This code is distributed in the hope that it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License10* version 2 for more details (a copy is included in the LICENSE file that11* accompanied this code).12*13* You should have received a copy of the GNU General Public License version14* 2 along with this work; if not, write to the Free Software Foundation,15* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16*17* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA18* or visit www.oracle.com if you need additional information or have any19* questions.20*21*/2223#include "precompiled.hpp"2425#include "gc_implementation/shenandoah/heuristics/shenandoahPassiveHeuristics.hpp"26#include "gc_implementation/shenandoah/shenandoahCollectionSet.hpp"27#include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"28#include "gc_implementation/shenandoah/shenandoahHeapRegion.inline.hpp"29#include "gc_implementation/shenandoah/shenandoahLogging.hpp"3031bool ShenandoahPassiveHeuristics::should_start_gc() const {32// Never do concurrent GCs.33return false;34}3536bool ShenandoahPassiveHeuristics::should_process_references() {37// Always process references, if we can.38return can_process_references();39}4041bool ShenandoahPassiveHeuristics::should_unload_classes() {42// Always unload classes, if we can.43return can_unload_classes();44}4546bool ShenandoahPassiveHeuristics::should_degenerate_cycle() {47// Always fail to Degenerated GC, if enabled48return ShenandoahDegeneratedGC;49}5051void ShenandoahPassiveHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,52RegionData* data, size_t size,53size_t actual_free) {54assert(ShenandoahDegeneratedGC, "This path is only taken for Degenerated GC");5556// Do not select too large CSet that would overflow the available free space.57// Take at least the entire evacuation reserve, and be free to overflow to free space.58size_t max_capacity = ShenandoahHeap::heap()->max_capacity();59size_t available = MAX2(max_capacity / 100 * ShenandoahEvacReserve, actual_free);60size_t max_cset = (size_t)(available / ShenandoahEvacWaste);6162log_info(gc, ergo)("CSet Selection. Actual Free: " SIZE_FORMAT "%s, Max CSet: " SIZE_FORMAT "%s",63byte_size_in_proper_unit(actual_free), proper_unit_for_byte_size(actual_free),64byte_size_in_proper_unit(max_cset), proper_unit_for_byte_size(max_cset));6566size_t threshold = ShenandoahHeapRegion::region_size_bytes() * ShenandoahGarbageThreshold / 100;6768size_t live_cset = 0;69for (size_t idx = 0; idx < size; idx++) {70ShenandoahHeapRegion* r = data[idx]._region;71size_t new_cset = live_cset + r->get_live_data_bytes();72if (new_cset < max_cset && r->garbage() > threshold) {73live_cset = new_cset;74cset->add_region(r);75}76}77}787980