-
Notifications
You must be signed in to change notification settings - Fork 739
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
Modify rememberClass to return the offset to the class chain identifying the class #18832
Modify rememberClass to return the offset to the class chain identifying the class #18832
Conversation
Attn @mpirvu, @dsouzai. This is a fairly mechanical change that implements what I talked about in #18821 (comment), though I decided to have |
I'll go through the code in more detail as well, but just from a high level overview, I don't think it's a good idea to compare the returned encoded offset against 0; it weakens the conceptual integrity of the API because it exposes the implementation details to the callers of the API. That said, I do think taking advantage of the fact that the SCC offset is always an offset from the end, and therefore is low tagged, is a valid approach to take. So, in keeping with the contract that a caller of this API should not directly interact with the offset (which conceptually is a token or key of sorts), it would be better to add another method to J9SharedCache along the lines of |
In a few places we (now) rely on the existence of a class chain offset that is not valid; before, we would just store a |
0903e6b
to
d0cfdd0
Compare
Yeah that seems reasonable to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; however, I'll let Marius be the final reviewer/committer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, it looks good I have a few inline comments though.
} | ||
|
||
if (!create) | ||
{ | ||
LOG(1, "\tnot asked to create but could create, returning non-null\n"); | ||
return (uintptr_t *)0x1; | ||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a symbolic value. Can 1 be a valid offset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the only time create
is false in a rememberClass
call is when canRememberClass
or one of its overloads is run:
openj9/runtime/compiler/env/J9SharedCache.hpp
Lines 176 to 179 in 00a123d
virtual bool canRememberClass(TR_OpaqueClassBlock *classPtr) | |
{ | |
return rememberClass((J9Class *)classPtr, NULL, false) != NULL; | |
} |
In those cases we don't care about the offset at all, and the return 1
is just a method of communicating that the chain could have been created. It looks like the intent is to avoid duplicating the rememberClass
code in canRememberClass
.
I'm not sure if 1 could be a valid offset - judging from isPointerInSharedCache
:
openj9/runtime/compiler/env/J9SharedCache.cpp
Line 734 in 00a123d
TR_J9SharedCache::isPointerInSharedCache(void *ptr, uintptr_t *cacheOffset) |
that would happen only if a class chain started at exactly the metadataStartAddress
of the first layer of an SCC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a symbolic constant.
@@ -7227,6 +7227,19 @@ TR_J9VM::getClassFromSignature(const char * sig, int32_t sigLength, J9ConstantPo | |||
return returnValue; // 0 means failure | |||
} | |||
|
|||
uint32_t | |||
TR_J9VMBase::numInterfacesImplemented(J9Class *clazz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be overridden for server fe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the cls.iTableOf()
and cls.iTableNext()
calls handle this properly:
openj9/runtime/compiler/env/J9ClassEnv.cpp
Lines 217 to 241 in 66c4255
J9ITable * | |
J9::ClassEnv::iTableOf(TR_OpaqueClassBlock * clazz) | |
{ | |
#if defined(J9VM_OPT_JITSERVER) | |
if (auto stream = TR::CompilationInfo::getStream()) | |
{ | |
stream->write(JITServer::MessageType::ClassEnv_iTableOf, clazz); | |
return std::get<0>(stream->read<J9ITable*>()); | |
} | |
#endif /* defined(J9VM_OPT_JITSERVER) */ | |
return (J9ITable*) self()->convertClassOffsetToClassPtr(clazz)->iTable; | |
} | |
J9ITable * | |
J9::ClassEnv::iTableNext(J9ITable *current) | |
{ | |
#if defined(J9VM_OPT_JITSERVER) | |
if (auto stream = TR::CompilationInfo::getStream()) | |
{ | |
stream->write(JITServer::MessageType::ClassEnv_iTableNext, current); | |
return std::get<0>(stream->read<J9ITable*>()); | |
} | |
#endif /* defined(J9VM_OPT_JITSERVER) */ | |
return current->next; | |
} |
openj9/runtime/compiler/control/JITClientCompilationThread.cpp
Lines 2043 to 2054 in 00a123d
case MessageType::ClassEnv_iTableOf: | |
{ | |
auto clazz = std::get<0>(client->getRecvData<TR_OpaqueClassBlock *>()); | |
client->write(response, TR::Compiler->cls.iTableOf(clazz)); | |
} | |
break; | |
case MessageType::ClassEnv_iTableNext: | |
{ | |
auto clazz = std::get<0>(client->getRecvData<J9ITable *>()); | |
client->write(response, TR::Compiler->cls.iTableNext(clazz)); | |
} | |
break; |
so it shouldn't need a server override.
642d05e
to
16c7ebf
Compare
Rebasing to pull in the reversion in #18843, and to fix the JITServer version merge conflict. The review comments should all be addressed as well. |
The length of the class chain associated to a class is relevant to the JITServer AOT cache, as this quantity is used to construct RAMClass chains that are sent from the client to the server. To support the operation of the JITServer AOT cache without a local SCC, this length must always be available.
16c7ebf
to
7e9e21b
Compare
Signed-off-by: Christian Despres <[email protected]>
Signed-off-by: Christian Despres <[email protected]>
Signed-off-by: Christian Despres <[email protected]>
Signed-off-by: Christian Despres <[email protected]>
7e9e21b
to
32ad2f5
Compare
Signed-off-by: Christian Despres <[email protected]>
Signed-off-by: Christian Despres <[email protected]>
Signed-off-by: Christian Despres <[email protected]>
32ad2f5
to
528739f
Compare
That should be all of the log messages fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
jenkins test sanity all jdk17 |
jenkins test sanity aix jdk17 |
jenkins test sanity plinuxjit,xlinuxjit,zlinuxjit,alinux64jit jdk17 |
The
rememberClass
function now returns the offset to the class chain that it creates or finds in the local SCC, instead of returning the chain directly. Instead of returningNULL
when class remembering fails, it now returns the value0
. The offset of a class chain can never be zero in the local SCC, because that offset is always encoded withencodeOffsetFromEnd
byisPointerInSharedCache
, which means that the resulting value will always be odd:openj9/runtime/compiler/env/J9SharedCache.hpp
Lines 363 to 364 in c6df01b
Various structures that previously stored class chain pointers now instead store offsets instead.