Skip to content
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

Add jit compile helper time to detect @ForceInline annotation #11993

Closed
tajila opened this issue Feb 17, 2021 · 15 comments · Fixed by #13109
Closed

Add jit compile helper time to detect @ForceInline annotation #11993

tajila opened this issue Feb 17, 2021 · 15 comments · Fixed by #13109
Assignees
Labels
comp:jit comp:vm project:panama Used to track Project Panama related work

Comments

@tajila
Copy link
Contributor

tajila commented Feb 17, 2021

The @ForceInline (jdk.internal.vm.annotation.ForceInline) will be used to notify the JIT that the method will benefit from inlining.

We will introduce a compile time jithelper to so the JIT can query if the method is annotated with @ForceInline or not.

First we will add a VMHelper

//@param clazz, the class that own the field
//@param the cpindex of the method to query
//@return true, if forceinline, false otherwise
BOOLEAN
isMethodTaggedForForceInline(J9Class clazz, UDATA cpIndex);

Take a look at dumpAnnotationInfo in rcdump.c to see how to look up method annotations.
To find the name of the field given a cpIndex romFieldRef = (J9ROMMethodRef *)&clazz->ramConstantPool->romConstantPool[cpIndex];

Compile time helpers are stored in cthelpers.cpp

@tajila tajila added comp:jit comp:vm project:panama Used to track Project Panama related work labels Feb 17, 2021
@tajila
Copy link
Contributor Author

tajila commented Feb 17, 2021

@gita-omr ^^

@sharon-wang
Copy link
Contributor

I'll take a dive into this

@fjeremic
Copy link
Contributor

fjeremic commented Feb 17, 2021

See related #2076 which talks about @HotSpotIntrinsicCandidate. I would love to see this made available as well (perhaps @OpenJ9IntrinsicCandidate?). Also may I suggest a slight change to the name:

isMethodTagged **With** ForceInline

@fjeremic fjeremic changed the title Add jit compile time to detect @forceline annotation Add jit compile time to detect @ForceInline annotation Feb 17, 2021
@fjeremic
Copy link
Contributor

fjeremic commented Feb 17, 2021

Also unfortunate for @forceinline 😅
I wonder how often he gets accidentally tagged in issues.

@tajila tajila changed the title Add jit compile time to detect @ForceInline annotation Add jit compile helper time to detect @ForceInline annotation Feb 18, 2021
@tajila tajila assigned tajila and unassigned sharon-wang Apr 22, 2021
@r30shah
Copy link
Contributor

r30shah commented May 5, 2021

See related #2076 which talks about @HotSpotIntrinsicCandidate. I would love to see this made available as well (perhaps @OpenJ9IntrinsicCandidate?). Also may I suggest a slight change to the name:

I am experimenting with certain methods which are tagged with @IntrinsicCandidate and was adding those to list of methods calls for which I can skip HCR guards in the compiled code. It would be nice if we have jit compiler helper that can process such tags as well. I would make JIT compiler code cleaner.

tajila added a commit to tajila/openj9 that referenced this issue May 20, 2021
Details are in the issues below.

Fixes: eclipse-openj9#11993
Fixes: eclipse-openj9#11990

Most of the work was done by Sharon Wang. Creating this PR on her
behalf.

Signed-off-by: Tobi Ajila <atobia@ca.ibm.com>
@gita-omr
Copy link
Contributor

gita-omr commented Jun 7, 2021

@tajila could we resume the discussion on what exactly is needed to implement this?

@tajila
Copy link
Contributor Author

tajila commented Jun 7, 2021

We would need to know the defining class and the method name (or moethodref). Essentially, we need to know which implementation the JIT is referring to.

The challenge is that in polymorhpic callsites there is no way to determine this statically.

@gita-omr
Copy link
Contributor

gita-omr commented Jun 8, 2021

Right. I was thinking that sometimes we try to de-virtualize a call but not necessarily inline it. At this point, we could check the annotation. Then, we could provide the exact class of the object on which we are invoking the method(might not be the one that have the method implementation though, but some of its parents would).

@tajila
Copy link
Contributor Author

tajila commented Jun 10, 2021

We can provide something like this:

BOOLEAN
jitIsMethodForceInline(J9Class *definingClass, J9ROMNameAndSignature *nameAndSig)

This means if you dont call this on the defining class you may get FALSE.

@gita-omr
Copy link
Contributor

Not sure we can find the defining class... I think it might be derived class that uses definition of some parent class...

@gita-omr
Copy link
Contributor

@tajila Please see my previous comment

@tajila
Copy link
Contributor Author

tajila commented Jun 23, 2021

for @forceinline we know that the annotation is always going to be on a final or static method. This means that if you devirtualize a callsite you can always know query the correct method. If pass the VM the implemenation method then we will always be able to respond with the correct answer.

@mzdw89
Copy link

mzdw89 commented Jun 23, 2021

Also unfortunate for @forceinline 😅
I wonder how often he gets accidentally tagged in issues.

too often 😔

@tajila
Copy link
Contributor Author

tajila commented Jun 23, 2021

sorry about that

@gita-omr
Copy link
Contributor

or @forceinline we know that the annotation is always going to be on a final or static method. This means that if you devirtualize a callsite you can always know query the correct method. If pass the VM the implemenation method then we will always be able to respond with the correct answe

Ok, will need to double check, but let's assume that for now.

EricYangIBM added a commit to EricYangIBM/openj9 that referenced this issue Jul 12, 2021
Helpers to detect `@ForceInline` and `@IntrinsicCandidate`, general
helper `methodContainsRuntimeAnnotation`

Fixes: eclipse-openj9#11993
Signed-off-by: Eric Yang <eric.yang@ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:jit comp:vm project:panama Used to track Project Panama related work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants