Path: blob/master/runtime/gc_structs/ClassIteratorDeclarationOrder.hpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2014 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(CLASSITERATORDECLARATIONORDER_HPP_)29#define CLASSITERATORDECLARATIONORDER_HPP_3031#include "j9.h"32#include "j9cfg.h"33#include "modron.h"34#include "j9modron.h"3536#include "ClassIterator.hpp"37#include "ClassStaticsDeclarationOrderIterator.hpp"38#include "GCExtensionsBase.hpp"3940/**41* Iterate through <i>all</i> slots in the class which contain an object reference42* in the order declared in the class where applicable.43*44* @see GC_ClassIterator45* @ingroup GC_Structs46*/47class GC_ClassIteratorDeclarationOrder : public GC_ClassIterator48{49protected:50GC_ClassStaticsDeclarationOrderIterator _classStaticsDeclarationOrderIterator;5152public:5354GC_ClassIteratorDeclarationOrder(J9JavaVM *jvm, J9Class *clazz, bool shouldPreindexInterfaceFields)55: GC_ClassIterator(MM_GCExtensionsBase::getExtensions(jvm->omrVM), clazz)56, _classStaticsDeclarationOrderIterator(jvm, clazz, shouldPreindexInterfaceFields)57{};585960/**61* Gets the current index corresponding to the current state.62* @return current index of the current state where appropriate.63* @return -1 if the current state is not indexed.64*/65MMINLINE IDATA getIndex()66{67switch (getState()) {68case classiterator_state_statics:69return _classStaticsDeclarationOrderIterator.getIndex();7071case classiterator_state_constant_pool:72return _constantPoolObjectSlotIterator.getIndex();7374case classiterator_state_slots:75return (IDATA)_scanIndex;7677case classiterator_state_callsites:78return _callSitesIterator.getIndex();7980default:81return -1;82}83}8485/**86* Gets the reference type of the slot referred to for the current state87* @return88*/89MMINLINE IDATA getSlotReferenceType()90{91IDATA refType = J9GC_REFERENCE_TYPE_UNKNOWN;9293switch (getState()) {94case classiterator_state_statics:95refType = J9GC_REFERENCE_TYPE_STATIC;96break;97case classiterator_state_constant_pool:98refType = J9GC_REFERENCE_TYPE_CONSTANT_POOL;99break;100case classiterator_state_slots:101{102/* NOTE: asking for index after nextSlot, so 1 larger than actual index in offset array */103switch (_scanIndex) {104case 1:105refType = J9GC_REFERENCE_TYPE_PROTECTION_DOMAIN;106break;107case 2:108refType = J9GC_REFERENCE_TYPE_CLASS_NAME_STRING;109break;110default:111refType = J9GC_REFERENCE_TYPE_UNKNOWN;112break;113}114}115break;116case classiterator_state_callsites:117refType = J9GC_REFERENCE_TYPE_CALL_SITE;118break;119default:120refType = J9GC_REFERENCE_TYPE_UNKNOWN;121break;122}123return refType;124}125126virtual volatile j9object_t *nextSlot();127};128129#endif /* CLASSITERATORDECLARATIONORDER_HPP_ */130131132133