Path: blob/master/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAggressiveHeuristics.cpp
40975 views
/*1* Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"2526#include "gc/shenandoah/heuristics/shenandoahAggressiveHeuristics.hpp"27#include "gc/shenandoah/shenandoahCollectionSet.hpp"28#include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"29#include "logging/log.hpp"30#include "logging/logTag.hpp"31#include "runtime/os.hpp"3233ShenandoahAggressiveHeuristics::ShenandoahAggressiveHeuristics() : ShenandoahHeuristics() {34// Do not shortcut evacuation35SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahImmediateThreshold, 100);3637// Aggressive evacuates everything, so it needs as much evac space as it can get38SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahEvacReserveOverflow);3940// If class unloading is globally enabled, aggressive does unloading even with41// concurrent cycles.42if (ClassUnloading) {43SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahUnloadClassesFrequency, 1);44}45}4647void ShenandoahAggressiveHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,48RegionData* data, size_t size,49size_t free) {50for (size_t idx = 0; idx < size; idx++) {51ShenandoahHeapRegion* r = data[idx]._region;52if (r->garbage() > 0) {53cset->add_region(r);54}55}56}5758bool ShenandoahAggressiveHeuristics::should_start_gc() {59log_info(gc)("Trigger: Start next cycle immediately");60return true;61}6263bool ShenandoahAggressiveHeuristics::should_unload_classes() {64if (!can_unload_classes_normal()) return false;65if (has_metaspace_oom()) return true;66// Randomly unload classes with 50% chance.67return (os::random() & 1) == 1;68}697071