Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_glue_java/CompactSchemeFixupObject.cpp
5990 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2021 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 "CompactSchemeFixupObject.hpp"
24
25
#include "objectdescription.h"
26
27
#include "CollectorLanguageInterfaceImpl.hpp"
28
#include "EnvironmentStandard.hpp"
29
#include "Debug.hpp"
30
#include "HeapRegionIteratorStandard.hpp"
31
#include "MixedObjectIterator.hpp"
32
#include "ObjectAccessBarrier.hpp"
33
#include "OwnableSynchronizerObjectBuffer.hpp"
34
#include "ParallelDispatcher.hpp"
35
#include "PointerContiguousArrayIterator.hpp"
36
#include "FlattenedContiguousArrayIterator.hpp"
37
#include "Task.hpp"
38
39
void
40
MM_CompactSchemeFixupObject::fixupMixedObject(omrobjectptr_t objectPtr)
41
{
42
GC_MixedObjectIterator it(_omrVM, objectPtr);
43
GC_SlotObject *slotObject;
44
45
while (NULL != (slotObject = it.nextSlot())) {
46
_compactScheme->fixupObjectSlot(slotObject);
47
}
48
}
49
50
void
51
MM_CompactSchemeFixupObject::fixupArrayObject(omrobjectptr_t objectPtr)
52
{
53
GC_PointerContiguousArrayIterator it(_omrVM, objectPtr);
54
GC_SlotObject *slotObject;
55
56
while (NULL != (slotObject = it.nextSlot())) {
57
_compactScheme->fixupObjectSlot(slotObject);
58
}
59
}
60
61
void
62
MM_CompactSchemeFixupObject::fixupFlattenedArrayObject(omrobjectptr_t objectPtr)
63
{
64
GC_FlattenedContiguousArrayIterator it(_omrVM, objectPtr);
65
GC_SlotObject *slotObject;
66
67
while (NULL != (slotObject = it.nextSlot())) {
68
_compactScheme->fixupObjectSlot(slotObject);
69
}
70
}
71
72
MMINLINE void
73
MM_CompactSchemeFixupObject::addOwnableSynchronizerObjectInList(MM_EnvironmentBase *env, omrobjectptr_t objectPtr)
74
{
75
/* if isObjectInOwnableSynchronizerList() return NULL, it means the object isn't in OwnableSynchronizerList,
76
* it could be the constructing object which would be added in the list after the construction finish later. ignore the object to avoid duplicated reference in the list. */
77
if (NULL != _extensions->accessBarrier->isObjectInOwnableSynchronizerList(objectPtr)) {
78
env->getGCEnvironment()->_ownableSynchronizerObjectBuffer->add(env, objectPtr);
79
}
80
}
81
82
void
83
MM_CompactSchemeFixupObject::fixupObject(MM_EnvironmentStandard *env, omrobjectptr_t objectPtr)
84
{
85
switch(env->getExtensions()->objectModel.getScanType(objectPtr)) {
86
case GC_ObjectModel::SCAN_MIXED_OBJECT_LINKED:
87
case GC_ObjectModel::SCAN_ATOMIC_MARKABLE_REFERENCE_OBJECT:
88
case GC_ObjectModel::SCAN_MIXED_OBJECT:
89
case GC_ObjectModel::SCAN_CLASS_OBJECT:
90
case GC_ObjectModel::SCAN_CLASSLOADER_OBJECT:
91
case GC_ObjectModel::SCAN_REFERENCE_MIXED_OBJECT:
92
fixupMixedObject(objectPtr);
93
break;
94
95
case GC_ObjectModel::SCAN_POINTER_ARRAY_OBJECT:
96
fixupArrayObject(objectPtr);
97
break;
98
99
case GC_ObjectModel::SCAN_PRIMITIVE_ARRAY_OBJECT:
100
/* nothing to do */
101
break;
102
103
case GC_ObjectModel::SCAN_OWNABLESYNCHRONIZER_OBJECT:
104
addOwnableSynchronizerObjectInList(env, objectPtr);
105
fixupMixedObject(objectPtr);
106
break;
107
108
case GC_ObjectModel::SCAN_FLATTENED_ARRAY_OBJECT:
109
fixupFlattenedArrayObject(objectPtr);
110
break;
111
112
default:
113
Assert_MM_unreachable();
114
}
115
}
116
117
118
void
119
MM_CompactSchemeFixupObject::verifyForwardingPtr(omrobjectptr_t objectPtr, omrobjectptr_t forwardingPtr)
120
{
121
assume0(forwardingPtr <= objectPtr);
122
assume0(J9GC_J9OBJECT_CLAZZ(forwardingPtr, _extensions) && ((UDATA)J9GC_J9OBJECT_CLAZZ(forwardingPtr, _extensions) & 0x3) == 0);
123
}
124
125