Skip to content

Commit

Permalink
Fix string literal conversion warnings in runtime/compiler/env
Browse files Browse the repository at this point in the history
Fix string literal conversion warnings in runtime/compiler/env

Signed-off-by: Dylan Tuttle <[email protected]>
  • Loading branch information
dylanjtuttle committed Nov 23, 2023
1 parent 3215b09 commit b910686
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 189 deletions.
2 changes: 1 addition & 1 deletion runtime/compiler/env/CHTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ class TR_PersistentArrayFieldInfo : public TR_PersistentFieldInfo
int32_t *dimensionInfo = NULL,
uint8_t b1 = VALID_BUT_NOT_ALWAYS_INITIALIZED,
uint8_t b2 = VALID_BUT_NOT_ALWAYS_INITIALIZED,
char *c = "",
char *c = (char *)"",
int32_t numChars = -1)
: TR_PersistentFieldInfo(sig, sigLength, next, b2, c, numChars),
_numDimensions(numDimensions),
Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/env/J2IThunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ TR_MHJ2IThunk::allocate(
}


TR_MHJ2IThunkTable::TR_MHJ2IThunkTable(TR_PersistentMemory *m, char *name):
TR_MHJ2IThunkTable::TR_MHJ2IThunkTable(TR_PersistentMemory *m, const char *name):
_name(name),
_monitor(TR::Monitor::create(name)),
_nodes(m)
Expand Down
4 changes: 2 additions & 2 deletions runtime/compiler/env/J2IThunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class TR_MHJ2IThunkTable

private: // Fields

char *_name;
const char *_name;
TR::Monitor *_monitor;
TR_PersistentArray<Node> _nodes;

Expand All @@ -116,7 +116,7 @@ class TR_MHJ2IThunkTable
int16_t terseSignatureLength(char *signature);
void getTerseSignature(char *buf, int16_t bufLength, char *signature);

TR_MHJ2IThunkTable(TR_PersistentMemory *m, char *name);
TR_MHJ2IThunkTable(TR_PersistentMemory *m, const char *name);
TR_PERSISTENT_ALLOC(TR_Memory::JSR292)

void dumpTo(TR_FrontEnd *fe, TR::FILE *file);
Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/env/J9SharedCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ TR_J9SharedCache::getCacheDescriptorList()
}

void
TR_J9SharedCache::log(char *format, ...)
TR_J9SharedCache::log(const char *format, ...)
{
PORT_ACCESS_FROM_PORT(_javaVM->portLibrary);
char outputBuffer[512] = "TR_J9SC:";
Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/env/J9SharedCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class TR_J9SharedCache : public TR_SharedCache

TR_AOTStats *aotStats() { return _aotStats; }

void log(char *format, ...);
void log(const char *format, ...);

SCCHint getHint(J9VMThread * vmThread, J9Method *method);

Expand Down
43 changes: 21 additions & 22 deletions runtime/compiler/env/VMJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4247,10 +4247,10 @@ TR_J9VMBase::persistMHJ2IThunk(void *thunk)
}

static char *
getJ2IThunkSignature(char *invokeHandleSignature, uint32_t signatureLength, int argsToSkip, char *description, TR::Compilation *comp)
getJ2IThunkSignature(char *invokeHandleSignature, uint32_t signatureLength, int argsToSkip, const char *description, TR::Compilation *comp)
{
char *argsToCopy;
for (argsToCopy = invokeHandleSignature+1; argsToSkip > 0; argsToSkip--)
for (argsToCopy = invokeHandleSignature + 1; argsToSkip > 0; argsToSkip--)
argsToCopy = nextSignatureArgument(argsToCopy);
uint32_t lengthToCopy = signatureLength - (argsToCopy - invokeHandleSignature);

Expand All @@ -4263,7 +4263,7 @@ getJ2IThunkSignature(char *invokeHandleSignature, uint32_t signatureLength, int
}

static TR::Node *
getEquivalentVirtualCallNode(TR::Node *callNode, int argsToSkip, char *description, TR::Compilation *comp)
getEquivalentVirtualCallNode(TR::Node *callNode, int argsToSkip, const char *description, TR::Compilation *comp)
{
TR::Node *j2iThunkCall = TR::Node::createWithSymRef(callNode, callNode->getOpCodeValue(), callNode->getNumChildren() - argsToSkip + 1, callNode->getSymbolReference());
j2iThunkCall->setChild(0, callNode->getFirstChild()); // first child should be vft pointer but we don't have one
Expand Down Expand Up @@ -4400,7 +4400,7 @@ TR_J9VMBase::mutableCallSite_findOrCreateBypassLocation(uintptr_t mutableCallSit
return mutableCallSite_bypassLocation(mutableCallSite);
}

static TR_OpaqueMethodBlock *findClosestArchetype(TR_OpaqueClassBlock *clazz, char *name, char *signature, char *currentArgument, TR_FrontEnd *fe, J9VMThread *vmThread)
static TR_OpaqueMethodBlock *findClosestArchetype(TR_OpaqueClassBlock *clazz, const char *name, const char *signature, char *currentArgument, TR_FrontEnd *fe, J9VMThread *vmThread)
{
// NOTE: signature will be edited in-place

Expand Down Expand Up @@ -4457,7 +4457,7 @@ static TR_OpaqueMethodBlock *findClosestArchetype(TR_OpaqueClassBlock *clazz, ch
}

TR_OpaqueMethodBlock *
TR_J9VMBase::lookupArchetype(TR_OpaqueClassBlock *clazz, char *name, char *signature)
TR_J9VMBase::lookupArchetype(TR_OpaqueClassBlock *clazz, const char *name, const char *signature)
{
// Find the best match for the signature. Start by appending an "I"
// placeholder argument. findClosestArchetype will progressively truncate
Expand Down Expand Up @@ -4583,15 +4583,14 @@ TR::KnownObjectTable::Index TR_J9VMBase::mutableCallSiteEpoch(TR::Compilation *c
if (knot == NULL)
return TR::KnownObjectTable::UNKNOWN;

// getVolatileReferenceField() doesn't accept const char*
#if defined(J9VM_OPT_OPENJDK_METHODHANDLE)
char *fieldName = "target"; // There is no separate epoch field.
// There is no separate epoch field
uintptr_t mh = getVolatileReferenceField(
mutableCallSite, "target", "Ljava/lang/invoke/MethodHandle;");
#else
char *fieldName = "epoch";
#endif

uintptr_t mh = getVolatileReferenceField(
mutableCallSite, fieldName, "Ljava/lang/invoke/MethodHandle;");
mutableCallSite, "epoch", "Ljava/lang/invoke/MethodHandle;");
#endif

return mh == 0 ? TR::KnownObjectTable::UNKNOWN : knot->getOrCreateIndex(mh);
}
Expand Down Expand Up @@ -5035,7 +5034,7 @@ TR_J9VMBase::getVMIndexOffset()
#endif /* defined(J9VM_OPT_OPENJDK_METHODHANDLE) */

TR::KnownObjectTable::Index
TR_J9VMBase::getMemberNameFieldKnotIndexFromMethodHandleKnotIndex(TR::Compilation *comp, TR::KnownObjectTable::Index mhIndex, char *fieldName)
TR_J9VMBase::getMemberNameFieldKnotIndexFromMethodHandleKnotIndex(TR::Compilation *comp, TR::KnownObjectTable::Index mhIndex, const char *fieldName)
{
TR::VMAccessCriticalSection dereferenceKnownObjectField(this);
TR::KnownObjectTable *knot = comp->getKnownObjectTable();
Expand Down Expand Up @@ -5974,7 +5973,7 @@ void revertMethodToInterpreted(J9Method * method)

struct TrustedClass
{
char * name;
const char * name;
int32_t length;
int32_t argNum;
};
Expand Down Expand Up @@ -6324,7 +6323,7 @@ TR_J9VMBase::getBytecodePC(TR_OpaqueMethodBlock *method, TR_ByteCodeInfo &bcInfo
//whose signatures are given in methodSig. methodCount is the number of methods.
//Returns the number of methods found in the class
//This function handles static and virtual functions only.
int TR_J9VMBase::findOrCreateMethodSymRef(TR::Compilation* comp, TR::ResolvedMethodSymbol* owningMethodSym, char* classSig, char** methodSig, TR::SymbolReference** symRefs, int methodCount)
int TR_J9VMBase::findOrCreateMethodSymRef(TR::Compilation *comp, TR::ResolvedMethodSymbol *owningMethodSym, const char *classSig, const char **methodSig, TR::SymbolReference **symRefs, int methodCount)
{
TR_OpaqueClassBlock *c = getClassFromSignature(classSig,
strlen(classSig),
Expand Down Expand Up @@ -6389,7 +6388,7 @@ int TR_J9VMBase::findOrCreateMethodSymRef(TR::Compilation* comp, TR::ResolvedMet
//Given a class signature and a method signature returns a symref for that method.
//If the method is not resolved or doesn't exist in that class, it returns NULL
//This function handles static and virtual functions only.
TR::SymbolReference* TR_J9VMBase::findOrCreateMethodSymRef(TR::Compilation* comp, TR::ResolvedMethodSymbol* owningMethodSym, char* classSig, char* methodSig)
TR::SymbolReference* TR_J9VMBase::findOrCreateMethodSymRef(TR::Compilation *comp, TR::ResolvedMethodSymbol *owningMethodSym, const char *classSig, const char *methodSig)
{
TR::SymbolReference* symRef = NULL;
int numMethodsFound = findOrCreateMethodSymRef(comp, owningMethodSym, classSig, &methodSig, &symRef, 1);
Expand All @@ -6400,23 +6399,23 @@ TR::SymbolReference* TR_J9VMBase::findOrCreateMethodSymRef(TR::Compilation* comp
//returns a symref for that method. If the method is not resolved or doesn't exist
//in that class, it returns NULL
//This function handles static and virtual functions only.
TR::SymbolReference* TR_J9VMBase::findOrCreateMethodSymRef(TR::Compilation* comp, TR::ResolvedMethodSymbol* owningMethodSym, char* methodSig) {
TR::SymbolReference* TR_J9VMBase::findOrCreateMethodSymRef(TR::Compilation *comp, TR::ResolvedMethodSymbol *owningMethodSym, const char *methodSig) {
int methodSigLen = strlen(methodSig);
char* classSig = (char*)comp->trMemory()->allocateStackMemory(sizeof(char)*methodSigLen);
char* separator = strchr(methodSig, '.');
char *classSig = (char *)comp->trMemory()->allocateStackMemory(sizeof(char) * methodSigLen);
const char *separator = strchr(methodSig, '.');
TR_ASSERT(separator, ". not found in method name");
int classSigLen = separator - methodSig;
strncpy(classSig, methodSig, classSigLen);
classSig[classSigLen] = 0;
TR::SymbolReference* result = findOrCreateMethodSymRef(comp, owningMethodSym, classSig, methodSig);
TR::SymbolReference *result = findOrCreateMethodSymRef(comp, owningMethodSym, classSig, methodSig);
return result;
}

//Given an array of full method signatures (i.e., including full class name), this method
//gives symrefs for those methods. The number of input methods are given in methodCount.
//The function returns the number of methods found
//this function handles static and virtual functions only
int TR_J9VMBase::findOrCreateMethodSymRef(TR::Compilation* comp, TR::ResolvedMethodSymbol* owningMethodSym, char** methodSig, TR::SymbolReference** symRefs, int methodCount) {
int TR_J9VMBase::findOrCreateMethodSymRef(TR::Compilation *comp, TR::ResolvedMethodSymbol *owningMethodSym, const char **methodSig, TR::SymbolReference **symRefs, int methodCount) {
int numMethodsFound = 0;
for (int i = 0; i < methodCount; i++) {
if (!methodSig[i]) continue;
Expand Down Expand Up @@ -6786,7 +6785,7 @@ TR_J9VMBase::getClassFlagsValue(TR_OpaqueClassBlock * classPointer)
#define LOOKUP_OPTION_NO_THROW 8192

TR_OpaqueMethodBlock *
TR_J9VM::getMethodFromName(char *className, char *methodName, char *signature)
TR_J9VM::getMethodFromName(const char *className, const char *methodName, const char *signature)
{
TR::VMAccessCriticalSection getMethodFromName(this);
TR_OpaqueClassBlock *methodClass = getSystemClassFromClassName(className, strlen(className), true);
Expand Down Expand Up @@ -6820,7 +6819,7 @@ TR_J9VM::getMethodFromName(char *className, char *methodName, char *signature)
* Only methods visible to the callingClass will be returned.
*/
TR_OpaqueMethodBlock *
TR_J9VMBase::getMethodFromClass(TR_OpaqueClassBlock * methodClass, char * methodName, char * signature, TR_OpaqueClassBlock * callingClass)
TR_J9VMBase::getMethodFromClass(TR_OpaqueClassBlock *methodClass, const char *methodName, const char *signature, TR_OpaqueClassBlock *callingClass)
{
J9JNINameAndSignature nameAndSig;
nameAndSig.name = methodName;
Expand Down
Loading

0 comments on commit b910686

Please sign in to comment.