Path: blob/master/runtime/gc_modron_standard/StandardAccessBarrier.hpp
5986 views
1/*******************************************************************************2* Copyright (c) 1991, 2021 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*******************************************************************************/222324/**25* @file26* @ingroup GC_Modron_Standard27*/2829#if !defined(STANDARDACCESSBARRIER_HPP_)30#define STANDARDACCESSBARRIER_HPP_313233#include "j9.h"34#include "j9cfg.h"35#include "ObjectAccessBarrier.hpp"36#include "Configuration.hpp"37#include "GenerationalAccessBarrierComponent.hpp"38#if defined(OMR_GC_REALTIME)39#include "RememberedSetSATB.hpp"40#endif /* OMR_GC_REALTIME */4142/**43* Access barrier for Modron collector.44*/4546class MM_StandardAccessBarrier : public MM_ObjectAccessBarrier47{48private:49#if defined(J9VM_GC_GENERATIONAL)50MM_GenerationalAccessBarrierComponent _generationalAccessBarrierComponent; /**< Generational Component of Access Barrier */51#endif /* J9VM_GC_GENERATIONAL */52MM_MarkingScheme *_markingScheme;5354void postObjectStoreImpl(J9VMThread *vmThread, J9Object *dstObject, J9Object *srcObject);55void postBatchObjectStoreImpl(J9VMThread *vmThread, J9Object *dstObject);5657#if defined(OMR_GC_CONCURRENT_SCAVENGER)58I_32 doCopyContiguousBackwardWithReadBarrier(J9VMThread *vmThread, J9IndexableObject *srcObject, J9IndexableObject *destObject, I_32 srcIndex, I_32 destIndex, I_32 lengthInSlots);59I_32 doCopyContiguousForwardWithReadBarrier(J9VMThread *vmThread, J9IndexableObject *srcObject, J9IndexableObject *destObject, I_32 srcIndex, I_32 destIndex, I_32 lengthInSlots);60#endif /* OMR_GC_CONCURRENT_SCAVENGER */6162protected:63virtual bool initialize(MM_EnvironmentBase *env);64virtual void tearDown(MM_EnvironmentBase *env);6566public:67static MM_StandardAccessBarrier *newInstance(MM_EnvironmentBase *env, MM_MarkingScheme *markingScheme);68virtual void kill(MM_EnvironmentBase *env);6970MM_StandardAccessBarrier(MM_EnvironmentBase *env, MM_MarkingScheme *markingScheme) :71MM_ObjectAccessBarrier(env)72, _markingScheme(markingScheme)73{74_typeId = __FUNCTION__;75}7677virtual J9Object* asConstantPoolObject(J9VMThread *vmThread, J9Object* toConvert, UDATA allocationFlags);7879virtual void rememberObjectImpl(MM_EnvironmentBase *env, J9Object* object);80virtual bool preObjectStore(J9VMThread *vmThread, J9Object *destObject, fj9object_t *destAddress, J9Object *value, bool isVolatile=false);81virtual bool preObjectStore(J9VMThread *vmThread, J9Object *destClass, J9Object **destAddress, J9Object *value, bool isVolatile=false);82virtual bool preObjectStore(J9VMThread *vmThread, J9Object **destAddress, J9Object *value, bool isVolatile=false);8384virtual void postObjectStore(J9VMThread *vmThread, J9Object *destObject, fj9object_t *destAddress, J9Object *value, bool isVolatile=false);85virtual void postObjectStore(J9VMThread *vmThread, J9Class *destClass, J9Object **destAddress, J9Object *value, bool isVolatile=false);86virtual bool postBatchObjectStore(J9VMThread *vmThread, J9Object *destObject, bool isVolatile=false);87virtual bool postBatchObjectStore(J9VMThread *vmThread, J9Class *destClass, bool isVolatile=false);88virtual void recentlyAllocatedObject(J9VMThread *vmThread, J9Object *object);8990virtual void* jniGetPrimitiveArrayCritical(J9VMThread* vmThread, jarray array, jboolean *isCopy);91virtual void jniReleasePrimitiveArrayCritical(J9VMThread* vmThread, jarray array, void * elems, jint mode);92virtual const jchar* jniGetStringCritical(J9VMThread* vmThread, jstring str, jboolean *isCopy);93virtual void jniReleaseStringCritical(J9VMThread* vmThread, jstring str, const jchar* elems);94virtual void initializeForNewThread(MM_EnvironmentBase* env);9596virtual I_32 backwardReferenceArrayCopyIndex(J9VMThread *vmThread, J9IndexableObject *srcObject, J9IndexableObject *destObject, I_32 srcIndex, I_32 destIndex, I_32 lengthInSlots);97virtual I_32 forwardReferenceArrayCopyIndex(J9VMThread *vmThread, J9IndexableObject *srcObject, J9IndexableObject *destObject, I_32 srcIndex, I_32 destIndex, I_32 lengthInSlots);9899#if defined(OMR_GC_CONCURRENT_SCAVENGER)100/* heap slot (possibly compressed refs) */101virtual bool preObjectRead(J9VMThread *vmThread, J9Object *srcObject, fj9object_t *srcAddress);102/* off-heap slot (always non-compressed) */103virtual bool preObjectRead(J9VMThread *vmThread, J9Class *srcClass, j9object_t *srcAddress);104virtual bool preWeakRootSlotRead(J9VMThread *vmThread, j9object_t *srcAddress);105virtual bool preWeakRootSlotRead(J9JavaVM *vm, j9object_t *srcAddress);106#endif107108bool preObjectStoreImpl(J9VMThread *vmThread, J9Object *destObject, fj9object_t *destAddress, J9Object *value, bool isVolatile);109bool preObjectStoreImpl(J9VMThread *vmThread, J9Object **destAddress, J9Object *value, bool isVolatile);110111void rememberObjectToRescan(MM_EnvironmentBase *env, J9Object *object);112113MMINLINE bool isIncrementalUpdateBarrierActive(J9VMThread *vmThread)114{115return ((vmThread->privateFlags & J9_PRIVATE_FLAGS_CONCURRENT_MARK_ACTIVE) &&116_extensions->configuration->isIncrementalUpdateBarrierEnabled());117}118119virtual J9Object* referenceGet(J9VMThread *vmThread, J9Object *refObject);120virtual void referenceReprocess(J9VMThread *vmThread, J9Object *refObject);121122/**123* Return the number of currently active JNI critical regions.124*125* Must hold exclusive VM access to call this!126*/127static UDATA getJNICriticalRegionCount(MM_GCExtensions *extensions);128129virtual void forcedToFinalizableObject(J9VMThread* vmThread, J9Object *object);130131virtual void jniDeleteGlobalReference(J9VMThread *vmThread, J9Object *reference);132133virtual void stringConstantEscaped(J9VMThread *vmThread, J9Object *stringConst);134virtual bool checkStringConstantsLive(J9JavaVM *javaVM, j9object_t stringOne, j9object_t stringTwo);135virtual bool checkStringConstantLive(J9JavaVM *javaVM, j9object_t string);136137#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)138/**139* Check is class alive140* Required to prevent visibility of dead classes in SATB GC policies141* Check is J9_GC_CLASS_LOADER_DEAD flag set for classloader and try to mark142* class loader object if bit is not set to force class to be alive143* @param javaVM pointer to J9JavaVM144* @param classPtr class to check145* @return true if class is alive146*/147virtual bool checkClassLive(J9JavaVM *javaVM, J9Class *classPtr);148#endif /* defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING) */149};150151#endif /* STANDARDACCESSBARRIER_HPP_ */152153154