Skip to content

Refactor the Deserializer to use a helper struct #22135

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions runtime/compiler/control/JITClientCompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3031,13 +3031,14 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
if (auto deserializer = compInfo->getJITServerAOTDeserializer())
{
bool wasReset = false;
deserializer->cacheRecords((const uint8_t *)recordsStr.data(), recordsStr.size(), comp,
auto context = DeserializerContext(comp);
deserializer->cacheRecords((const uint8_t *)recordsStr.data(), recordsStr.size(), context,
/*ignoreFailures=*/true, wasReset);
if (!wasReset)
{
for (uintptr_t id : classIds)
{
J9Class *ramClass = deserializer->getRAMClass(id, comp, wasReset);
J9Class *ramClass = deserializer->getRAMClass(id, context, wasReset);
if (wasReset)
{
ramClasses.clear();
Expand Down Expand Up @@ -3446,7 +3447,8 @@ remoteCompile(J9VMThread *vmThread, TR::Compilation *compiler, TR_ResolvedMethod
// 2. Accesses the JITServer AOT deserializer in any way.
// That moment is currently right here, when we get the new known IDs that are cached in the deserializer.
compInfoPT->getJ9VM()->clearDeserializerWasReset();
std::vector<uintptr_t> newKnownIds = deserializer ? deserializer->getNewKnownIds(compiler) : std::vector<uintptr_t>();
auto context = DeserializerContext(compiler);
std::vector<uintptr_t> newKnownIds = deserializer ? deserializer->getNewKnownIds(context) : std::vector<uintptr_t>();

// TODO: make this a synchronized region to avoid bad_alloc exceptions
compInfo->getSequencingMonitor()->enter();
Expand Down Expand Up @@ -3564,7 +3566,8 @@ remoteCompile(J9VMThread *vmThread, TR::Compilation *compiler, TR_ResolvedMethod

auto method = SerializedAOTMethod::get(methodStr);
bool usesSVM = false;
if (deserializer->deserialize(method, records, compiler, usesSVM))
auto context = DeserializerContext(compiler);
if (deserializer->deserialize(method, records, context, usesSVM))
{
compiler->setDeserializedAOTMethodStore(true);
compiler->setDeserializedAOTMethod(true);
Expand Down Expand Up @@ -3598,7 +3601,8 @@ remoteCompile(J9VMThread *vmThread, TR::Compilation *compiler, TR_ResolvedMethod

auto method = SerializedAOTMethod::get(methodStr);
bool usesSVM = false;
if (deserializer->deserialize(method, records, compiler, usesSVM))
auto context = DeserializerContext(compiler);
if (deserializer->deserialize(method, records, context, usesSVM))
{
compiler->setDeserializedAOTMethod(true);
compiler->setDeserializedAOTMethodUsingSVM(usesSVM);
Expand Down
18 changes: 12 additions & 6 deletions runtime/compiler/env/J9SharedCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,8 @@ TR_J9SharedCache::lookupClassFromChainAndLoader(uintptr_t *chainData, void *clas
if (!clazz && comp->isDeserializedAOTMethod())
{
auto deserializer = TR::CompilationInfo::get()->getJITServerAOTDeserializer();
clazz = deserializer->getGeneratedClass((J9ClassLoader *)classLoader, romClassOffset, comp);
auto context = DeserializerContext(comp);
clazz = deserializer->getGeneratedClass((J9ClassLoader *)classLoader, romClassOffset, context);
}
#endif /* defined(J9VM_OPT_JITSERVER) */

Expand Down Expand Up @@ -1870,7 +1871,8 @@ TR_J9DeserializerSharedCache::romClassFromOffsetInSharedCache(uintptr_t offset)
{
TR::Compilation *comp = _compInfoPT->getCompilation();
bool wasReset = false;
auto romClass = _deserializer->romClassFromOffsetInSharedCache(offset, comp, wasReset);
auto context = DeserializerContext(comp);
auto romClass = _deserializer->romClassFromOffsetInSharedCache(offset, context, wasReset);
if (wasReset)
comp->failCompilation<J9::AOTDeserializerReset>(
"Deserializer reset during relocation of method %s", comp->signature());
Expand All @@ -1886,7 +1888,8 @@ TR_J9DeserializerSharedCache::pointerFromOffsetInSharedCache(uintptr_t offset)
{
TR::Compilation *comp = _compInfoPT->getCompilation();
bool wasReset = false;
auto ptr = _deserializer->pointerFromOffsetInSharedCache(offset, comp, wasReset);
auto context = DeserializerContext(comp);
auto ptr = _deserializer->pointerFromOffsetInSharedCache(offset, context, wasReset);
if (wasReset)
comp->failCompilation<J9::AOTDeserializerReset>(
"Deserializer reset during relocation of method %s", comp->signature());
Expand Down Expand Up @@ -1916,7 +1919,8 @@ TR_J9DeserializerSharedCache::classMatchesCachedVersion(J9Class *clazz, UDATA *c
// is equal to the one we are trying to validate.
TR::Compilation *comp = _compInfoPT->getCompilation();
bool wasReset = false;
auto ramClass = _deserializer->classFromOffset(chainData[1], comp, wasReset);
auto context = DeserializerContext(comp);
auto ramClass = _deserializer->classFromOffset(chainData[1], context, wasReset);
if (wasReset)
comp->failCompilation<J9::AOTDeserializerReset>(
"Deserializer reset during relocation of method %s", comp->signature());
Expand All @@ -1935,7 +1939,8 @@ TR_J9DeserializerSharedCache::lookupClassFromChainAndLoader(uintptr_t *chainData
// We do not need to perform that checking here, because during deserialization we will have already resolved the first class in the chain to
// a J9Class and verified that it matches. Thus we can simply return that cached first J9Class.
bool wasReset = false;
auto clazz = _deserializer->classFromOffset(chainData[1], comp, wasReset);
auto context = DeserializerContext(comp);
auto clazz = _deserializer->classFromOffset(chainData[1], context, wasReset);
if (wasReset)
comp->failCompilation<J9::AOTDeserializerReset>(
"Deserializer reset during relocation of method %s", comp->signature());
Expand All @@ -1951,7 +1956,8 @@ TR_J9DeserializerSharedCache::romMethodFromOffsetInSharedCache(uintptr_t offset)
{
TR::Compilation *comp = _compInfoPT->getCompilation();
bool wasReset = false;
auto romMethod = _deserializer->romMethodFromOffsetInSharedCache(offset, comp, wasReset);
auto context = DeserializerContext(comp);
auto romMethod = _deserializer->romMethodFromOffsetInSharedCache(offset, context, wasReset);
if (wasReset)
comp->failCompilation<J9::AOTDeserializerReset>(
"Deserializer reset during relocation of method %s", comp->signature());
Expand Down
Loading