Skip to content

Enable inlineIntrinsicIndexOf for off-heap #21796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025

Conversation

VermaSh
Copy link
Contributor

@VermaSh VermaSh commented May 2, 2025

The acceleration was initially disabled because it added array header size to the array object, which was required to reach the elements. However, this is unnecessary for off-heap mode. Consequently, the evaluator has been updated to add the array header size exclusively for non-off-heap mode, enabling acceleration in off-heap mode.

@VermaSh VermaSh force-pushed the enableStringIndexOf branch from 0fd1762 to 0ba0739 Compare May 2, 2025 20:50
@VermaSh
Copy link
Contributor Author

VermaSh commented May 2, 2025

Launched a test build (re-run) for final verification.

@VermaSh
Copy link
Contributor Author

VermaSh commented May 2, 2025

cc: @r30shah, @zl-wang, @dchopra001

@VermaSh VermaSh marked this pull request as ready for review May 9, 2025 17:18
@VermaSh VermaSh changed the title WIP: Enable inlineIntrinsicIndexOf for off-heap Enable inlineIntrinsicIndexOf for off-heap May 9, 2025
@VermaSh
Copy link
Contributor Author

VermaSh commented May 9, 2025

Marking this ready for review since the failure weren't related to these changes. @dchopra001 Since you worked on most of these APIs, can I please get an initial review?

@VermaSh VermaSh force-pushed the enableStringIndexOf branch 2 times, most recently from de4932e to afea548 Compare May 12, 2025 16:08
Copy link
Contributor

@dchopra001 dchopra001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@VermaSh
Copy link
Contributor Author

VermaSh commented May 13, 2025

@r30shah , @zl-wang Can I please get a review?

if (TR::Compiler->om.isOffHeapAllocationEnabled())
{
// Load first data element address
generateRXInstruction(cg,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment as I had previously, TR::Register array is not clobberable register.

@@ -1168,6 +1168,30 @@ J9::Z::TreeEvaluator::inlineVectorizedStringIndexOf(TR::Node* node, TR::CodeGene
TR::Register* patternLenReg = cg->gprClobberEvaluate(node->getChild(firstCallArgIdx+3));
TR::Register* stringIndexReg = cg->gprClobberEvaluate(node->getChild(firstCallArgIdx+4));

// Offset to be added to array object pointer to get to the data elements
int32_t offsetToDataElements = TR::Compiler->om.contiguousArrayHeaderSizeInBytes();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int32_t offsetToDataElements = TR::Compiler->om.contiguousArrayHeaderSizeInBytes();
int32_t offsetToDataElements = static_cast<int32_t>(TR::Compiler->om.contiguousArrayHeaderSizeInBytes());

@@ -1880,6 +1904,23 @@ J9::Z::TreeEvaluator::inlineIntrinsicIndexOf(TR::Node * node, TR::CodeGenerator
regDeps->addPostCondition(resultVector, TR::RealRegister::AssignAny);
regDeps->addPostCondition(valueVector, TR::RealRegister::AssignAny);

// Offset to be added to array object pointer to get to the data elements
int32_t offsetToDataElements = TR::Compiler->om.contiguousArrayHeaderSizeInBytes();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int32_t offsetToDataElements = TR::Compiler->om.contiguousArrayHeaderSizeInBytes();
int32_t offsetToDataElements = static_cast<int32_t>(TR::Compiler->om.contiguousArrayHeaderSizeInBytes());

Copy link
Contributor

@zl-wang zl-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent spot-on by @r30shah . I have no further comments.

@VermaSh VermaSh force-pushed the enableStringIndexOf branch from afea548 to 758c00c Compare May 14, 2025 18:32
@VermaSh
Copy link
Contributor Author

VermaSh commented May 14, 2025

@r30shah I have updated the PR based on your suggestions. Can I please get another review?
I have launched a test build for verification.

#ifdef J9VM_GC_SPARSE_HEAP_ALLOCATION
if (TR::Compiler->om.isOffHeapAllocationEnabled())
{
srm = cg->generateScratchRegisterManager(11);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we simply clobberEvaluate node->getChild(firstCallArgIdx) and other one ?

@VermaSh VermaSh force-pushed the enableStringIndexOf branch 2 times, most recently from 54fbe6f to fa786e0 Compare May 15, 2025 21:50
@r30shah
Copy link
Contributor

r30shah commented May 15, 2025

Jenkins test sanity zlinux jdk11,jdk21

@r30shah r30shah closed this May 15, 2025
@r30shah r30shah reopened this May 15, 2025
@r30shah
Copy link
Contributor

r30shah commented May 15, 2025

Jenkins test sanity zlinux jdk11,jdk21

@VermaSh VermaSh force-pushed the enableStringIndexOf branch from fa786e0 to bf12070 Compare May 16, 2025 20:03
Copy link
Contributor

@r30shah r30shah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@r30shah
Copy link
Contributor

r30shah commented May 16, 2025

Jenkins test sanity zlinux jdk11,jdk21

The acceleration was initially disabled because it added array header
size to the array object, which was required to reach the elements.
However, this is unnecessary for off-heap mode. As a result, the
evaluator has been updated to add the array header size exclusively
for non-off-heap mode, while in off-heap mode, it now retrieves the
data element address directly from the array header, enabling
acceleration in off-heap mode.
Signed-off-by: Shubham Verma <[email protected]>
@VermaSh VermaSh force-pushed the enableStringIndexOf branch from bf12070 to d77e768 Compare May 17, 2025 03:06
@VermaSh
Copy link
Contributor Author

VermaSh commented May 17, 2025

The build failure was due to a typo. @r30shah can you please relaunch the tests?

@r30shah
Copy link
Contributor

r30shah commented May 17, 2025

Jenkins test sanity zlinux jdk11,jdk21

@r30shah r30shah merged commit a785cc7 into eclipse-openj9:master May 20, 2025
9 checks passed
@VermaSh VermaSh deleted the enableStringIndexOf branch May 20, 2025 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants