From 67d3ec50be04276fc82b29f6edb1c6d059c4fe9f Mon Sep 17 00:00:00 2001 From: Akira Saitoh Date: Wed, 13 Dec 2023 11:26:57 +0900 Subject: [PATCH] AArch64: Add class unload pic to class constant under ifacmp node Class unload pics must be added to class constants so that constants can be invalidated when they are unloaded. aconstEvaluator does add them on AArch64. However, ificmpHelper does not evaluate aconst node if the constant value can be encoded into the immediate field of the cmp instruction. This commit updates ificmpHelper to evaluate aconst node if class unload pic is required. Signed-off-by: Akira Saitoh --- compiler/aarch64/codegen/ControlFlowEvaluator.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/aarch64/codegen/ControlFlowEvaluator.cpp b/compiler/aarch64/codegen/ControlFlowEvaluator.cpp index dc78bbe94ac..24e5f3dcf31 100644 --- a/compiler/aarch64/codegen/ControlFlowEvaluator.cpp +++ b/compiler/aarch64/codegen/ControlFlowEvaluator.cpp @@ -155,6 +155,11 @@ static TR::Instruction *ificmpHelper(TR::Node *node, TR::ARM64ConditionCode cc, TR::RegisterDependencyConditions *deps; bool secondChildNeedsRelocation = cg->profiledPointersRequireRelocation() && (secondChild->getOpCodeValue() == TR::aconst) && (secondChild->isClassPointerConstant() || secondChild->isMethodPointerConstant()); + TR_ResolvedMethod *method = comp->getCurrentMethod(); + bool secondChildNeedsPicSite = (secondChild->getOpCodeValue() == TR::aconst) && + ((secondChild->isClassPointerConstant() && cg->fe()->isUnloadAssumptionRequired(reinterpret_cast(secondChild->getAddress()), method)) || + (node->isMethodPointerConstant() && cg->fe()->isUnloadAssumptionRequired( + cg->fe()->createResolvedMethod(cg->trMemory(), reinterpret_cast(secondChild->getAddress()), method)->classOfMethod(), method))); #ifdef J9_PROJECT_SPECIFIC if (secondChildNeedsRelocation) @@ -226,7 +231,7 @@ if (secondChildNeedsRelocation) } } - if ((!secondChildNeedsRelocation) && secondChild->getOpCode().isLoadConst() && secondChild->getRegister() == NULL) + if ((!secondChildNeedsRelocation) && (!secondChildNeedsPicSite) && secondChild->getOpCode().isLoadConst() && secondChild->getRegister() == NULL) { int64_t value = is64bit ? secondChild->getLongInt() : secondChild->getInt(); if (constantIsUnsignedImm12(value) || constantIsUnsignedImm12(-value) ||