Skip to content

Commit

Permalink
Fix implicit conversion causing truncation warnings
Browse files Browse the repository at this point in the history
Fix AIX/pLinux, Arm, and AArch64 warnings concerning constant values
being implicitly converted from an unsigned to a signed type or from
a larger to a smaller type which had the potential to cause truncation.

Fixes #18626

Co-authored-by: Dylan Tuttle <[email protected]>
Co-authored-by: Daryl Maier <[email protected]>
  • Loading branch information
dylanjtuttle and 0xdaryl committed Dec 19, 2023
1 parent 4af048a commit 28c8327
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions runtime/compiler/p/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10574,7 +10574,7 @@ static TR::Register *inlineStringHashcode(TR::Node *node, TR::CodeGenerator *cg)

// vend = end & (~0xf)
// if v is 16byte aligned goto VSX_LOOP
generateTrg1ImmInstruction(cg, TR::InstOpCode::li, node, tempReg, 0xFFFFFFFFFFFFFFF0);
generateTrg1ImmInstruction(cg, TR::InstOpCode::li, node, tempReg, 0xFFFFFFF0);
generateTrg1Src2Instruction(cg, TR::InstOpCode::AND, node, vendReg, endReg, tempReg);
loadConstant(cg, node, 0xF, tempReg);
generateTrg1Src2Instruction(cg, TR::InstOpCode::AND, node, tempReg, valueReg, tempReg);
Expand Down Expand Up @@ -10607,7 +10607,7 @@ static TR::Register *inlineStringHashcode(TR::Node *node, TR::CodeGenerator *cg)
// advance v to next aligned pointer
// if v >= vend goto POST_VSX
generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::addi, node, valueReg, valueReg, 0xF);
generateTrg1ImmInstruction(cg, TR::InstOpCode::li, node, tempReg, 0xFFFFFFFFFFFFFFF0);
generateTrg1ImmInstruction(cg, TR::InstOpCode::li, node, tempReg, 0xFFFFFFF0);
generateTrg1Src2Instruction(cg, TR::InstOpCode::AND, node, valueReg, valueReg, tempReg);
generateTrg1Src2Instruction(cg, TR::InstOpCode::cmp8, node, condReg, valueReg, vendReg);
generateConditionalBranchInstruction(cg, TR::InstOpCode::bge, node, POSTVSXLabel, condReg);
Expand Down
30 changes: 18 additions & 12 deletions runtime/compiler/runtime/J9Runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,29 +62,35 @@ void replaceFirstTwoBytesWithData(void *startPC, int32_t startPCToData);

#if defined(TR_HOST_POWER)
#define OFFSET_REVERT_INTP_PRESERVED_FSD (-4)
#define OFFSET_REVERT_INTP_FIXED_PORTION (-12-2*sizeof(intptr_t))
#define OFFSET_REVERT_INTP_FIXED_PORTION (-(12 + 2 * (int32_t)sizeof(intptr_t)))

#define OFFSET_SAMPLING_PREPROLOGUE_FROM_STARTPC (-(16+sizeof(intptr_t)))
#define OFFSET_SAMPLING_BRANCH_FROM_STARTPC (-(12+sizeof(intptr_t)))
#define OFFSET_SAMPLING_METHODINFO_FROM_STARTPC (-(8+sizeof(intptr_t)))
#define OFFSET_SAMPLING_PREPROLOGUE_FROM_STARTPC (-(16 + (int32_t)sizeof(intptr_t)))
#define OFFSET_SAMPLING_BRANCH_FROM_STARTPC (-(12 + (int32_t)sizeof(intptr_t)))
#define OFFSET_SAMPLING_METHODINFO_FROM_STARTPC (-(8 + (int32_t)sizeof(intptr_t)))
#define OFFSET_SAMPLING_PRESERVED_FROM_STARTPC (-8)
#endif

#if defined(TR_HOST_ARM)
#define OFFSET_REVERT_INTP_FIXED_PORTION (-12-2*sizeof(intptr_t))
#define OFFSET_SAMPLING_PREPROLOGUE_FROM_STARTPC (-(16+sizeof(intptr_t)))
#define OFFSET_SAMPLING_BRANCH_FROM_STARTPC (-(12+sizeof(intptr_t)))
#define OFFSET_METHODINFO_FROM_STARTPC (-(8+sizeof(intptr_t)))
#define OFFSET_REVERT_INTP_FIXED_PORTION (-(12 + 2 * (int32_t)sizeof(intptr_t)))
#define OFFSET_SAMPLING_PREPROLOGUE_FROM_STARTPC (-(16 + (int32_t)sizeof(intptr_t)))
#define OFFSET_SAMPLING_BRANCH_FROM_STARTPC (-(12 + (int32_t)sizeof(intptr_t)))
#define OFFSET_METHODINFO_FROM_STARTPC (-(8 + (int32_t)sizeof(intptr_t)))
#define OFFSET_SAMPLING_PRESERVED_FROM_STARTPC (-8)
#define START_PC_TO_METHOD_INFO_ADDRESS -8 // offset from startpc to jitted body info
#define OFFSET_COUNTING_BRANCH_FROM_JITENTRY 36
#endif

#if defined(TR_HOST_ARM64)
#define OFFSET_REVERT_INTP_FIXED_PORTION (-12-2*sizeof(intptr_t)) // See generateSwitchToInterpreterPrePrologue()
#define OFFSET_SAMPLING_PREPROLOGUE_FROM_STARTPC (-(16+sizeof(intptr_t)))
#define OFFSET_SAMPLING_BRANCH_FROM_STARTPC (-(12+sizeof(intptr_t)))
#define OFFSET_SAMPLING_METHODINFO_FROM_STARTPC (-(8+sizeof(intptr_t)))
/**
* Prior to refactoring, the type of these expressions was an intptr_t, and
* some of the contexts in which these macros are currently used rely on them
* being that type. Until those contexts are changed to handle int32_t
* types, explicitly cast these expressions to intptr_t for type correctness.
*/
#define OFFSET_REVERT_INTP_FIXED_PORTION ( (intptr_t)(-(12 + 2 * (int32_t)sizeof(intptr_t))) ) // See generateSwitchToInterpreterPrePrologue()
#define OFFSET_SAMPLING_PREPROLOGUE_FROM_STARTPC ( (intptr_t)(-(16 + (int32_t)sizeof(intptr_t))) )
#define OFFSET_SAMPLING_BRANCH_FROM_STARTPC ( (intptr_t)(-(12 + (int32_t)sizeof(intptr_t))) )
#define OFFSET_SAMPLING_METHODINFO_FROM_STARTPC ( (intptr_t)(-(8 + (int32_t)sizeof(intptr_t))) )
#define OFFSET_SAMPLING_PRESERVED_FROM_STARTPC (-8)
#define OFFSET_COUNTING_BRANCH_FROM_JITENTRY (9*ARM64_INSTRUCTION_LENGTH)
#endif
Expand Down

0 comments on commit 28c8327

Please sign in to comment.