Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/codegen/J9TreeEvaluator.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_TREE_EVALUATOR_INCL
24
#define J9_TREE_EVALUATOR_INCL
25
26
/*
27
* The following #define and typedef must appear before any #includes in this file
28
*/
29
#ifndef J9_TREE_EVALUATOR_CONNECTOR
30
#define J9_TREE_EVALUATOR_CONNECTOR
31
namespace J9 { class TreeEvaluator; }
32
namespace J9 { typedef J9::TreeEvaluator TreeEvaluatorConnector; }
33
#endif
34
35
#include "codegen/OMRTreeEvaluator.hpp"
36
#include "codegen/Snippet.hpp"
37
38
namespace J9
39
{
40
41
class OMR_EXTENSIBLE TreeEvaluator: public OMR::TreeEvaluatorConnector
42
{
43
public:
44
enum InstanceOfOrCheckCastSequences
45
{
46
EvaluateCastClass,
47
LoadObjectClass,
48
49
NullTest, // Needs object class: n, needs cast class: n
50
GoToTrue, // Needs object class: n, needs cast class: n
51
GoToFalse, // Needs object class: n, needs cast class: n
52
ProfiledClassTest, // Needs object class: y, needs cast class: n
53
CompileTimeGuessClassTest, // Needs object class: y, needs cast class: n
54
ArrayOfJavaLangObjectTest, // Needs object class: y, needs cast class: n
55
ClassEqualityTest, // Needs object class: y, needs cast class: y
56
SuperClassTest, // Needs object class: y, needs cast class: y
57
CastClassCacheTest, // Needs object class: y, needs cast class: y
58
DynamicCacheObjectClassTest, // Needs object class: y, needs cast class: n
59
DynamicCacheDynamicCastClassTest, // Needs object class: y, needs cast class: y
60
HelperCall, // Needs object class: n, needs cast class: y
61
62
InstanceOfOrCheckCastMaxSequences
63
};
64
65
/** \brief
66
* A structure containing following information
67
* 1. class
68
* 2. boolean representing if the class is instanceof cast class or not
69
* 3. probability
70
*/
71
struct InstanceOfOrCheckCastProfiledClasses
72
{
73
TR_OpaqueClassBlock *profiledClass;
74
bool isProfiledClassInstanceOfCastClass;
75
float frequency;
76
};
77
78
static TR::Register *zdloadEvaluator(TR::Node *node, TR::CodeGenerator *cg);
79
static TR::Register *zdloadiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
80
static TR::Register *zdstoreEvaluator(TR::Node *node, TR::CodeGenerator *cg);
81
static TR::Register *zdstoreiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
82
static TR::Register *pd2zdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
83
static TR::Register *zd2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
84
static TR::Register *zdsleLoadEvaluator(TR::Node *node, TR::CodeGenerator *cg);
85
static TR::Register *zdslsLoadEvaluator(TR::Node *node, TR::CodeGenerator *cg);
86
static TR::Register *zdstsLoadEvaluator(TR::Node *node, TR::CodeGenerator *cg);
87
static TR::Register *zdsleLoadiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
88
static TR::Register *zdslsLoadiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
89
static TR::Register *zdstsLoadiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
90
static TR::Register *zdsleStoreEvaluator(TR::Node *node, TR::CodeGenerator *cg);
91
static TR::Register *zdslsStoreEvaluator(TR::Node *node, TR::CodeGenerator *cg);
92
static TR::Register *zdstsStoreEvaluator(TR::Node *node, TR::CodeGenerator *cg);
93
static TR::Register *zdsleStoreiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
94
static TR::Register *zdslsStoreiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
95
static TR::Register *zdstsStoreiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
96
static TR::Register *zd2zdsleEvaluator(TR::Node *node, TR::CodeGenerator *cg);
97
static TR::Register *zd2zdslsEvaluator(TR::Node *node, TR::CodeGenerator *cg);
98
static TR::Register *zd2zdstsEvaluator(TR::Node *node, TR::CodeGenerator *cg);
99
static TR::Register *zdsle2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
100
static TR::Register *zdsls2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
101
static TR::Register *zdsts2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
102
static TR::Register *zdsle2zdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
103
static TR::Register *zdsls2zdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
104
static TR::Register *zdsts2zdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
105
static TR::Register *pd2zdslsEvaluator(TR::Node *node, TR::CodeGenerator *cg);
106
static TR::Register *pd2zdslsSetSignEvaluator(TR::Node *node, TR::CodeGenerator *cg);
107
static TR::Register *pd2zdstsEvaluator(TR::Node *node, TR::CodeGenerator *cg);
108
static TR::Register *pd2zdstsSetSignEvaluator(TR::Node *node, TR::CodeGenerator *cg);
109
static TR::Register *udLoadEvaluator(TR::Node *node, TR::CodeGenerator *cg);
110
static TR::Register *udslLoadEvaluator(TR::Node *node, TR::CodeGenerator *cg);
111
static TR::Register *udstLoadEvaluator(TR::Node *node, TR::CodeGenerator *cg);
112
static TR::Register *udLoadiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
113
static TR::Register *udslLoadiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
114
static TR::Register *udstLoadiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
115
static TR::Register *udStoreEvaluator(TR::Node *node, TR::CodeGenerator *cg);
116
static TR::Register *udslStoreEvaluator(TR::Node *node, TR::CodeGenerator *cg);
117
static TR::Register *udstStoreEvaluator(TR::Node *node, TR::CodeGenerator *cg);
118
static TR::Register *udStoreiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
119
static TR::Register *udslStoreiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
120
static TR::Register *udstStoreiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
121
static TR::Register *pd2udEvaluator(TR::Node *node, TR::CodeGenerator *cg);
122
static TR::Register *pd2udslEvaluator(TR::Node *node, TR::CodeGenerator *cg);
123
static TR::Register *pd2udstEvaluator(TR::Node *node, TR::CodeGenerator *cg);
124
static TR::Register *udsl2udEvaluator(TR::Node *node, TR::CodeGenerator *cg);
125
static TR::Register *udst2udEvaluator(TR::Node *node, TR::CodeGenerator *cg);
126
static TR::Register *ud2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
127
static TR::Register *udsl2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
128
static TR::Register *udst2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
129
static TR::Register *pdloadEvaluator(TR::Node *node, TR::CodeGenerator *cg);
130
static TR::Register *pdloadiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
131
static TR::Register *pdstoreEvaluator(TR::Node *node, TR::CodeGenerator *cg);
132
static TR::Register *pdstoreiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
133
static TR::Register *pdaddEvaluator(TR::Node *node, TR::CodeGenerator *cg);
134
static TR::Register *pdsubEvaluator(TR::Node *node, TR::CodeGenerator *cg);
135
static TR::Register *pdmulEvaluator(TR::Node *node, TR::CodeGenerator *cg);
136
static TR::Register *pddivEvaluator(TR::Node *node, TR::CodeGenerator *cg);
137
static TR::Register *pdremEvaluator(TR::Node *node, TR::CodeGenerator *cg);
138
static TR::Register *pdnegEvaluator(TR::Node *node, TR::CodeGenerator *cg);
139
static TR::Register *pdabsEvaluator(TR::Node *node, TR::CodeGenerator *cg);
140
static TR::Register *pdshrEvaluator(TR::Node *node, TR::CodeGenerator *cg);
141
static TR::Register *pdshlEvaluator(TR::Node *node, TR::CodeGenerator *cg);
142
static TR::Register *pdshrSetSignEvaluator(TR::Node *node, TR::CodeGenerator *cg);
143
static TR::Register *pdshlSetSignEvaluator(TR::Node *node, TR::CodeGenerator *cg);
144
static TR::Register *pdshlOverflowEvaluator(TR::Node *node, TR::CodeGenerator *cg);
145
static TR::Register *pdchkEvaluator(TR::Node *node, TR::CodeGenerator *cg);
146
static TR::Register *pd2iEvaluator(TR::Node *node, TR::CodeGenerator *cg);
147
static TR::Register *pd2iuEvaluator(TR::Node *node, TR::CodeGenerator *cg);
148
static TR::Register *pd2iOverflowEvaluator(TR::Node *node, TR::CodeGenerator *cg);
149
static TR::Register *i2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
150
static TR::Register *iu2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
151
static TR::Register *pd2lEvaluator(TR::Node *node, TR::CodeGenerator *cg);
152
static TR::Register *pd2luEvaluator(TR::Node *node, TR::CodeGenerator *cg);
153
static TR::Register *pd2lOverflowEvaluator(TR::Node *node, TR::CodeGenerator *cg);
154
static TR::Register *l2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
155
static TR::Register *lu2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
156
static TR::Register *pd2fEvaluator(TR::Node *node, TR::CodeGenerator *cg);
157
static TR::Register *pd2dEvaluator(TR::Node *node, TR::CodeGenerator *cg);
158
static TR::Register *f2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
159
static TR::Register *d2pdEvaluator(TR::Node *node, TR::CodeGenerator *cg);
160
static TR::Register *pdcmpeqEvaluator(TR::Node *node, TR::CodeGenerator *cg);
161
static TR::Register *pdcmpneEvaluator(TR::Node *node, TR::CodeGenerator *cg);
162
static TR::Register *pdcmpltEvaluator(TR::Node *node, TR::CodeGenerator *cg);
163
static TR::Register *pdcmpgeEvaluator(TR::Node *node, TR::CodeGenerator *cg);
164
static TR::Register *pdcmpgtEvaluator(TR::Node *node, TR::CodeGenerator *cg);
165
static TR::Register *pdcmpleEvaluator(TR::Node *node, TR::CodeGenerator *cg);
166
static TR::Register *pdcleanEvaluator(TR::Node *node, TR::CodeGenerator *cg);
167
static TR::Register *pdclearEvaluator(TR::Node *node, TR::CodeGenerator *cg);
168
static TR::Register *pdclearSetSignEvaluator(TR::Node *node, TR::CodeGenerator *cg);
169
static TR::Register *pdSetSignEvaluator(TR::Node *node, TR::CodeGenerator *cg);
170
static TR::Register *pdModifyPrecisionEvaluator(TR::Node *node, TR::CodeGenerator *cg);
171
static TR::Register *countDigitsEvaluator(TR::Node *node, TR::CodeGenerator *cg);
172
static TR::Register *BCDCHKEvaluator(TR::Node *node, TR::CodeGenerator *cg);
173
174
static uint32_t calculateInstanceOfOrCheckCastSequences(TR::Node *instanceOfOrCheckCastNode, InstanceOfOrCheckCastSequences *sequences, TR_OpaqueClassBlock **compileTimeGuessClass, TR::CodeGenerator *cg, InstanceOfOrCheckCastProfiledClasses *profiledClassList, uint32_t *numberOfProfiledClass, uint32_t maxProfileClass, float *topClassProbability, bool *topClassWasCastClass);
175
176
static uint8_t interpreterProfilingInstanceOfOrCheckCastInfo(TR::CodeGenerator * cg, TR::Node * node, TR_OpaqueClassBlock **classArray, float* probability=NULL, bool recordAll = false);
177
178
static TR_OpaqueClassBlock* interpreterProfilingInstanceOfOrCheckCastInfo(TR::CodeGenerator * cg, TR::Node * node);
179
180
static bool checkcastShouldOutlineSuperClassTest(TR::Node *castClassNode, TR::CodeGenerator *cg);
181
182
static bool loadLookaheadAfterHeaderAccess(TR::Node *node, int32_t &fieldOffset, TR::CodeGenerator *cg);
183
184
static bool instanceOfNeedHelperCall(bool testCastClassIsSuper, bool isFinalClass);
185
186
static bool instanceOfOrCheckCastIsJavaLangObjectArray(TR::Node * castClassNode, TR::CodeGenerator *cg);
187
static TR_OpaqueClassBlock * getCastClassAddress(TR::Node * castClassNode);
188
static bool instanceOfOrCheckCastIsFinalArray(TR::Node * castClassNode, TR::CodeGenerator *cg);
189
190
static TR::Register *bwrtbarEvaluator(TR::Node *node, TR::CodeGenerator *cg);
191
static TR::Register *bwrtbariEvaluator(TR::Node *node, TR::CodeGenerator *cg);
192
static TR::Register *swrtbarEvaluator(TR::Node *node, TR::CodeGenerator *cg);
193
static TR::Register *swrtbariEvaluator(TR::Node *node, TR::CodeGenerator *cg);
194
static TR::Register *iwrtbarEvaluator(TR::Node *node, TR::CodeGenerator *cg);
195
static TR::Register *iwrtbariEvaluator(TR::Node *node, TR::CodeGenerator *cg);
196
static TR::Register *lwrtbarEvaluator(TR::Node *node, TR::CodeGenerator *cg);
197
static TR::Register *lwrtbariEvaluator(TR::Node *node, TR::CodeGenerator *cg);
198
199
static TR::Register *frdbarEvaluator(TR::Node *node, TR::CodeGenerator *cg);
200
static TR::Register *frdbariEvaluator(TR::Node *node, TR::CodeGenerator *cg);
201
static TR::Register *drdbarEvaluator(TR::Node *node, TR::CodeGenerator *cg);
202
static TR::Register *drdbariEvaluator(TR::Node *node, TR::CodeGenerator *cg);
203
static TR::Register *brdbarEvaluator(TR::Node *node, TR::CodeGenerator *cg);
204
static TR::Register *brdbariEvaluator(TR::Node *node, TR::CodeGenerator *cg);
205
static TR::Register *srdbarEvaluator(TR::Node *node, TR::CodeGenerator *cg);
206
static TR::Register *srdbariEvaluator(TR::Node *node, TR::CodeGenerator *cg);
207
static TR::Register *lrdbarEvaluator(TR::Node *node, TR::CodeGenerator *cg);
208
static TR::Register *lrdbariEvaluator(TR::Node *node, TR::CodeGenerator *cg);
209
static TR::Register *monexitfenceEvaluator(TR::Node *node, TR::CodeGenerator *cg);
210
211
/*
212
* \brief
213
* Invokes the sequence of codegen routines to report the watched field.
214
*/
215
static void rdWrtbarHelperForFieldWatch(TR::Node *node, TR::CodeGenerator *cg, TR::Register *sideEffectRegister, TR::Register *valueReg);
216
/*
217
* \brief
218
* Populates and Returns the FieldWatchStaticSnippet corresponding to the specific codegen.
219
*/
220
static TR::Snippet *getFieldWatchStaticSnippet(TR::CodeGenerator *cg, TR::Node *node, J9Method *m, UDATA loc, void *fieldAddress, J9Class *fieldClass);
221
/*
222
* \brief
223
* Populates and Returns the FieldWatchInstanceSnippet corresponding to the specific codegen.
224
*/
225
static TR::Snippet *getFieldWatchInstanceSnippet(TR::CodeGenerator *cg, TR::Node *node, J9Method *m, UDATA loc, UDATA os);
226
/*
227
* \brief
228
* Sets the node representing the value to be written for an indirect wrtbar. Returns
229
* true/false if the correct pattern was found (i.e. if compressedReferences is being used).
230
*
231
* \note
232
* For address type nodes using compressedrefs, the compressed refs sequence is skipped
233
* from the sub tree and the uncompressed address value is set to sourceChild.
234
* For all other cases, sourceChild is set to the secondChild.
235
*/
236
static bool getIndirectWrtbarValueNode(TR::CodeGenerator *cg, TR::Node *node, TR::Node*& sourceChild, bool incSrcRefCount);
237
static void evaluateLockForReservation(TR::Node *node, bool *reservingLock, bool *normalLockPreservingReservation, TR::CodeGenerator *cg);
238
static bool isPrimitiveMonitor (TR::Node *node, TR::CodeGenerator *cg);
239
static bool isDummyMonitorEnter (TR::Node *node, TR::CodeGenerator *cg);
240
static bool isDummyMonitorExit (TR::Node *node, TR::CodeGenerator *cg);
241
242
static void preEvaluateEscapingNodesForSpineCheck(TR::Node *root, TR::CodeGenerator *cg);
243
244
static TR::Register *resolveCHKEvaluator(TR::Node *node, TR::CodeGenerator *cg);
245
246
/*
247
* \brief
248
* Checks if inline allocation is allowed when value type is enabled.
249
* The helper call is required if the first child of the "new" node, the class node, is a value type class
250
* but it tries to create a non-value type instance, or if the class node is non-value type class but it
251
* tries to create a value type instance.
252
*/
253
static bool requireHelperCallValueTypeAllocation(TR::Node *node, TR::CodeGenerator *cg);
254
};
255
256
}
257
258
#endif
259
260