Skip to content

Commit c113b72

Browse files
authored
Merge pull request #20507 from r30shah/zNextSupportPR
Add zNext support
2 parents 64284dd + 7366e65 commit c113b72

21 files changed

+613
-8
lines changed

Diff for: runtime/cmake/caches/common.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,4 @@ set(J9VM_THR_LOCK_RESERVATION ON CACHE BOOL "")
216216
set(J9VM_THR_PREEMPTIVE ON CACHE BOOL "")
217217
set(J9VM_THR_SMART_DEFLATION ON CACHE BOOL "")
218218
set(J9VM_OPT_OPENJDK_FFI ON CACHE BOOL "")
219+
set(J9VM_JIT_EMULATE_ZNEXT OFF CACHE BOOL "Enable ZNext emulation")

Diff for: runtime/compiler/codegen/J9RecognizedMethodsEnum.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@
527527
java_lang_Integer_reverseBytes,
528528
java_lang_Integer_rotateLeft,
529529
java_lang_Integer_rotateRight,
530+
java_lang_Integer_compress,
531+
java_lang_Integer_expand,
530532
java_lang_Integer_valueOf,
531533
java_lang_Integer_toUnsignedLong,
532534
java_lang_Integer_stringSize,
@@ -544,6 +546,8 @@
544546
java_lang_Long_reverseBytes,
545547
java_lang_Long_rotateLeft,
546548
java_lang_Long_rotateRight,
549+
java_lang_Long_compress,
550+
java_lang_Long_expand,
547551
java_lang_Short_reverseBytes,
548552
java_lang_Long_stringSize,
549553
java_lang_Long_toString,
@@ -720,6 +724,12 @@
720724
com_ibm_dataaccess_PackedDecimal_movePackedDecimal_,
721725
com_ibm_dataaccess_PackedDecimal_checkPackedDecimal_,
722726

727+
// wrapper methods
728+
com_ibm_dataaccess_ExternalDecimal_checkExternalDecimal,
729+
730+
//inline methods
731+
com_ibm_dataaccess_ExternalDecimal_checkExternalDecimal_,
732+
723733
com_ibm_Compiler_Internal__TR_Prefetch,
724734

725735
com_ibm_Compiler_Internal_Quad_enableQuadOptimization,

Diff for: runtime/compiler/codegen/J9TreeEvaluator.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
#include "runtime/J9ValueProfiler.hpp"
3737
#include "util_api.h"
3838

39+
TR::Register*
40+
J9::TreeEvaluator::zdchkEvaluator(TR::Node *node, TR::CodeGenerator *cg)
41+
{
42+
return TR::TreeEvaluator::unImpOpEvaluator(node, cg);
43+
}
44+
3945
TR::Register*
4046
J9::TreeEvaluator::zdloadEvaluator(TR::Node *node, TR::CodeGenerator *cg)
4147
{

Diff for: runtime/compiler/codegen/J9TreeEvaluator.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class OMR_EXTENSIBLE TreeEvaluator: public OMR::TreeEvaluatorConnector
7575
float frequency;
7676
};
7777

78+
static TR::Register *zdchkEvaluator(TR::Node *node, TR::CodeGenerator *cg);
7879
static TR::Register *zdloadEvaluator(TR::Node *node, TR::CodeGenerator *cg);
7980
static TR::Register *zdloadiEvaluator(TR::Node *node, TR::CodeGenerator *cg);
8081
static TR::Register *zdstoreEvaluator(TR::Node *node, TR::CodeGenerator *cg);

Diff for: runtime/compiler/env/j9method.cpp

+29-2
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,14 @@ void TR_ResolvedJ9Method::construct()
26172617
{TR::unknownMethod}
26182618
};
26192619

2620+
static X DataAccessExternalDecimalMethods[] =
2621+
{
2622+
{x(TR::com_ibm_dataaccess_ExternalDecimal_checkExternalDecimal , "checkExternalDecimal" , "([BIIII)I")},
2623+
{x(TR::com_ibm_dataaccess_ExternalDecimal_checkExternalDecimal_, "checkExternalDecimal_", "([BIIII)I")},
2624+
2625+
{TR::unknownMethod}
2626+
};
2627+
26202628

26212629
static X BigDecimalMethods[] =
26222630
{
@@ -3314,6 +3322,8 @@ void TR_ResolvedJ9Method::construct()
33143322
{x(TR::java_lang_Integer_reverseBytes, "reverseBytes", "(I)I")},
33153323
{x(TR::java_lang_Integer_rotateLeft, "rotateLeft", "(II)I")},
33163324
{x(TR::java_lang_Integer_rotateRight, "rotateRight", "(II)I")},
3325+
{x(TR::java_lang_Integer_compress, "compress", "(II)I")},
3326+
{x(TR::java_lang_Integer_expand, "expand", "(II)I")},
33173327
{x(TR::java_lang_Integer_valueOf, "valueOf", "(I)Ljava/lang/Integer;")},
33183328
{ TR::java_lang_Integer_init, 6, "<init>", (int16_t)-1, "*"},
33193329
{x(TR::java_lang_Integer_toUnsignedLong, "toUnsignedLong", "(I)J")},
@@ -3335,6 +3345,8 @@ void TR_ResolvedJ9Method::construct()
33353345
{x(TR::java_lang_Long_reverseBytes, "reverseBytes", "(J)J")},
33363346
{x(TR::java_lang_Long_rotateLeft, "rotateLeft", "(JI)J")},
33373347
{x(TR::java_lang_Long_rotateRight, "rotateRight", "(JI)J")},
3348+
{x(TR::java_lang_Long_compress, "compress", "(JJ)J")},
3349+
{x(TR::java_lang_Long_expand, "expand", "(JJ)J")},
33383350
{ TR::java_lang_Long_init, 6, "<init>", (int16_t)-1, "*"},
33393351
{x(TR::java_lang_Long_stringSize, "stringSize", "(J)I") },
33403352
{x(TR::java_lang_Long_toString, "toString", "(J)Ljava/lang/String;") },
@@ -4287,6 +4299,7 @@ void TR_ResolvedJ9Method::construct()
42874299
{ "java/util/Hashtable$HashEnumerator", HashtableHashEnumeratorMethods },
42884300
{ "com/ibm/Compiler/Internal/Prefetch", PrefetchMethods },
42894301
{ "java/lang/invoke/VarHandleInternal", VarHandleMethods },
4302+
{ "com/ibm/dataaccess/ExternalDecimal", DataAccessExternalDecimalMethods },
42904303
{ 0 }
42914304
};
42924305

@@ -9822,10 +9835,17 @@ TR_ResolvedJ9Method::isFieldFlattened(TR::Compilation *comp, int32_t cpIndex, bo
98229835
return vmThread->javaVM->internalVMFunctions->isFlattenableFieldFlattened(reinterpret_cast<J9Class *>(containingClass), fieldShape);
98239836
}
98249837

9838+
bool
9839+
TR_ResolvedJ9Method::isDAAExternalDecimalWrapperMethod()
9840+
{
9841+
// DAA External Decimal check method
9842+
return (this->TR_ResolvedMethod::getRecognizedMethod() == TR::com_ibm_dataaccess_ExternalDecimal_checkExternalDecimal);
9843+
}
9844+
98259845
bool
98269846
TR_ResolvedJ9Method::isDAAWrapperMethod()
98279847
{
9828-
return isDAAMarshallingWrapperMethod() || isDAAPackedDecimalWrapperMethod();
9848+
return isDAAMarshallingWrapperMethod() || isDAAPackedDecimalWrapperMethod() || isDAAExternalDecimalWrapperMethod();
98299849
}
98309850

98319851
bool
@@ -9966,10 +9986,17 @@ TR_ResolvedJ9Method::isDAAPackedDecimalWrapperMethod()
99669986
return false;
99679987
}
99689988

9989+
bool
9990+
TR_ResolvedJ9Method::isDAAExternalDecimalIntrinsicMethod()
9991+
{
9992+
// DAA External Decimal check method
9993+
return (this->TR_ResolvedMethod::getRecognizedMethod() == TR::com_ibm_dataaccess_ExternalDecimal_checkExternalDecimal_);
9994+
}
9995+
99699996
bool
99709997
TR_ResolvedJ9Method::isDAAIntrinsicMethod()
99719998
{
9972-
return isDAAMarshallingIntrinsicMethod() || isDAAPackedDecimalIntrinsicMethod();
9999+
return isDAAMarshallingIntrinsicMethod() || isDAAPackedDecimalIntrinsicMethod() || isDAAExternalDecimalIntrinsicMethod();
997310000
}
997410001

997510002
bool

Diff for: runtime/compiler/env/j9method.h

+2
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,11 @@ class TR_ResolvedJ9Method : public TR_J9Method, public TR_ResolvedJ9MethodBase
471471
bool isDAAWrapperMethod();
472472
bool isDAAMarshallingWrapperMethod();
473473
bool isDAAPackedDecimalWrapperMethod();
474+
bool isDAAExternalDecimalWrapperMethod();
474475
bool isDAAIntrinsicMethod();
475476
bool isDAAMarshallingIntrinsicMethod();
476477
bool isDAAPackedDecimalIntrinsicMethod();
478+
bool isDAAExternalDecimalIntrinsicMethod();
477479

478480
protected:
479481
TR_ResolvedMethod * aotMaskResolvedPossiblyPrivateVirtualMethod(TR::Compilation *comp, TR_ResolvedMethod *method);

Diff for: runtime/compiler/il/ILOpCodesEnum.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "compiler/il/OMRILOpCodesEnum.hpp"
2727

2828
FirstJ9Op = LastScalarOMROp + 1,
29-
LastJ9Op = BCDCHK,
29+
LastJ9Op = zdchk,
3030
FirstTROp = FirstOMROp,
3131
LastTROp = LastJ9Op,
3232

Diff for: runtime/compiler/il/Opcodes.enum

+16
Original file line numberDiff line numberDiff line change
@@ -1542,3 +1542,19 @@ OPCODE_MACRO(\
15421542
/* .ifCompareOpCode = */ TR::BadILOp, \
15431543
/* .description = */ \
15441544
)
1545+
OPCODE_MACRO(\
1546+
/* .opcode = */ zdchk, \
1547+
/* .name = */ "zdchk", \
1548+
/* .properties1 = */ 0, \
1549+
/* .properties2 = */ ILProp2::ValueNumberShare | ILProp2::SupportedForPRE, \
1550+
/* .properties3 = */ 0, \
1551+
/* .properties4 = */ ILProp4::BinaryCodedDecimalOp, \
1552+
/* .dataType = */ TR::Int32, \
1553+
/* .typeProperties = */ ILTypeProp::Size_4 | ILTypeProp::Integer, \
1554+
/* .childProperties = */ TWO_CHILD(TR::ZonedDecimal, TR::Int8), \
1555+
/* .swapChildrenOpCode = */ TR::BadILOp, \
1556+
/* .reverseBranchOpCode = */ TR::BadILOp, \
1557+
/* .booleanCompareOpCode = */ TR::BadILOp, \
1558+
/* .ifCompareOpCode = */ TR::BadILOp, \
1559+
/* .description = zoned decimal validity checking */ \
1560+
)

Diff for: runtime/compiler/ilgen/Walker.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -4190,6 +4190,8 @@ break
41904190
DAA_PRINT(TR::com_ibm_dataaccess_PackedDecimal_shiftRightPackedDecimal);
41914191
DAA_PRINT(TR::com_ibm_dataaccess_PackedDecimal_movePackedDecimal);
41924192

4193+
DAA_PRINT(TR::com_ibm_dataaccess_ExternalDecimal_checkExternalDecimal);
4194+
41934195
default:
41944196
break;
41954197
}

Diff for: runtime/compiler/optimizer/DataAccessAccelerator.cpp

+101
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,14 @@ int32_t TR_DataAccessAccelerator::performOnBlock(TR::Block* block, TreeTopContai
343343
++result;
344344
}
345345
break;
346+
// DAA External Decimal Check
347+
case TR::com_ibm_dataaccess_ExternalDecimal_checkExternalDecimal_:
348+
if (comp()->target().cpu.supportsFeature(OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL_ENHANCEMENT_FACILITY_3)
349+
&& inlineCheckExternalDecimal(treeTop, callNode))
350+
{
351+
++result;
352+
}
353+
break;
346354

347355
default:
348356
matched = false;
@@ -846,6 +854,99 @@ bool TR_DataAccessAccelerator::inlineCheckPackedDecimal(TR::TreeTop *callTreeTop
846854
return false;
847855
}
848856

857+
bool TR_DataAccessAccelerator::inlineCheckExternalDecimal(TR::TreeTop *callTreeTop, TR::Node *callNode)
858+
{
859+
TR::Node *byteArrayNode = callNode->getChild(0);
860+
TR::Node *offsetNode = callNode->getChild(1);
861+
TR::Node *precisionNode = callNode->getChild(2);
862+
TR::Node *typeNode = callNode->getChild(3);
863+
TR::Node *bytesWithSpacesNode = callNode->getChild(4);
864+
865+
int32_t precision = precisionNode->getInt();
866+
int32_t bytesWithSpaces = bytesWithSpacesNode->getInt();
867+
int32_t type = typeNode->getInt();
868+
const char *failMsg = NULL;
869+
870+
/* Hardware expects both, precision and bytesWithSpaces to be
871+
* 5 bit unsigned binary integer. However, 0 is valid only for
872+
* bytesWithSpaces. This is why precision must be within [1-31]
873+
* range and bytesWithSpaces must be within [0-31] range.
874+
*/
875+
// TODO: Add support for non-constant arguments
876+
if (!isChildConst(callNode, 2))
877+
failMsg = "Precision is not constant";
878+
else if (precision < 1 || precision > 31)
879+
failMsg = "Precision value is not in valid range [1-31]";
880+
else if (!isChildConst(callNode, 3))
881+
failMsg = "Decimal type node is not constant";
882+
else if (type < 1 || type > 4)
883+
failMsg = "Invalid decimal type. Supported types are (1|2|3|4)";
884+
else if (!isChildConst(callNode, 4))
885+
failMsg = "bytesWithSpaces node is not constant";
886+
else if (bytesWithSpaces < 0 || bytesWithSpaces > 31)
887+
failMsg = "bytesWithSpaces value not in valid range [0-31]";
888+
889+
if (failMsg)
890+
{
891+
TR::DebugCounter::incStaticDebugCounter(comp(),
892+
TR::DebugCounter::debugCounterName(comp(),
893+
"DAA/rejected/chkZonedDecimal"));
894+
895+
return printInliningStatus (false, callNode, failMsg);
896+
}
897+
898+
if (performTransformation(comp(), "O^O TR_DataAccessAccelerator: inlineCheckZonedDecimal on callNode %p\n", callNode))
899+
{
900+
TR::DebugCounter::incStaticDebugCounter(comp(),
901+
TR::DebugCounter::debugCounterName(comp(),
902+
"DAA/inlined/chkZonedDecimal"));
903+
904+
insertByteArrayNULLCHK(callTreeTop, callNode, byteArrayNode);
905+
906+
TR::DataType decimalType = TR::DataTypes::NoType;
907+
TR::ILOpCodes loadOpCode = TR::BadILOp;
908+
if (type == 1)
909+
{
910+
decimalType = TR::ZonedDecimal;
911+
loadOpCode = TR::zdloadi;
912+
}
913+
else if (type == 2)
914+
{
915+
decimalType = TR::ZonedDecimalSignLeadingEmbedded;
916+
loadOpCode = TR::zdsleLoadi;
917+
}
918+
else if (type == 3)
919+
{
920+
decimalType = TR::ZonedDecimalSignTrailingSeparate;
921+
loadOpCode = TR::zdstsLoadi;
922+
}
923+
else if (type == 4)
924+
{
925+
decimalType = TR::ZonedDecimalSignLeadingSeparate;
926+
loadOpCode = TR::zdslsLoadi;
927+
}
928+
int32_t precisionSizeInNumberOfBytes = TR::DataType::getSizeFromBCDPrecision(decimalType, precision);
929+
930+
insertByteArrayBNDCHK(callTreeTop, callNode, byteArrayNode, offsetNode, 0);
931+
insertByteArrayBNDCHK(callTreeTop, callNode, byteArrayNode, offsetNode, precisionSizeInNumberOfBytes - 1);
932+
933+
TR::SymbolReference* zonedDecimalSymbolReference = comp()->getSymRefTab()->findOrCreateArrayShadowSymbolRef(decimalType, NULL, precisionSizeInNumberOfBytes, fe());
934+
TR::Node* zdchkChild0Node = TR::Node::createWithSymRef(loadOpCode, 1, 1, constructAddressNode(callNode, byteArrayNode, offsetNode), zonedDecimalSymbolReference);
935+
zdchkChild0Node->setDecimalPrecision(precision);
936+
937+
byteArrayNode->decReferenceCount();
938+
offsetNode->decReferenceCount();
939+
precisionNode->decReferenceCount();
940+
typeNode->decReferenceCount();
941+
942+
TR::Node* bytesWithSpacesConstNode = TR::Node::bconst(static_cast<uint8_t>(bytesWithSpaces));
943+
TR::Node::recreateWithoutProperties(callNode, TR::zdchk, 2, zdchkChild0Node, bytesWithSpacesConstNode);
944+
return true;
945+
}
946+
947+
return false;
948+
}
949+
849950
TR::Node* TR_DataAccessAccelerator::insertIntegerGetIntrinsic(TR::TreeTop* callTreeTop, TR::Node* callNode, int32_t sourceNumBytes, int32_t targetNumBytes)
850951
{
851952
if (targetNumBytes != 1 && targetNumBytes != 2 && targetNumBytes != 4 && targetNumBytes != 8)

Diff for: runtime/compiler/optimizer/DataAccessAccelerator.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ class TR_DataAccessAccelerator : public TR::Optimization
211211
TR::Node* insertDecimalSetIntrinsic(TR::TreeTop* callTreeTop, TR::Node* callNode, int32_t sourceNumBytes, int32_t targetNumBytes);
212212

213213
bool inlineCheckPackedDecimal(TR::TreeTop* callTreeTop, TR::Node* callNode);
214+
bool inlineCheckExternalDecimal(TR::TreeTop* callTreeTop, TR::Node* callNode);
214215

215216
private:
216217

Diff for: runtime/compiler/optimizer/InlinerTempForJ9.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -5431,6 +5431,9 @@ TR_J9InlinerPolicy::supressInliningRecognizedInitialCallee(TR_CallSite* callsite
54315431
// DAA Packed Decimal check method
54325432
case TR::com_ibm_dataaccess_PackedDecimal_checkPackedDecimal_:
54335433

5434+
// DAA External Decimal check method
5435+
case TR::com_ibm_dataaccess_ExternalDecimal_checkExternalDecimal_:
5436+
54345437
// DAA Packed Decimal <-> Integer
54355438
case TR::com_ibm_dataaccess_DecimalData_convertPackedDecimalToInteger_:
54365439
case TR::com_ibm_dataaccess_DecimalData_convertPackedDecimalToInteger_ByteBuffer_:

Diff for: runtime/compiler/optimizer/J9LocalCSE.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ J9::LocalCSE::shouldCommonNode(TR::Node *parent, TR::Node *node)
117117
case TR::com_ibm_dataaccess_PackedDecimal_equalsPackedDecimal_:
118118
case TR::com_ibm_dataaccess_PackedDecimal_notEqualsPackedDecimal_:
119119
case TR::com_ibm_dataaccess_PackedDecimal_checkPackedDecimal_:
120+
case TR::com_ibm_dataaccess_ExternalDecimal_checkExternalDecimal_:
120121
case TR::com_ibm_dataaccess_DecimalData_convertExternalDecimalToPackedDecimal_:
121122
case TR::com_ibm_dataaccess_DecimalData_convertPackedDecimalToExternalDecimal_:
122123
case TR::com_ibm_dataaccess_DecimalData_convertPackedDecimalToUnicodeDecimal_:

Diff for: runtime/compiler/optimizer/J9SimplifierTable.enum

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
#define pdModifyPrecisionSimplifierHandler pdshlSimplifier
119119
#define countDigitsSimplifierHandler dftSimplifier
120120
#define BCDCHKSimplifierHandler dftSimplifier
121+
#define zdchkSimplifierHandler dftSimplifier
121122

122123
#include "optimizer/OMRSimplifierTable.enum"
123124

Diff for: runtime/compiler/runtime/SignalHandler.c

+15-4
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,11 @@ UDATA jitPPCHandler(J9VMThread* vmThread, U_32 sigType, void* sigInfo)
564564
*iarPtr = (UDATA) ((void *) &jitHandleInternalErrorTrap);
565565
#endif
566566
return J9PORT_SIG_EXCEPTION_CONTINUE_EXECUTION;
567-
567+
568568
}
569569
else if (J9PORT_SIG_FLAG_SIGTRAP == sigType) {
570570
IDATA trapType = jitPPCIdentifyCodeCacheTrapType((U_8 *) *iarPtr);
571-
571+
572572
switch (trapType) {
573573

574574
case TRAP_TYPE_NULL_CHECK:
@@ -937,8 +937,19 @@ UDATA restoreSystemStackPointerState(J9VMThread* vmThread, U_32 sigType, void* s
937937
return J9PORT_SIG_EXCEPTION_CONTINUE_EXECUTION;
938938
}
939939

940+
#ifdef EMULATE_ZNEXT
941+
extern int jitS390Emulation(J9VMThread* vmThread, void* sigInfo);
942+
#endif
943+
940944
UDATA jit390Handler(J9VMThread* vmThread, U_32 sigType, void* sigInfo)
941945
{
946+
#ifdef EMULATE_ZNEXT
947+
if (J9PORT_SIG_FLAG_SIGILL == sigType && jitS390Emulation(vmThread, sigInfo) == 0)
948+
{
949+
return J9PORT_SIG_EXCEPTION_CONTINUE_EXECUTION;
950+
}
951+
#endif
952+
942953
PORT_ACCESS_FROM_VMC(vmThread);
943954

944955
J9JITConfig *jitConfig = vmThread->javaVM->jitConfig;
@@ -1251,13 +1262,13 @@ UDATA jit390Handler(J9VMThread* vmThread, U_32 sigType, void* sigInfo)
12511262
/* add one to *controlPC for symmetry with IA32, handler check subs one */
12521263
jit390SetTrapHandler(controlPC, entryPointRegister, (void *) &jitHandleNullPointerExceptionTrap);
12531264
return restoreSystemStackPointerState(vmThread, sigType, sigInfo);
1254-
1265+
12551266
case TRAP_TYPE_INTERNAL_ERROR:
12561267
vmThread->jitException = (J9Object *) (controlPCValue + 1);
12571268
/* add one to *controlPC for symmetry with IA32, handler check subs one */
12581269
jit390SetTrapHandler(controlPC, entryPointRegister, (void *) &jitHandleInternalErrorTrap);
12591270
return restoreSystemStackPointerState(vmThread, sigType, sigInfo);
1260-
1271+
12611272
case TRAP_TYPE_ARRAY_BOUNDS:
12621273
vmThread->jitException = (J9Object *) (controlPCValue + 1);
12631274
/* add one to *controlPC for symmetry with IA32, handler check subs one */

0 commit comments

Comments
 (0)