Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_glue_java/MixedObjectScanner.hpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 2016, 2020 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
/**
24
* @file
25
* @ingroup GC_Structs
26
*/
27
28
#if !defined(MIXEDOBJECTSCANNER_HPP_)
29
#define MIXEDOBJECTSCANNER_HPP_
30
31
#include "j9.h"
32
#include "j9cfg.h"
33
#include "modron.h"
34
#include "objectdescription.h"
35
#include "GCExtensions.hpp"
36
#include "HeadlessMixedObjectScanner.hpp"
37
38
/**
39
* This class is used to iterate over the slots of a Java object.
40
*/
41
class GC_MixedObjectScanner : public GC_HeadlessMixedObjectScanner
42
{
43
44
/* Data Members */
45
private:
46
47
protected:
48
49
public:
50
51
/* Member Functions */
52
private:
53
protected:
54
/**
55
* @param env The scanning thread environment
56
* @param objectPtr the object to be processed
57
* @param flags Scanning context flags
58
*/
59
MMINLINE GC_MixedObjectScanner(MM_EnvironmentBase *env, omrobjectptr_t objectPtr, uintptr_t flags)
60
: GC_HeadlessMixedObjectScanner(env, env->getExtensions()->mixedObjectModel.getHeadlessObject(objectPtr), env->getExtensions()->mixedObjectModel.getSizeInBytesWithoutHeader(J9GC_J9OBJECT_CLAZZ(objectPtr, env)), flags)
61
{
62
_typeId = __FUNCTION__;
63
}
64
65
/**
66
* Subclasses must call this method to set up the instance description bits and description pointer.
67
* @param[in] env The scanning thread environment
68
*/
69
MMINLINE void
70
initialize(MM_EnvironmentBase *env, J9Class *clazzPtr)
71
{
72
#if defined(J9VM_GC_LEAF_BITS)
73
GC_HeadlessMixedObjectScanner::initialize(env, clazzPtr->instanceDescription, clazzPtr->instanceLeafDescription);
74
#else /* J9VM_GC_LEAF_BITS */
75
GC_HeadlessMixedObjectScanner::initialize(env, clazzPtr->instanceDescription);
76
#endif /* J9VM_GC_LEAF_BITS */
77
}
78
79
public:
80
/**
81
* In-place instantiation and initialization for mixed object scanner.
82
* @param[in] env The scanning thread environment
83
* @param[in] objectPtr The object to scan
84
* @param[in] allocSpace Pointer to space for in-place instantiation (at least sizeof(GC_MixedObjectScanner) bytes)
85
* @param[in] flags Scanning context flags
86
* @return Pointer to GC_MixedObjectScanner instance in allocSpace
87
*/
88
MMINLINE static GC_MixedObjectScanner *
89
newInstance(MM_EnvironmentBase *env, omrobjectptr_t objectPtr, void *allocSpace, uintptr_t flags)
90
{
91
GC_MixedObjectScanner *objectScanner = (GC_MixedObjectScanner *)allocSpace;
92
J9Class *classPtr = J9GC_J9OBJECT_CLAZZ(objectPtr, env);
93
94
new(objectScanner) GC_MixedObjectScanner(env, objectPtr, flags);
95
objectScanner->initialize(env, classPtr);
96
return objectScanner;
97
}
98
};
99
#endif /* MIXEDOBJECTSCANNER_HPP_ */
100
101