Skip to content

Conversation

@ehsankianifar
Copy link
Contributor

@r30shah
This PR add support for offheap 2D array allocation. It is calling helper if the second dim is zero length and allocating offheap. I have a few possible solutions for that.

@ehsankianifar ehsankianifar changed the title Z: Add support for offheap allocation in multianewarray evaluator Add support for offheap allocation in multianewarray evaluator on IBM Z platform Oct 17, 2025
@ehsankianifar ehsankianifar marked this pull request as draft October 17, 2025 15:39
@ehsankianifar
Copy link
Contributor Author

Remove WIP when I finish testing

@ehsankianifar
Copy link
Contributor Author

Local tests pass. I remove the WIP and launching jenkin tests.
The compilation logs:
offHeap.log

@ehsankianifar ehsankianifar self-assigned this Oct 17, 2025
@ehsankianifar ehsankianifar requested a review from r30shah October 17, 2025 16:53
@ehsankianifar ehsankianifar marked this pull request as ready for review October 17, 2025 16:53
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.

@VermaSh - Can I request your review on this first for off heap?

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.

Enhances the multianewarray evaluator to support offheap allocation on
IMB Z platform. Offheap allocation for arrays with a zero-length second
dimension is not supported; in such cases, a helper call is triggered
to handle the allocation.

Please fix typo (IBM Z not IMB Z).

I have not looked into your code - but can you confirm this statement is true or not.

  • We did inline zero-length first / second dimension array when off-heap is enabled. But changes in this PR will divert those case to helper (Or only zero length second dimension) and only inlines if both dimension is not zero?

@ehsankianifar ehsankianifar force-pushed the Z_AddOffheapSupportInMultianewarrayEvaluator branch from d4792d2 to f7b0fe2 Compare October 20, 2025 13:47
@ehsankianifar
Copy link
Contributor Author

Thanks @r30shah! I fixed the commit message. Yes, we were inlining zero length 2D arrays before, then we disable inlining offheap and with this change we enable offheap except for zero length second dim.
A subsequent PR will fix inlining of zero second length arrays.

@r30shah
Copy link
Contributor

r30shah commented Oct 20, 2025

Is it that complicated to fix for zero second length that you will do in second PR?

@ehsankianifar
Copy link
Contributor Author

Is it that complicated to fix for zero second length that you will do in second PR?

No I have a few ideas but want to select a plan that has minimum impact on the non zero allocation since I expect non-zero to get called more frequently.

dependencies->addPostCondition(dim2SizeReg, TR::RealRegister::AssignAny);
cursor = generateRXInstruction(cg, TR::InstOpCode::LTGF, node, dim2SizeReg, generateS390MemoryReference(dimsPtrReg, 0, cg), cursor);
iComment("Load 2st dim length.");
// The size of zero length array is already loaded in size register. Jump over the array size calculation instructions if length is 0.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're no longer writing 0 to dim2SizeReg, this comment can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks shubham. Comment was removed

@ehsankianifar ehsankianifar force-pushed the Z_AddOffheapSupportInMultianewarrayEvaluator branch from f7b0fe2 to deaab6d Compare October 20, 2025 16:17
@ehsankianifar
Copy link
Contributor Author

@r30shah @VermaSh I pushed the changes to support zero length offheap allocation as well as non-zero length.

@ehsankianifar
Copy link
Contributor Author

ehsankianifar commented Oct 23, 2025

@hzongaro pointed that we do not inline constant non-zero second dimension 2D arrays (#22562 (review)). I am trying to see why it was added and will remove the condition if it is not necessary anymore.

@ehsankianifar ehsankianifar force-pushed the Z_AddOffheapSupportInMultianewarrayEvaluator branch 2 times, most recently from f788654 to fa536c3 Compare October 24, 2025 16:29
@VermaSh
Copy link
Contributor

VermaSh commented Oct 27, 2025

@ehsankianifar Is this ready for review or are you still working on adding changes?

@ehsankianifar
Copy link
Contributor Author

@ehsankianifar Is this ready for review or are you still working on adding changes?

Thanks @VermaSh, Yes it is ready for review.

Enhances the multianewarray evaluator to support offheap allocation on
IBM Z platform. Offheap allocation for arrays with a zero-length second
dimension is not supported; in such cases, a helper call is triggered
to handle the allocation.

signed-off-by: Ehsan Kiani Far <[email protected]>
Enhances the multianewarray evaluator to support zero-length offheap
allocation on IBM Z platform.

signed-off-by: Ehsan Kiani Far <[email protected]>
Previously, inlining of constant 2D arrays with a non-zero second
dimension was disabled on z due to limitations in handling such cases.
However, recent improvements have resolved those issues, making it safe
and beneficial to inline these arrays.
Remove the constraint that prevented inlining of non-zero constant
second dimension 2D arrays.

signed-off-by: Ehsan Kiani Far <[email protected]>
@ehsankianifar ehsankianifar force-pushed the Z_AddOffheapSupportInMultianewarrayEvaluator branch from 50f14ea to 1618674 Compare October 27, 2025 18:50
@ehsankianifar
Copy link
Contributor Author

I upload a sample compilation log with constant zero length here for reference:
zeroLength.log
FYI @VermaSh

@VermaSh
Copy link
Contributor

VermaSh commented Oct 28, 2025

Thank you! @ehsankianifar. Can you please share trace logs for constant and non-constant non-zero 2nd dimension?

@ehsankianifar
Copy link
Contributor Author

Thanks @VermaSh,
The node after post lower trees is always the same regardless of the argument types and values. Here is an example of non constant length compilation log:
jitCompilation.log
The node in Pre Instruction Selection is exactly like the const zero length logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants