Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_base/PacketSlotIterator.cpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 2001, 2014 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* 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 and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
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-exception
21
*******************************************************************************/
22
23
#include "j9.h"
24
25
#include "PacketSlotIterator.hpp"
26
27
#include "ModronAssertions.h"
28
29
30
J9Object **
31
MM_PacketSlotIterator::nextSlot()
32
{
33
/* 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 */
34
bool found = false;
35
while ((!found) && (_nextSlot < (J9Object **)_packet->_currentPtr)) {
36
if ((NULL != *_nextSlot) && (PACKET_ARRAY_SPLIT_TAG != (PACKET_ARRAY_SPLIT_TAG & (UDATA)*_nextSlot))) {
37
/* we have found a valid slot which we want to return so fall out of the loop without advancing the cursor */
38
found = true;
39
} else {
40
/* this slot was not acceptable so advance to the next - we will fall out of the loop if this advances us past the end */
41
_nextSlot += 1;
42
}
43
}
44
/* by this point, _nextSlot points either at the next valid slot or past the end of the packet */
45
J9Object **slotToReturn = NULL;
46
if (_nextSlot < (J9Object **)_packet->_currentPtr) {
47
/* this is a valid slot so return it */
48
slotToReturn = _nextSlot;
49
/* advance the _nextSlot past the value we have read */
50
_nextSlot += 1;
51
}
52
return slotToReturn;
53
}
54
55
void
56
MM_PacketSlotIterator::resetSplitTagIndexForObject(J9Object *correspondingObject, UDATA newValue)
57
{
58
J9Object **tagSlot = _nextSlot - 2;
59
if (tagSlot >= (J9Object **)_packet->_basePtr) {
60
/* the next slot is within the range of the packet */
61
if (PACKET_ARRAY_SPLIT_TAG == (PACKET_ARRAY_SPLIT_TAG & (UDATA)*tagSlot)) {
62
/* the next slot is an array split */
63
J9Object **objectSlot = _nextSlot - 1;
64
Assert_MM_true(correspondingObject == *objectSlot);
65
*tagSlot = (J9Object *)newValue;
66
}
67
}
68
}
69
70