Path: blob/master/runtime/gc_structs/ClassIteratorClassSlots.hpp
5985 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*******************************************************************************/2223/**24* @file25* @ingroup GC_Structs26*/2728#if !defined(CLASSITERATORCLASSSLOTS_HPP_)29#define CLASSITERATORCLASSSLOTS_HPP_3031#include "j9.h"32#include "j9cfg.h"33#include "modron.h"3435#include "ConstantPoolClassSlotIterator.hpp"36#include "ClassSuperclassesIterator.hpp"37#include "ClassLocalInterfaceIterator.hpp"38#include "ClassArrayClassSlotIterator.hpp"39#include "ClassFCCSlotIterator.hpp"40#include "ClassModel.hpp"4142/**43* State constants representing the current stage of the iteration process44* @anchor ClassIteratorClassSlotsState45*/46enum {47classiteratorclassslots_state_start = 0,48classiteratorclassslots_state_constant_pool,49classiteratorclassslots_state_superclasses,50classiteratorclassslots_state_interfaces,51classiteratorclassslots_state_array_class_slots,52classiteratorclassslots_state_flattened_class_cache_slots,53classiteratorclassslots_state_end54};555657/**58* Iterate through slots in the class which contain a class reference (as compared to59* GC_ClassIterator, which iterates over object references).60*61* @see GC_ClassIterator62* @ingroup GC_Structs63*/64class GC_ClassIteratorClassSlots65{66protected:67const bool _shouldScanInterfaces;68J9Class *_clazzPtr;69int _state;7071GC_ConstantPoolClassSlotIterator _constantPoolClassSlotIterator;72GC_ClassSuperclassesIterator _classSuperclassesIterator;73GC_ClassLocalInterfaceIterator _classLocalInterfaceIterator;74GC_ClassArrayClassSlotIterator _classArrayClassSlotIterator;75GC_ClassFCCSlotIterator _classFCCSlotIterator;7677public:7879GC_ClassIteratorClassSlots(J9JavaVM *vm, J9Class *clazz) :80_shouldScanInterfaces(!GC_ClassModel::usesSharedITable(vm, clazz)),81_clazzPtr(clazz),82_state(classiteratorclassslots_state_start),83_constantPoolClassSlotIterator(clazz),84_classSuperclassesIterator(clazz),85_classLocalInterfaceIterator(clazz),86_classArrayClassSlotIterator(clazz),87_classFCCSlotIterator(clazz)88{}8990/**91* @return @ref ClassIteratorClassSlotsState representing the current state (stage92* of the iteration process)93*/94MMINLINE int getState()95{96return _state;97};9899/**100* Gets the current index corresponding to the current state.101* @return current index of the current state where appropriate.102* @return -1 if the current state is not indexed.103*/104MMINLINE IDATA getIndex()105{106switch (getState()) {107case classiteratorclassslots_state_constant_pool:108return _constantPoolClassSlotIterator.getIndex();109110case classiteratorclassslots_state_superclasses:111return _classSuperclassesIterator.getIndex();112113case classiteratorclassslots_state_array_class_slots:114return _classArrayClassSlotIterator.getIndex();115116case classiteratorclassslots_state_flattened_class_cache_slots:117return _classFCCSlotIterator.getIndex();118119case classiteratorclassslots_state_interfaces:120default:121return -1;122}123}124125J9Class *nextSlot();126127};128129#endif /* CLASSITERATORCLASSSLOTS_HPP_ */130131132133