Path: blob/master/runtime/gc_glue_java/GlobalCollectorDelegate.hpp
5985 views
/*******************************************************************************1* Copyright (c) 2017, 2020 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#ifndef GLOBALCOLLECTORDELEGATE_HPP_23#define GLOBALCOLLECTORDELEGATE_HPP_2425#include "omrcfg.h"2627struct J9JavaVM;2829class MM_EnvironmentBase;30class MM_GCExtensions;31class MM_GlobalCollector;32class MM_MarkingScheme;3334class MM_GlobalCollectorDelegate35{36/*37* Data members38*/39private:4041protected:42J9JavaVM *_javaVM;43MM_GCExtensions *_extensions;44MM_MarkingScheme *_markingScheme;45MM_GlobalCollector *_globalCollector;46#if defined(J9VM_GC_MODRON_COMPACTION)47uintptr_t _criticalSectionCount;48#endif /* defined(J9VM_GC_MODRON_COMPACTION) */49#if defined(J9VM_GC_FINALIZATION)50bool _finalizationRequired;51#endif /* defined(J9VM_GC_FINALIZATION) */5253public:5455/*56* Function members57*/58private:59#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)60bool enterClassUnloadMutex(MM_EnvironmentBase *env, bool force);61void exitClassUnloadMutex(MM_EnvironmentBase *env);62void unloadDeadClassLoaders(MM_EnvironmentBase *env);63#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */6465protected:6667public:68/**69* Initialize the delegate. For standard GC policies, the global collector and marking scheme70* instances must be provided.71*72* @param env environment for calling thread73* @param globalCollector the MM_GlobalCollector instance that the delegate is bound to74* @param markingScheme the MM_MarkingScheme instance (may be null if not standard GC)75* @return true if delegate initialized successfully76*/77bool initialize(MM_EnvironmentBase *env, MM_GlobalCollector *globalCollector, MM_MarkingScheme *markingScheme);78void tearDown(MM_EnvironmentBase *env);7980void mainThreadGarbageCollectStarted(MM_EnvironmentBase *env);81void postMarkProcessing(MM_EnvironmentBase *env);82void mainThreadGarbageCollectFinished(MM_EnvironmentBase *env, bool compactedThisCycle);83void postCollect(MM_EnvironmentBase* env, MM_MemorySubSpace* subSpace);8485bool isAllowUserHeapWalk();86void prepareHeapForWalk(MM_EnvironmentBase *env);8788#if defined(OMR_ENV_DATA64) && defined(OMR_GC_FULL_POINTERS)89void poisonSlots(MM_EnvironmentBase *env);90void healSlots(MM_EnvironmentBase *env);91#endif /* defined(OMR_ENV_DATA64) && defined(OMR_GC_FULL_POINTERS) */9293bool heapAddRange(MM_EnvironmentBase *env, MM_MemorySubSpace *subspace, UDATA size, void *lowAddress, void *highAddress);94bool heapRemoveRange(MM_EnvironmentBase *env, MM_MemorySubSpace *subspace, UDATA size, void *lowAddress, void *highAddress, void *lowValidAddress, void *highValidAddress);9596bool isTimeForGlobalGCKickoff();9798#if defined(J9VM_GC_MODRON_COMPACTION)99CompactPreventedReason checkIfCompactionShouldBePrevented(MM_EnvironmentBase *env);100#endif /* J9VM_GC_MODRON_COMPACTION */101102#if defined(J9VM_GC_FINALIZATION)103void setFinalizationRequired() { _finalizationRequired = true; }104bool isFinalizationRequired() { return _finalizationRequired; }105#endif /* defined(J9VM_GC_FINALIZATION) */106107MM_GlobalCollectorDelegate()108: _javaVM(NULL)109, _extensions(NULL)110, _markingScheme(NULL)111, _globalCollector(NULL)112#if defined(J9VM_GC_MODRON_COMPACTION)113, _criticalSectionCount(0)114#endif /* defined(J9VM_GC_MODRON_COMPACTION) */115#if defined(J9VM_GC_FINALIZATION)116, _finalizationRequired(false)117#endif /* defined(J9VM_GC_FINALIZATION) */118{}119};120#endif /* GLOBALCOLLECTORDELEGATE_HPP_ */121122123