Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_base/ReferenceObjectList.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 REFERENCEOBJECTLIST_HPP_
25
#define REFERENCEOBJECTLIST_HPP_
26
27
#include "j9.h"
28
#include "j9cfg.h"
29
30
#include "BaseNonVirtual.hpp"
31
32
class MM_EnvironmentBase;
33
34
/**
35
* A global list of reference objects.
36
*/
37
class MM_ReferenceObjectList : public MM_BaseNonVirtual
38
{
39
/* data members */
40
private:
41
volatile j9object_t _weakHead; /**< the head of the linked list of weak reference objects */
42
volatile j9object_t _softHead; /**< the head of the linked list of soft reference objects */
43
volatile j9object_t _phantomHead; /**< the head of the linked list of phantom reference objects */
44
j9object_t _priorWeakHead; /**< the head of the weak linked list before reference object processing */
45
j9object_t _priorSoftHead; /**< the head of the soft linked list before reference object processing */
46
j9object_t _priorPhantomHead; /**< the head of the phantom linked list before reference object processing */
47
protected:
48
public:
49
50
/* function members */
51
private:
52
protected:
53
public:
54
/**
55
* Add the specified linked list of objects to the buffer.
56
* The objects are expected to be in a NULL terminated linked
57
* list, starting from head and end at tail.
58
* This call is thread safe.
59
*
60
* @param env[in] the current thread
61
* @param referenceObjectType the type of objects being added (weak/soft/phantom)
62
* @param head[in] the first object in the list to add
63
* @param tail[in] the last object in the list to add
64
*/
65
void addAll(MM_EnvironmentBase* env, UDATA referenceObjectType, j9object_t head, j9object_t tail);
66
67
/**
68
* Move the list to the prior list and reset the current list to empty.
69
* The prior list may be examined with wasEmpty() and getPriorList().
70
*/
71
void startWeakReferenceProcessing() {
72
_priorWeakHead = _weakHead;
73
_weakHead = NULL;
74
}
75
76
/**
77
* Move the list to the prior list and reset the current list to empty.
78
* The prior list may be examined with wasEmpty() and getPriorList().
79
*/
80
void startSoftReferenceProcessing() {
81
_priorSoftHead = _softHead;
82
_softHead = NULL;
83
}
84
85
/**
86
* Move the list to the prior list and reset the current list to empty.
87
* The prior list may be examined with wasEmpty() and getPriorList().
88
*/
89
void startPhantomReferenceProcessing() {
90
_priorPhantomHead = _phantomHead;
91
_phantomHead = NULL;
92
}
93
94
/**
95
* Determine if the list was empty at the beginning of reference object processing.
96
* @return true if the list was empty, false otherwise
97
*/
98
bool wasWeakListEmpty() { return NULL == _priorWeakHead; }
99
100
/**
101
* Determine if the list was empty at the beginning of reference object processing.
102
* @return true if the list was empty, false otherwise
103
*/
104
bool wasSoftListEmpty() { return NULL == _priorSoftHead; }
105
106
/**
107
* Determine if the list was empty at the beginning of reference object processing.
108
* @return true if the list was empty, false otherwise
109
*/
110
bool wasPhantomListEmpty() { return NULL == _priorPhantomHead; }
111
112
bool isWeakListEmpty() { return NULL == _weakHead; }
113
bool isSoftListEmpty() { return NULL == _softHead; }
114
bool isPhantomListEmpty() { return NULL == _phantomHead; }
115
116
/**
117
* Fetch the head of the linked list, as it appeared at the beginning of reference object processing.
118
* @return the head object, or NULL if the list is empty
119
*/
120
j9object_t getPriorWeakList() { return _priorWeakHead; }
121
122
/**
123
* Fetch the head of the linked list, as it appeared at the beginning of reference object processing.
124
* @return the head object, or NULL if the list is empty
125
*/
126
j9object_t getPriorSoftList() { return _priorSoftHead; }
127
128
/**
129
* Fetch the head of the linked list, as it appeared at the beginning of reference object processing.
130
* @return the head object, or NULL if the list is empty
131
*/
132
j9object_t getPriorPhantomList() { return _priorPhantomHead; }
133
134
/**
135
* Clear all of the prior lists.
136
* After this call, was{Weak|Soft|Phantom}ListEmpty() will return true.
137
*/
138
void resetPriorLists() {
139
_priorWeakHead = NULL;
140
_priorSoftHead = NULL;
141
_priorPhantomHead = NULL;
142
}
143
144
/**
145
* Clear all lists, head or prior.
146
* After this call, was{Weak|Soft|Phantom}ListEmpty() will return true.
147
*/
148
void resetLists() {
149
resetPriorLists();
150
_weakHead = NULL;
151
_softHead = NULL;
152
_phantomHead = NULL;
153
}
154
155
/**
156
* Construct a new list.
157
*/
158
MM_ReferenceObjectList();
159
};
160
161
#endif /* REFERENCEOBJECTLIST_HPP_ */
162
163