Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_base/JavaObjectAllocationModel.hpp
5991 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2018 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(JAVAOBJECTALLOCATIONMODEL_HPP_)
25
#define JAVAOBJECTALLOCATIONMODEL_HPP_
26
27
#include "j9.h"
28
#include "j9cfg.h"
29
#include "objectdescription.h"
30
#include "modron.h"
31
32
#include "AllocateInitialization.hpp"
33
#include "ObjectAccessBarrier.hpp"
34
35
/**
36
* Class definition for the Java object allocation model.
37
*/
38
class MM_JavaObjectAllocationModel : public MM_AllocateInitialization
39
{
40
/*
41
* Member data and types
42
*/
43
public:
44
/**
45
* Define object allocation categories. These are represented in MM_AllocateInitialization
46
* objects and are used in GC_ObjectModel::initializeAllocation() to determine how to
47
* initialize the header of a newly allocated object.
48
*/
49
enum {
50
allocation_category_mixed
51
, allocation_category_indexable
52
};
53
54
protected:
55
J9Class *_class;
56
57
private:
58
59
/*
60
* Member functions
61
*/
62
private:
63
64
MMINLINE J9Class *getClass() { return J9_CURRENT_CLASS(_class); }
65
66
protected:
67
68
public:
69
70
/**
71
* Initializer.
72
*/
73
MMINLINE omrobjectptr_t
74
initializeJavaObject(MM_EnvironmentBase *env, void *allocatedBytes)
75
{
76
omrobjectptr_t objectPtr = (omrobjectptr_t)allocatedBytes;
77
78
if (NULL != objectPtr) {
79
/* Initialize class pointer in object header -- preserve flags set by base class */
80
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env);
81
extensions->objectModel.setObjectClass(objectPtr, getClass());
82
83
/* This might set the remembered bit in the header flags ... */
84
J9VMThread *vmThread = (J9VMThread *)env->getOmrVMThread()->_language_vmthread;
85
extensions->accessBarrier->recentlyAllocatedObject(vmThread, objectPtr);
86
}
87
88
return objectPtr;
89
}
90
91
/**
92
* Constructor.
93
*/
94
MM_JavaObjectAllocationModel(MM_EnvironmentBase *env,
95
J9Class *clazz,
96
uintptr_t allocationCategory,
97
uintptr_t requiredSizeInBytes,
98
uintptr_t allocateObjectFlags = 0
99
)
100
: MM_AllocateInitialization(env, allocationCategory, requiredSizeInBytes, allocateObjectFlags)
101
, _class(clazz)
102
{}
103
};
104
#endif /* JAVAOBJECTALLOCATIONMODEL_HPP_ */
105
106