Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_glue_java/CompactSchemeFixupRoots.cpp
5990 views
1
/*******************************************************************************
2
* Copyright (c) 2001, 2020 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
#include "CompactSchemeFixupRoots.hpp"
23
24
#include "objectdescription.h"
25
26
#include "Base.hpp"
27
#include "ConfigurationDelegate.hpp"
28
#include "EnvironmentBase.hpp"
29
#include "FinalizableObjectBuffer.hpp"
30
#include "FinalizableReferenceBuffer.hpp"
31
#include "FinalizeListManager.hpp"
32
#include "GCExtensions.hpp"
33
#include "Heap.hpp"
34
#include "HeapRegionIteratorStandard.hpp"
35
#include "ObjectAccessBarrier.hpp"
36
#include "Task.hpp"
37
#include "UnfinalizedObjectBuffer.hpp"
38
#include "UnfinalizedObjectList.hpp"
39
40
41
#if defined(J9VM_GC_FINALIZATION)
42
void
43
MM_CompactSchemeFixupRoots::fixupFinalizableObjects(MM_EnvironmentBase *env)
44
{
45
MM_GCExtensions* extensions = MM_GCExtensions::getExtensions(env);
46
GC_FinalizeListManager * finalizeListManager = extensions->finalizeListManager;
47
48
{
49
GC_FinalizableObjectBuffer objectBuffer(extensions);
50
/* walk finalizable objects loaded by the system class loader */
51
omrobjectptr_t systemObject = finalizeListManager->resetSystemFinalizableObjects();
52
while (NULL != systemObject) {
53
omrobjectptr_t forwardedPtr = _compactScheme->getForwardingPtr(systemObject);
54
/* read the next link out of the moved copy of the object before we add it to the buffer */
55
systemObject = extensions->accessBarrier->getFinalizeLink(forwardedPtr);
56
/* store the object in this thread's buffer. It will be flushed to the appropriate list when necessary. */
57
objectBuffer.add(env, forwardedPtr);
58
}
59
objectBuffer.flush(env);
60
}
61
62
{
63
GC_FinalizableObjectBuffer objectBuffer(extensions);
64
/* walk finalizable objects loaded by the all other class loaders */
65
omrobjectptr_t defaultObject = finalizeListManager->resetDefaultFinalizableObjects();
66
while (NULL != defaultObject) {
67
omrobjectptr_t forwardedPtr = _compactScheme->getForwardingPtr(defaultObject);
68
/* read the next link out of the moved copy of the object before we add it to the buffer */
69
defaultObject = extensions->accessBarrier->getFinalizeLink(forwardedPtr);
70
/* store the object in this thread's buffer. It will be flushed to the appropriate list when necessary. */
71
objectBuffer.add(env, forwardedPtr);
72
}
73
objectBuffer.flush(env);
74
}
75
76
{
77
/* walk reference objects */
78
GC_FinalizableReferenceBuffer referenceBuffer(_extensions);
79
omrobjectptr_t referenceObject = finalizeListManager->resetReferenceObjects();
80
while (NULL != referenceObject) {
81
omrobjectptr_t forwardedPtr = _compactScheme->getForwardingPtr(referenceObject);
82
/* read the next link out of the moved copy of the object before we add it to the buffer */
83
referenceObject = _extensions->accessBarrier->getReferenceLink(forwardedPtr);
84
/* store the object in this thread's buffer. It will be flushed to the appropriate list when necessary. */
85
referenceBuffer.add(env, forwardedPtr);
86
}
87
referenceBuffer.flush(env);
88
}
89
}
90
91
void
92
MM_CompactSchemeFixupRoots::fixupUnfinalizedObjects(MM_EnvironmentBase *env)
93
{
94
MM_GCExtensions* extensions = MM_GCExtensions::getExtensions(env);
95
if (env->_currentTask->synchronizeGCThreadsAndReleaseMain(env, UNIQUE_ID)) {
96
MM_HeapRegionDescriptorStandard *region = NULL;
97
GC_HeapRegionIteratorStandard regionIterator(extensions->getHeap()->getHeapRegionManager());
98
while(NULL != (region = regionIterator.nextRegion())) {
99
MM_HeapRegionDescriptorStandardExtension *regionExtension = MM_ConfigurationDelegate::getHeapRegionDescriptorStandardExtension(env, region);
100
for (UDATA i = 0; i < regionExtension->_maxListIndex; i++) {
101
MM_UnfinalizedObjectList *list = &regionExtension->_unfinalizedObjectLists[i];
102
list->startUnfinalizedProcessing();
103
}
104
}
105
env->_currentTask->releaseSynchronizedGCThreads(env);
106
}
107
MM_HeapRegionDescriptorStandard *region = NULL;
108
GC_HeapRegionIteratorStandard regionIterator(extensions->getHeap()->getHeapRegionManager());
109
while(NULL != (region = regionIterator.nextRegion())) {
110
MM_HeapRegionDescriptorStandardExtension *regionExtension = MM_ConfigurationDelegate::getHeapRegionDescriptorStandardExtension(env, region);
111
for (UDATA i = 0; i < regionExtension->_maxListIndex; i++) {
112
MM_UnfinalizedObjectList *list = &regionExtension->_unfinalizedObjectLists[i];
113
if (!list->wasEmpty()) {
114
if(J9MODRON_HANDLE_NEXT_WORK_UNIT(env)) {
115
omrobjectptr_t object = list->getPriorList();
116
while (NULL != object) {
117
omrobjectptr_t forwardedPtr = _compactScheme->getForwardingPtr(object);
118
/* read the next link out of the moved copy of the object before we add it to the buffer */
119
object = extensions->accessBarrier->getFinalizeLink(forwardedPtr);
120
/* store the object in this thread's buffer. It will be flushed to the appropriate list when necessary. */
121
env->getGCEnvironment()->_unfinalizedObjectBuffer->add(env, forwardedPtr);
122
}
123
}
124
}
125
}
126
}
127
128
/* restore everything to a flushed state before exiting */
129
env->getGCEnvironment()->_unfinalizedObjectBuffer->flush(env);
130
}
131
#endif /* J9VM_GC_FINALIZATION */
132
133