Skip to content

Commit

Permalink
Merge pull request #11092 from liqunl/adoptOpenjdkMH/ldc
Browse files Browse the repository at this point in the history
Use the right symbol for constant string placeholder
  • Loading branch information
DanHeidinga committed Nov 25, 2020
2 parents 8c76311 + ba1bec5 commit fb11ea2
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 20 deletions.
24 changes: 23 additions & 1 deletion runtime/compiler/compile/J9SymbolReferenceTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ J9::SymbolReferenceTable::findOrCreateStringSymbol(TR::ResolvedMethodSymbol * ow
TR_ResolvedMethod * owningMethod = owningMethodSymbol->getResolvedMethod();
void * stringConst = owningMethod->stringConstant(cpIndex);
TR::SymbolReference * symRef;
bool isString = true;
if (owningMethod->isUnresolvedString(cpIndex))
{
symRef = findOrCreateCPSymbol(owningMethodSymbol, cpIndex, TR::Address, false, 0);
Expand All @@ -1300,8 +1301,29 @@ J9::SymbolReferenceTable::findOrCreateStringSymbol(TR::ResolvedMethodSymbol * ow
}
symRef = findOrCreateCPSymbol(owningMethodSymbol, cpIndex, TR::Address, true, stringConst, knownObjectIndex);
}

TR::StaticSymbol * sym = (TR::StaticSymbol *)symRef->getSymbol();
sym->setConstString();

// If symbol is created the first time
if (!symRef->isUnresolved() &&
!sym->isConstString() &&
!sym->isNonSpecificConstObject())
{
TR::VMAccessCriticalSection constantCriticalSection(comp()->fej9());
TR_OpaqueClassBlock *clazz = comp()->fej9()->getObjectClassAt((uintptr_t)stringConst);
isString = comp()->fej9()->isString(clazz);
}

if (isString)
sym->setConstString();
else
{
if (comp()->compileRelocatableCode())
comp()->failCompilation<J9::AOTHasPatchedCPConstant>("Patched Constant not supported in AOT.");

sym->setNonSpecificConstObject();
}

return symRef;
}

Expand Down
5 changes: 5 additions & 0 deletions runtime/compiler/control/CompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2151,6 +2151,7 @@ bool TR::CompilationInfo::shouldRetryCompilation(TR_MethodToBeCompiled *entry, T
case compilationAotThunkReloFailure:
case compilationAotHasInvokehandle:
case compilationAotHasInvokeVarHandle:
case compilationAotPatchedCPConstant:
case compilationAotHasInvokeSpecialInterface:
case compilationAotValidateMethodExitFailure:
case compilationAotValidateMethodEnterFailure:
Expand Down Expand Up @@ -10970,6 +10971,10 @@ TR::CompilationInfoPerThreadBase::processException(
{
_methodBeingCompiled->_compErrCode = compilationRestrictedMethod;
}
catch (const J9::AOTHasPatchedCPConstant &e)
{
_methodBeingCompiled->_compErrCode = compilationAotPatchedCPConstant;
}
catch (const TR::NoRecompilationRecoverableILGenException &e)
{
_methodBeingCompiled->_compErrCode = compilationRestrictedMethod;
Expand Down
6 changes: 6 additions & 0 deletions runtime/compiler/control/JITClientCompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,12 @@ handleServerMessage(JITServer::ClientStream *client, TR_J9VM *fe, JITServer::Mes
client->write(response, fe->getObjectClass(objectPointer));
}
break;
case MessageType::VM_getObjectClassAt:
{
uintptr_t objectAddress = std::get<0>(client->getRecvData<uintptr_t>());
client->write(response, fe->getObjectClassAt(objectAddress));
}
break;
case MessageType::VM_getStaticReferenceFieldAtAddress:
{
TR::VMAccessCriticalSection getStaticReferenceFieldAtAddress(fe);
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/control/rossa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ char *compilationErrorNames[]={
"compilationAOTValidateTMFailure", //52
"compilationILGenUnsupportedValueTypeOperationFailure", //53
"compilationAOTRelocationRecordGenerationFailure", //54
"compilationAotPatchedCPConstant", //55
#if defined(J9VM_OPT_JITSERVER)
"compilationStreamFailure", //55
"compilationStreamLostMessage", // 56
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/control/rossa.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ typedef enum {
compilationAOTValidateTMFailure = 52,
compilationILGenUnsupportedValueTypeOperationFailure = 53,
compilationAOTRelocationRecordGenerationFailure = 54,
compilationAotPatchedCPConstant = 55,
#if defined(J9VM_OPT_JITSERVER)
compilationFirstJITServerFailure,
compilationStreamFailure = compilationFirstJITServerFailure,
Expand Down
7 changes: 7 additions & 0 deletions runtime/compiler/env/VMJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,13 @@ TR_J9VMBase::getObjectClass(uintptr_t objectPointer)
return convertClassPtrToClassOffset(j9class);
}

TR_OpaqueClassBlock *
TR_J9VMBase::getObjectClassAt(uintptr_t objectAddress)
{
TR::VMAccessCriticalSection getObjectClassAt(this);
return getObjectClass(getStaticReferenceFieldAtAddress(objectAddress));
}

uintptr_t
TR_J9VMBase::getStaticReferenceFieldAtAddress(uintptr_t fieldAddress)
{
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/env/VMJ9.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ class TR_J9VMBase : public TR_FrontEnd
virtual uint32_t getAllocationSize(TR::StaticSymbol *classSym, TR_OpaqueClassBlock * clazz);

virtual TR_OpaqueClassBlock *getObjectClass(uintptr_t objectPointer);
virtual TR_OpaqueClassBlock *getObjectClassAt(uintptr_t objectAddress);
virtual uintptr_t getReferenceFieldAt(uintptr_t objectPointer, uintptr_t offsetFromHeader);
virtual uintptr_t getVolatileReferenceFieldAt(uintptr_t objectPointer, uintptr_t offsetFromHeader);
virtual uintptr_t getReferenceFieldAtAddress(uintptr_t fieldAddress);
Expand Down
8 changes: 8 additions & 0 deletions runtime/compiler/env/VMJ9Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,14 @@ TR_J9ServerVM::getObjectClass(uintptr_t objectPointer)
return std::get<0>(stream->read<TR_OpaqueClassBlock *>());
}

TR_OpaqueClassBlock *
TR_J9ServerVM::getObjectClassAt(uintptr_t objectAddress)
{
JITServer::ServerStream *stream = _compInfoPT->getMethodBeingCompiled()->_stream;
stream->write(JITServer::MessageType::VM_getObjectClassAt, objectAddress);
return std::get<0>(stream->read<TR_OpaqueClassBlock *>());
}

uintptr_t
TR_J9ServerVM::getStaticReferenceFieldAtAddress(uintptr_t fieldAddress)
{
Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/env/VMJ9Server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class TR_J9ServerVM: public TR_J9VM
virtual bool isPrimitiveArray(TR_OpaqueClassBlock *clazz) override;
virtual uint32_t getAllocationSize(TR::StaticSymbol *classSym, TR_OpaqueClassBlock *clazz) override;
virtual TR_OpaqueClassBlock * getObjectClass(uintptr_t objectPointer) override;
virtual TR_OpaqueClassBlock * getObjectClassAt(uintptr_t objectAddress) override;
virtual uintptr_t getStaticReferenceFieldAtAddress(uintptr_t fieldAddress) override;

virtual bool stackWalkerMaySkipFrames(TR_OpaqueMethodBlock *method, TR_OpaqueClassBlock *clazz) override;
Expand Down
10 changes: 10 additions & 0 deletions runtime/compiler/exceptions/AOTFailure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ class AOTHasMethodTypeConstant : public virtual TR::RecoverableILGenException
virtual const char* what() const throw() { return "AOT Has Method Type Constant"; }
};

/**
* AOT Has patched CP constant exception type.
*
* Thrown when a method that has a constant object in CP entry patched to a different type is AOT Compiled.
*/
class AOTHasPatchedCPConstant: public virtual TR::RecoverableILGenException
{
virtual const char* what() const throw() { return "AOT Has Patched CP Constant"; }
};

/**
* AOT Relocation Failure exception type.
*
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 @@ -109,7 +109,7 @@ class CommunicationStream
ClientMessage _cMsg;

static const uint8_t MAJOR_NUMBER = 1;
static const uint16_t MINOR_NUMBER = 14;
static const uint16_t MINOR_NUMBER = 15;
static const uint8_t PATCH_NUMBER = 0;
static uint32_t CONFIGURATION_FLAGS;

Expand Down
38 changes: 20 additions & 18 deletions runtime/compiler/net/MessageTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ enum MessageType : uint16_t
VM_isPrimitiveArray,
VM_getAllocationSize,
VM_getObjectClass,
VM_getObjectClassAt,
VM_stackWalkerMaySkipFrames,
VM_hasFinalFieldsInClass,
VM_getClassNameSignatureFromMethod,
Expand Down Expand Up @@ -207,7 +208,7 @@ enum MessageType : uint16_t
VM_getFields,

// For static TR::CompilationInfo methods
CompInfo_isCompiled, // 172
CompInfo_isCompiled, // 173
CompInfo_getPCIfCompiled,
CompInfo_getInvocationCount,
CompInfo_setInvocationCount,
Expand All @@ -221,7 +222,7 @@ enum MessageType : uint16_t
CompInfo_getJ9MethodStartPC,

// For J9::ClassEnv Methods
ClassEnv_classFlagsValue, // 184
ClassEnv_classFlagsValue, // 185
ClassEnv_classDepthOf,
ClassEnv_classInstanceSize,
ClassEnv_superClassesOf,
Expand All @@ -234,13 +235,13 @@ enum MessageType : uint16_t
ClassEnv_getROMClassRefName,

// For TR_J9SharedCache
SharedCache_getClassChainOffsetInSharedCache, // 195
SharedCache_getClassChainOffsetInSharedCache, // 196
SharedCache_rememberClass,
SharedCache_addHint,
SharedCache_storeSharedData,

// For runFEMacro
runFEMacro_invokeCollectHandleNumArgsToCollect, // 199
runFEMacro_invokeCollectHandleNumArgsToCollect, // 200
runFEMacro_invokeExplicitCastHandleConvertArgs,
runFEMacro_targetTypeL,
runFEMacro_invokeILGenMacrosInvokeExactAndFixup,
Expand All @@ -266,24 +267,24 @@ enum MessageType : uint16_t
runFEMacro_invokeCollectHandleAllocateArray,

// for JITServerPersistentCHTable
CHTable_getAllClassInfo, // 223
CHTable_getAllClassInfo, // 224
CHTable_getClassInfoUpdates,
CHTable_commit,
CHTable_clearReservable,

// for JITServerIProfiler
IProfiler_profilingSample, // 227
IProfiler_profilingSample, // 228
IProfiler_searchForMethodSample,
IProfiler_getMaxCallCount,
IProfiler_setCallCount,

Recompilation_getExistingMethodInfo, // 231
Recompilation_getExistingMethodInfo, // 232
Recompilation_getJittedBodyInfoFromPC,

ClassInfo_getRemoteROMString,

// for KnownObjectTable
KnownObjectTable_getOrCreateIndex, // 234
KnownObjectTable_getOrCreateIndex, // 235
KnownObjectTable_getOrCreateIndexAt,
KnownObjectTable_getPointer,
KnownObjectTable_getExistingIndexAt,
Expand All @@ -297,7 +298,7 @@ enum MessageType : uint16_t
KnownObjectTable_invokeDirectHandleDirectCall,
KnownObjectTable_getKnownObjectTableDumpInfo,

ClassEnv_isClassRefValueType, // 246
ClassEnv_isClassRefValueType, // 247
MessageType_MAXTYPE
};

Expand Down Expand Up @@ -407,6 +408,7 @@ static const char *messageNames[MessageType_ARRAYSIZE] =
"VM_isPrimitiveArray",
"VM_getAllocationSize",
"VM_getObjectClass",
"VM_getObjectClassAt",
"VM_stackWalkerMaySkipFrames",
"VM_hasFinalFieldsInClass",
"VM_getClassNameSignatureFromMethod",
Expand Down Expand Up @@ -477,7 +479,7 @@ static const char *messageNames[MessageType_ARRAYSIZE] =
"VM_getObjectSizeClass",
"VM_stackWalkerMaySkipFramesSVM",
"VM_getFields",
"CompInfo_isCompiled", // 172
"CompInfo_isCompiled", // 173
"CompInfo_getPCIfCompiled",
"CompInfo_getInvocationCount",
"CompInfo_setInvocationCount",
Expand All @@ -489,7 +491,7 @@ static const char *messageNames[MessageType_ARRAYSIZE] =
"CompInfo_setInvocationCountAtomic",
"CompInfo_isClassSpecial",
"CompInfo_getJ9MethodStartPC",
"ClassEnv_classFlagsValue", // 184
"ClassEnv_classFlagsValue", // 185
"ClassEnv_classDepthOf",
"ClassEnv_classInstanceSize",
"ClassEnv_superClassesOf",
Expand All @@ -500,11 +502,11 @@ static const char *messageNames[MessageType_ARRAYSIZE] =
"ClassEnv_getITable",
"ClassEnv_classHasIllegalStaticFinalFieldModification",
"ClassEnv_getROMClassRefName",
"SharedCache_getClassChainOffsetInSharedCache", // 195
"SharedCache_getClassChainOffsetInSharedCache", // 196
"SharedCache_rememberClass",
"SharedCache_addHint",
"SharedCache_storeSharedData",
"runFEMacro_invokeCollectHandleNumArgsToCollect", // 199
"runFEMacro_invokeCollectHandleNumArgsToCollect", // 200
"runFEMacro_invokeExplicitCastHandleConvertArgs",
"runFEMacro_targetTypeL",
"runFEMacro_invokeILGenMacrosInvokeExactAndFixup",
Expand All @@ -528,18 +530,18 @@ static const char *messageNames[MessageType_ARRAYSIZE] =
"runFEMacro_invokeFilterArgumentsWithCombinerHandleFilterPosition",
"runFEMacro_invokeFilterArgumentsWithCombinerHandleArgumentIndices",
"runFEMacro_invokeCollectHandleAllocateArray",
"CHTable_getAllClassInfo", // 223
"CHTable_getAllClassInfo", // 224
"CHTable_getClassInfoUpdates",
"CHTable_commit",
"CHTable_clearReservable",
"IProfiler_profilingSample", // 227
"IProfiler_profilingSample", // 228
"IProfiler_searchForMethodSample",
"IProfiler_getMaxCallCount",
"IProfiler_setCallCount",
"Recompilation_getExistingMethodInfo", // 231
"Recompilation_getExistingMethodInfo", // 232
"Recompilation_getJittedBodyInfoFromPC",
"ClassInfo_getRemoteROMString",
"KnownObjectTable_getOrCreateIndex", // 233
"KnownObjectTable_getOrCreateIndex", // 234
"KnownObjectTable_getOrCreateIndexAt",
"KnownObjectTable_getPointer",
"KnownObjectTable_getExistingIndexAt",
Expand All @@ -551,7 +553,7 @@ static const char *messageNames[MessageType_ARRAYSIZE] =
"KnownObjectTable_getReferenceField",
"KnownObjectTable_invokeDirectHandleDirectCall",
"KnownObjectTable_getKnownObjectTableDumpInfo",
"ClassEnv_isClassRefValueType", // 246
"ClassEnv_isClassRefValueType", // 247
};
}; // namespace JITServer
#endif // MESSAGE_TYPES_HPP

0 comments on commit fb11ea2

Please sign in to comment.