Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp
40957 views
/*1* Copyright (c) 2021, 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 "compiler/oopMap.hpp"27#include "gc/shared/workgroup.hpp"28#include "gc/shenandoah/shenandoahClosures.inline.hpp"29#include "gc/shenandoah/shenandoahGC.hpp"30#include "gc/shenandoah/shenandoahHeap.hpp"31#include "gc/shenandoah/shenandoahPhaseTimings.hpp"32#include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"33#include "gc/shenandoah/shenandoahUtils.hpp"3435const char* ShenandoahGC::degen_point_to_string(ShenandoahDegenPoint point) {36switch(point) {37case _degenerated_unset:38return "<UNSET>";39case _degenerated_outside_cycle:40return "Outside of Cycle";41case _degenerated_mark:42return "Mark";43case _degenerated_evac:44return "Evacuation";45case _degenerated_updaterefs:46return "Update References";47default:48ShouldNotReachHere();49return "ERROR";50}51}5253class ShenandoahUpdateRootsTask : public AbstractGangTask {54private:55ShenandoahRootUpdater* _root_updater;56bool _check_alive;57public:58ShenandoahUpdateRootsTask(ShenandoahRootUpdater* root_updater, bool check_alive) :59AbstractGangTask("Shenandoah Update Roots"),60_root_updater(root_updater),61_check_alive(check_alive){62}6364void work(uint worker_id) {65assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");66ShenandoahParallelWorkerSession worker_session(worker_id);6768ShenandoahHeap* heap = ShenandoahHeap::heap();69ShenandoahUpdateRefsClosure cl;70if (_check_alive) {71ShenandoahForwardedIsAliveClosure is_alive;72_root_updater->roots_do<ShenandoahForwardedIsAliveClosure, ShenandoahUpdateRefsClosure>(worker_id, &is_alive, &cl);73} else {74AlwaysTrueClosure always_true;;75_root_updater->roots_do<AlwaysTrueClosure, ShenandoahUpdateRefsClosure>(worker_id, &always_true, &cl);76}77}78};7980void ShenandoahGC::update_roots(bool full_gc) {81assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Must be at a safepoint");82assert(ShenandoahHeap::heap()->is_full_gc_in_progress() ||83ShenandoahHeap::heap()->is_degenerated_gc_in_progress(),84"Only for degenerated GC and full GC");8586bool check_alive = !full_gc;87ShenandoahPhaseTimings::Phase p = full_gc ?88ShenandoahPhaseTimings::full_gc_update_roots :89ShenandoahPhaseTimings::degen_gc_update_roots;9091ShenandoahGCPhase phase(p);92#if COMPILER2_OR_JVMCI93DerivedPointerTable::clear();94#endif9596ShenandoahHeap* const heap = ShenandoahHeap::heap();97WorkGang* workers = heap->workers();98uint nworkers = workers->active_workers();99100ShenandoahRootUpdater root_updater(nworkers, p);101ShenandoahUpdateRootsTask update_roots(&root_updater, check_alive);102workers->run_task(&update_roots);103104#if COMPILER2_OR_JVMCI105DerivedPointerTable::update_pointers();106#endif107}108109110