Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/il/J9Node.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_NODE_INCL
24
#define J9_NODE_INCL
25
26
/*
27
* The following #define and typedef must appear before any #includes in this file
28
*/
29
#ifndef J9_NODE_CONNECTOR
30
#define J9_NODE_CONNECTOR
31
namespace J9 { class Node; }
32
namespace J9 { typedef J9::Node NodeConnector; }
33
#endif
34
35
#include "j9cfg.h"
36
#include "il/OMRNode.hpp"
37
38
class TR_OpaquePseudoRegister;
39
class TR_StorageReference;
40
class TR_PseudoRegister;
41
namespace TR { class Compilation; }
42
namespace TR { class Node; }
43
namespace TR { class ResolvedMethodSymbol; }
44
namespace TR { class TreeTop; }
45
46
namespace J9 {
47
48
class OMR_EXTENSIBLE Node : public OMR::NodeConnector
49
{
50
51
protected:
52
53
Node(TR::Node *originatingByteCodeNode, TR::ILOpCodes op, uint16_t numChildren);
54
55
Node(TR::Node *from, uint16_t numChildren = 0);
56
57
Node(Node& from) : OMR::NodeConnector(from) {}
58
59
60
public:
61
62
Node()
63
: OMR::NodeConnector(),
64
_unionPropertyB()
65
{ }
66
67
~Node();
68
69
static void copyValidProperties(TR::Node *fromNode, TR::Node *toNode);
70
71
uint32_t getSize();
72
73
bool dontEliminateStores(bool isForLocalDeadStore = false);
74
75
/// given a direct call to Object.clone node, return the class of the receiver.
76
///
77
TR_OpaqueClassBlock* getCloneClassInNode();
78
TR::Node * processJNICall(TR::TreeTop *, TR::ResolvedMethodSymbol *);
79
80
void devirtualizeCall(TR::TreeTop*);
81
82
/**
83
* @return the signature of the node's type if applicable.
84
* @note the signature's storage may have been created on the stack!
85
*/
86
const char * getTypeSignature(int32_t &, TR_AllocationKind = stackAlloc, bool parmAsAuto = false);
87
88
#if defined(TR_TARGET_S390)
89
TR_PseudoRegister *getPseudoRegister();
90
TR_OpaquePseudoRegister *getOpaquePseudoRegister();
91
#endif
92
93
/**
94
* @brief Answers whether the act of evaluating this node will
95
* require a register pair (two registers) to hold the
96
* result.
97
* @param comp, the TR::Compilation object
98
* @return true if two registers are required; false otherwise
99
*/
100
bool requiresRegisterPair(TR::Compilation *comp);
101
102
TR::Node *getSetSignValueNode();
103
void setKnownSignCodeFromRawSign(int32_t rawSignCode);
104
static bool typeSupportedForTruncateOrWiden(TR::DataType dt);
105
static bool typeSupportedForSignCodeTracking(TR::DataType dt);
106
static void truncateOrWidenBCDLiteral(TR::DataType dt, char *newLit, int32_t newPrecision, char *oldLit, int32_t oldPrecision);
107
static void setNewBCDSignOnLiteral(uint32_t newSignCode, TR::DataType dt, char *lit, int32_t litSize);
108
109
bool alwaysGeneratesAKnownCleanSign();
110
bool alwaysGeneratesAKnownPositiveCleanSign();
111
#ifdef TR_TARGET_S390
112
int32_t getStorageReferenceSize();
113
int32_t getStorageReferenceSourceSize();
114
#endif
115
116
bool isEvenPrecision();
117
bool isOddPrecision();
118
bool pdshrRoundIsConstantZero();
119
120
bool isSimpleTruncation();
121
bool isSimpleWidening();
122
bool mustClean();
123
bool hasIntermediateTruncation();
124
bool isTruncatingBCDShift();
125
bool isWideningBCDShift();
126
bool isTruncating();
127
int32_t survivingDigits();
128
129
130
131
bool isTruncatingOrWideningAggrOrBCD();
132
133
bool canRemoveArithmeticOperand();
134
bool canGCandReturn();
135
136
static uint32_t hashOnBCDOrAggrLiteral(char *lit, size_t litSize);
137
138
bool referencesSymbolInSubTree(TR::SymbolReference * symRef, vcount_t visitCount);
139
bool referencesMayKillAliasInSubTree(TR::Node * rootNode, vcount_t visitCount);
140
void getSubTreeReferences(TR::SparseBitVector &references, vcount_t visitCount);
141
TR_ParentOfChildNode * referencesSymbolExactlyOnceInSubTree(TR::Node *, int32_t, TR::SymbolReference *, vcount_t);
142
143
/**
144
* Node field functions
145
*/
146
147
#ifdef TR_TARGET_S390
148
TR_StorageReference *getStorageReferenceHint();
149
TR_StorageReference *setStorageReferenceHint(TR_StorageReference *s);
150
#endif
151
152
/**
153
* Node field functions end
154
*/
155
156
157
158
/**
159
* UnionPropertyB functions
160
*/
161
162
void setDecimalPrecision(int32_t p);
163
uint8_t getDecimalPrecision();
164
165
// These precision setting routines set a precision big enough to hold the
166
// full computed result A caller or codegen may choose to set a different
167
// value (bigger or smaller) to satisfy a specific semantic or encoding
168
// requirement -- see getPDMulEncodedPrecision et al. in the platform code
169
// generators
170
void setPDMulPrecision();
171
void setPDAddSubPrecision();
172
173
void setDecimalAdjust(int32_t a);
174
int32_t getDecimalAdjust();
175
176
void setDecimalFraction(int32_t f);
177
int32_t getDecimalFraction();
178
179
// Source precisions are valid for conversions from a non-BCD type to a BCD type
180
bool canHaveSourcePrecision();
181
bool hasSourcePrecision();
182
void setSourcePrecision(int32_t prec);
183
int32_t getSourcePrecision();
184
185
int32_t getDecimalAdjustOrFractionOrDivisor();
186
int32_t getDecimalRoundOrDividend();
187
188
bool isSetSignValueOnNode();
189
void setSetSign(TR_RawBCDSignCode setSign);
190
TR_RawBCDSignCode getSetSign();
191
bool isDecimalSizeAndShapeEquivalent(TR::Node *other);
192
193
void setDecimalRound(int32_t r);
194
uint8_t getDecimalRound();
195
196
bool signStateIsKnown();
197
void setSignStateIsKnown();
198
bool signStateIsAssumed();
199
void setSignStateIsAssumed();
200
201
bool hasKnownCleanSign();
202
void setHasKnownCleanSign(bool v);
203
bool hasAssumedCleanSign();
204
void setHasAssumedCleanSign(bool v);
205
bool hasKnownOrAssumedCleanSign();
206
void setHasKnownAndAssumedCleanSign(bool v);
207
void transferCleanSign(TR::Node *srcNode);
208
209
bool hasKnownPreferredSign();
210
void setHasKnownPreferredSign(bool v);
211
bool hasAssumedPreferredSign();
212
void setHasAssumedPreferredSign(bool v);
213
bool hasKnownOrAssumedPreferredSign();
214
215
bool hasKnownSignCode();
216
TR_RawBCDSignCode getKnownSignCode();
217
bool hasAssumedSignCode();
218
TR_RawBCDSignCode getAssumedSignCode();
219
bool hasKnownOrAssumedSignCode();
220
TR_RawBCDSignCode getKnownOrAssumedSignCode();
221
void setKnownOrAssumedSignCode(TR_RawBCDSignCode sign, bool isKnown);
222
void setKnownSignCode(TR_RawBCDSignCode sign);
223
void transferSignCode(TR::Node *srcNode);
224
225
// The mapping to/from TR_BCDSignCode from/to the 0xc/0xd/0xf 'raw'
226
// encodings in setKnownSignCode/knownSignCodeIs below // is temporary until
227
// TR_BCDSignCode is tracked on the nodes instead of TR_RawBCDSignCode
228
// Doing it this way allows new code (such as VP constrainBCDAggrLoad) to
229
// start using this new more general interface // The final code will be just
230
// calling setKnownOrAssumedSignCode(sign, true, c) but now the 'sign' parm will
231
// be TR_BCDSignCode of TR_RawBCDSignCode
232
bool knownSignCodeIs(TR_BCDSignCode sign);
233
void setKnownSignCode(TR_BCDSignCode sign);
234
bool assumedSignCodeIs(TR_BCDSignCode sign);
235
void setAssumedSignCode(TR_RawBCDSignCode sign);
236
bool knownOrAssumedSignCodeIs(TR_BCDSignCode sign);
237
238
// the hasSignState property is stored in the reverse sense to make the interface easier to use (at the expense of some confusion here);
239
bool hasSignStateOnLoad();
240
void setHasSignStateOnLoad(bool v);
241
242
void transferSignState(TR::Node *srcNode, bool digitsLost);
243
bool hasAnyKnownOrAssumedSignState();
244
bool hasAnyDecimalSignState();
245
void resetDecimalSignFlags();
246
void resetSignState();
247
248
bool isSignStateEquivalent(TR::Node *other);
249
bool isSignStateAnImprovementOver(TR::Node *other);
250
251
bool chkOpsCastedToBCD();
252
bool castedToBCD();
253
void setCastedToBCD(bool v);
254
255
/**
256
* UnionPropertyB functions end
257
*/
258
259
260
261
/**
262
* Node flag functions
263
*/
264
265
// Flag used by TR::BNDCHK nodes
266
bool isSpineCheckWithArrayElementChild();
267
void setSpineCheckWithArrayElementChild(bool v);
268
bool chkSpineCheckWithArrayElementChild();
269
const char *printSpineCheckWithArrayElementChild();
270
271
// Flags used by call nodes
272
bool isUnsafePutOrderedCall();
273
bool isDontInlinePutOrderedCall();
274
void setDontInlinePutOrderedCall();
275
bool chkDontInlineUnsafePutOrderedCall();
276
const char * printIsDontInlineUnsafePutOrderedCall();
277
278
/**
279
* Checks and return true if the callNode is JNI Call to Unsafe.copyMemory
280
*/
281
bool isUnsafeCopyMemoryIntrinsic();
282
283
bool isUnsafeGetPutCASCallOnNonArray();
284
void setUnsafeGetPutCASCallOnNonArray();
285
286
bool isProcessedByCallCloneConstrain();
287
void setProcessedByCallCloneConstrain();
288
289
bool isDAAVariableSlowCall();
290
void setDAAVariableSlowCall(bool v);
291
292
// Flag used by binary coded decimal load nodes
293
bool isBCDStoreTemporarilyALoad();
294
void setBCDStoreIsTemporarilyALoad(bool v);
295
296
// Flag used by isPackedLeftShift nodes
297
bool cleanSignDuringPackedLeftShift();
298
void setCleanSignDuringPackedLeftShift(bool v);
299
bool chkCleanSignDuringPackedLeftShift();
300
const char *printCleanSignDuringPackedLeftShift();
301
302
// Flag used by non-store and non-call binary coded decimal and aggregate nodes
303
bool chkOpsSkipCopyOnLoad();
304
bool skipCopyOnLoad();
305
void setSkipCopyOnLoad(bool v);
306
bool chkSkipCopyOnLoad();
307
const char *printSkipCopyOnLoad();
308
309
// Flag used by binary coded decimal and aggregate store nodes
310
bool chkOpsSkipCopyOnStore();
311
bool skipCopyOnStore();
312
void setSkipCopyOnStore(bool v);
313
bool chkSkipCopyOnStore();
314
const char *printSkipCopyOnStore();
315
316
// Flag used by packed decimal stores
317
bool chkOpsCleanSignInPDStoreEvaluator();
318
bool mustCleanSignInPDStoreEvaluator();
319
void setCleanSignInPDStoreEvaluator(bool v);
320
bool chkCleanSignInPDStoreEvaluator();
321
const char *printCleanSignInPDStoreEvaluator();
322
323
// Flag used by binary coded decimal stores and aggregate stores
324
bool chkOpsUseStoreAsAnAccumulator();
325
bool useStoreAsAnAccumulator();
326
void setUseStoreAsAnAccumulator(bool v);
327
bool chkUseStoreAsAnAccumulator();
328
const char *printUseStoreAsAnAccumulator();
329
330
// Flag used by non-store packed types
331
bool canSkipPadByteClearing();
332
void setSkipPadByteClearing(bool v);
333
bool chkSkipPadByteClearing();
334
const char *printSkipPadByteClearing();
335
336
// Flag used for BCD and Aggr type stores
337
bool chkOpsIsInMemoryCopyProp();
338
bool isInMemoryCopyProp();
339
void setIsInMemoryCopyProp(bool v);
340
bool chkIsInMemoryCopyProp();
341
const char *printIsInMemoryCopyProp();
342
343
// Flag used by address type nodes in Java
344
bool chkSharedMemory();
345
void setSharedMemory(bool v);
346
const char *printSharedMemory();
347
348
349
bool isArrayCopyCall();
350
351
/**
352
* Node flag functions end
353
*/
354
355
inline float getFloat();
356
inline float setFloat(float f);
357
358
#ifdef J9VM_OPT_JAVA_CRYPTO_ACCELERATION
359
bool processJNICryptoMethodCall(TR::ResolvedMethodSymbol *methodSymbol, TR::Compilation *comp);
360
#endif
361
362
protected:
363
364
/// \note update the following routines when adding field to DecimalInfo
365
/// isDecimalSizeAndShapeEquivalent()
366
/// isSignStateEquivalent()
367
/// resetDecimalSignFlags()
368
/// transferSignState()
369
/// Also be sure to initialize any new field in the Node.cpp constructor
370
struct DecimalInfo
371
{
372
uint32_t _decimalPrecision : 6; ///< range 0->63
373
int32_t _decimalAdjustOrFractionOrDivisor : 7; ///< range as Adjust -63->63 (on all except conversion nodes)
374
///< range as Fraction -63->63 (only on isConversionWithFraction nodes)
375
///< range as divisorPrecision 0->63 (on select nodes)
376
///< range as extFloatSrcIntDigits 0->63 (but should only need 16, on extFloat to other conversions, e.g. zf2uf,zf2d)
377
uint32_t _decimalSourcePrecisionOrDividend : 6; ///< range as source precision (on non-BCD-to-BCD conversions) 0->63, as dividendPrecision 0->63 (on select nodes)
378
TR_RawBCDSignCode _setSign : 3; ///< range on isSetSign opcodes
379
uint32_t _signStateIsKnown : 1; ///< true (known) or false (assumed)
380
uint32_t _hasCleanSign : 1; ///< true/false
381
uint32_t _hasPreferredSign : 1; ///< true/false
382
uint32_t _round : 1; ///< true/false
383
uint32_t _hasNoSignStateOnLoad : 1; ///< true/false // for BCD loads : false for PRE created loads that must preserve sign state (conservative setting), true for FE created loads
384
uint32_t _castedToBCD : 1; ///< true/false // if true node was not originally a BCD type but casted to BCD by the optimizer from a non-BCD type (e.g. aggr or int)
385
TR_RawBCDSignCode _signCode : 3;
386
};
387
388
// keep nodes as small as possible for frontends that do not need the data below
389
// The fields below are all disjoint, which fields exist for which platforms/opcodes are provided by the given has<Field> functions
390
union UnionPropertyB
391
{
392
// field exists when following is true: only one of these should be true for a given node
393
// eventually should replace by exclusive representation (eg. enum)
394
DecimalInfo _decimalInfo; ///< hasDecimalInfo()
395
// overflow/rounding option
396
UnionPropertyB()
397
{
398
memset(this, 0, sizeof(UnionPropertyB)); ///< in C++11 notation: _unionPropertyB = {0};
399
}
400
};
401
402
enum UnionPropertyB_Type
403
{
404
HasNoUnionPropertyB = 0,
405
HasDecimalInfo, ///< hasDecimalInfo()
406
HasBcdFlags ///< hasBCDFlags()
407
};
408
409
bool hasDecimalInfo();
410
bool hasBCDFlags();
411
UnionPropertyB_Type getUnionPropertyB_Type();
412
413
// for DecimalInfo subtypes
414
bool hasDecimalPrecision();
415
bool hasDecimalAdjust();
416
bool hasSetSign();
417
bool hasDecimalFraction();
418
bool hasDecimalRound();
419
420
// Fields
421
private:
422
423
#ifdef TR_TARGET_S390
424
///< hasStorageReferenceHint()
425
TR_StorageReference * _storageReferenceHint;
426
#endif
427
428
// Holds DecimalInfo and BCDFlags
429
UnionPropertyB _unionPropertyB;
430
431
protected:
432
// Flag bits
433
enum
434
{
435
// Flag used by TR::BNDCHK nodes
436
spineCHKWithArrayElementChild = 0x00004000,
437
438
// Flags used by call nodes
439
dontInlineUnsafePutOrderedCall = 0x00000800, ///< unsafe putOrdered calls
440
processedByCallCloneConstrain = 0x00100000,
441
unsafeGetPutOnNonArray = 0x00200000,
442
DAAVariableSlowCall = 0x00400000, ///< Used to avoid Variable precision DAA optimization
443
444
// Flag used by binary coded decimal load nodes
445
IsBCDStoreTemporarilyALoad = 0x00400000,
446
447
// Flag used by isPackedLeftShift nodes (pdshl,pdshlSetSign...)
448
CleanSignDuringPackedLeftShift = 0x00400000,
449
450
// Flag used by non-store and non-call binary coded decimal and aggregate nodes
451
SkipCopyOnLoad = 0x00800000,
452
453
// Flag used by binary coded decimal and aggregate store nodes
454
SkipCopyOnStore = 0x00080000,
455
456
// Flag used by packed decimal stores (eg pdstore/ipdstore)
457
cleanSignInPDStoreEvaluator = 0x00040000,
458
459
// Flag used by binary coded decimal stores and aggregate stores (eg pdstore/ipdstore/zdstore/izdstore etc)
460
// (all nodes where ILProp3::CanUseStoreAsAnAccumulator is set)
461
UseStoreAsAnAccumulator = 0x00200000,
462
463
// Flag used by non-store packed types
464
skipPadByteClearing = 0x00020000,
465
466
// Flag used by BCD and Aggr type stores -- for in memory types set when 1 or more child of the store was changed
467
// during local or global copy propagation
468
IsInMemoryCopyProp = 0x08000000,
469
470
// Flag used by address type nodes in Java
471
sharedMemory = 0x00000400,
472
473
};
474
475
};
476
477
}
478
479
#endif
480
481
482