Skip to content

Commit 2b95d24

Browse files
committed
Cache unresolvedInCP at the JIT Server
Cache the value of unresolvedInCP for virtual, static, and special calls when caching a resolved method at the JIT Server, instead of assuming it is true for all cases. Signed-off-by: Luke Li <[email protected]>
1 parent abfb92f commit 2b95d24

6 files changed

+71
-16
lines changed

runtime/compiler/control/JITClientCompilationThread.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,8 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
17881788
std::vector<TR_OpaqueMethodBlock *> ramMethods(numMethods);
17891789
std::vector<uint32_t> vTableOffsets(numMethods);
17901790
std::vector<TR_ResolvedJ9JITServerMethodInfo> methodInfos(numMethods);
1791+
// vector<bool> does not seem to work
1792+
std::vector<char> unresolvedInCPs(numMethods);
17911793
for (int32_t i = 0; i < numMethods; ++i)
17921794
{
17931795
int32_t cpIndex = cpIndices[i];
@@ -1796,7 +1798,7 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
17961798
TR_OpaqueMethodBlock *ramMethod = NULL;
17971799
uint32_t vTableOffset = 0;
17981800
TR_ResolvedJ9JITServerMethodInfo methodInfo;
1799-
bool unresolvedInCP = false;
1801+
bool unresolvedInCP = true;
18001802
switch (type)
18011803
{
18021804
case TR_ResolvedMethodType::VirtualFromCP:
@@ -1834,8 +1836,9 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
18341836
ramMethods[i] = ramMethod;
18351837
vTableOffsets[i] = vTableOffset;
18361838
methodInfos[i] = methodInfo;
1839+
unresolvedInCPs[i] = unresolvedInCP;
18371840
}
1838-
client->write(response, ramMethods, vTableOffsets, methodInfos);
1841+
client->write(response, ramMethods, vTableOffsets, methodInfos, unresolvedInCPs);
18391842
}
18401843
break;
18411844
case MessageType::ResolvedMethod_getConstantDynamicTypeFromCP:

runtime/compiler/control/JITServerCompilationThread.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,12 +1477,18 @@ TR::CompilationInfoPerThreadRemote::getCachedIProfilerInfo(TR_OpaqueMethodBlock
14771477
* @param key Identifier used to identify a resolved method in resolved methods cache
14781478
* @param method The resolved method of interest
14791479
* @param vTableSlot The vTableSlot for the resolved method of interest
1480+
* @param isUnresolvedInCP The unresolvedInCP boolean value of interest
14801481
* @param methodInfo Additional method info about the resolved method of interest
14811482
* @return returns void
14821483
*/
14831484
void
1484-
TR::CompilationInfoPerThreadRemote::cacheResolvedMethod(TR_ResolvedMethodKey key, TR_OpaqueMethodBlock *method,
1485-
uint32_t vTableSlot, const TR_ResolvedJ9JITServerMethodInfo &methodInfo, int32_t ttlForUnresolved)
1485+
TR::CompilationInfoPerThreadRemote::cacheResolvedMethod(TR_ResolvedMethodKey key,
1486+
TR_OpaqueMethodBlock *method,
1487+
uint32_t vTableSlot,
1488+
const TR_ResolvedJ9JITServerMethodInfo
1489+
&methodInfo,
1490+
bool isUnresolvedInCP,
1491+
int32_t ttlForUnresolved)
14861492
{
14871493
static bool useCaching = !feGetEnv("TR_DisableResolvedMethodsCaching");
14881494
if (!useCaching)
@@ -1518,6 +1524,7 @@ TR::CompilationInfoPerThreadRemote::cacheResolvedMethod(TR_ResolvedMethodKey key
15181524
cacheEntry.persistentBodyInfo = bodyInfo;
15191525
cacheEntry.persistentMethodInfo = pMethodInfo;
15201526
cacheEntry.IPMethodInfo = entry;
1527+
cacheEntry.isUnresolvedInCP = isUnresolvedInCP;
15211528

15221529
// time-to-live for cached unresolved methods.
15231530
// Irrelevant for resolved methods.
@@ -1599,7 +1606,7 @@ TR::CompilationInfoPerThreadRemote::getCachedResolvedMethod(TR_ResolvedMethodKey
15991606
if (*resolvedMethod)
16001607
{
16011608
if (unresolvedInCP)
1602-
*unresolvedInCP = false;
1609+
*unresolvedInCP = methodCacheEntry.isUnresolvedInCP;
16031610
return true;
16041611
}
16051612
else

runtime/compiler/control/JITServerCompilationThread.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class CompilationInfoPerThreadRemote : public TR::CompilationInfoPerThread
8585
bool cacheIProfilerInfo(TR_OpaqueMethodBlock *method, uint32_t byteCodeIndex, TR_IPBytecodeHashTableEntry *entry);
8686
TR_IPBytecodeHashTableEntry *getCachedIProfilerInfo(TR_OpaqueMethodBlock *method, uint32_t byteCodeIndex, bool *methodInfoPresent);
8787

88-
void cacheResolvedMethod(TR_ResolvedMethodKey key, TR_OpaqueMethodBlock *method, uint32_t vTableSlot, const TR_ResolvedJ9JITServerMethodInfo &methodInfo, int32_t ttlForUnresolved = 2);
88+
void cacheResolvedMethod(TR_ResolvedMethodKey key, TR_OpaqueMethodBlock *method, uint32_t vTableSlot, const TR_ResolvedJ9JITServerMethodInfo &methodInfo, bool isUnresolvedInCP, int32_t ttlForUnresolved = 2);
8989
bool getCachedResolvedMethod(TR_ResolvedMethodKey key, TR_ResolvedJ9JITServerMethod *owningMethod, TR_ResolvedMethod **resolvedMethod, bool *unresolvedInCP = NULL);
9090
TR_ResolvedMethodKey getResolvedMethodKey(TR_ResolvedMethodType type, TR_OpaqueClassBlock *ramClass, int32_t cpIndex, TR_OpaqueClassBlock *classObject = NULL);
9191

runtime/compiler/env/j9methodServer.cpp

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,14 @@ TR_ResolvedJ9JITServerMethod::getResolvedPossiblyPrivateVirtualMethod(TR::Compil
387387
if (createResolvedMethod)
388388
{
389389
resolvedMethod = createResolvedMethodFromJ9Method(comp, cpIndex, vTableIndex, ramMethod, unresolvedInCP, aotStats, methodInfo);
390-
compInfoPT->cacheResolvedMethod(compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::VirtualFromCP, (TR_OpaqueClassBlock *) _ramClass, cpIndex), (TR_OpaqueMethodBlock *) ramMethod, (uint32_t) vTableIndex, methodInfo);
390+
compInfoPT->cacheResolvedMethod(
391+
compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::VirtualFromCP,
392+
(TR_OpaqueClassBlock *) _ramClass, cpIndex),
393+
(TR_OpaqueMethodBlock *) ramMethod,
394+
(uint32_t) vTableIndex,
395+
methodInfo,
396+
*unresolvedInCP
397+
);
391398
}
392399
}
393400
}
@@ -694,7 +701,14 @@ TR_ResolvedJ9JITServerMethod::getResolvedStaticMethod(TR::Compilation * comp, I_
694701
}
695702
else
696703
{
697-
compInfoPT->cacheResolvedMethod(compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::Static, (TR_OpaqueClassBlock *) _ramClass, cpIndex), (TR_OpaqueMethodBlock *) ramMethod, 0, methodInfo);
704+
compInfoPT->cacheResolvedMethod(
705+
compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::Static,
706+
(TR_OpaqueClassBlock *) _ramClass, cpIndex),
707+
(TR_OpaqueMethodBlock *) ramMethod,
708+
0,
709+
methodInfo,
710+
*unresolvedInCP
711+
);
698712
}
699713

700714
return resolvedMethod;
@@ -751,7 +765,13 @@ TR_ResolvedJ9JITServerMethod::getResolvedSpecialMethod(TR::Compilation * comp, I
751765
}
752766
else
753767
{
754-
compInfoPT->cacheResolvedMethod(compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::Special, clazz, cpIndex), (TR_OpaqueMethodBlock *) ramMethod, 0, methodInfo);
768+
compInfoPT->cacheResolvedMethod(
769+
compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::Special, clazz, cpIndex),
770+
(TR_OpaqueMethodBlock *) ramMethod,
771+
0,
772+
methodInfo,
773+
*unresolvedInCP
774+
);
755775
}
756776

757777
return resolvedMethod;
@@ -882,7 +902,14 @@ TR_ResolvedJ9JITServerMethod::getResolvedInterfaceMethod(TR::Compilation * comp,
882902
// to uniquely identify it.
883903
if (resolvedMethod)
884904
{
885-
compInfoPT->cacheResolvedMethod(compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::Interface, clazz, cpIndex, classObject), (TR_OpaqueMethodBlock *) ramMethod, 0, methodInfo);
905+
compInfoPT->cacheResolvedMethod(
906+
compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::Interface,
907+
clazz, cpIndex, classObject),
908+
(TR_OpaqueMethodBlock *) ramMethod,
909+
0,
910+
methodInfo,
911+
true
912+
);
886913
return resolvedMethod;
887914
}
888915

@@ -932,8 +959,14 @@ TR_ResolvedJ9JITServerMethod::getResolvedImproperInterfaceMethod(TR::Compilation
932959
j9method = NULL;
933960
}
934961

935-
compInfoPT->cacheResolvedMethod(compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::ImproperInterface, (TR_OpaqueClassBlock *) _ramClass, cpIndex),
936-
(TR_OpaqueMethodBlock *) j9method, vtableOffset, methodInfo);
962+
compInfoPT->cacheResolvedMethod(
963+
compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::ImproperInterface,
964+
(TR_OpaqueClassBlock *) _ramClass, cpIndex),
965+
(TR_OpaqueMethodBlock *) j9method,
966+
vtableOffset,
967+
methodInfo,
968+
true
969+
);
937970
if (j9method == NULL)
938971
return NULL;
939972
else
@@ -997,7 +1030,14 @@ TR_ResolvedJ9JITServerMethod::getResolvedVirtualMethod(TR::Compilation * comp, T
9971030
resolvedMethod = ramMethod ? new (comp->trHeapMemory()) TR_ResolvedJ9JITServerMethod((TR_OpaqueMethodBlock *) ramMethod, _fe, comp->trMemory(), methodInfo, this) : 0;
9981031
}
9991032
if (resolvedMethod)
1000-
compInfoPT->cacheResolvedMethod(compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::VirtualFromOffset, clazz, virtualCallOffset, classObject), ramMethod, 0, methodInfo);
1033+
compInfoPT->cacheResolvedMethod(
1034+
compInfoPT->getResolvedMethodKey(TR_ResolvedMethodType::VirtualFromOffset,
1035+
clazz, virtualCallOffset, classObject),
1036+
(TR_OpaqueMethodBlock *) ramMethod,
1037+
0,
1038+
methodInfo,
1039+
true
1040+
);
10011041
return resolvedMethod;
10021042
}
10031043

@@ -1664,12 +1704,13 @@ TR_ResolvedJ9JITServerMethod::cacheResolvedMethodsCallees(int32_t ttlForUnresolv
16641704

16651705
// 2. Send a remote query to mirror all uncached resolved methods
16661706
_stream->write(JITServer::MessageType::ResolvedMethod_getMultipleResolvedMethods, (TR_ResolvedJ9Method *) _remoteMirror, methodTypes, cpIndices);
1667-
auto recv = _stream->read<std::vector<TR_OpaqueMethodBlock *>, std::vector<uint32_t>, std::vector<TR_ResolvedJ9JITServerMethodInfo>>();
1707+
auto recv = _stream->read<std::vector<TR_OpaqueMethodBlock *>, std::vector<uint32_t>, std::vector<TR_ResolvedJ9JITServerMethodInfo>, std::vector<char>>();
16681708

16691709
// 3. Cache all received resolved methods
16701710
auto &ramMethods = std::get<0>(recv);
16711711
auto &vTableOffsets = std::get<1>(recv);
16721712
auto &methodInfos = std::get<2>(recv);
1713+
auto &unresolvedInCPs = std::get<3>(recv);
16731714
TR_ASSERT(numMethods == ramMethods.size(), "Number of received methods does not match the number of requested methods");
16741715
for (int32_t i = 0; i < numMethods; ++i)
16751716
{
@@ -1686,6 +1727,7 @@ TR_ResolvedJ9JITServerMethod::cacheResolvedMethodsCallees(int32_t ttlForUnresolv
16861727
ramMethods[i],
16871728
vTableOffsets[i],
16881729
methodInfos[i],
1730+
(bool) unresolvedInCPs[i],
16891731
ttlForUnresolved
16901732
);
16911733
}
@@ -1806,7 +1848,9 @@ TR_ResolvedJ9JITServerMethod::collectImplementorsCapped(
18061848
(TR_OpaqueMethodBlock *) ramMethods[i],
18071849
cpIndexOrOffset,
18081850
methodInfos[i],
1809-
0); // all received methods should be resolved
1851+
true,
1852+
0
1853+
); // all received methods should be resolved
18101854
success = compInfoPT->getCachedResolvedMethod(key, this, &resolvedMethod);
18111855
}
18121856

runtime/compiler/env/j9methodServer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ TR_ResolvedMethodCacheEntry
128128
TR_PersistentMethodInfo *persistentMethodInfo;
129129
TR_ContiguousIPMethodHashTableEntry *IPMethodInfo;
130130
int32_t ttlForUnresolved;
131+
bool isUnresolvedInCP;
131132
};
132133

133134
using TR_ResolvedMethodInfoCache = UnorderedMap<TR_ResolvedMethodKey, TR_ResolvedMethodCacheEntry>;

runtime/compiler/net/CommunicationStream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class CommunicationStream
128128
// likely to lose an increment when merging/rebasing/etc.
129129
//
130130
static const uint8_t MAJOR_NUMBER = 1;
131-
static const uint16_t MINOR_NUMBER = 72; // ID: PB545sJS3QOBXIIPV5JZ
131+
static const uint16_t MINOR_NUMBER = 73; // ID: AwP1pJjbiAVBRCpcwuDt
132132
static const uint8_t PATCH_NUMBER = 0;
133133
static uint32_t CONFIGURATION_FLAGS;
134134

0 commit comments

Comments
 (0)