Path: blob/master/runtime/gc_realtime/RealtimeMarkingSchemeRootMarker.hpp
5986 views
/*******************************************************************************1* Copyright (c) 2019, 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/**23* @file24* @ingroup GC_Metronome25*/2627#if !defined(REALTIMEROOTMARKER_HPP_)28#define REALTIMEROOTMARKER_HPP_2930#include "j9.h"31#include "j9cfg.h"32#include "modronopt.h"3334#include "EnvironmentRealtime.hpp"35#include "ObjectAllocationInterface.hpp"36#include "RealtimeRootScanner.hpp"37#include "RealtimeGC.hpp"38#include "RealtimeMarkingScheme.hpp"39#include "StackSlotValidator.hpp"4041/**42* This scanner will mark objects that pass through its doSlot.43*/44class MM_RealtimeMarkingSchemeRootMarker : public MM_RealtimeRootScanner45{46/* Data members / types */47public:48protected:49private:5051/* Methods */52public:5354/**55* Simple chained constructor.56*/57MM_RealtimeMarkingSchemeRootMarker(MM_EnvironmentRealtime *env, MM_RealtimeGC *realtimeGC) :58MM_RealtimeRootScanner(env, realtimeGC)59{60_typeId = __FUNCTION__;61}6263/**64* This scanner can be instantiated so we must give it a name.65*/66virtual const char*67scannerName()68{69return "Mark";70}7172/**73* Wraps the scanning of one thread to only happen if it hasn't already occured in this phase of this GC,74* also sets the thread up for the upcoming forwarding phase.75* @return true if the thread was scanned (the caller should offer to yield), false otherwise.76* @see MM_RootScanner::scanOneThread()77*/78virtual void79scanOneThreadImpl(MM_EnvironmentRealtime *env, J9VMThread* walkThread, void* localData)80{81MM_EnvironmentRealtime* walkThreadEnv = MM_EnvironmentRealtime::getEnvironment(walkThread->omrVMThread);82/* Scan the thread by invoking superclass */83MM_RootScanner::scanOneThread(env, walkThread, localData);8485/*86* TODO CRGTMP we should be able to premark the cache instead of flushing the cache87* but this causes problems in overflow. When we have some time we should look into88* this again.89*/90/*((MM_SegregatedAllocationInterface *)walkThreadEnv->_objectAllocationInterface)->preMarkCache(walkThreadEnv);*/91walkThreadEnv->_objectAllocationInterface->flushCache(walkThreadEnv);92/* Disable the double barrier on the scanned thread. */93_realtimeGC->disableDoubleBarrierOnThread(env, walkThread->omrVMThread);94}9596#if defined(J9VM_GC_FINALIZATION)97virtual void doFinalizableObject(j9object_t object) {98_markingScheme->markObject(_env, object);99}100#endif /* J9VM_GC_FINALIZATION */101102/**103* Simply pass the call on to the RealtimeGC.104* @see MM_Metronome::markObject()105*/106virtual void107doSlot(J9Object** slot)108{109_markingScheme->markObject(_env, *slot);110}111112virtual void113doStackSlot(J9Object **slotPtr, void *walkState, const void* stackLocation)114{115J9Object *object = *slotPtr;116if (_markingScheme->isHeapObject(object)) {117/* heap object - validate and mark */118Assert_MM_validStackSlot(MM_StackSlotValidator(0, object, stackLocation, walkState).validate(_env));119_markingScheme->markObject(_env, object);120} else if (NULL != object) {121/* stack object - just validate */122Assert_MM_validStackSlot(MM_StackSlotValidator(MM_StackSlotValidator::NOT_ON_HEAP, object, stackLocation, walkState).validate(_env));123}124}125126virtual void127doVMThreadSlot(J9Object **slotPtr, GC_VMThreadIterator *vmThreadIterator) {128J9Object *object = *slotPtr;129if (_markingScheme->isHeapObject(object)) {130_markingScheme->markObject(_env, object);131} else if (NULL != object) {132Assert_MM_true(vmthreaditerator_state_monitor_records == vmThreadIterator->getState());133}134}135136/**137* Scans non-collectable internal objects (immortal) and classes138*/139virtual void140scanIncrementalRoots(MM_EnvironmentRealtime *env)141{142#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)143if (_classDataAsRoots) {144#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */145scanClasses(env);146#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)147} else {148scanPermanentClasses(env);149}150#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */151152CompletePhaseCode status = scanClassesComplete(env);153154if (complete_phase_ABORT == status) {155return ;156}157}158protected:159private:160};161162#endif /* REALTIMEROOTMARKER_HPP_ */163164165166