Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_base/IndexableObjectAllocationModel.hpp
5986 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 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
#if !defined(INDEXABLEOBJECTALLOCATIONMODEL_HPP_)
25
#define INDEXABLEOBJECTALLOCATIONMODEL_HPP_
26
27
#include "j9.h"
28
#include "j9cfg.h"
29
#include "modron.h"
30
#include "objectdescription.h"
31
#include "ModronAssertions.h"
32
33
#include "ArrayletObjectModel.hpp"
34
#include "JavaObjectAllocationModel.hpp"
35
#include "MemorySpace.hpp"
36
37
/**
38
* Class definition for the array object allocation model.
39
*/
40
class MM_IndexableObjectAllocationModel : public MM_JavaObjectAllocationModel
41
{
42
/*
43
* Member data and types
44
*/
45
private:
46
const uint32_t _numberOfIndexedFields;
47
const uintptr_t _dataSize;
48
const GC_ArrayletObjectModel::ArrayLayout _layout;
49
const bool _alignSpineDataSection;
50
const uintptr_t _numberOfArraylets;
51
52
protected:
53
54
public:
55
56
/*
57
* Member functions
58
*/
59
private:
60
/**
61
* For contiguous arraylet all data is subsumed into the spine.
62
* @return initialized arraylet spine with its arraylet pointers initialized.
63
*/
64
MMINLINE J9IndexableObject *layoutContiguousArraylet(MM_EnvironmentBase *env, J9IndexableObject *spine);
65
66
/**
67
* For non-contiguous arraylet (i.e. discontiguous and hybrid), perform separate allocations
68
* for spine and leaf data. The spine and attached leaves may move as each leaf is allocated
69
* is GC is allowed. The final location of the spine is returned.
70
* @return initialized arraylet spine with its arraylet pointers initialized.
71
*/
72
MMINLINE J9IndexableObject *layoutDiscontiguousArraylet(MM_EnvironmentBase *env, J9IndexableObject *spine);
73
74
protected:
75
76
public:
77
MM_IndexableObjectAllocationModel(MM_EnvironmentBase *env,
78
J9Class *clazz,
79
uint32_t numberOfIndexedFields,
80
uintptr_t allocateObjectFlags = 0
81
)
82
: MM_JavaObjectAllocationModel(env, clazz, allocation_category_indexable,
83
0, allocateObjectFlags | OMR_GC_ALLOCATE_OBJECT_INDEXABLE)
84
, _numberOfIndexedFields(numberOfIndexedFields)
85
, _dataSize(env->getExtensions()->indexableObjectModel.getDataSizeInBytes(_class, _numberOfIndexedFields))
86
, _layout(env->getExtensions()->indexableObjectModel.getArrayletLayout(_class, _dataSize,
87
_allocateDescription.getMemorySpace()->getDefaultMemorySubSpace()->largestDesirableArraySpine()))
88
, _alignSpineDataSection(env->getExtensions()->indexableObjectModel.shouldAlignSpineDataSection(_class))
89
, _numberOfArraylets(env->getExtensions()->indexableObjectModel.numArraylets(_dataSize))
90
{
91
/* check for overflow of _dataSize in indexableObjectModel.getDataSizeInBytes() */
92
if (J9_MAXIMUM_INDEXABLE_DATA_SIZE < _dataSize) {
93
J9VMThread *vmThread = (J9VMThread *)env->getLanguageVMThread();
94
switch (J9GC_CLASS_SHAPE(_class)) {
95
case OBJECT_HEADER_SHAPE_BYTES:
96
break;
97
case OBJECT_HEADER_SHAPE_WORDS:
98
Trc_MM_ShortArrayAllocationFailedDueToOverflow(vmThread, _numberOfIndexedFields);
99
break;
100
case OBJECT_HEADER_SHAPE_LONGS:
101
Trc_MM_IntArrayAllocationFailedDueToOverflow(vmThread, _numberOfIndexedFields);
102
break;
103
case OBJECT_HEADER_SHAPE_DOUBLES:
104
Trc_MM_DoubleArrayAllocationFailedDueToOverflow(vmThread, _numberOfIndexedFields);
105
break;
106
case OBJECT_HEADER_SHAPE_POINTERS:
107
Trc_MM_ObjectArrayAllocationFailedDueToOverflow(vmThread, _numberOfIndexedFields);
108
break;
109
default:
110
Assert_MM_unreachable();
111
break;
112
}
113
setAllocatable(false);
114
}
115
}
116
117
118
MMINLINE uint32_t getNumberOfIndexedFields() { return _numberOfIndexedFields; }
119
120
MMINLINE uintptr_t getNumberOfArraylets() { return _numberOfArraylets; }
121
122
/**
123
* Allocation description and layout initialization.
124
*/
125
bool initializeAllocateDescription(MM_EnvironmentBase *env);
126
127
#if defined(J9VM_GC_ENABLE_DOUBLE_MAP)
128
/**
129
* For non-contiguous arraylets (discontiguous arraylets, hybrid not allowed
130
* when double map is enabled), double maps the arraylet leaves to a contiguous
131
* region outside the heap, making a discontiguous arraylet look contiguous.
132
* Double map is enabled by default, if one wants to disable it, manually pass
133
* command line option -Xgc:disableArrayletDoubleMapping; however, if the
134
* system supports huge pages then double map will be disabled. That's because
135
* double map does support huge pages yet. If one still wants to enable double
136
* map in such systems, one must manually force the application to use the
137
* small system page size
138
*
139
* @param env thread GC Environment
140
* @param objectPtr indexable object spine
141
* @return the contiguous address pointer
142
*/
143
void *doubleMapArraylets(MM_EnvironmentBase *env, J9Object *objectPtr, void *preferredAddress);
144
#endif /* J9VM_GC_ENABLE_DOUBLE_MAP */
145
146
/**
147
* Initializer.
148
*/
149
omrobjectptr_t initializeIndexableObject(MM_EnvironmentBase *env, void *allocatedBytes);
150
};
151
152
#endif /* INDEXABLEOBJECTALLOCATIONMODEL_HPP_ */
153
154