Path: blob/master/runtime/gc_api/HeapIteratorAPIRootIterator.cpp
5985 views
/*******************************************************************************1* Copyright (c) 2001, 2014 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*******************************************************************************/21#include "HeapIteratorAPIRootIterator.hpp"22#include "HeapIteratorAPI.h"2324void25HeapIteratorAPI_RootIterator::scanAllSlots()26{27if(!_nurseryReferencesOnly && !_nurseryReferencesPossibly) {28if( _flags & SCAN_CLASSES) {29scanClasses();30}31if( _flags & SCAN_VM_CLASS_SLOTS) {32scanVMClassSlots();33}34}3536if(_flags & SCAN_CLASS_LOADERS) {37scanClassLoaders();38}3940if(_flags & SCAN_THREADS) {41scanThreads();42}4344#if defined(J9VM_GC_FINALIZATION)45if(_flags & SCAN_FINALIZABLE_OBJECTS) {46/* TODO: MM_GCExtensionCore does not contain GC_FinalizeListManager,47* which is required to walk finalizable objects.48*/49scanFinalizableObjects();50}51#endif /* J9VM_GC_FINALIZATION */5253if(_flags & SCAN_JNI_GLOBAL) {54scanJNIGlobalReferences();55}56if(!_nurseryReferencesOnly && !_nurseryReferencesPossibly) {57if(_flags & SCAN_STRING_TABLE) {58scanStringTable();59}60}6162#if defined(J9VM_GC_FINALIZATION)63if(_flags & SCAN_UNFINALIZABLE) {64scanUnfinalizedObjects();65}66#endif /* J9VM_GC_FINALIZATION */6768if(_flags & SCAN_MONITORS) {69scanMonitorReferences();70}7172if(_flags & SCAN_JNI_WEAK) {73scanJNIWeakGlobalReferences();74}7576#if defined(J9VM_GC_MODRON_SCAVENGER)77if(!_nurseryReferencesOnly && !_nurseryReferencesPossibly) {78if(_flags & SCAN_REMEBERED_SET) {79scanRememberedSet();80}81}82#endif /* J9VM_GC_MODRON_SCAVENGER */8384#if defined(J9VM_OPT_JVMTI)85if(_includeJVMTIObjectTagTables) {86if(_flags & SCAN_JVMTI_OBJECT_TAG_TABLE) {87/* TODO: The J9JVMTI_DATA_FROM_VM is OOP unsafe - convert code when it is. */88scanJVMTIObjectTagTables();89}90}91#endif /* J9VM_OPT_JVMTI */9293if (_flags & SCAN_OWNABLE_SYNCHRONIZER) {94scanOwnableSynchronizerObjects();95}96}979899void100HeapIteratorAPI_RootIterator::doSlot(J9Object** slotPtr)101{102J9MM_HeapRootSlotDescriptor rootDesc;103104rootDesc.slotType = _scanningEntity;105rootDesc.scanType = HEAP_ROOT_SLOT_DESCRIPTOR_OBJECT;106rootDesc.slotReachability = _scanningEntityReachability;107108if( NULL != ((void *)*slotPtr) ) {109_func((void *)*slotPtr, &rootDesc, _userData);110}111}112113void114HeapIteratorAPI_RootIterator::doObject(J9Object* slotPtr)115{116J9MM_HeapRootSlotDescriptor rootDesc;117118rootDesc.slotType = _scanningEntity;119rootDesc.scanType = HEAP_ROOT_SLOT_DESCRIPTOR_OBJECT;120rootDesc.slotReachability = _scanningEntityReachability;121122_func( (void *)slotPtr, &rootDesc, _userData);123124}125126void127HeapIteratorAPI_RootIterator::doClass(J9Class *clazz)128{129J9MM_HeapRootSlotDescriptor rootDesc;130131rootDesc.slotType = _scanningEntity;132rootDesc.scanType = HEAP_ROOT_SLOT_DESCRIPTOR_CLASS;133rootDesc.slotReachability = _scanningEntityReachability;134135if( NULL != clazz ) {136_func( (void *)clazz, &rootDesc, _userData);137}138}139140141