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

Use front-end implementation of the instanceOfOrCheckCast routines #6909

Merged
merged 3 commits into from
Nov 1, 2019

Conversation

dchopra001
Copy link
Contributor

[skip ci]
Signed-off-by: Dhruv Chopra Dhruv.C.Chopra@ibm.com

@dchopra001 dchopra001 mentioned this pull request Aug 30, 2019
32 tasks
Copy link
Contributor

@mpirvu mpirvu left a comment

Choose a reason for hiding this comment

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

extern "C" {

IDATA
instanceOfOrCheckCast(J9Class *instanceClass, J9Class *castClass)
{
	return VM_VMHelpers::inlineCheckCast(instanceClass, castClass, true) ? TRUE : FALSE;
}

IDATA
instanceOfOrCheckCastNoCacheUpdate(J9Class *instanceClass, J9Class *castClass)
{
	return VM_VMHelpers::inlineCheckCast(instanceClass, castClass, false) ? TRUE : FALSE;
}

} /* extern "C" */

The implementation of instanceOfOrCheckCastNoCacheUpdate is different than instanceOfOrCheckCast and I don't know whether we can substitute one for another. maybe we need another frontend query?
I wonder how come we haven't hit this issue on x86

@mpirvu mpirvu added comp:jitserver Artifacts related to JIT-as-a-Service project arch:z labels Sep 4, 2019
@dchopra001
Copy link
Contributor Author

I think the cacheUpdate option is there for profiling purposes. Just a guess but perhaps we didn't see it because it's not functionally incorrect.

With regards to the change in the common J9TreeEvaluator.cpp, the routines where I made this change are only invoked by the Power and Z codgens. So that's why that particular issue wasn't seen on x86.

@dchopra001
Copy link
Contributor Author

With regards to the new query, I can add a similar noCacheUpdate version of this routine. The current Server implementation of this routine (TR_J9ServerVM::instanceOfOrCheckCast) doesn't cache anything on the server. It does however call the client's version of the instanceOfOrCheckCast routine which will end up updating the cache on the client.

In the new routine, we can use the same implementation as TR_J9ServerVM::instanceOfOrCheckCast. The only difference will be that we will make a remote call to the client's instanceOfOrCheckCastNoCacheUpdate routine instead. Unless you think we should update the cache on the server.

@mpirvu
Copy link
Contributor

mpirvu commented Sep 4, 2019

I can add a similar noCacheUpdate version of this routine.

Let's do that please.

@mpirvu mpirvu self-assigned this Sep 4, 2019
[skip ci]
Signed-off-by: Dhruv Chopra <Dhruv.C.Chopra@ibm.com>
Signed-off-by: Dhruv Chopra <Dhruv.C.Chopra@ibm.com>
@dchopra001
Copy link
Contributor Author

@mpirvu Done. This is good for another look.

@dchopra001
Copy link
Contributor Author

@mpirvu This is ready for another review.

Copy link
Contributor

@mpirvu mpirvu left a comment

Choose a reason for hiding this comment

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

I have some comments regarding the implemetation.

{
if (instanceClass == castClass)
if (instanceClass == castClass)
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra spaces here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed here: 3148b1f

Comment on lines 1506 to 1509
if (cacheUpdate)
stream->write(JITServer::MessageType::VM_instanceOfOrCheckCast, instanceClass, castClass);
else
stream->write(JITServer::MessageType::VM_instanceOfOrCheckCastNoCacheUpdate, instanceClass, castClass);
Copy link
Contributor

Choose a reason for hiding this comment

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

The original implementation has a flaw in that we keep the romMapMonitor while sending a message which can be a lenghty operation. Could you please fix by ending the critical sectin before sending any messages?

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 should be addressed here: 3148b1f. If we end up at this point in this if block, we no longer do any remote calls and instead will fall through to the final remote call at the end of this routine

@@ -167,6 +167,8 @@ class TR_J9ServerVM: public TR_J9VM
virtual uintptrj_t getFieldOffset(TR::Compilation * comp, TR::SymbolReference* classRef, TR::SymbolReference* fieldRef) override { return 0; } // safe answer
virtual bool canDereferenceAtCompileTime(TR::SymbolReference *fieldRef, TR::Compilation *comp) { return false; } // safe answer, might change in the future
virtual bool instanceOfOrCheckCast(J9Class *instanceClass, J9Class* castClass) override;
virtual bool instanceOfOrCheckCastNoCacheUpdate(J9Class *instanceClass, J9Class* castClass) override;
virtual bool instanceOfOrCheckCastHelper(J9Class *instanceClass, J9Class* castClass, bool cacheUpdate);
Copy link
Contributor

Choose a reason for hiding this comment

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

instanceOfOrCheckCastHelper does not have to be virtual and can be made private because nobody else outside its class needs it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed here: 3148b1f

Send a remote message in instanceCheckcast helper outside
of the critical section as it's a lengthy operation. Also perform
some minor cleanup and make the instanceCheckcast helper a private
routine.

Signed-off-by: Dhruv Chopra <Dhruv.C.Chopra@ibm.com>
Copy link
Contributor

@mpirvu mpirvu left a comment

Choose a reason for hiding this comment

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

LGTM

@mpirvu
Copy link
Contributor

mpirvu commented Nov 1, 2019

Jenkins test sanity.functional+jitaas xlinux jdk8,jdk11 depends eclipse/openj9-omr#jitaas

@mpirvu
Copy link
Contributor

mpirvu commented Nov 1, 2019

Only the known cmdLineTester_gcsuballoctests_0 test has failed, hence merging.

@mpirvu mpirvu merged commit 917503c into eclipse-openj9:jitaas Nov 1, 2019
@dchopra001 dchopra001 deleted the instanceCheckcast branch July 13, 2021 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch:z comp:jitserver Artifacts related to JIT-as-a-Service project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants