Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_base/OwnableSynchronizerObjectList.hpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2014 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* 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
22
*******************************************************************************/
23
24
#ifndef OWNABLESYNCHRONIZEROBJECTLIST_HPP_
25
#define OWNABLESYNCHRONIZEROBJECTLIST_HPP_
26
27
#include "j9.h"
28
#include "j9cfg.h"
29
#include "modron.h"
30
31
#include "BaseNonVirtual.hpp"
32
#include "ObjectAccessBarrier.hpp"
33
34
class MM_EnvironmentBase;
35
36
/**
37
* A global list of OwnableSynchronizer objects.
38
*/
39
class MM_OwnableSynchronizerObjectList : public MM_BaseNonVirtual
40
{
41
/* data members */
42
private:
43
volatile j9object_t _head; /**< the head of the linked list of OwnableSynchronizer objects */
44
j9object_t _priorHead; /**< the head of the linked list before OwnableSynchronizer object processing */
45
MM_OwnableSynchronizerObjectList *_nextList; /**< a pointer to the next OwnableSynchronizer list in the global linked list of lists */
46
MM_OwnableSynchronizerObjectList *_previousList; /**< a pointer to the previous OwnableSynchronizer list in the global linked list of lists */
47
#if defined(J9VM_GC_VLHGC)
48
UDATA _objectCount; /**< the number of objects in the list */
49
#endif /* defined(J9VM_GC_VLHGC) */
50
protected:
51
public:
52
53
/* function members */
54
private:
55
protected:
56
public:
57
/**
58
* Add the specified linked list of objects to the buffer.
59
* The objects are expected to be in a NULL terminated linked
60
* list, starting from head and end at tail.
61
* This call is thread safe.
62
*
63
* @param env[in] the current thread
64
* @param head[in] the first object in the list to add
65
* @param tail[in] the last object in the list to add
66
*/
67
void addAll(MM_EnvironmentBase* env, j9object_t head, j9object_t tail);
68
69
/**
70
* Fetch the head of the linked list, as it appeared at the beginning of OwnableSynchronizer object processing.
71
* @return the head object, or NULL if the list is empty
72
*/
73
MMINLINE j9object_t getHeadOfList() { return _head; }
74
75
/**
76
* Move the list to the prior list and reset the current list to empty.
77
* The prior list may be examined with wasEmpty() and getPriorList().
78
*/
79
void startOwnableSynchronizerProcessing() {
80
_priorHead = _head;
81
_head = NULL;
82
#if defined(J9VM_GC_VLHGC)
83
clearObjectCount();
84
#endif /* defined(J9VM_GC_VLHGC) */
85
}
86
87
/**
88
* copy the list to the prior list for backup, can be restored via calling backoutList()
89
*/
90
MMINLINE void backupList() {
91
_priorHead = _head;
92
}
93
94
/**
95
* restore the list from the prior list, and reset the prior list to empty.
96
*/
97
MMINLINE void backoutList() {
98
_head = _priorHead;
99
_priorHead = NULL;
100
}
101
102
/**
103
* Determine if the list was empty at the beginning of OwnableSynchronizer object processing.
104
* @return true if the list was empty, false otherwise
105
*/
106
bool wasEmpty() { return NULL == _priorHead; }
107
108
/**
109
* Fetch the head of the linked list, as it appeared at the beginning of OwnableSynchronizer object processing.
110
* @return the head object, or NULL if the list is empty
111
*/
112
j9object_t getPriorList() { return _priorHead; }
113
114
/**
115
* Return a pointer to the next OwnableSynchronizer object list in the global linked list of lists, or NULL if this is the last list.
116
* @return the next list in the global list
117
*/
118
MMINLINE MM_OwnableSynchronizerObjectList* getNextList() { return _nextList; }
119
120
/**
121
* Set the link to the next OwnableSynchronizer object list in the global linked list of lists.
122
* @param nextList[in] the next list, or NULL
123
*/
124
void setNextList(MM_OwnableSynchronizerObjectList* nextList) { _nextList = nextList; }
125
126
/**
127
* Return a pointer to the previous OwnableSynchronizer object list in the global linked list of lists, or NULL if this is the first list.
128
* @return the next list in the global list
129
*/
130
MMINLINE MM_OwnableSynchronizerObjectList* getPreviousList() { return _previousList; }
131
132
/**
133
* Set the link to the previous OwnableSynchronizer object list in the global linked list of lists.
134
* @param nextList[in] the next list, or NULL
135
*/
136
void setPreviousList(MM_OwnableSynchronizerObjectList* previousList) { _previousList = previousList; }
137
138
/**
139
* Construct a new list.
140
*/
141
MM_OwnableSynchronizerObjectList();
142
143
#if defined(J9VM_GC_VLHGC)
144
MMINLINE UDATA getObjectCount() { return _objectCount; }
145
MMINLINE void clearObjectCount() { _objectCount = 0; }
146
MMINLINE void incrementObjectCount(UDATA count)
147
{
148
MM_AtomicOperations::add((volatile UDATA *)&_objectCount, count);
149
}
150
#endif /* defined(J9VM_GC_VLHGC) */
151
152
};
153
154
#endif /* OWNABLESYNCHRONIZEROBJECTLIST_HPP_ */
155
156