Skip to content

Commit a4cf5e4

Browse files
Yiling Hana7ehuo
Yiling Han
authored andcommitted
Add 'Q' prefix handling
Many places need proper handling for 'Q' prefix. In some places it can be handled in the same way as 'L', whereas in some other places, how to handle 'Q' needs to be further considered or determined if the situation change (e.g. if 'Q' ends up being passed by value). Related to #12237 Co-authored-by:: Yiling Han <Yiling.Han@ibm.com> Signed-off-by: Annabelle Huo <Annabelle.Huo@ibm.com>
1 parent e5daca3 commit a4cf5e4

16 files changed

+98
-75
lines changed

runtime/compiler/env/J2IThunk.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2020 IBM Corp. and others
2+
* Copyright (c) 2000, 2021 IBM Corp. and others
33
*
44
* This program and the accompanying materials are made available under
55
* the terms of the Eclipse Public License 2.0 which accompanies this
@@ -56,7 +56,7 @@ TR_J2IThunk::allocate(
5656
#if defined(J9VM_OPT_JITSERVER)
5757
if (cg->comp()->isOutOfProcessCompilation())
5858
{
59-
// Don't need to use code cache because the entire thunk will be copied and sent to the client
59+
// Don't need to use code cache because the entire thunk will be copied and sent to the client
6060
result = (TR_J2IThunk*)cg->comp()->trMemory()->allocateMemory(totalSize, heapAlloc);
6161
}
6262
else
@@ -108,6 +108,7 @@ char TR_J2IThunkTable::terseTypeChar(char *type)
108108
{
109109
case '[':
110110
case 'L':
111+
case 'Q':
111112
return TR::Compiler->target.is64Bit()? 'L' : 'I';
112113
case 'Z':
113114
case 'B':

runtime/compiler/env/J2IThunk.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2016 IBM Corp. and others
2+
* Copyright (c) 2000, 2021 IBM Corp. and others
33
*
44
* This program and the accompanying materials are made available under
55
* the terms of the Eclipse Public License 2.0 which accompanies this
@@ -72,7 +72,8 @@ class TR_J2IThunkTable
7272
case 'J': return TC_LONG;
7373
case 'F': return TC_FLOAT;
7474
case 'D': return TC_DOUBLE;
75-
case 'L': return TC_REFERENCE;
75+
case 'L':
76+
case 'Q': return TC_REFERENCE;
7677
default:
7778
TR_ASSERT(0, "Unknown type char '%c'", typeChar);
7879
return -1;

runtime/compiler/env/J9ClassEnv.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ static void addEntryForFieldImpl(TR_VMField *field, TR::TypeLayoutBuilder &tlb,
557557
dataType = TR::Double;
558558
break;
559559
}
560-
// VALHALLA_TODO: Might require different TR::DataType for value types (Q)
561560
case 'L':
562561
case 'Q':
563562
case '[':

runtime/compiler/env/VMJ9.cpp

+20-9
Original file line numberDiff line numberDiff line change
@@ -2521,7 +2521,12 @@ TR_J9VMBase::getClassSignature_DEPRECATED(TR_OpaqueClassBlock * clazz, int32_t &
25212521
for (i = 0; i < numDims; i++)
25222522
sig[i] = '[';
25232523
if (* name != '[')
2524-
sig[i++] = 'L';
2524+
{
2525+
if (TR::Compiler->om.areValueTypesEnabled() && TR::Compiler->cls.isValueTypeClass(myClass))
2526+
sig[i++] = 'Q';
2527+
else
2528+
sig[i++] = 'L';
2529+
}
25252530
memcpy(sig+i, name, len);
25262531
i += len;
25272532
if (* name != '[')
@@ -2543,13 +2548,18 @@ TR_J9VMBase::getClassSignature(TR_OpaqueClassBlock * clazz, TR_Memory * trMemory
25432548
if (* name != '[')
25442549
length += 2;
25452550

2546-
length++; //for null-termination
2551+
length++; //for null-termination
25472552
char * sig = (char *)trMemory->allocateStackMemory(length);
25482553
int32_t i;
25492554
for (i = 0; i < numDims; i++)
25502555
sig[i] = '[';
25512556
if (* name != '[')
2552-
sig[i++] = 'L';
2557+
{
2558+
if (TR::Compiler->om.areValueTypesEnabled() && TR::Compiler->cls.isValueTypeClass(myClass))
2559+
sig[i++] = 'Q';
2560+
else
2561+
sig[i++] = 'L';
2562+
}
25532563
memcpy(sig+i, name, len);
25542564
i += len;
25552565
if (* name != '[')
@@ -4081,10 +4091,10 @@ TR_J9VMBase::isStable(int cpIndex, TR_ResolvedMethod *owningMethod, TR::Compilat
40814091

40824092
if (comp->getOption(TR_DisableStableAnnotations))
40834093
return false;
4084-
4094+
40854095
if (cpIndex < 0)
40864096
return false;
4087-
4097+
40884098
J9Class *fieldClass = (J9Class*)owningMethod->classOfMethod();
40894099
if (!fieldClass)
40904100
return false;
@@ -4727,6 +4737,7 @@ TR_J9VMBase::lookupMethodHandleThunkArchetype(uintptr_t methodHandle)
47274737
{
47284738
case '[':
47294739
case 'L':
4740+
case 'Q':
47304741
// The thunkable signature might return some other class, but archetypes
47314742
// returning a reference are always declared to return Object.
47324743
//
@@ -7263,7 +7274,7 @@ TR_J9VM::getClassFromSignature(const char * sig, int32_t sigLength, J9ConstantPo
72637274
J9Class * j9class = NULL;
72647275
TR_OpaqueClassBlock * returnValue = NULL;
72657276

7266-
// For a non-array class type, strip off the first 'L' and last ';' of the
7277+
// For a non-array class type, strip off the first 'L' or 'Q' and last ';' of the
72677278
// signature
72687279
//
72697280
if ((*sig == 'L' || *sig == 'Q') && sigLength > 2)
@@ -7606,9 +7617,9 @@ TR_J9VM::inlineNativeCall(TR::Compilation * comp, TR::TreeTop * callNodeTreeTop,
76067617
{
76077618
return 0;
76087619
}
7609-
7620+
76107621
int32_t targetInlineDepth = 1;
7611-
7622+
76127623
int32_t callerIndex = callNode->getByteCodeInfo().getCallerIndex();
76137624
J9Class *callerClass = NULL;
76147625
J9Method *callerMethod = NULL;
@@ -7700,7 +7711,7 @@ TR_J9VM::inlineNativeCall(TR::Compilation * comp, TR::TreeTop * callNodeTreeTop,
77007711
}
77017712
}
77027713
return callNode;
7703-
7714+
77047715
case TR::java_lang_Thread_currentThread:
77057716
if (comp->cg()->getGRACompleted())
77067717
{

runtime/compiler/env/annotations/AnnotationBase.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void TR_AnnotationBase::loadExpectedAnnotationClasses(J9VMThread * vmThread)
7878
acquireVMAccess(vmThread); // this is not the comp thread so suspension is possible
7979
for(i=0;i < kLastAnnotationSignature;++i)
8080
{
81-
// Strip off 'L' prefix and ';' suffix
81+
// Strip off 'L' prefix or 'Q' prefix and ';' suffix
8282
const char *name = recognizedAnnotations[i].name;
8383
int32_t nameLen = recognizedAnnotations[i].nameLen;
8484
TR_ASSERT(strlen(name) == nameLen,"Table entry for %s is %d but should be %d\n",name,nameLen,strlen(name));
@@ -251,7 +251,7 @@ TR_AnnotationBase::getDefaultAnnotationInfo(const char *annotationName)
251251
}
252252
}
253253
if(NULL == clazz) return NULL;
254-
const char * className = annotationName+1; // strip off leading 'L';
254+
const char * className = annotationName+1; // strip off leading 'L' or 'Q';
255255
int32_t classNameLength = strlen (className) -1; // strip off trailing ';'
256256
J9AnnotationInfoEntry *defaultEntry = intFunc->getAnnotationDefaultsForNamedAnnotation(vmThread, clazz, (char *)className, classNameLength,
257257
J9_FINDCLASS_FLAG_EXISTING_ONLY);

runtime/compiler/env/j9fieldsInfo.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2020 IBM Corp. and others
2+
* Copyright (c) 2000, 2021 IBM Corp. and others
33
*
44
* This program and the accompanying materials are made available under
55
* the terms of the Eclipse Public License 2.0 which accompanies this
@@ -36,7 +36,7 @@
3636

3737
static int isReferenceSignature(char *signature)
3838
{
39-
return ( (signature[0] == 'L' ) || (signature[0] == '[') );
39+
return ( (signature[0] == 'L' ) || (signature[0] == '[') || (signature[0] == 'Q'));
4040
}
4141

4242
int TR_VMField::isReference()

runtime/compiler/env/j9method.cpp

+51-46
Original file line numberDiff line numberDiff line change
@@ -7096,9 +7096,9 @@ TR_ResolvedJ9Method::makeParameterList(TR::ResolvedMethodSymbol *methodSym)
70967096
}
70977097

70987098
// Walk to the end of the class name, if this is a class name
7099-
if (*end == 'L')
7099+
if (*end == 'L' || *end == 'Q')
71007100
{
7101-
// Assume the form is L<classname>; where <classname> is
7101+
// Assume the form is L<classname> or Q<classname>; where <classname> is
71027102
// at least 1 char and therefore skip the first 2 chars
71037103
end += 2;
71047104
end = (char *)memchr(end, ';', sigEnd - end);
@@ -7277,71 +7277,72 @@ TR_J9MethodParameterIterator::TR_J9MethodParameterIterator(TR_J9MethodBase &j9Me
72777277

72787278
TR::DataType TR_J9MethodParameterIterator::getDataType()
72797279
{
7280-
if (*_sig == 'L' || *_sig == '[')
7280+
if (*_sig == 'L' || *_sig == '[' || *_sig == 'Q')
72817281
{
72827282
_nextIncrBy = 0;
72837283
while (_sig[_nextIncrBy] == '[')
7284-
{
7285-
++_nextIncrBy;
7286-
}
7287-
if (_sig[_nextIncrBy] != 'L')
7288-
{
7289-
// Primitive array
7290-
++_nextIncrBy;
7291-
}
7284+
{
7285+
++_nextIncrBy;
7286+
}
7287+
7288+
if (_sig[_nextIncrBy] != 'L' && _sig[_nextIncrBy] != 'Q')
7289+
{
7290+
// Primitive array
7291+
++_nextIncrBy;
7292+
}
72927293
else
7293-
{
7294-
while (_sig[_nextIncrBy++] != ';') ;
7295-
}
7294+
{
7295+
while (_sig[_nextIncrBy++] != ';') ;
7296+
}
72967297
return TR::Aggregate;
72977298
}
72987299
else
72997300
{
73007301
_nextIncrBy = 1;
73017302
if (*_sig == 'Z')
7302-
{
7303-
return TR::Int8;
7304-
}
7303+
{
7304+
return TR::Int8;
7305+
}
73057306
else if (*_sig == 'B')
7306-
{
7307-
return TR::Int8;
7308-
}
7307+
{
7308+
return TR::Int8;
7309+
}
73097310
else if (*_sig == 'C')
7310-
{
7311-
return TR::Int16;
7312-
}
7311+
{
7312+
return TR::Int16;
7313+
}
73137314
else if (*_sig == 'S')
7314-
{
7315-
return TR::Int16;
7316-
}
7315+
{
7316+
return TR::Int16;
7317+
}
73177318
else if (*_sig == 'I')
7318-
{
7319-
return TR::Int32;
7320-
}
7319+
{
7320+
return TR::Int32;
7321+
}
73217322
else if (*_sig == 'J')
7322-
{
7323-
return TR::Int64;
7324-
}
7323+
{
7324+
return TR::Int64;
7325+
}
73257326
else if (*_sig == 'F')
7326-
{
7327-
return TR::Float;
7328-
}
7327+
{
7328+
return TR::Float;
7329+
}
73297330
else if (*_sig == 'D')
7330-
{
7331-
return TR::Double;
7332-
}
7331+
{
7332+
return TR::Double;
7333+
}
73337334
else
7334-
{
7335-
TR_ASSERT(0, "Unknown character in Java signature.");
7336-
return TR::NoType;
7337-
}
7335+
{
7336+
TR_ASSERT(0, "Unknown character in Java signature.");
7337+
return TR::NoType;
7338+
}
73387339
}
73397340
}
73407341

73417342
TR_OpaqueClassBlock * TR_J9MethodParameterIterator::getOpaqueClass()
73427343
{
73437344
TR_J9VMBase *fej9 = (TR_J9VMBase *)(_comp.fe());
7344-
TR_ASSERT(*_sig == '[' || *_sig == 'L', "Asked for class of incorrect Java parameter.");
7345+
TR_ASSERT(*_sig == '[' || *_sig == 'L' || *_sig == 'Q', "Asked for class of incorrect Java parameter.");
73457346
if (_nextIncrBy == 0) getDataType();
73467347
return _resolvedMethod == NULL ? NULL :
73477348
fej9->getClassFromSignature(_sig, _nextIncrBy, _resolvedMethod);
@@ -7360,7 +7361,7 @@ bool TR_J9MethodParameterIterator::isArray()
73607361

73617362
bool TR_J9MethodParameterIterator::isClass()
73627363
{
7363-
return (*_sig == 'L');
7364+
return (*_sig == 'L' || *_sig == 'Q');
73647365
}
73657366

73667367
bool TR_J9MethodParameterIterator::atEnd()
@@ -7410,6 +7411,7 @@ static TR::DataType typeFromSig(char sig)
74107411
{
74117412
case 'L':
74127413
case '[':
7414+
case 'Q':
74137415
return TR::Address;
74147416
case 'I':
74157417
case 'Z':
@@ -7663,7 +7665,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)
76637665
if (strcmp(sourceType, targetType))
76647666
{
76657667
char methodName[30], methodSignature[50];
7666-
if (sourceType[0] == 'L' && isExplicit)
7668+
if ((sourceType[0] == 'L' || sourceType[0] == 'Q') && isExplicit)
76677669
sprintf(methodName, "explicitObject2%s", targetName);
76687670
else
76697671
sprintf(methodName, "%s2%s", sourceName, targetName);
@@ -7684,7 +7686,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)
76847686

76857687
// Address conversions need a downcast after the call
76867688
//
7687-
if (targetType[0] == 'L')
7689+
if (targetType[0] == 'L' || targetType[0] == 'Q')
76887690
{
76897691
uintptr_t methodHandle;
76907692
uintptr_t sourceArguments;
@@ -7851,6 +7853,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)
78517853
break;
78527854
case 'L':
78537855
case '[':
7856+
case 'Q':
78547857
callOp = TR::acalli;
78557858
break;
78567859
case 'V':
@@ -7987,6 +7990,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)
79877990
{
79887991
case 'L':
79897992
case '[':
7993+
case 'Q':
79907994
sprintf(extraName, "extra_L");
79917995
extraSignature = artificialSignature(stackAlloc, "(L" JSR292_ArgumentMoverHandle ";I)Ljava/lang/Object;");
79927996
break;
@@ -8070,6 +8074,7 @@ TR_J9ByteCodeIlGenerator::runFEMacro(TR::SymbolReference *symRef)
80708074
{
80718075
case 'L':
80728076
case '[':
8077+
case 'Q':
80738078
sprintf(extraName, "extra_L");
80748079
extraSignature = artificialSignature(stackAlloc, "(L" JSR292_ArgumentMoverHandle ";I)Ljava/lang/Object;");
80758080
break;

runtime/compiler/il/J9SymbolReference.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ SymbolReference::getTypeSignature(int32_t & len, TR_AllocationKind allocKind, bo
272272
else
273273
{
274274
int32_t numParens = 0;
275-
while (s && (s[0] == '[') && (s[1] == 'L'))
275+
while (s && (s[0] == '[') && (s[1] == 'L' || s[1] == 'Q'))
276276
{
277277
numParens++;
278278
classOfObject = comp->fe()->getComponentClassFromArrayClass(classOfObject);
279279
s = TR::Compiler->cls.classNameChars(comp, classOfObject, len);
280-
}
280+
}
281281
s = classNameToSignature(s, len, comp);
282282
s = prependNumParensToSig(s, len, numParens);
283283
}

runtime/compiler/ilgen/Walker.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -5008,6 +5008,7 @@ TR_J9ByteCodeIlGenerator::runMacro(TR::SymbolReference * symRef)
50085008
break;
50095009
case 'L':
50105010
case '[':
5011+
case 'Q':
50115012
arrayElementDataType = TR::Address;
50125013
break;
50135014
default:

runtime/compiler/optimizer/InlinerTempForJ9.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5687,7 +5687,7 @@ TR_PrexArgInfo* TR_PrexArgInfo::buildPrexArgInfoForMethodSymbol(TR::ResolvedMeth
56875687
int32_t len = 0;
56885688
const char *sig = p->getTypeSignature(len);
56895689

5690-
if (*sig == 'L')
5690+
if (*sig == 'L' || *sig == 'Q')
56915691
{
56925692
TR_OpaqueClassBlock *clazz = (index == 0 && !methodSymbol->isStatic()) ? feMethod->containingClass() : comp->fe()->getClassFromSignature(sig, len, feMethod);
56935693
if (clazz)

runtime/compiler/optimizer/J9EstimateCodeSize.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class NeedsPeekingHeuristic
9191
int32_t len;
9292
const char *sig = p->getTypeSignature(len);
9393
if (i >= argInfo->getNumArgs() || //not enough slots in argInfo
94-
*sig != 'L' || //primitive arg
94+
(*sig != 'L' && *sig != 'Q') || //primitive arg
9595
!argInfo->get(i) || //no arg at the i-th slot
9696
!argInfo->get(i)->getClass() //no classInfo at the i-th slot
9797
)

0 commit comments

Comments
 (0)