Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shenandoah/heuristics/shenandoahStaticHeuristics.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/shenandoahStaticHeuristics.hpp"26#include "gc_implementation/shenandoah/shenandoahCollectionSet.hpp"27#include "gc_implementation/shenandoah/shenandoahFreeSet.hpp"28#include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp"29#include "gc_implementation/shenandoah/shenandoahHeapRegion.inline.hpp"30#include "gc_implementation/shenandoah/shenandoahLogging.hpp"3132ShenandoahStaticHeuristics::ShenandoahStaticHeuristics() : ShenandoahHeuristics() {33SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent);34SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);35}3637ShenandoahStaticHeuristics::~ShenandoahStaticHeuristics() {}3839bool ShenandoahStaticHeuristics::should_start_gc() const {40ShenandoahHeap* heap = ShenandoahHeap::heap();4142size_t max_capacity = heap->max_capacity();43size_t capacity = heap->soft_max_capacity();44size_t available = heap->free_set()->available();4546// Make sure the code below treats available without the soft tail.47size_t soft_tail = max_capacity - capacity;48available = (available > soft_tail) ? (available - soft_tail) : 0;4950size_t threshold_available = capacity / 100 * ShenandoahMinFreeThreshold;5152if (available < threshold_available) {53log_info(gc)("Trigger: Free (" SIZE_FORMAT "%s) is below minimum threshold (" SIZE_FORMAT "%s)",54byte_size_in_proper_unit(available), proper_unit_for_byte_size(available),55byte_size_in_proper_unit(threshold_available), proper_unit_for_byte_size(threshold_available));56return true;57}58return ShenandoahHeuristics::should_start_gc();59}6061void ShenandoahStaticHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,62RegionData* data, size_t size,63size_t free) {64size_t threshold = ShenandoahHeapRegion::region_size_bytes() * ShenandoahGarbageThreshold / 100;6566for (size_t idx = 0; idx < size; idx++) {67ShenandoahHeapRegion* r = data[idx]._region;68if (r->garbage() > threshold) {69cset->add_region(r);70}71}72}737475