Path: blob/master/runtime/gc_realtime/RealtimeMarkingScheme.hpp
5986 views
/*******************************************************************************1* Copyright (c) 1991, 2019 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122#if !defined(REALTIMEMARKINGSCHEME_HPP_)23#define REALTIMEMARKINGSCHEME_HPP_2425#include "omr.h"2627#include "Base.hpp"28#include "EnvironmentRealtime.hpp"29#include "GCExtensionsBase.hpp"30#include "MarkMap.hpp"3132#include "SegregatedMarkingScheme.hpp"3334class MM_RealtimeGC;35class MM_RealtimeRootScanner;36class MM_Scheduler;3738#define ITEM_IS_ARRAYLET 0x139#define IS_ITEM_OBJECT(item) ((item & ITEM_IS_ARRAYLET) == 0x0)40#define IS_ITEM_ARRAYLET(item) ((item & ITEM_IS_ARRAYLET) == ITEM_IS_ARRAYLET)41#define ITEM_TO_OBJECT(item) ((omrobjectptr_t)(((uintptr_t)item) & (~ITEM_IS_ARRAYLET)))42#define ITEM_TO_ARRAYLET(item) ((fomrobject_t *)(((uintptr_t)item) & (~ITEM_IS_ARRAYLET)))43#define ITEM_TO_UDATAP(item) ((uintptr_t *)(((uintptr_t)item) & (~ITEM_IS_ARRAYLET)))44#define OBJECT_TO_ITEM(obj) ((uintptr_t) obj)45#define ARRAYLET_TO_ITEM(arraylet) (((uintptr_t) arraylet) | ITEM_IS_ARRAYLET)4647#define REFERENCE_OBJECT_YIELD_CHECK_INTERVAL 20048#define UNFINALIZED_OBJECT_YIELD_CHECK_INTERVAL 7049#define OWNABLE_SYNCHRONIZER_OBJECT_YIELD_CHECK_INTERVAL 705051class MM_RealtimeMarkingScheme : public MM_SegregatedMarkingScheme52{53/*54* Data members55*/56public:57protected:58private:59MM_RealtimeGC *_realtimeGC; /**< The GC that this markingScheme is associated*/60MM_Scheduler *_scheduler;6162/*63* Function members64*/65public:66static MM_RealtimeMarkingScheme *newInstance(MM_EnvironmentBase *env, MM_RealtimeGC *realtimeGC);67void kill(MM_EnvironmentBase *env);6869void markLiveObjectsInit(MM_EnvironmentBase *env, bool initMarkMap);70void markLiveObjectsRoots(MM_EnvironmentBase *env);71void markLiveObjectsScan(MM_EnvironmentBase *env);72void markLiveObjectsComplete(MM_EnvironmentBase *env);7374MMINLINE bool isScanned(omrobjectptr_t objectPtr)75{76return isMarked((omrobjectptr_t)((1 << J9VMGC_SIZECLASSES_LOG_SMALLEST) + (uintptr_t)objectPtr));77}7879MMINLINE void unmark(omrobjectptr_t objPtr)80{81_markMap->clearBit(objPtr);82}8384MMINLINE void mark(omrobjectptr_t objectPtr)85{86_markMap->setBit(objectPtr);87}8889MMINLINE void markAtomic(omrobjectptr_t objectPtr)90{91_markMap->atomicSetBit(objectPtr);92}9394MMINLINE void setScanAtomic(omrobjectptr_t objectPtr)95{96_markMap->atomicSetBit((omrobjectptr_t)((1 << J9VMGC_SIZECLASSES_LOG_SMALLEST) + (uintptr_t)objectPtr));97}9899MMINLINE bool100markObject(MM_EnvironmentRealtime *env, omrobjectptr_t objectPtr, bool leafType = false)101{102if (objectPtr == NULL) {103return false;104}105106if (isMarked(objectPtr)) {107return false;108}109110if (!_markMap->atomicSetBit(objectPtr)) {111return false;112}113if (!leafType) {114env->getWorkStack()->push(env, (void *)OBJECT_TO_ITEM(objectPtr));115}116117return true;118}119120bool incrementalCompleteScan(MM_EnvironmentRealtime *env, uintptr_t maxCount);121122/**123* Create a MM_RealtimeMarkingScheme object124*/125MM_RealtimeMarkingScheme(MM_EnvironmentBase *env, MM_RealtimeGC *realtimeGC)126: MM_SegregatedMarkingScheme(env)127, _realtimeGC(realtimeGC)128, _scheduler(NULL)129{130_typeId = __FUNCTION__;131}132protected:133virtual bool initialize(MM_EnvironmentBase *env);134virtual void tearDown(MM_EnvironmentBase *env);135136/*137* Friends138*/139friend class MM_MetronomeDelegate;140};141142#endif /* REALTIMEMARKINGSCHEME_HPP_ */143144145