Skip to content

Commit

Permalink
Store classes not worth remembering per client for JITServer
Browse files Browse the repository at this point in the history
PR eclipse-openj9#10644 added a static array of classes not worth remembering
to Symbol Validation Manager. JITServer, however, requires this array
to be stored on a per client bases, since pointers to J9 classes
are different between clients.

Signed-off-by: Dmitry Ten <Dmitry.Ten@ibm.com>
  • Loading branch information
dmitry-ten committed Sep 25, 2020
1 parent 78472c6 commit 355e038
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 8 deletions.
3 changes: 3 additions & 0 deletions runtime/compiler/runtime/JITClientSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "net/ServerStream.hpp" // for JITServer::ServerStream
#include "runtime/RuntimeAssumptions.hpp" // for TR_AddressSet
#include "env/JITServerPersistentCHTable.hpp"
#include "runtime/SymbolValidationManager.hpp"


ClientSessionData::ClientSessionData(uint64_t clientUID, uint32_t seqNo) :
Expand Down Expand Up @@ -66,6 +67,8 @@ ClientSessionData::ClientSessionData(uint64_t clientUID, uint32_t seqNo) :
{
TR_ASSERT_FATAL(false, "Failed to initialize JITServer class unload RWMutex");
}

TR::SymbolValidationManager::populateSystemClassesNotWorthRemembering(this);
}

ClientSessionData::~ClientSessionData()
Expand Down
5 changes: 5 additions & 0 deletions runtime/compiler/runtime/JITClientSession.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "env/PersistentCollections.hpp" // for PersistentUnorderedMap
#include "il/DataTypes.hpp" // for DataType
#include "env/VMJ9.h" // for TR_StaticFinalData
#include "runtime/SymbolValidationManager.hpp"

class J9ROMClass;
class J9Class;
Expand Down Expand Up @@ -434,6 +435,8 @@ class ClientSessionData
void writeAcquireClassUnloadRWMutex();
void writeReleaseClassUnloadRWMutex();

TR::SymbolValidationManager::SystemClassNotWorthRemembering *getSystemClassesNotWorthRemembering() { return _systemClassesNotWorthRemembering; }

private:
const uint64_t _clientUID;
int64_t _timeOfLastAccess; // in ms
Expand Down Expand Up @@ -481,6 +484,8 @@ class ClientSessionData

omrthread_rwmutex_t _classUnloadRWMutex;
volatile bool _bClassUnloadingAttempt;

TR::SymbolValidationManager::SystemClassNotWorthRemembering _systemClassesNotWorthRemembering[TR::SymbolValidationManager::SYSTEM_CLASSES_NOT_WORTH_REMEMBERING_COUNT];
}; // class ClientSessionData


Expand Down
48 changes: 42 additions & 6 deletions runtime/compiler/runtime/SymbolValidationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "runtime/RelocationRuntime.hpp"
#include "runtime/SymbolValidationManager.hpp"

#if defined(J9VM_OPT_JITSERVER)
#include "runtime/JITClientSession.hpp"
#endif

#include "j9protos.h"

#if defined (_MSC_VER) && _MSC_VER < 1900
Expand All @@ -52,10 +56,7 @@ TR::SymbolValidationManager::_systemClassesNotWorthRemembering[] = {
/* Newer java code is moving towards using StringBuilder. Therefore, ignoring this class
* reduces load failures, while having minimal impact on steady state throughput.
*/
{ "java/lang/StringBuffer", NULL, false },

/* Terminating entry */
{ NULL, NULL, false }
{ "java/lang/StringBuffer", NULL, false }
};

TR::SymbolValidationManager::SymbolValidationManager(TR::Region &region, TR_ResolvedMethod *compilee)
Expand Down Expand Up @@ -111,7 +112,26 @@ TR::SymbolValidationManager::SymbolValidationManager(TR::Region &region, TR_Reso
_alreadyGeneratedRecords.insert(
new (_region) ArrayClassFromComponentClassRecord(arrayClass, component));
}

// Ensure that the count of classes not worth remembering is defined correctly
static_assert(SYSTEM_CLASSES_NOT_WORTH_REMEMBERING_COUNT == sizeof(_systemClassesNotWorthRemembering) / sizeof(_systemClassesNotWorthRemembering[0]),
"SYSTEM_CLASSES_NOT_WORTH_REMEMBERING_COUNT doesn't match the size of _systemClassesNotWorthRemembering");

}

#if defined(J9VM_OPT_JITSERVER)
void
TR::SymbolValidationManager::populateSystemClassesNotWorthRemembering(ClientSessionData *clientData)
{
// Populate the client session with classes not worth remembering
auto classesNotWorthRemembering = clientData->getSystemClassesNotWorthRemembering();
for (int i = 0; i < SYSTEM_CLASSES_NOT_WORTH_REMEMBERING_COUNT; ++i)
{
auto classNotWorthRemembering = &_systemClassesNotWorthRemembering[i];
classesNotWorthRemembering[i] = { classNotWorthRemembering->_className, NULL, classNotWorthRemembering->_checkIsSuperClass };
}
}
#endif

void
TR::SymbolValidationManager::defineGuaranteedID(void *symbol, TR::SymbolType type)
Expand All @@ -127,9 +147,9 @@ TR::SymbolValidationManager::isClassWorthRemembering(TR_OpaqueClassBlock *clazz)
{
bool worthRemembering = true;

for (int i = 0; worthRemembering && _systemClassesNotWorthRemembering[i]._className; i++)
for (int i = 0; worthRemembering && i < SYSTEM_CLASSES_NOT_WORTH_REMEMBERING_COUNT; i++)
{
SystemClassNotWorthRemembering *systemClassNotWorthRemembering = &_systemClassesNotWorthRemembering[i];
SystemClassNotWorthRemembering *systemClassNotWorthRemembering = getSystemClassNotWorthRemembering(i);
if (!systemClassNotWorthRemembering->_clazz)
{
systemClassNotWorthRemembering->_clazz = _fej9->getSystemClassFromClassName(
Expand Down Expand Up @@ -158,6 +178,22 @@ TR::SymbolValidationManager::isClassWorthRemembering(TR_OpaqueClassBlock *clazz)
return worthRemembering;
}

TR::SymbolValidationManager::SystemClassNotWorthRemembering *
TR::SymbolValidationManager::getSystemClassNotWorthRemembering(int idx)
{
#if defined(J9VM_OPT_JITSERVER)
if (_comp->isOutOfProcessCompilation())
{
auto classesNotWorthRemembering = _fej9->_compInfoPT->getClientData()->getSystemClassesNotWorthRemembering();
return &classesNotWorthRemembering[idx];
}
else
#endif
{
return &_systemClassesNotWorthRemembering[idx];
}
}

void
TR::SymbolValidationManager::populateWellKnownClasses()
{
Expand Down
15 changes: 13 additions & 2 deletions runtime/compiler/runtime/SymbolValidationManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#include "exceptions/AOTFailure.hpp"
#include "runtime/J9Runtime.hpp"

#if defined(J9VM_OPT_JITSERVER)
class ClientSessionData;
#endif

#define SVM_ASSERT_LOCATION_INNER(line) __FILE__ ":" #line
#define SVM_ASSERT_LOCATION(line) SVM_ASSERT_LOCATION_INNER(line)

Expand Down Expand Up @@ -637,9 +641,9 @@ class SymbolValidationManager

struct SystemClassNotWorthRemembering
{
const char * const _className;
const char *_className;
TR_OpaqueClassBlock *_clazz;
const bool _checkIsSuperClass;
bool _checkIsSuperClass;
};

void populateWellKnownClasses();
Expand Down Expand Up @@ -764,11 +768,18 @@ class SymbolValidationManager

static bool assertionsAreFatal();

static int getSystemClassesNotWorthRememberingCount();

#if defined(J9VM_OPT_JITSERVER)
std::string serializeSymbolToIDMap();
void deserializeSymbolToIDMap(const std::string &symbolToIdStr);
static void populateSystemClassesNotWorthRemembering(ClientSessionData *clientData);
#endif /* defined(J9VM_OPT_JITSERVER) */

SystemClassNotWorthRemembering *getSystemClassNotWorthRemembering(int idx);

static const int SYSTEM_CLASSES_NOT_WORTH_REMEMBERING_COUNT = 2;

private:

static const uint16_t NO_ID = 0;
Expand Down

0 comments on commit 355e038

Please sign in to comment.