Skip to content

Define trivialInliningOnly() in TR_InlinerBase and OMR_InlinerPolicy - #7702

Merged
vijaysun-omr merged 1 commit into
eclipse-omr:masterfrom
jdmpapin:trivialInliningOnly
Mar 28, 2025
Merged

Define trivialInliningOnly() in TR_InlinerBase and OMR_InlinerPolicy#7702
vijaysun-omr merged 1 commit into
eclipse-omr:masterfrom
jdmpapin:trivialInliningOnly

Conversation

@jdmpapin

Copy link
Copy Markdown
Contributor

Some targets are meant to be handled by tryToInlineTrivialMethod() and cannot be inlined by generating IL in the usual way. So far the implementation of tryToInlineTrivialMethod() has been required to return true for such targets even in cases where the call is not transformed.

This new method provides a way to tell the inliner that a given target should have been handled by tryToInlineTrivialMethod() and that IL generation should not be attempted. If the inliner is informed in this way, then it will be possible for tryToInlineTrivialMethod() to return false when it fails.

Some targets are meant to be handled by tryToInlineTrivialMethod() and
cannot be inlined by generating IL in the usual way. So far the
implementation of tryToInlineTrivialMethod() has been required to return
true for such targets even in cases where the call is not transformed.

This new method provides a way to tell the inliner that a given target
should have been handled by tryToInlineTrivialMethod() and that IL
generation should not be attempted. If the inliner is informed in this
way, then it will be possible for tryToInlineTrivialMethod() to return
false when it fails.
@jdmpapin

Copy link
Copy Markdown
Contributor Author

@vijaysun-omr, could you please review?

@vijaysun-omr

Copy link
Copy Markdown
Contributor

Just so I understand, is this change being made because there was a specific issue with tryToInlineTrivialMethod() returning true when it did not do any transformation ? Or is it a change for making things cleaner in that it separates the notion of "can it be tranformed" vs "was it transformed" ?

@vijaysun-omr

Copy link
Copy Markdown
Contributor

Jenkins build all

@jdmpapin

Copy link
Copy Markdown
Contributor Author

is this change being made because there was a specific issue with tryToInlineTrivialMethod() returning true when it did not do any transformation ?

Yes, see eclipse-openj9/openj9#21501. OpenJ9's override of tryToInlineTrivialMethod() currently always returns true for "inlineable JNI" methods, even in failure cases. If it were to return false, inlineCallTarget2() would try to generate IL for the target, and when I tried with Unsafe.getInt(), IL generation appeared to succeed, but the generated IL was malformed.

@vijaysun-omr

Copy link
Copy Markdown
Contributor

Okay so you wanted to change the return value to false, and in that case, it led to an issue (that I can see). Returning false when we did not transform in all cases is cleaner, and so I was okay with the change, but I was asking about whether something was going wrong by returning true for such cases where we did not transform.

@jdmpapin

Copy link
Copy Markdown
Contributor Author

Oh, no, I haven't seen any actual problem caused by returning true without transforming. We do unnecessarily leave the target in the inlining table because it looks like inlining succeeded, but that should be harmless. The intention here is just to do a bit of cleanup.

@vijaysun-omr

Copy link
Copy Markdown
Contributor

Looks safe to me. Thanks for clarifying.

@vijaysun-omr
vijaysun-omr merged commit cd707e2 into eclipse-omr:master Mar 28, 2025
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.

2 participants