Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/env/J9ObjectModel.hpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2022 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
#ifndef J9_OBJECTMODEL_INCL
24
#define J9_OBJECTMODEL_INCL
25
26
/*
27
* The following #define and typedef must appear before any #includes in this file
28
*/
29
#ifndef J9_OBJECTMODEL_CONNECTOR
30
#define J9_OBJECTMODEL_CONNECTOR
31
namespace J9 { class ObjectModel; }
32
namespace J9 { typedef J9::ObjectModel ObjectModelConnector; }
33
#endif
34
35
#include "env/OMRObjectModel.hpp"
36
37
#include <stdint.h>
38
#include "env/jittypes.h"
39
40
namespace TR { class Node; }
41
namespace TR { class Compilation; }
42
43
namespace J9
44
{
45
46
class ObjectModel : public OMR::ObjectModelConnector
47
{
48
public:
49
50
ObjectModel() :
51
OMR::ObjectModelConnector(),
52
_compressObjectReferences(false),
53
_usesDiscontiguousArraylets(false),
54
_arrayLetLeafSize(0),
55
_arrayLetLeafLogSize(0),
56
_readBarrierType(gc_modron_readbar_none),
57
_writeBarrierType(gc_modron_wrtbar_none),
58
_objectAlignmentInBytes(0)
59
{}
60
61
void initialize();
62
63
bool mayRequireSpineChecks();
64
65
bool areValueTypesEnabled();
66
/**
67
* @brief Whether the check is enabled on monitor object being value based class type
68
*/
69
bool areValueBasedMonitorChecksEnabled();
70
71
int32_t sizeofReferenceField();
72
bool isHotReferenceFieldRequired();
73
uintptr_t elementSizeOfBooleanArray();
74
uint32_t getSizeOfArrayElement(TR::Node *node);
75
int64_t maxArraySizeInElementsForAllocation(TR::Node *newArray, TR::Compilation *comp);
76
int64_t maxArraySizeInElements(int32_t knownMinElementSize, TR::Compilation *comp);
77
78
int32_t maxContiguousArraySizeInBytes();
79
80
uintptr_t contiguousArrayHeaderSizeInBytes();
81
82
uintptr_t discontiguousArrayHeaderSizeInBytes();
83
84
// For array access
85
bool isDiscontiguousArray(int32_t sizeInBytes);
86
bool isDiscontiguousArray(int32_t sizeInElements, int32_t elementSize);
87
bool isDiscontiguousArray(TR::Compilation* comp, uintptr_t objectPointer);
88
intptr_t getArrayLengthInElements(TR::Compilation* comp, uintptr_t objectPointer);
89
uintptr_t getArrayLengthInBytes(TR::Compilation* comp, uintptr_t objectPointer);
90
uintptr_t getArrayElementWidthInBytes(TR::DataType type);
91
uintptr_t getArrayElementWidthInBytes(TR::Compilation* comp, uintptr_t objectPointer);
92
uintptr_t getAddressOfElement(TR::Compilation* comp, uintptr_t objectPointer, int64_t offset);
93
uintptr_t decompressReference(TR::Compilation* comp, uintptr_t compressedReference);
94
95
bool generateCompressedObjectHeaders();
96
97
bool usesDiscontiguousArraylets();
98
bool canGenerateArraylets() { return usesDiscontiguousArraylets(); }
99
bool useHybridArraylets() { return usesDiscontiguousArraylets(); }
100
int32_t arrayletLeafSize();
101
int32_t arrayletLeafLogSize();
102
103
int32_t compressedReferenceShiftOffset();
104
int32_t compressedReferenceShift();
105
106
bool nativeAddressesCanChangeSize();
107
108
uintptr_t offsetOfObjectVftField();
109
110
uintptr_t offsetOfHeaderFlags();
111
112
uintptr_t maskOfObjectVftField();
113
114
int32_t arraySpineShift(int32_t width);
115
int32_t arrayletMask(int32_t width);
116
int32_t arrayletLeafIndex(int32_t index, int32_t elementSize);
117
int32_t objectAlignmentInBytes();
118
uintptr_t offsetOfContiguousArraySizeField();
119
uintptr_t offsetOfDiscontiguousArraySizeField();
120
uintptr_t objectHeaderSizeInBytes();
121
uintptr_t offsetOfIndexableSizeField();
122
#if defined(TR_TARGET_64BIT)
123
uintptr_t offsetOfContiguousDataAddrField();
124
uintptr_t offsetOfDiscontiguousDataAddrField();
125
#endif /* TR_TARGET_64BIT */
126
127
/**
128
* @brief Returns the read barrier type of VM's GC
129
*/
130
MM_GCReadBarrierType readBarrierType();
131
132
/**
133
* @brief Returns the write barrier type of VM's GC
134
*/
135
MM_GCWriteBarrierType writeBarrierType();
136
137
/**
138
* @brief Returns whether or not object references are compressed
139
*/
140
bool compressObjectReferences();
141
142
int32_t getObjectAlignmentInBytes();
143
144
private:
145
146
bool _compressObjectReferences;
147
bool _usesDiscontiguousArraylets;
148
int32_t _arrayLetLeafSize;
149
int32_t _arrayLetLeafLogSize;
150
MM_GCReadBarrierType _readBarrierType;
151
MM_GCWriteBarrierType _writeBarrierType;
152
int32_t _objectAlignmentInBytes;
153
};
154
155
}
156
157
#endif
158
159