Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_glue_java/CompactDelegate.cpp
5990 views
1
2
/*******************************************************************************
3
* Copyright (c) 2017, 2020 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
#include "CompactDelegate.hpp"
25
#include "CompactSchemeCheckMarkRoots.hpp"
26
#include "CompactSchemeFixupRoots.hpp"
27
#include "ConfigurationDelegate.hpp"
28
#include "HeapMapIterator.hpp"
29
#include "HeapRegionDescriptorStandard.hpp"
30
#include "HeapRegionIteratorStandard.hpp"
31
#include "MarkMap.hpp"
32
#include "OwnableSynchronizerObjectBuffer.hpp"
33
#include "OwnableSynchronizerObjectList.hpp"
34
#include "PointerContiguousArrayIterator.hpp"
35
36
#if defined(OMR_GC_MODRON_COMPACTION)
37
bool
38
MM_CompactDelegate::initialize(MM_EnvironmentBase *env, OMR_VM *omrVM, MM_MarkMap *markMap, MM_CompactScheme *compactScheme)
39
{
40
_omrVM = omrVM;
41
_compactScheme = compactScheme;
42
_markMap = markMap;
43
return true;
44
}
45
46
/**
47
* Free any internal structures associated to the receiver.
48
*/
49
void
50
MM_CompactDelegate::tearDown(MM_EnvironmentBase *env)
51
{
52
53
}
54
55
void
56
MM_CompactDelegate::verifyHeap(MM_EnvironmentBase *env, MM_MarkMap *markMap)
57
{
58
MM_GCExtensionsBase *extensions = env->getExtensions();
59
MM_CompactSchemeCheckMarkRoots rootChecker(MM_EnvironmentStandard::getEnvironment(env));
60
rootChecker.scanAllSlots(env);
61
62
/* Check that the heap alignment is as compaction expects it. Compaction
63
* expects that the heap will split into a whole number of pages where
64
* each pages maps to 2 mark bit slots so heap alignment needs to be a multiple
65
* of the compaction page size
66
*/
67
assume0(extensions->heapAlignment % (2 * J9BITS_BITS_IN_SLOT * sizeof(UDATA)) == 0);
68
69
MM_HeapRegionManager *regionManager = env->getExtensions()->getHeap()->getHeapRegionManager();
70
GC_HeapRegionIteratorStandard regionIterator(regionManager);
71
MM_HeapRegionDescriptorStandard *region = NULL;
72
73
while(NULL != (region = regionIterator.nextRegion())) {
74
void *lowAddress = region->getLowAddress();
75
void *highAddress = region->getHighAddress();
76
MM_HeapMapIterator markedObjectIterator(extensions, markMap, (UDATA *)lowAddress, (UDATA *)highAddress);
77
78
omrobjectptr_t objectPtr = NULL;
79
while (NULL != (objectPtr = markedObjectIterator.nextObject())) {
80
switch(extensions->objectModel.getScanType(objectPtr)) {
81
case GC_ObjectModel::SCAN_MIXED_OBJECT_LINKED:
82
case GC_ObjectModel::SCAN_ATOMIC_MARKABLE_REFERENCE_OBJECT:
83
case GC_ObjectModel::SCAN_MIXED_OBJECT:
84
case GC_ObjectModel::SCAN_OWNABLESYNCHRONIZER_OBJECT:
85
case GC_ObjectModel::SCAN_CLASS_OBJECT:
86
case GC_ObjectModel::SCAN_CLASSLOADER_OBJECT:
87
case GC_ObjectModel::SCAN_REFERENCE_MIXED_OBJECT:
88
{
89
GC_MixedObjectIterator it(_omrVM, objectPtr);
90
while (GC_SlotObject* slotObject = it.nextSlot()) {
91
if ((slotObject->readReferenceFromSlot() >= extensions->getHeap()->getHeapBase()) && (slotObject->readReferenceFromSlot() < extensions->getHeap()->getHeapTop())) {
92
Assert_MM_true (markMap->isBitSet(slotObject->readReferenceFromSlot()));
93
}
94
}
95
break;
96
}
97
98
case GC_ObjectModel::SCAN_POINTER_ARRAY_OBJECT:
99
{
100
GC_PointerContiguousArrayIterator it(_omrVM, objectPtr);
101
while (GC_SlotObject* slotObject = it.nextSlot()) {
102
if ((slotObject->readReferenceFromSlot() >= extensions->getHeap()->getHeapBase()) && (slotObject->readReferenceFromSlot() < extensions->getHeap()->getHeapTop())) {
103
Assert_MM_true (markMap->isBitSet(slotObject->readReferenceFromSlot()));
104
}
105
}
106
break;
107
}
108
109
case GC_ObjectModel::SCAN_PRIMITIVE_ARRAY_OBJECT:
110
/* nothing to do */
111
break;
112
113
default:
114
Assert_MM_unreachable();
115
}
116
}
117
}
118
}
119
120
void
121
MM_CompactDelegate::fixupRoots(MM_EnvironmentBase *env, MM_CompactScheme *compactScheme)
122
{
123
MM_CompactSchemeFixupRoots rootScanner(env, compactScheme);
124
rootScanner.scanAllSlots(env);
125
}
126
127
void
128
MM_CompactDelegate::workerCleanupAfterGC(MM_EnvironmentBase *env)
129
{
130
/* flush ownable synchronizer object buffer after rebuild the ownableSynchronizerObjectList during fixupObjects */
131
env->getGCEnvironment()->_ownableSynchronizerObjectBuffer->flush(env);
132
}
133
134
void
135
MM_CompactDelegate::mainSetupForGC(MM_EnvironmentBase *env)
136
{
137
MM_GCExtensionsBase *extensions = env->getExtensions();
138
MM_HeapRegionDescriptorStandard *region = NULL;
139
GC_HeapRegionIteratorStandard regionIterator(extensions->getHeap()->getHeapRegionManager());
140
while (NULL != (region = regionIterator.nextRegion())) {
141
MM_HeapRegionDescriptorStandardExtension *regionExtension = MM_ConfigurationDelegate::getHeapRegionDescriptorStandardExtension(env, region);
142
for (uintptr_t i = 0; i < regionExtension->_maxListIndex; i++) {
143
MM_OwnableSynchronizerObjectList *list = &regionExtension->_ownableSynchronizerObjectLists[i];
144
list->startOwnableSynchronizerProcessing();
145
}
146
}
147
}
148
149
#endif /* OMR_GC_MODRON_COMPACTION */
150
151