Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_glue_java/MixedObjectModel.hpp
5990 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
#if !defined(MIXEDOBJECTMODEL_HPP_)
24
#define MIXEDOBJECTMODEL_HPP_
25
26
#include "j9.h"
27
#include "j9cfg.h"
28
#include "modron.h"
29
#include "objectdescription.h"
30
31
#include "Bits.hpp"
32
33
class MM_GCExtensionsBase;
34
35
/**
36
* Provides information for mixed objects.
37
* @ingroup GC_Base
38
*/
39
class GC_MixedObjectModel
40
{
41
42
/*
43
* Data members
44
*/
45
private:
46
protected:
47
#if defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS)
48
bool _compressObjectReferences;
49
#endif /* defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS) */
50
public:
51
52
/*
53
* Function members
54
*/
55
private:
56
protected:
57
public:
58
/**
59
* Return back true if object references are compressed
60
* @return true, if object references are compressed
61
*/
62
MMINLINE bool
63
compressObjectReferences()
64
{
65
return OMR_COMPRESS_OBJECT_REFERENCES(_compressObjectReferences);
66
}
67
68
/**
69
* Returns the size of a class, in bytes, excluding the header.
70
* @param clazzPtr Pointer to the class whose size is required
71
* @return Size of class in bytes excluding the header
72
*/
73
MMINLINE UDATA
74
getSizeInBytesWithoutHeader(J9Class *clazz)
75
{
76
return clazz->totalInstanceSize;
77
}
78
79
/**
80
* Returns the size of a mixed object, in bytes, excluding the header.
81
* @param objectPtr Pointer to the object whose size is required
82
* @return Size of object in bytes excluding the header
83
*/
84
MMINLINE UDATA
85
getSizeInBytesWithoutHeader(J9Object *objectPtr)
86
{
87
return getSizeInBytesWithoutHeader(J9GC_J9OBJECT_CLAZZ(objectPtr, this));
88
}
89
90
/**
91
* Returns the size of a mixed object, in bytes, including the header.
92
* @param objectPtr Pointer to the object whose size is required
93
* @return Size of object in bytes including the header
94
*/
95
MMINLINE UDATA
96
getSizeInBytesWithHeader(J9Object *objectPtr)
97
{
98
return getSizeInBytesWithoutHeader(objectPtr) + getHeaderSize(objectPtr);
99
}
100
101
/**
102
* Returns an address of first data slot of the object
103
* @param objectPtr Pointer to the object
104
* @return Address of first data slot of the object
105
*/
106
MMINLINE fomrobject_t *
107
getHeadlessObject(J9Object *objectPtr)
108
{
109
return (fomrobject_t *)((uint8_t*)objectPtr + getHeaderSize(objectPtr));
110
}
111
112
/**
113
* Returns the header size of a given object.
114
* @param arrayPtr Ptr to an array for which header size will be returned
115
* @return Size of header in bytes
116
*/
117
MMINLINE UDATA
118
getHeaderSize(J9Object *objectPtr)
119
{
120
return J9GC_OBJECT_HEADER_SIZE(this);
121
}
122
123
/**
124
* Returns the offset of the hashcode slot, in bytes, from the beginning of the header.
125
* @param clazzPtr Pointer to the class of the object
126
* @return offset of the hashcode slot
127
*/
128
MMINLINE UDATA
129
getHashcodeOffset(J9Class *clazzPtr)
130
{
131
return clazzPtr->backfillOffset;
132
}
133
134
/**
135
* Returns the offset of the hashcode slot, in bytes, from the beginning of the header.
136
* @param arrayPtr Pointer to the object
137
* @return offset of the hashcode slot
138
*/
139
MMINLINE UDATA
140
getHashcodeOffset(J9Object *objectPtr)
141
{
142
return getHashcodeOffset(J9GC_J9OBJECT_CLAZZ(objectPtr, this));
143
}
144
145
/**
146
* Initialize the receiver, a new instance of GC_ObjectModel
147
*
148
* @return true on success, false on failure
149
*/
150
bool initialize(MM_GCExtensionsBase *extensions);
151
152
/**
153
* Tear down the receiver
154
*/
155
void tearDown(MM_GCExtensionsBase *extensions);
156
};
157
158
#endif /* MIXEDOBJECTMODEL_HPP_ */
159
160