Path: blob/master/runtime/gc_structs/MixedObjectDeclarationOrderIterator.hpp
5990 views
/*******************************************************************************1* Copyright (c) 1991, 2019 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/**23* @file24* @ingroup GC_Structs25*/2627#if !defined(MIXEDOBJECTDECLARATIONORDERITERATOR_HPP_)28#define MIXEDOBJECTDECLARATIONORDERITERATOR_HPP_2930#include "j9.h"31#include "j9cfg.h"32#include "modron.h"33#include "locknursery.h"3435#include "MixedObjectModel.hpp"36#include "SlotObject.hpp"37#include "locknursery.h"3839/**40* Iterate over all slots in a mixed object which contain an object reference.41* @note This iterator relies on a VM iterator which is not out of process safe, and consequently42* it is also not out of process safe.43*44* @ingroup GC_Structs45*/46class GC_MixedObjectDeclarationOrderIterator47{48protected:49J9ROMFullTraversalFieldOffsetWalkState _walkState;50J9ROMFieldShape *_fieldShape;51J9JavaVM *_javaVM;52J9Object *_objectPtr;53GC_SlotObject _slotObject;54IDATA _index;5556public:57GC_MixedObjectDeclarationOrderIterator(J9JavaVM *jvm, J9Object *objectPtr, bool shouldPreindexInterfaceFields) :58_javaVM(jvm),59_objectPtr(objectPtr),60_slotObject(jvm->omrVM, NULL),61_index(-1)62{63U_32 flags = J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE | J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS;64if (shouldPreindexInterfaceFields) {65flags |= J9VM_FIELD_OFFSET_WALK_PREINDEX_INTERFACE_FIELDS;66}6768J9Class *clazz = J9GC_J9OBJECT_CLAZZ_VM(objectPtr, _javaVM);69_fieldShape = _javaVM->internalVMFunctions->fullTraversalFieldOffsetsStartDo(_javaVM, clazz, &_walkState, flags);70}7172GC_SlotObject *nextSlot();7374/**75* Gets the current slot's declaration order index.76* The current slot's declaration order index is based on the indices of its superclass and superinterfaces.77* @return slot's declaration order index of the entry returned by the last call of nextSlot.78* @return -1 if nextSlot has yet to be called.79*/80MMINLINE IDATA getIndex() {81return _index;82}83};8485#endif /* MIXEDOBJECTDECLARATIONORDERITERATOR_HPP_ */86878889