Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_glue_java/ArrayletObjectModelBase.cpp
5985 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 "ArrayletObjectModelBase.hpp"
24
#include "GCExtensionsBase.hpp"
25
26
bool
27
GC_ArrayletObjectModelBase::initialize(MM_GCExtensionsBase * extensions)
28
{
29
#if defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS)
30
_compressObjectReferences = extensions->compressObjectReferences();
31
#endif /* defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS) */
32
_omrVM = extensions->getOmrVM();
33
_arrayletRangeBase = NULL;
34
_arrayletRangeTop = (void *)UDATA_MAX;
35
_arrayletSubSpace = NULL;
36
#if defined(J9VM_GC_ENABLE_DOUBLE_MAP)
37
_enableDoubleMapping = false;
38
#endif /* J9VM_GC_ENABLE_DOUBLE_MAP */
39
_largestDesirableArraySpineSize = UDATA_MAX;
40
41
return true;
42
}
43
44
void
45
GC_ArrayletObjectModelBase::tearDown(MM_GCExtensionsBase * extensions)
46
{
47
48
/* ensure that we catch any invalid uses during shutdown */
49
_omrVM = NULL;
50
_arrayletRangeTop = NULL;
51
_arrayletSubSpace = NULL;
52
_arrayletRangeBase = 0;
53
_largestDesirableArraySpineSize = 0;
54
}
55
56
57
void
58
GC_ArrayletObjectModelBase::expandArrayletSubSpaceRange(MM_MemorySubSpace * subSpace, void * rangeBase, void * rangeTop, UDATA largestDesirableArraySpineSize)
59
{
60
/* Is this the first expand? */
61
if(NULL == _arrayletSubSpace) {
62
_arrayletRangeBase = rangeBase;
63
_arrayletRangeTop = rangeTop;
64
_arrayletSubSpace = subSpace;
65
_largestDesirableArraySpineSize = largestDesirableArraySpineSize;
66
} else {
67
/* Expand the valid range for arraylets. */
68
if (rangeBase < _arrayletRangeBase) {
69
_arrayletRangeBase = rangeBase;
70
}
71
if (rangeTop > _arrayletRangeTop) {
72
_arrayletRangeTop = rangeTop;
73
}
74
}
75
}
76
77
UDATA
78
GC_ArrayletObjectModelBase::getSpineSizeWithoutHeader(ArrayLayout layout, UDATA numberArraylets, UDATA dataSize, bool alignData)
79
{
80
/* The spine consists of three (possibly empty) sections, not including the header:
81
* 1. the alignment word - padding between arrayoid and inline-data
82
* 2. the arrayoid - an array of pointers to the leaves
83
* 3. in-line data
84
* In hybrid specs, the spine may also include padding for a secondary size field in empty arrays
85
*/
86
UDATA const slotSize = J9GC_REFERENCE_SIZE(this);
87
MM_GCExtensionsBase* extensions = MM_GCExtensionsBase::getExtensions(_omrVM);
88
UDATA spineArrayoidSize = 0;
89
UDATA spinePaddingSize = 0;
90
if (InlineContiguous != layout) {
91
if (0 != dataSize) {
92
/* not in-line, so there in an arrayoid */
93
spinePaddingSize = alignData ? (extensions->getObjectAlignmentInBytes() - slotSize) : 0;
94
spineArrayoidSize = numberArraylets * slotSize;
95
}
96
}
97
UDATA spineDataSize = 0;
98
if (InlineContiguous == layout) {
99
spineDataSize = dataSize; // All data in spine
100
} else if (Hybrid == layout) {
101
#if defined(J9VM_GC_ENABLE_DOUBLE_MAP)
102
if (extensions->indexableObjectModel.isDoubleMappingEnabled()) {
103
spineDataSize = 0;
104
} else
105
#endif /* J9VM_GC_ENABLE_DOUBLE_MAP */
106
{
107
/* Last arraylet in spine */
108
spineDataSize = (dataSize & (_omrVM->_arrayletLeafSize - 1));
109
}
110
}
111
112
return spinePaddingSize + spineArrayoidSize + spineDataSize;
113
}
114
115