Skip to content
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

Add API getDefaultValueSlotAddress #15118

Merged
Merged
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
7 changes: 7 additions & 0 deletions runtime/compiler/control/JITClientCompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2079,6 +2079,13 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
client->write(response, TR::Compiler->cls.flattenedArrayElementSize(comp, arrayClass));
}
break;
case MessageType::ClassEnv_getDefaultValueSlotAddress:
{
auto recv = client->getRecvData<TR_OpaqueClassBlock *>();
auto clazz = std::get<0>(recv);
client->write(response, TR::Compiler->cls.getDefaultValueSlotAddress(comp, clazz));
}
break;
case MessageType::ClassEnv_enumerateFields:
{
auto recv = client->getRecvData<TR_OpaqueClassBlock *>();
Expand Down
15 changes: 14 additions & 1 deletion runtime/compiler/control/JITServerHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ JITServerHelpers::cacheRemoteROMClass(ClientSessionData *clientSessionData, J9Cl
auto &origROMMethods = std::get<21>(classInfoTuple);
classInfoStruct._classNameIdentifyingLoader = std::get<22>(classInfoTuple);
classInfoStruct._arrayElementSize = std::get<23>(classInfoTuple);
classInfoStruct._defaultValueSlotAddress = std::get<24>(classInfoTuple);

auto result = clientSessionData->getROMClassMap().insert({ clazz, classInfoStruct });

Expand Down Expand Up @@ -663,12 +664,21 @@ JITServerHelpers::packRemoteROMClassInfo(J9Class *clazz, J9VMThread *vmThread, T

int32_t arrayElementSize = vmThread->javaVM->internalVMFunctions->arrayElementSize((J9ArrayClass*)clazz);

// getDefaultValueSlotAddress can only be called if the value type class is initialized
j9object_t* defaultValueSlotAddress = NULL;
if (TR::Compiler->om.areValueTypesEnabled() &&
classInitialized &&
TR::Compiler->cls.isValueTypeClass(TR::Compiler->cls.convertClassPtrToClassOffset(clazz)))
{
defaultValueSlotAddress = vmThread->javaVM->internalVMFunctions->getDefaultValueSlotAddress(clazz);
}

return std::make_tuple(
packedROMClassStr, methodsOfClass, baseClass, numDims, parentClass,
TR::Compiler->cls.getITable((TR_OpaqueClassBlock *)clazz), methodTracingInfo,
classHasFinalFields, classDepthAndFlags, classInitialized, byteOffsetToLockword, leafComponentClass,
classLoader, hostClass, componentClass, arrayClass, totalInstanceSize, clazz->romClass,
cp, classFlags, classChainOffsetIdentifyingLoader, origROMMethods, classNameIdentifyingLoader, arrayElementSize
cp, classFlags, classChainOffsetIdentifyingLoader, origROMMethods, classNameIdentifyingLoader, arrayElementSize, defaultValueSlotAddress
);
}

Expand Down Expand Up @@ -841,6 +851,9 @@ JITServerHelpers::getROMClassData(const ClientSessionData::ClassInfo &classInfo,
case CLASSINFO_ARRAY_ELEMENT_SIZE:
*(int32_t *)data = classInfo._arrayElementSize;
break;
case CLASSINFO_DEFAULT_VALUE_SLOT_ADDRESS:
*(j9object_t **)data = classInfo._defaultValueSlotAddress;
break;
default:
TR_ASSERT(false, "Class Info not supported %u\n", dataType);
break;
Expand Down
4 changes: 3 additions & 1 deletion runtime/compiler/control/JITServerHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class JITServerHelpers
CLASSINFO_CONSTANT_POOL,
CLASSINFO_CLASS_CHAIN_OFFSET_IDENTIFYING_LOADER,
CLASSINFO_ARRAY_ELEMENT_SIZE,
CLASSINFO_DEFAULT_VALUE_SLOT_ADDRESS,
};

// NOTE: when adding new elements to this tuple, add them to the end,
Expand Down Expand Up @@ -84,7 +85,8 @@ class JITServerHelpers
uintptr_t, // 20: _classChainOffsetIdentifyingLoader
std::vector<J9ROMMethod *>, // 21: _origROMMethods
std::string, // 22: _classNameIdentifyingLoader
int32_t // 23: _arrayElementSize
int32_t, // 23: _arrayElementSize
j9object_t * // 24: _defaultValueSlotAddress
>;

// Packs a ROMClass to be transferred to the server.
Expand Down
47 changes: 44 additions & 3 deletions runtime/compiler/env/J9ClassEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ J9::ClassEnv::enumerateFields(TR::Region &region, TR_OpaqueClassBlock *opaqueCla
#if defined(J9VM_OPT_JITSERVER)
if (comp->isOutOfProcessCompilation())
{
auto stream = TR::CompilationInfo::getStream();
auto stream = comp->getStream();
stream->write(JITServer::MessageType::ClassEnv_enumerateFields, opaqueClazz);
auto recv = stream->read<std::vector<TR::TypeLayoutEntry>, std::vector<std::string>, std::vector<std::string>>();
auto &entries = std::get<0>(recv);
Expand Down Expand Up @@ -981,7 +981,7 @@ bool
J9::ClassEnv::isClassRefPrimitiveValueType(TR::Compilation *comp, TR_OpaqueClassBlock *cpContextClass, int32_t cpIndex)
{
#if defined(J9VM_OPT_JITSERVER)
if (auto stream = TR::CompilationInfo::getStream())
if (auto stream = comp->getStream())
{
stream->write(JITServer::MessageType::ClassEnv_isClassRefPrimitiveValueType, cpContextClass, cpIndex);
return std::get<0>(stream->read<bool>());
Expand Down Expand Up @@ -1025,7 +1025,7 @@ int32_t
J9::ClassEnv::flattenedArrayElementSize(TR::Compilation *comp, TR_OpaqueClassBlock *arrayClass)
{
#if defined(J9VM_OPT_JITSERVER)
if (auto stream = TR::CompilationInfo::getStream())
if (auto stream = comp->getStream())
{
int32_t arrayElementSize = 0;
JITServerHelpers::getAndCacheRAMClassInfo((J9Class *)arrayClass, TR::compInfoPT->getClientData(), stream, JITServerHelpers::CLASSINFO_ARRAY_ELEMENT_SIZE, (void *)&arrayElementSize);
Expand All @@ -1038,3 +1038,44 @@ J9::ClassEnv::flattenedArrayElementSize(TR::Compilation *comp, TR_OpaqueClassBlo
return vm->internalVMFunctions->arrayElementSize((J9ArrayClass*)self()->convertClassOffsetToClassPtr(arrayClass));
}
}

j9object_t*
J9::ClassEnv::getDefaultValueSlotAddress(TR::Compilation *comp, TR_OpaqueClassBlock *clazz)
{
TR_ASSERT_FATAL(self()->isClassInitialized(comp, clazz), "clazz %p must be initialized when getDefaultValueSlotAddress is called", clazz);

#if defined(J9VM_OPT_JITSERVER)
if (auto stream = comp->getStream())
{
j9object_t* defaultValueSlotAddress = NULL;
ClientSessionData *clientSessionData = TR::compInfoPT->getClientData();

JITServerHelpers::getAndCacheRAMClassInfo((J9Class *)clazz, clientSessionData, stream, JITServerHelpers::CLASSINFO_DEFAULT_VALUE_SLOT_ADDRESS, (void *)&defaultValueSlotAddress);

if (!defaultValueSlotAddress)
{
stream->write(JITServer::MessageType::ClassEnv_getDefaultValueSlotAddress, clazz);
defaultValueSlotAddress = std::get<0>(stream->read<j9object_t*>());

if (defaultValueSlotAddress)
{
OMR::CriticalSection getRemoteROMClass(clientSessionData->getROMMapMonitor());
auto it = clientSessionData->getROMClassMap().find((J9Class*) clazz);
if (it != clientSessionData->getROMClassMap().end())
{
it->second._defaultValueSlotAddress = defaultValueSlotAddress;
}
}
}

return defaultValueSlotAddress;
}
else // non-jitserver
#endif /* defined(J9VM_OPT_JITSERVER) */
{
J9Class *j9class = reinterpret_cast<J9Class *>(clazz);
J9JavaVM *vm = comp->fej9()->getJ9JITConfig()->javaVM;

return vm->internalVMFunctions->getDefaultValueSlotAddress(j9class);
}
}
11 changes: 11 additions & 0 deletions runtime/compiler/env/J9ClassEnv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@ class OMR_EXTENSIBLE ClassEnv : public OMR::ClassEnvConnector
* 2 concrete classses and false otherwise.
*/
bool containsZeroOrOneConcreteClass(TR::Compilation *comp, List<TR_PersistentClassInfo>* subClasses);

/** \brief
* Returns the reference to the address of the default value instance for a value class.
*
* \param clazz
* The class that the default value instance belongs to. Must be an initialized value class.
*
* \return
* The reference to the address of the default value instance.
*/
j9object_t *getDefaultValueSlotAddress(TR::Compilation *comp, TR_OpaqueClassBlock *clazz);
};

}
Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/net/CommunicationStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class CommunicationStream
ClientMessage _cMsg;

static const uint8_t MAJOR_NUMBER = 1;
static const uint16_t MINOR_NUMBER = 39;
static const uint16_t MINOR_NUMBER = 40;
static const uint8_t PATCH_NUMBER = 0;
static uint32_t CONFIGURATION_FLAGS;

Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/net/MessageTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ const char *messageNames[] =
"ClassEnv_enumerateFields",
"ClassEnv_isClassRefPrimitiveValueType",
"ClassEnv_flattenedArrayElementSize",
"ClassEnv_getDefaultValueSlotAddress",
"SharedCache_getClassChainOffsetIdentifyingLoader",
"SharedCache_rememberClass",
"SharedCache_addHint",
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/net/MessageTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ enum MessageType : uint16_t
ClassEnv_enumerateFields,
ClassEnv_isClassRefPrimitiveValueType,
ClassEnv_flattenedArrayElementSize,
ClassEnv_getDefaultValueSlotAddress,

// For TR_J9SharedCache
SharedCache_getClassChainOffsetIdentifyingLoader,
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/runtime/JITClientSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ ClientSessionData::ClassInfo::ClassInfo(TR_PersistentMemory *persistentMemory) :
_classNameIdentifyingLoader(),
_aotCacheClassRecord(NULL),
_arrayElementSize(0),
_defaultValueSlotAddress(NULL),
_classOfStaticCache(decltype(_classOfStaticCache)::allocator_type(persistentMemory->_persistentAllocator.get())),
_constantClassPoolCache(decltype(_constantClassPoolCache)::allocator_type(persistentMemory->_persistentAllocator.get())),
_fieldAttributesCache(decltype(_fieldAttributesCache)::allocator_type(persistentMemory->_persistentAllocator.get())),
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/runtime/JITClientSession.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class ClientSessionData
std::string _classNameIdentifyingLoader;
const AOTCacheClassRecord *_aotCacheClassRecord;
int32_t _arrayElementSize;
j9object_t * _defaultValueSlotAddress;

PersistentUnorderedMap<int32_t, TR_OpaqueClassBlock *> _classOfStaticCache;
PersistentUnorderedMap<int32_t, TR_OpaqueClassBlock *> _constantClassPoolCache;
Expand Down