Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/ilgen/J9IlGeneratorMethodDetails.hpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 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
#ifndef J9_ILGENERATOR_METHOD_DETAILS_INCL
24
#define J9_ILGENERATOR_METHOD_DETAILS_INCL
25
26
/*
27
* The following #define and typedef must appear before any #includes in this file
28
*/
29
#ifndef J9_ILGENERATOR_METHOD_DETAILS_CONNECTOR
30
#define J9_ILGENERATOR_METHOD_DETAILS_CONNECTOR
31
namespace J9 { class IlGeneratorMethodDetails; }
32
namespace J9 { typedef J9::IlGeneratorMethodDetails IlGeneratorMethodDetailsConnector; }
33
#endif
34
35
#include "ilgen/OMRIlGeneratorMethodDetails.hpp"
36
37
#include <stdint.h>
38
#include "control/Options.hpp"
39
#include "env/IO.hpp"
40
#include "env/jittypes.h"
41
#include "infra/Annotations.hpp"
42
43
class J9Class;
44
class J9Method;
45
class J9ROMClass;
46
class J9ROMMethod;
47
class TR_FrontEnd;
48
class TR_IlGenerator;
49
class TR_InlineBlocks;
50
class TR_J9VMBase;
51
class TR_ResolvedMethod;
52
namespace TR { class Compilation; }
53
namespace TR { class IlGeneratorMethodDetails; }
54
namespace TR { class ResolvedMethodSymbol; }
55
namespace TR { class SymbolReferenceTable;}
56
57
namespace J9
58
{
59
#if defined(J9VM_OPT_JITSERVER)
60
enum IlGeneratorMethodDetailsType
61
{
62
EMPTY = 0,
63
ORDINARY_METHOD = 1<<0,
64
DUMP_METHOD = 1<<1,
65
NEW_INSTANCE_THUNK = 1<<2,
66
METHOD_IN_PROGRESS = 1<<3,
67
ARCHETYPE_SPECIMEN = 1<<4,
68
METHOD_HANDLE_THUNK = 1<<5,
69
SHAREABLE_THUNK = 1<<6,
70
CUSTOM_THUNK = 1<<7,
71
};
72
#endif /* defined(J9VM_OPT_JITSERVER) */
73
74
class OMR_EXTENSIBLE IlGeneratorMethodDetails : public OMR::IlGeneratorMethodDetailsConnector
75
{
76
friend class IlGeneratorMethodDetailsOverrideForReplay;
77
78
public:
79
IlGeneratorMethodDetails() :
80
OMR::IlGeneratorMethodDetailsConnector()
81
{
82
_method = NULL;
83
}
84
85
IlGeneratorMethodDetails(J9Method* method) :
86
OMR::IlGeneratorMethodDetailsConnector(),
87
_method(method)
88
{ }
89
90
IlGeneratorMethodDetails(TR_ResolvedMethod *method);
91
92
IlGeneratorMethodDetails(const TR::IlGeneratorMethodDetails & other);
93
94
static TR::IlGeneratorMethodDetails & create(TR::IlGeneratorMethodDetails & target, TR_ResolvedMethod *method);
95
96
static TR::IlGeneratorMethodDetails * clone(TR::IlGeneratorMethodDetails & storage, const TR::IlGeneratorMethodDetails & other);
97
98
#if defined(J9VM_OPT_JITSERVER)
99
// Constructs a new IlGeneratorMethodDetails object of given type based on an existing TR::IlGeneratorMethodDetails object (other).
100
// The existing TR::IlGeneratorMethodDetails object (other) is obtained through de-serialization. It is missing the vtable pointer.
101
// Therefore the new object instance type cannot be determined through the virtual function calls such as other.isOrdinaryMethod(), etc.
102
static TR::IlGeneratorMethodDetails * clone(TR::IlGeneratorMethodDetails & storage, const TR::IlGeneratorMethodDetails & other, const IlGeneratorMethodDetailsType type);
103
#endif /* defined(J9VM_OPT_JITSERVER) */
104
105
virtual const char * name() const { return "OrdinaryMethod"; }
106
107
virtual bool isOrdinaryMethod() const { return true; }
108
virtual bool isJitDumpMethod() const { return false; }
109
virtual bool isJitDumpAOTMethod() const { return false; }
110
virtual bool isNewInstanceThunk() const { return false; }
111
virtual bool isMethodInProgress() const { return false; }
112
virtual bool isArchetypeSpecimen() const { return false; }
113
virtual bool isMethodHandleThunk() const { return false; }
114
virtual bool supportsInvalidation() const { return true; }
115
116
J9Method *getMethod() const { return _method; }
117
virtual J9Class *getClass() const;
118
#if defined(J9VM_OPT_JITSERVER)
119
IlGeneratorMethodDetailsType getType() const;
120
#endif /* defined(J9VM_OPT_JITSERVER) */
121
virtual const J9ROMClass *getRomClass() const;
122
virtual const J9ROMMethod *getRomMethod(TR_J9VMBase *fe);
123
124
125
virtual TR_IlGenerator *getIlGenerator(TR::ResolvedMethodSymbol *methodSymbol,
126
TR_FrontEnd * fe,
127
TR::Compilation *comp,
128
TR::SymbolReferenceTable *symRefTab,
129
bool forceClassLookahead,
130
TR_InlineBlocks *blocksToInline);
131
132
virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe);
133
134
bool sameMethod(TR::IlGeneratorMethodDetails & other);
135
136
void print(TR_FrontEnd *fe, TR::FILE *file);
137
138
virtual void printDetails(TR_FrontEnd *fe, TR::FILE *file);
139
140
protected:
141
142
// All data across subclasses of IlGeneratorMethodDetails MUST be stored in the base class
143
// (using a union to save space across the hierarchy where possible)
144
// Primary reason is that an embedded instance of this class is stored in MethodToBeCompiled so that instance
145
// must be able to transmute itself into any kind of IlGeneratorMethodDetails in place (i.e. via placement new)
146
147
J9Method *_method;
148
union
149
{
150
J9Class *_class;
151
int32_t _byteCodeIndex;
152
struct
153
{
154
uintptr_t *_handleRef;
155
uintptr_t *_argRef;
156
} _methodHandleData;
157
bool _aotCompile;
158
} _data;
159
160
/// A cached options object from the original (crashed) compilation thread
161
TR::Options *_optionsFromOriginalCompile;
162
};
163
164
// Replay compilation support that must not be used by anyone else because it breaks encapsulation
165
//
166
class IlGeneratorMethodDetailsOverrideForReplay
167
{
168
public:
169
170
// When replay compilation initializes it needs to redirect the existing
171
// details object to compile the requested replay method.
172
//
173
static void changeMethod(TR::IlGeneratorMethodDetails & details, J9Method *newMethod);
174
};
175
176
177
178
179
}
180
181
#endif
182
183