Path: blob/master/runtime/gc_base/PacketSlotIterator.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*******************************************************************************/2122#include "j9.h"2324#include "PacketSlotIterator.hpp"2526#include "ModronAssertions.h"272829J9Object **30MM_PacketSlotIterator::nextSlot()31{32/* we can't assume that _nextSlot points inside the packet or contains a value which we want to return so cue it up to the next valid slot */33bool found = false;34while ((!found) && (_nextSlot < (J9Object **)_packet->_currentPtr)) {35if ((NULL != *_nextSlot) && (PACKET_ARRAY_SPLIT_TAG != (PACKET_ARRAY_SPLIT_TAG & (UDATA)*_nextSlot))) {36/* we have found a valid slot which we want to return so fall out of the loop without advancing the cursor */37found = true;38} else {39/* this slot was not acceptable so advance to the next - we will fall out of the loop if this advances us past the end */40_nextSlot += 1;41}42}43/* by this point, _nextSlot points either at the next valid slot or past the end of the packet */44J9Object **slotToReturn = NULL;45if (_nextSlot < (J9Object **)_packet->_currentPtr) {46/* this is a valid slot so return it */47slotToReturn = _nextSlot;48/* advance the _nextSlot past the value we have read */49_nextSlot += 1;50}51return slotToReturn;52}5354void55MM_PacketSlotIterator::resetSplitTagIndexForObject(J9Object *correspondingObject, UDATA newValue)56{57J9Object **tagSlot = _nextSlot - 2;58if (tagSlot >= (J9Object **)_packet->_basePtr) {59/* the next slot is within the range of the packet */60if (PACKET_ARRAY_SPLIT_TAG == (PACKET_ARRAY_SPLIT_TAG & (UDATA)*tagSlot)) {61/* the next slot is an array split */62J9Object **objectSlot = _nextSlot - 1;63Assert_MM_true(correspondingObject == *objectSlot);64*tagSlot = (J9Object *)newValue;65}66}67}686970