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

JIT common and x86 support for constant dynamic #2912

Merged
merged 1 commit into from
Sep 6, 2018

Conversation

yanluo7
Copy link
Contributor

@yanluo7 yanluo7 commented Aug 30, 2018

Signed-off-by: Yan Luo Yan_Luo@ca.ibm.com

@yanluo7
Copy link
Contributor Author

yanluo7 commented Aug 30, 2018

openj9 dependency: eclipse-openj9/openj9#2754
Design documentation is detailed in eclipse-openj9/openj9#2307

@yanluo7
Copy link
Contributor Author

yanluo7 commented Aug 30, 2018

@cathyzhyi Could you do a review?

@cathyzhyi
Copy link
Contributor

LGTM

@@ -243,7 +243,9 @@ OMR::SymbolReference::getUseDefAliasesBV(bool isDirectCall, bool includeGCSafePo
case TR::Symbol::IsShadow:
case TR::Symbol::IsStatic:
{
if ((self()->isUnresolved() && !_symbol->isConstObjectRef()) || _symbol->isVolatile() || self()->isLiteralPoolAddress() ||
// For condy symbol, be conservative due to potential side effects from bootstrap method
if ((self()->isUnresolved() && (_symbol->isConstantDynamic() || !_symbol->isConstObjectRef())) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please elaborate on this condition ?

"is constant dynamic OR !is constant object ref" seems like an odd combination...

Copy link
Contributor Author

@yanluo7 yanluo7 Sep 5, 2018

Choose a reason for hiding this comment

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

Previously, if the symbol is true for isConstObjectRef, we would not return the conservative aliasing BV here, which in this place, is opposite to what we want for ConstantDynamic. On the other hand, the query isConstObjectRef is used in other places in the JIT and upon examining each of these uses, we believe ConstantDynamic should also be included as part of the query instead of explicit ORing them isConstantDynamic() || isConstObjectRef(). So in the few exception cases here in Aliases.cpp, we made the logic that says in case of isConstObjectRef. don't return the conservative aliasing unless it's condy.

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems... confusing. I would think it would warrant a more elaborated explanation within a comment in the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm still a bit unclear after the explanation. Two questions that come to mind:

  1. You said "if the symbol is true for isConstObjectRef, we would not return the conservative aliasing BV here, which in this place, is opposite to what we want for ConstantDynamic." Why do we want the opposite behaviour for constant dynamic here ?

  2. You said "isConstObjectRef is used in other places in the JIT and upon examining each of these uses, we believe ConstantDynamic should also be included as part of the query instead of explicit ORing them". To be completely clear does this mean that we return true for a constant dynamic symbol reference when we call isConstObjectRef ? If the answer to that question is "yes" then I don't understand how the logical OR can achieve the desired result you mention in your comment "So in the few exception cases here in Aliases.cpp, we made the logic that says in case of isConstObjectRef. don't return the conservative aliasing unless it's condy." ... I'd have thought you would have needed a logical AND instead, i.e. if isConstObjectRef && !isConstantDynamic then do the original behaviour for const object ref at this spot in the code. I'm probably missing something...

Copy link
Contributor Author

@yanluo7 yanluo7 Sep 5, 2018

Choose a reason for hiding this comment

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

  1. For unresolved condy, we need to invoke a Java bootstrap method, which can have arbitrary side effects, so the aliasing should be conservative here.

  2. Yes to returning true for a constant dynamic symbol reference when we call isConstObjectRef.
    We added |ConstantDynamic in the _flags2.testAny check:

bool
OMR::Symbol::isConstObjectRef()
    {
    return self()->isStatic() && (_flags.testAny(ConstString)  || 
         _flags2.testAny(ConstMethodType|ConstMethodHandle|ConstantDynamic));
    }

In the JIT code, there are quite a few uses of isConstObjectRef where ConstantDynamic should also apply, e.g.:

   if (isConstObjectRef())
       // certain inliner heuristic

So by incorporating ConstantDynamic into the isConstObjectRef query, we don't need to change all of those places.

The exception cases are in Alaises.cpp. In this place previously the logic was:

 if (self()->isUnresolved() && !_symbol->isConstObjectRef() 
        || ...)
            {
            return &comp->getSymRefTab()->aliasBuilder.defaultMethodDefAliases();
            }

If we are unresolved and not isConstObjectRef, we return the conservative defaultMethodDefAliases, and defaultMethodDefAliases is the desired for condy.
But given that isConstObjectRef now returns true for condy, this logic as-is would not work for condy. So we add an explicit condition, more like a short-circuit, to say if we are unresolved and not isConstObjectRef (this is the same as before), or if we are unresolved and condy (this is the extra condition added), we would return conservative aliases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay thanks for the explanation. Please add some version of this explanation to the code comments as Filip requested.

Signed-off-by: Yan Luo <Yan_Luo@ca.ibm.com>
@vijaysun-omr vijaysun-omr merged commit c5c00d4 into eclipse-omr:master Sep 6, 2018
@mstoodle
Copy link
Contributor

mstoodle commented Sep 6, 2018

genie-omr build all

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.

5 participants