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

Replace calls to indexedTrampolineLookup with findHelperTrampoline #4746

Merged
merged 1 commit into from
Feb 19, 2019

Conversation

0xdaryl
Copy link
Contributor

@0xdaryl 0xdaryl commented Feb 14, 2019

Ask the CodeCacheManager directly for the helper trampoline address.

Change the return type of CodeCacheManager::findHelperTrampoline to an intptrj_t
and fix up references. Introduce a J9 version of findHelperTrampoline to
prevent breakages while upstream OMR is changed.

Change some invocations of findHelperTrampoline to use the new form where the
helper index is the first parameter.

Signed-off-by: Daryl Maier maier@ca.ibm.com

@0xdaryl 0xdaryl added comp:jit depends:omr Pull request is dependent on a corresponding change in OMR labels Feb 14, 2019
@0xdaryl 0xdaryl changed the title Replace calls to indexedTrampolineLookup with findHelperTrampoline WIP: Replace calls to indexedTrampolineLookup with findHelperTrampoline Feb 14, 2019
@0xdaryl
Copy link
Contributor Author

0xdaryl commented Feb 14, 2019

Depends on eclipse-omr/omr#3570

@0xdaryl
Copy link
Contributor Author

0xdaryl commented Feb 15, 2019

Jenkins test sanity all jdk11

@0xdaryl 0xdaryl marked this pull request as ready for review February 15, 2019 21:03
@0xdaryl 0xdaryl changed the title WIP: Replace calls to indexedTrampolineLookup with findHelperTrampoline Replace calls to indexedTrampolineLookup with findHelperTrampoline Feb 15, 2019
@0xdaryl
Copy link
Contributor Author

0xdaryl commented Feb 15, 2019

Un-WIPing as upstream changes have made it to openj9-omr.

Copy link
Contributor Author

@0xdaryl 0xdaryl left a comment

Choose a reason for hiding this comment

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

This PR is the OpenJ9 piece of eliminating the FrontEnd function to lookup a helper trampoline, and instead ask the CodeCacheManager directly. For the most part, this is what the FrontEnd function does anyway.

One notable difference is that the OpenJ9 FrontEnd function indexedTrampolineLookup actually performs the lookup in a critical section. I'm not sure this is actually required as the helper trampolines never change in a code cache. Also, there are already direct calls to the CodeCacheManager::findHelperTrampoline throughout the compiler which would occur without the critical section. So, we're already wildly inconsistent on this. I chose to eliminate the critical section altogether. If anyone can think of the reason why it's needed then its easy for me to add back in as a specialization in the J9 version of CodeCacheManager.

The FrontEnd implementation of indexedTrampolineLookup will be deleted once uses are eliminated from upstream OMR.

@@ -237,19 +238,16 @@ void J9::Recompilation::methodHasBeenRecompiled(void *oldStartPC, void *newStart

uint32_t encodeRuntimeHelperBranchAndLink(TR_RuntimeHelper helper, uint8_t *cursor, TR_FrontEnd *fe)
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function needed a bit more love because of its inconsistent use of a single data type to represent the target address.

@@ -64,103 +64,3 @@ uint32_t TR::ARMRecompilationSnippet::getLength(int32_t estimatedSnippetStart)
{
return 12;
}
/*
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This commented out block of code has long been deprecated. It contained a reference to the indexedTrampolineLookup so I simply deleted the whole thing.

@@ -723,3 +723,9 @@ J9::CodeCacheManager::printOccupancyStats()
}
}


intptrj_t
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Provide a version of findHelperTrampoline that returns an intptrj_t type rather than void *. This eliminates a number of casts that would be immediately required when using this function.

@0xdaryl
Copy link
Contributor Author

0xdaryl commented Feb 15, 2019

@dsouzai @fjeremic @ymanton @mpirvu : I'd appreciate a review and merge from at least one of you please.

Copy link
Contributor

@dsouzai dsouzai left a comment

Choose a reason for hiding this comment

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

Why is there

OMR::CodeCacheManager::findHelperTrampoline(int32_t helperIndex, void *callSite)
OMR::CodeCacheManager::findHelperTrampoline(void *callingPC, int32_t helperIndex)

but only

J9::CodeCacheManager::findHelperTrampoline(int32_t helperIndex, void *callSite)

Wouldn't it be really easy for someone in OpenJ9 to accidentally switch the parameters and end up calling the OMR version?

EDIT: nvm, I see the comment about it being a temporary function; does this mean that eventually there will only be a single OMR function rather the two?

@@ -213,14 +214,14 @@ TR::S390J9CallSnippet::generateInvokeExactJ2IThunk(TR::Node * callNode, int32_t
cursor += 2;

TR::SymbolReference *helper = cg->symRefTab()->findOrCreateRuntimeHelper(TR_methodHandleJ2IGlue, false, false, false);
uintptrj_t destAddr = (uintptrj_t)helper->getMethodAddress();
intptrj_t destAddr = (uintptrj_t)helper->getMethodAddress();
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick, the cast is (uintptrj_t) but the type of destAddr is intptrj_t.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a nit pick. Thanks for pointing that out. I'll fix and re-push.

@dsouzai
Copy link
Contributor

dsouzai commented Feb 15, 2019

If anyone can think of the reason why it's needed then its easy for me to add back in as a specialization in the J9 version of CodeCacheManager.

I thought the critical section was using a monitor, but it's a VMAccessCriticalSection. I really can't think of why the JIT would need VM Access for the code cache. If I were grasping for straws, I'd say the only situation it might matter is under FSD (because of the jettisoning of the code cache)?

Copy link
Contributor

@dsouzai dsouzai left a comment

Choose a reason for hiding this comment

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

LGTM, though I'll hold off on merging until the response to the question about why there are two OMR APIs but only one OpenJ9 API.

@0xdaryl
Copy link
Contributor Author

0xdaryl commented Feb 16, 2019

re/ the findHelperTrampoline in J9::CodeCacheManager:

My intention is to change the return type of this function. I introduced this version of the function temporarily in OpenJ9 to prevent build breakages because of the coordinated changes required in OMR.

Next steps:

  • Once this PR is merged, in OMR replace uses of indexedTrampolineLookup with direct calls to findHelperTrampoline and add this findHelperTrampoline API to OMR
  • Once that PR is merged, in OpenJ9 remove the FrontEnd implementation of indexedTrampolineLookup and this temporary function
  • Once that PR is merged, remove deprecated FrontEnd API in OMR

Ask the CodeCacheManager directly for the helper trampoline address.

Change the return type of `CodeCacheManager::findHelperTrampoline` to an `intptrj_t`
and fix up references.  Introduce a J9 version of `findHelperTrampoline` to
prevent breakages while upstream OMR is changed.

Change some invocations of `findHelperTrampoline` to use the new form where the
helper index is the first parameter.

Signed-off-by: Daryl Maier <maier@ca.ibm.com>
@0xdaryl
Copy link
Contributor Author

0xdaryl commented Feb 16, 2019

Jenkins test sanity all jdk11

@dsouzai dsouzai merged commit 69efe7f into eclipse-openj9:master Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:jit depends:omr Pull request is dependent on a corresponding change in OMR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants