Path: blob/master/runtime/gc_glue_java/CompactSchemeFixupRoots.hpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2020 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception21*******************************************************************************/2223#ifndef FIXUPROOTS_HPP_24#define FIXUPROOTS_HPP_2526#include "CollectorLanguageInterfaceImpl.hpp"27#include "CompactScheme.hpp"28#include "CompactSchemeFixupObject.hpp"29#include "EnvironmentStandard.hpp"30#include "ParallelDispatcher.hpp"31#include "RootScanner.hpp"3233class MM_CompactSchemeFixupRoots : public MM_RootScanner {34private:35MM_CompactScheme* _compactScheme;3637public:38MM_CompactSchemeFixupRoots(MM_EnvironmentBase *env, MM_CompactScheme* compactScheme) :39MM_RootScanner(env),40_compactScheme(compactScheme)41{42setIncludeStackFrameClassReferences(false);43}4445virtual void doSlot(omrobjectptr_t* slot)46{47*slot = _compactScheme->getForwardingPtr(*slot);48}4950virtual void doClass(J9Class *clazz)51{52/* We MUST NOT store the forwarded class object back into the clazz since forwarding can53* only happen once and will be taken care of by the code below. ie: the classObject slot54* is part of the GC_ClassIterator.55*/56GC_ClassIterator classIterator(_env, clazz);57while (volatile omrobjectptr_t *slot = classIterator.nextSlot()) {58/* discard volatile since we must be in stop-the-world mode */59doSlot((omrobjectptr_t*)slot);60}61}6263virtual void doClassLoader(J9ClassLoader *classLoader)64{65if (J9_GC_CLASS_LOADER_DEAD != (classLoader->gcFlags & J9_GC_CLASS_LOADER_DEAD)) {66doSlot(&classLoader->classLoaderObject);67scanModularityObjects(classLoader);68}69}7071#if defined(J9VM_GC_FINALIZATION)72virtual void scanUnfinalizedObjects(MM_EnvironmentBase *env) {73/* allow the compact scheme to handle this */74reportScanningStarted(RootScannerEntity_UnfinalizedObjects);75MM_CompactSchemeFixupObject fixupObject(env, _compactScheme);76fixupUnfinalizedObjects(env);77reportScanningEnded(RootScannerEntity_UnfinalizedObjects);78}79#endif8081#if defined(J9VM_GC_FINALIZATION)82virtual void doFinalizableObject(omrobjectptr_t object) {83Assert_MM_unreachable();84}8586virtual void scanFinalizableObjects(MM_EnvironmentBase *env) {87if (_singleThread || J9MODRON_HANDLE_NEXT_WORK_UNIT(env)) {88reportScanningStarted(RootScannerEntity_FinalizableObjects);89MM_CompactSchemeFixupObject fixupObject(env, _compactScheme);90fixupFinalizableObjects(env);91reportScanningEnded(RootScannerEntity_FinalizableObjects);92}93}94#endif /* J9VM_GC_FINALIZATION */9596virtual void scanOwnableSynchronizerObjects(MM_EnvironmentBase *env) {97/* empty, move ownable synchronizer processing in fixupObject */98}99100private:101#if defined(J9VM_GC_FINALIZATION)102void fixupFinalizableObjects(MM_EnvironmentBase *env);103void fixupUnfinalizedObjects(MM_EnvironmentBase *env);104#endif105};106#endif /* FIXUPROOTS_HPP_ */107108109