Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_vlhgc/CopyForwardDelegate.cpp
5986 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 "j9.h"
24
#include "j9cfg.h"
25
26
#include "CopyForwardDelegate.hpp"
27
28
#include "ClassLoaderManager.hpp"
29
#include "CompactGroupManager.hpp"
30
#include "CompactGroupPersistentStats.hpp"
31
#include "CycleState.hpp"
32
#include "FinalizerSupport.hpp"
33
#include "HeapRegionIteratorVLHGC.hpp"
34
#include "HeapRegionManager.hpp"
35
#include "MarkMap.hpp"
36
#include "MemorySubSpace.hpp"
37
#include "ObjectAllocationInterface.hpp"
38
39
MM_CopyForwardDelegate::MM_CopyForwardDelegate(MM_EnvironmentVLHGC *env)
40
: _javaVM((J9JavaVM *)env->getLanguageVM())
41
, _extensions(MM_GCExtensions::getExtensions(env))
42
, _breadthFirstCopyForwardScheme(NULL)
43
{
44
_typeId = __FUNCTION__;
45
}
46
47
bool
48
MM_CopyForwardDelegate::initialize(MM_EnvironmentVLHGC *env)
49
{
50
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env);
51
_breadthFirstCopyForwardScheme = MM_CopyForwardScheme::newInstance(env, extensions->heapRegionManager);
52
53
return (NULL != _breadthFirstCopyForwardScheme);
54
}
55
56
void
57
MM_CopyForwardDelegate::tearDown(MM_EnvironmentVLHGC *env)
58
{
59
if (NULL != _breadthFirstCopyForwardScheme) {
60
_breadthFirstCopyForwardScheme->kill(env);
61
_breadthFirstCopyForwardScheme = NULL;
62
}
63
}
64
65
void
66
MM_CopyForwardDelegate::performCopyForwardForPartialGC(MM_EnvironmentVLHGC *env)
67
{
68
#if defined(OMR_GC_VLHGC_CONCURRENT_COPY_FORWARD)
69
if (_extensions->isConcurrentCopyForwardEnabled())
70
{
71
_breadthFirstCopyForwardScheme->concurrentCopyForwardCollectionSet(env);
72
} else
73
#endif /* defined(OMR_GC_VLHGC_CONCURRENT_COPY_FORWARD) */
74
{
75
_breadthFirstCopyForwardScheme->copyForwardCollectionSet(env);
76
}
77
}
78
79
void
80
MM_CopyForwardDelegate::preCopyForwardSetup(MM_EnvironmentVLHGC *env)
81
{
82
}
83
84
void
85
MM_CopyForwardDelegate::postCopyForwardCleanup(MM_EnvironmentVLHGC *env)
86
{
87
/* Restart the allocation caches associated to all threads */
88
{
89
GC_VMThreadListIterator vmThreadListIterator(_javaVM);
90
J9VMThread *walkThread;
91
while((walkThread = vmThreadListIterator.nextVMThread()) != NULL) {
92
MM_EnvironmentBase *walkEnv = MM_EnvironmentBase::getEnvironment(walkThread->omrVMThread);
93
walkEnv->_objectAllocationInterface->restartCache(env);
94
}
95
}
96
}
97
98
99
UDATA
100
MM_CopyForwardDelegate::estimateRequiredSurvivorBytes(MM_EnvironmentVLHGC *env)
101
{
102
UDATA estimatedSurvivorRequired = 0;
103
MM_HeapRegionManager *const regionManager = _extensions->heapRegionManager;
104
MM_CompactGroupPersistentStats *const persistentStats = _extensions->compactGroupPersistentStats;
105
GC_HeapRegionIteratorVLHGC regionIterator(regionManager, MM_HeapRegionDescriptor::MANAGED);
106
MM_HeapRegionDescriptorVLHGC *region = NULL;
107
while (NULL != (region = regionIterator.nextRegion())) {
108
if (region->_markData._shouldMark) {
109
UDATA compactGroup = MM_CompactGroupManager::getCompactGroupNumber(env, region);
110
double survivalRate = persistentStats[compactGroup]._historicalSurvivalRate;
111
UDATA freeMemory = region->getMemoryPool()->getFreeMemoryAndDarkMatterBytes();
112
estimatedSurvivorRequired += (UDATA)((double)(region->getSize() - freeMemory) * survivalRate);
113
}
114
}
115
return estimatedSurvivorRequired;
116
}
117
118