Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/ilgen/IlGeneratorMethodDetails.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 TR_ILGENERATOR_METHOD_DETAILS_INCL
24
#define TR_ILGENERATOR_METHOD_DETAILS_INCL
25
26
#include "ilgen/J9IlGeneratorMethodDetails.hpp"
27
28
#include <stdint.h>
29
#include "env/IO.hpp"
30
#include "env/jittypes.h"
31
#include "infra/Annotations.hpp"
32
33
class TR_InlineBlocks;
34
35
namespace TR
36
{
37
38
class OMR_EXTENSIBLE IlGeneratorMethodDetails : public J9::IlGeneratorMethodDetailsConnector
39
{
40
41
public:
42
43
IlGeneratorMethodDetails() :
44
J9::IlGeneratorMethodDetailsConnector() {}
45
46
IlGeneratorMethodDetails(J9Method* method) :
47
J9::IlGeneratorMethodDetailsConnector(method) {}
48
49
IlGeneratorMethodDetails(TR_ResolvedMethod *method) :
50
J9::IlGeneratorMethodDetailsConnector(method) {}
51
52
IlGeneratorMethodDetails(const TR::IlGeneratorMethodDetails & other) :
53
J9::IlGeneratorMethodDetailsConnector(other) {}
54
55
};
56
57
}
58
59
60
namespace J9
61
{
62
63
class JitDumpMethodDetails : public TR::IlGeneratorMethodDetails
64
{
65
// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails
66
67
public:
68
JitDumpMethodDetails(J9Method* method, TR::Options* optionsFromOriginalCompile, bool aotCompile)
69
: TR::IlGeneratorMethodDetails(method)
70
{
71
_optionsFromOriginalCompile = optionsFromOriginalCompile;
72
_data._aotCompile = aotCompile;
73
}
74
75
JitDumpMethodDetails(const JitDumpMethodDetails& other)
76
: TR::IlGeneratorMethodDetails(other.getMethod())
77
{
78
_optionsFromOriginalCompile = other._optionsFromOriginalCompile;
79
_data._aotCompile = other._data._aotCompile;
80
}
81
82
virtual const char * name() const { return "JitDumpMethod"; }
83
84
virtual bool isOrdinaryMethod() const { return false; }
85
virtual bool isJitDumpMethod() const { return true; }
86
virtual bool isJitDumpAOTMethod() const { return _data._aotCompile; }
87
88
89
virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)
90
{
91
return other.isJitDumpMethod() && sameMethod(other);
92
}
93
94
virtual bool supportsInvalidation() { return false; }
95
96
/**
97
* \brief
98
* Gets the options used in the original compilation which we are trying to reproduce.
99
*
100
* \returns
101
* The options from the original compile if it exists; \c NULL otherwise.
102
*/
103
TR::Options* getOptionsFromOriginalCompile() const
104
{
105
return _optionsFromOriginalCompile;
106
}
107
};
108
109
110
class MethodInProgressDetails : public TR::IlGeneratorMethodDetails
111
{
112
// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails
113
114
public:
115
MethodInProgressDetails(J9Method* method, int32_t byteCodeIndex) :
116
TR::IlGeneratorMethodDetails(method)
117
{
118
_data._byteCodeIndex = byteCodeIndex;
119
}
120
MethodInProgressDetails(TR_ResolvedMethod *method, int32_t byteCodeIndex) :
121
TR::IlGeneratorMethodDetails(method)
122
{
123
_data._byteCodeIndex = byteCodeIndex;
124
}
125
MethodInProgressDetails(const MethodInProgressDetails & other) :
126
TR::IlGeneratorMethodDetails(other.getMethod())
127
{
128
_data._byteCodeIndex = other.getByteCodeIndex();
129
}
130
131
virtual const char * name() const { return "MethodInProgress"; }
132
133
virtual bool isOrdinaryMethod() const { return false; }
134
virtual bool isMethodInProgress() const { return true; }
135
virtual bool supportsInvalidation() const { return false; }
136
137
int32_t getByteCodeIndex() const { return _data._byteCodeIndex; }
138
139
virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)
140
{
141
return other.isMethodInProgress() &&
142
isSimilarEnough(static_cast<MethodInProgressDetails &>(other), fe);
143
}
144
145
virtual void printDetails(TR_FrontEnd *fe, TR::FILE *file);
146
147
private:
148
bool isSimilarEnough(MethodInProgressDetails & other, TR_FrontEnd *fe)
149
{
150
return sameMethod(other);
151
}
152
153
bool sameAsMethodInProgress(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)
154
{
155
return TR::IlGeneratorMethodDetails::sameAs(other, fe) &&
156
static_cast<MethodInProgressDetails &>(other).getByteCodeIndex() == getByteCodeIndex();
157
}
158
159
};
160
161
162
class NewInstanceThunkDetails : public TR::IlGeneratorMethodDetails
163
{
164
// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails
165
166
public:
167
NewInstanceThunkDetails(J9Method* method, J9Class *clazz) :
168
TR::IlGeneratorMethodDetails(method)
169
{
170
_data._class = clazz;
171
}
172
NewInstanceThunkDetails(TR_ResolvedMethod *method, J9Class *clazz) :
173
TR::IlGeneratorMethodDetails(method)
174
{
175
_data._class = clazz;
176
}
177
NewInstanceThunkDetails(const NewInstanceThunkDetails & other) :
178
TR::IlGeneratorMethodDetails(other.getMethod())
179
{
180
_data._class = other.classNeedingThunk();
181
}
182
183
virtual const char * name() const { return "NewInstanceThunk"; }
184
185
virtual bool isOrdinaryMethod() const { return false; }
186
virtual bool isNewInstanceThunk() const { return true; }
187
virtual bool supportsInvalidation() const { return false; }
188
189
J9Class *classNeedingThunk() const { return _data._class; }
190
191
virtual J9Class *getClass() const { return classNeedingThunk(); }
192
193
bool isThunkFor(J9Class *clazz) const { return clazz == classNeedingThunk(); }
194
195
virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)
196
{
197
return other.isNewInstanceThunk() &&
198
sameMethod(other) &&
199
static_cast<NewInstanceThunkDetails &>(other).classNeedingThunk() == classNeedingThunk();
200
}
201
202
virtual void printDetails(TR_FrontEnd *fe, TR::FILE *file);
203
};
204
205
206
// This class is currently not instantiated directly
207
class ArchetypeSpecimenDetails : public TR::IlGeneratorMethodDetails
208
{
209
// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails
210
211
public:
212
ArchetypeSpecimenDetails(J9Method* method) : TR::IlGeneratorMethodDetails(method) { }
213
ArchetypeSpecimenDetails(TR_ResolvedMethod *method) : TR::IlGeneratorMethodDetails(method) { }
214
ArchetypeSpecimenDetails(const ArchetypeSpecimenDetails &other) : TR::IlGeneratorMethodDetails(other) { }
215
216
virtual const char * name() const { return "ArchetypeSpecimen"; }
217
218
virtual bool isOrdinaryMethod() const { return false; }
219
virtual bool isArchetypeSpecimen() const { return true; }
220
221
virtual TR_IlGenerator *getIlGenerator(TR::ResolvedMethodSymbol *methodSymbol,
222
TR_FrontEnd * fe,
223
TR::Compilation *comp,
224
TR::SymbolReferenceTable *symRefTab,
225
bool forceClassLookahead,
226
TR_InlineBlocks *blocksToInline);
227
228
virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)
229
{
230
return other.isArchetypeSpecimen() && sameMethod(other);
231
}
232
};
233
234
235
// This class is currently not instantiated directly
236
class MethodHandleThunkDetails : public ArchetypeSpecimenDetails
237
{
238
// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails
239
240
public:
241
MethodHandleThunkDetails(J9Method* method, uintptr_t *handleRef, uintptr_t *argRef) :
242
ArchetypeSpecimenDetails(method)
243
{
244
_data._methodHandleData._handleRef = handleRef;
245
_data._methodHandleData._argRef = argRef;
246
}
247
MethodHandleThunkDetails(TR_ResolvedMethod *method, uintptr_t *handleRef, uintptr_t *argRef) :
248
ArchetypeSpecimenDetails(method)
249
{
250
_data._methodHandleData._handleRef = handleRef;
251
_data._methodHandleData._argRef = argRef;
252
}
253
MethodHandleThunkDetails(const MethodHandleThunkDetails &other) :
254
ArchetypeSpecimenDetails(other)
255
{
256
_data._methodHandleData._handleRef = other.getHandleRef();
257
_data._methodHandleData._argRef = other.getArgRef();
258
}
259
260
virtual const char * name() const { return "MethodHandleThunk"; }
261
262
virtual bool isMethodHandleThunk() const { return true; }
263
264
uintptr_t *getHandleRef() const { return _data._methodHandleData._handleRef; }
265
uintptr_t *getArgRef() const { return _data._methodHandleData._argRef; }
266
267
virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)
268
{
269
return other.isMethodHandleThunk() &&
270
sameMethod(other) &&
271
isSameThunk(static_cast<MethodHandleThunkDetails &>(other),
272
(TR_J9VMBase *)(fe));
273
}
274
275
virtual bool supportsInvalidation() const { return false; }
276
277
virtual bool isShareable() const { return false; }
278
279
virtual bool isCustom() const { return false; }
280
281
virtual void printDetails(TR_FrontEnd *fe, TR::FILE *file);
282
283
private:
284
virtual bool isSameThunk(MethodHandleThunkDetails & otherThunk, TR_J9VMBase *fe);
285
};
286
287
288
class ShareableInvokeExactThunkDetails : public MethodHandleThunkDetails
289
{
290
// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails
291
292
public:
293
ShareableInvokeExactThunkDetails(J9Method* method, uintptr_t *handleRef, uintptr_t *argRef) :
294
MethodHandleThunkDetails(method, handleRef, argRef) { }
295
ShareableInvokeExactThunkDetails(TR_ResolvedMethod *method, uintptr_t *handleRef, uintptr_t *argRef) :
296
MethodHandleThunkDetails(method, handleRef, argRef) { }
297
ShareableInvokeExactThunkDetails(const ShareableInvokeExactThunkDetails & other) :
298
MethodHandleThunkDetails(other.getMethod(), other.getHandleRef(), other.getArgRef()) { }
299
300
virtual const char * name() const { return "SharableInvokeExactThunk"; }
301
302
virtual bool isShareable() const { return true; }
303
304
private:
305
virtual bool isSameThunk(MethodHandleThunkDetails & otherThunk, TR_J9VMBase *fe);
306
};
307
308
309
class CustomInvokeExactThunkDetails : public MethodHandleThunkDetails
310
{
311
// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails
312
313
public:
314
CustomInvokeExactThunkDetails(J9Method* method, uintptr_t *handleRef, uintptr_t *argRef) :
315
MethodHandleThunkDetails(method, handleRef, argRef) { }
316
CustomInvokeExactThunkDetails(TR_ResolvedMethod *method, uintptr_t *handleRef, uintptr_t *argRef) :
317
MethodHandleThunkDetails(method, handleRef, argRef) { }
318
CustomInvokeExactThunkDetails(const CustomInvokeExactThunkDetails & other) :
319
MethodHandleThunkDetails(other.getMethod(), other.getHandleRef(), other.getArgRef()) { }
320
321
virtual const char * name() const { return "CustomInvokeExactThunk"; }
322
323
virtual bool isCustom() const { return true; }
324
325
private:
326
virtual bool isSameThunk(MethodHandleThunkDetails & otherThunk, TR_J9VMBase *fe);
327
};
328
329
330
}
331
332
#endif
333
334