From 1208a4af3a71d0f844c6c756dca3db8fc7ce7fba Mon Sep 17 00:00:00 2001 From: Marius Pirvu Date: Thu, 9 May 2024 19:01:12 -0700 Subject: [PATCH] Eliminate VM_isClassLibraryClass messages for JITServer After work to improve constant field folding, the number of VM_isClassLibraryClass messages increased a lot affecting the CPU overhead of the client. This commit reimplements the `TR_J9ServerVM::isClassLibraryClass()` frontend query taking advantage of the caches maintained by JITServer and eliminating said messages completely. Signed-off-by: Marius Pirvu --- .../compiler/control/JITClientCompilationThread.cpp | 6 ------ runtime/compiler/env/VMJ9Server.cpp | 13 ++++++++----- runtime/compiler/net/CommunicationStream.hpp | 2 +- runtime/compiler/net/MessageTypes.cpp | 1 - runtime/compiler/net/MessageTypes.hpp | 1 - 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/runtime/compiler/control/JITClientCompilationThread.cpp b/runtime/compiler/control/JITClientCompilationThread.cpp index 6da09b078df..db0dd4f186b 100644 --- a/runtime/compiler/control/JITClientCompilationThread.cpp +++ b/runtime/compiler/control/JITClientCompilationThread.cpp @@ -269,12 +269,6 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes } } break; - case MessageType::VM_isClassLibraryClass: - { - bool rv = fe->isClassLibraryClass(std::get<0>(client->getRecvData())); - client->write(response, rv); - } - break; case MessageType::VM_isClassLibraryMethod: { auto tup = client->getRecvData(); diff --git a/runtime/compiler/env/VMJ9Server.cpp b/runtime/compiler/env/VMJ9Server.cpp index b2fdfe66f36..e1647e522dc 100644 --- a/runtime/compiler/env/VMJ9Server.cpp +++ b/runtime/compiler/env/VMJ9Server.cpp @@ -60,17 +60,20 @@ TR_J9ServerVM::getResolvedMethodsAndMethods(TR_Memory *trMemory, TR_OpaqueClassB bool TR_J9ServerVM::isClassLibraryMethod(TR_OpaqueMethodBlock *method, bool vettedForAOT) { - JITServer::ServerStream *stream = _compInfoPT->getMethodBeingCompiled()->_stream; - stream->write(JITServer::MessageType::VM_isClassLibraryMethod, method, vettedForAOT); - return std::get<0>(stream->read()); + return isClassLibraryClass(getClassFromMethodBlock(method)); } bool TR_J9ServerVM::isClassLibraryClass(TR_OpaqueClassBlock *clazz) { + // Use the local cache to determine whether the class loader of the given + // class is the same as the system classloader JITServer::ServerStream *stream = _compInfoPT->getMethodBeingCompiled()->_stream; - stream->write(JITServer::MessageType::VM_isClassLibraryClass, clazz); - return std::get<0>(stream->read()); + void *classLoader = NULL; + JITServerHelpers::getAndCacheRAMClassInfo((J9Class *)clazz, _compInfoPT->getClientData(), stream, JITServerHelpers::CLASSINFO_CLASS_LOADER, &classLoader); + auto *vmInfo = _compInfoPT->getClientData()->getOrCacheVMInfo(stream); + TR_ASSERT(vmInfo->_systemClassLoader, "_systemClassLoader cannot be NULL"); + return vmInfo->_systemClassLoader == classLoader; } TR_OpaqueClassBlock * diff --git a/runtime/compiler/net/CommunicationStream.hpp b/runtime/compiler/net/CommunicationStream.hpp index 5ad57972c65..a3276a9db97 100644 --- a/runtime/compiler/net/CommunicationStream.hpp +++ b/runtime/compiler/net/CommunicationStream.hpp @@ -118,7 +118,7 @@ class CommunicationStream // likely to lose an increment when merging/rebasing/etc. // static const uint8_t MAJOR_NUMBER = 1; - static const uint16_t MINOR_NUMBER = 61; // ID: 2WUGRj9RjAt4xrMCntc/ + static const uint16_t MINOR_NUMBER = 62; // ID: TNff0n0QdLOhsH6CmQlT/ static const uint8_t PATCH_NUMBER = 0; static uint32_t CONFIGURATION_FLAGS; diff --git a/runtime/compiler/net/MessageTypes.cpp b/runtime/compiler/net/MessageTypes.cpp index 507c9b562de..6ee4ce1f5a1 100644 --- a/runtime/compiler/net/MessageTypes.cpp +++ b/runtime/compiler/net/MessageTypes.cpp @@ -94,7 +94,6 @@ const char *messageNames[] = "ResolvedRelocatableMethod_fieldAttributes", "ResolvedRelocatableMethod_staticAttributes", "ResolvedRelocatableMethod_getFieldType", - "VM_isClassLibraryClass", "VM_isClassLibraryMethod", "VM_isClassArray", "VM_transformJlrMethodInvoke", diff --git a/runtime/compiler/net/MessageTypes.hpp b/runtime/compiler/net/MessageTypes.hpp index 3439fc6a086..79c83389b70 100644 --- a/runtime/compiler/net/MessageTypes.hpp +++ b/runtime/compiler/net/MessageTypes.hpp @@ -103,7 +103,6 @@ enum MessageType : uint16_t ResolvedRelocatableMethod_getFieldType, // For TR_J9ServerVM methods - VM_isClassLibraryClass, VM_isClassLibraryMethod, VM_isClassArray, VM_transformJlrMethodInvoke,