Skip to content

Commit

Permalink
Merge pull request #2754 from yanluo7/condy
Browse files Browse the repository at this point in the history
JIT common and x86 support for constant dynamic
  • Loading branch information
andrewcraik authored Sep 14, 2018
2 parents 8534c83 + d574214 commit 63bd3cc
Show file tree
Hide file tree
Showing 14 changed files with 451 additions and 8 deletions.
20 changes: 20 additions & 0 deletions runtime/compiler/compile/J9SymbolReferenceTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,26 @@ J9::SymbolReferenceTable::findOrCreateStringSymbol(TR::ResolvedMethodSymbol * ow
return symRef;
}

TR::SymbolReference *
J9::SymbolReferenceTable::findOrCreateConstantDynamicSymbol(TR::ResolvedMethodSymbol * owningMethodSymbol, int32_t cpIndex, char* symbolTypeSig, int32_t symbolTypeSigLength, bool isCondyPrimitive)
{
TR_ResolvedMethod * owningMethod = owningMethodSymbol->getResolvedMethod();
void * dynamicConst = owningMethod->dynamicConstant(cpIndex);
TR::SymbolReference * symRef;
if (owningMethod->isUnresolvedConstantDynamic(cpIndex))
{
symRef = findOrCreateCPSymbol(owningMethodSymbol, cpIndex, TR::Address, false, 0);
symRef->setOffset((uintptrj_t)dynamicConst);
}
else
{
symRef = findOrCreateCPSymbol(owningMethodSymbol, cpIndex, TR::Address, true, dynamicConst);
}
TR::StaticSymbol * sym = (TR::StaticSymbol *)symRef->getSymbol();
sym->setConstantDynamic();
sym->makeConstantDynamic(symbolTypeSig, symbolTypeSigLength, isCondyPrimitive);
return symRef;
}

TR::SymbolReference *
J9::SymbolReferenceTable::findOrCreateMethodMonitorEntrySymbolRef(TR::ResolvedMethodSymbol *)
Expand Down
22 changes: 22 additions & 0 deletions runtime/compiler/compile/J9SymbolReferenceTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,28 @@ class SymbolReferenceTable : public OMR::SymbolReferenceTableConnector
TR::SymbolReference * findOrCreatePerCodeCacheHelperSymbolRef(TR_CCPreLoadedCode helper, uintptrj_t helperAddr);
TR::SymbolReference * findOrCreateANewArraySymbolRef(TR::ResolvedMethodSymbol * owningMethodSymbol);
TR::SymbolReference * findOrCreateStringSymbol(TR::ResolvedMethodSymbol * owningMethodSymbol, int32_t cpIndex);
/** \brief
* Finds or creates a constant dynamic static symbol reference.
*
* \param owningMethodSymbol
* The owning resolved method symbol.
*
* \param cpIndex
* The constant pool index of the constant dynamic.
*
* \param symbolTypeSig
* The underlying class type signature string of the constant dynamic. For primitive this is the signature of the corresponding autobox class.
*
* \param symbolTypeSigLength
* Length of the underlying class type signature string.
*
* \param isCondyPrimitive
* Determines whether the constant dynamic is of primitive type.
*
* \return
* The static symbol reference of the constant dynamic.
*/
TR::SymbolReference * findOrCreateConstantDynamicSymbol(TR::ResolvedMethodSymbol * owningMethodSymbol, int32_t cpIndex, char* symbolTypeSig, int32_t symbolTypeSigLength, bool isCondyPrimitive);
TR::SymbolReference * findContiguousArraySizeSymbolRef() { return element(contiguousArraySizeSymbol); }
TR::SymbolReference * findOrCreateMethodMonitorEntrySymbolRef(TR::ResolvedMethodSymbol * owningMethodSymbol);
TR::SymbolReference * findOrCreateMethodMonitorExitSymbolRef(TR::ResolvedMethodSymbol * owningMethodSymbol);
Expand Down
49 changes: 49 additions & 0 deletions runtime/compiler/env/j9method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@ cpType2trType(UDATA cpType)
case J9CPTYPE_ANNOTATION_UTF8:
case J9CPTYPE_METHOD_TYPE:
case J9CPTYPE_METHODHANDLE:
case J9CPTYPE_CONSTANT_DYNAMIC:
return TR::Address;
case J9CPTYPE_INT:
return TR::Int32;
Expand Down Expand Up @@ -5839,6 +5840,54 @@ TR_ResolvedJ9Method::longConstant(I_32 cpIndex)
return *((uint64_t *) & romLiterals()[cpIndex]);
}

void *
TR_ResolvedJ9Method::getConstantDynamicTypeFromCP(I_32 cpIndex)
{
return jitGetConstantDynamicTypeFromCP(fej9()->vmThread(), cp(), cpIndex);
}

bool
TR_ResolvedJ9Method::isConstantDynamic(I_32 cpIndex)
{
TR_ASSERT_FATAL(cpIndex != -1, "ConstantDynamic cpIndex shouldn't be -1");
UDATA cpType = J9_CP_TYPE(J9ROMCLASS_CPSHAPEDESCRIPTION(cp()->ramClass->romClass), cpIndex);
return (J9CPTYPE_CONSTANT_DYNAMIC == cpType);
}

// Both value and exception slots are of object pointer type.
// If first slot is non null, the CP entry is resolved to a non-null value.
// Else if second slot is the class object of j/l/Void, the CP entry is resolved to null (0) value.
// We retrieve the Void class object via javaVM->voidReflectClass->classObject,
// which is protected by VMAccessCrtitical section to ensure vm access.
// Other casese, the CP entry is considered unresolved.
bool
TR_ResolvedJ9Method::isUnresolvedConstantDynamic(I_32 cpIndex)
{
TR_ASSERT(cpIndex != -1, "ConstantDynamic cpIndex shouldn't be -1");
if (((J9RAMConstantDynamicRef *) literals())[cpIndex].value != 0)
{
return false;
}
if (((J9RAMConstantDynamicRef *) literals())[cpIndex].exception == 0)
{
return true;
}

TR::VMAccessCriticalSection voidClassObjectCritSec(fej9());
J9JavaVM * javaVM = fej9()->_jitConfig->javaVM;
j9object_t voidClassObject = javaVM->voidReflectClass->classObject;
j9object_t slot2 = ((J9RAMConstantDynamicRef *) literals())[cpIndex].exception;

return (voidClassObject != slot2);
}

void *
TR_ResolvedJ9Method::dynamicConstant(I_32 cpIndex)
{
TR_ASSERT_FATAL(cpIndex != -1, "ConstantDynamic cpIndex shouldn't be -1");
return &((J9RAMConstantDynamicRef *) literals())[cpIndex].value;
}

bool
TR_ResolvedJ9Method::isUnresolvedString(I_32 cpIndex, bool optimizeForAOT)
{
Expand Down
40 changes: 40 additions & 0 deletions runtime/compiler/env/j9method.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,46 @@ class TR_ResolvedJ9Method : public TR_J9Method, public TR_ResolvedJ9MethodBase
virtual double * doubleConstant(int32_t cpIndex, TR_Memory *);
virtual void * stringConstant(int32_t cpIndex);
virtual bool isUnresolvedString(int32_t cpIndex, bool optimizeForAOT = false);
/** \brief
* Retrieves the underlying type infomation for a given constant dynamic.
*
* \param cpIndex
* The constant pool index of the constant dynamic.
*
* \return
* Opaque pointer to the UTF8 type string.
*/
virtual void * getConstantDynamicTypeFromCP(int32_t cpIndex);
/** \brief
* Determines whether the given constant pool entry is constant dynamic.
*
* \param cpIndex
* The constant pool index of the constant dynamic.
*
* \return
* <c>true</c> if the given constant pool entry type is constant dynamic; <c>false</c> otherwise.
*/
virtual bool isConstantDynamic(int32_t cpIndex);
/** \brief
* Determines whether the given constant dynamic is unresolved.
*
* \param cpIndex
* The constant pool index of the constant dynamic.
*
* \return
* <c>true</c> if the constant dynamic is unresolved; <c>false</c> otherwise.
*/
virtual bool isUnresolvedConstantDynamic(int32_t cpIndex);
/** \brief
* Retrieve the adress of the slot containing the constant dynamic.
*
* \param cpIndex
* The constant pool index of the constant dynamic.
*
* \return
* Opauqe pointer to the slot containing the resolved constant dynamic value.
*/
virtual void * dynamicConstant(int32_t cpIndex);
virtual void * methodTypeConstant(int32_t cpIndex);
virtual bool isUnresolvedMethodType(int32_t cpIndex);
virtual void * methodHandleConstant(int32_t cpIndex);
Expand Down
8 changes: 8 additions & 0 deletions runtime/compiler/il/J9SymbolReference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,14 @@ SymbolReference::getTypeSignature(int32_t & len, TR_AllocationKind allocKind, bo
len = 23;
return "Ljava/lang/invoke/MethodHandle;";
}
if (_symbol->isConstantDynamic())
{
TR::StaticSymbol * symbol = _symbol->castToStaticSymbol();
int32_t condySigLength;
char *returnType = symbol->getConstantDynamicClassSignature(condySigLength);
len = condySigLength;
return returnType;
}
if (_symbol->isConst())
{
len = 1;
Expand Down
47 changes: 46 additions & 1 deletion runtime/compiler/il/symbol/J9StaticSymbol.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corp. and others
* Copyright (c) 2000, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -70,6 +70,51 @@ class OMR_EXTENSIBLE StaticSymbol : public OMR::StaticSymbolConnector

int32_t _callSiteIndex;

/* ------- TR_ConstantDynamicSymbol --------- */
public:

/** \brief
* Populate the class signature fields and primitive flag of this constant dynamic symbol.
*
* \param classSignature
* The class signature string of the constant dynamic. For primitive this is the signature of the corresponding autobox class.
*
* \param classSignatureLength
* The length of the class signature string of the constant dynamic.
*
* \param isPrimitive
* Determines whether the constant dynamic is primitive type.
*
* \return
* Fields of this static symbol are populated.
*/
void makeConstantDynamic(char * classSignature, int32_t classSignatureLength, bool isPrimitive);

/** \brief
* Retrieves the class signature string for this constant dynamic static symbol.
*
* \param classSignatureLength
* The length of the class signature string of the constant dynamic. Modified in place.
*
* \return
* The class signature string for this constant dynamic static symbol.
*/
char * getConstantDynamicClassSignature(int32_t & classSignatureLength);

/** \brief
* Retrieves whether the underlying constant dynamic is of primitive type.
*
* \return
* <c>true</c> if the underlying constant dynamic is primitive; <c>false</c> otherwise.
*/
bool isConstantDynamicPrimitive();

private:

char * _classSignature;
int32_t _classSignatureLength;
bool _isPrimitive;

/* ------ TR_RecognizedStaticSymbol ---------- */
public:

Expand Down
24 changes: 23 additions & 1 deletion runtime/compiler/il/symbol/J9StaticSymbol_inlines.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2017 IBM Corp. and others
* Copyright (c) 2017, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -61,6 +61,28 @@ J9::StaticSymbol::getCallSiteIndex()
return _callSiteIndex;
}

inline void
J9::StaticSymbol::makeConstantDynamic(char * classSignature, int32_t classSignatureLength, bool isPrimitive)
{
TR_ASSERT(self()->getDataType() == TR::Address, "ConstantDynamic should have TR::Address as data type");
_classSignature = classSignature;
_classSignatureLength = classSignatureLength;
_isPrimitive = isPrimitive;
}

inline char *
J9::StaticSymbol::getConstantDynamicClassSignature(int32_t & classSignatureLength)
{
classSignatureLength = _classSignatureLength;
return _classSignature;
}

inline bool
J9::StaticSymbol::isConstantDynamicPrimitive()
{
return _isPrimitive;
}

inline TR::Symbol::RecognizedField
J9::StaticSymbol::getRecognizedField()
{
Expand Down
10 changes: 9 additions & 1 deletion runtime/compiler/il/symbol/J9Symbol.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corp. and others
* Copyright (c) 2000, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -155,6 +155,14 @@ J9::Symbol::searchRecognizedField(TR::Compilation * comp, TR_ResolvedMethod * ow
{r(TR::Symbol::Java_math_BigInteger_useLongRepresentation, "java/math/BigInteger", "useLongRepresentation", "Z")},
{r(TR::Symbol::Java_lang_ref_SoftReference_age, "java/lang/ref/SoftReference", "age", "I")},
{r(TR::Symbol::Java_lang_invoke_VarHandle_handleTable, "java/lang/invoke/VarHandle", "handleTable", "[Ljava/lang/invoke/MethodHandle;")},
{r(TR::Symbol::Java_lang_Integer_value, "java/lang/Integer", "value", "I")},
{r(TR::Symbol::Java_lang_Long_value, "java/lang/Long", "value", "J")},
{r(TR::Symbol::Java_lang_Float_value, "java/lang/Float", "value", "F")},
{r(TR::Symbol::Java_lang_Double_value, "java/lang/Double", "value", "D")},
{r(TR::Symbol::Java_lang_Byte_value, "java/lang/Byte", "value", "B")},
{r(TR::Symbol::Java_lang_Character_value, "java/lang/Character", "value", "C")},
{r(TR::Symbol::Java_lang_Short_value, "java/lang/Short", "value", "S")},
{r(TR::Symbol::Java_lang_Boolean_value, "java/lang/Boolean", "value", "Z")},
{TR::Symbol::UnknownField}
};

Expand Down
10 changes: 9 additions & 1 deletion runtime/compiler/il/symbol/J9Symbol.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corp. and others
* Copyright (c) 2000, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -158,6 +158,14 @@ class OMR_EXTENSIBLE Symbol : public OMR::SymbolConnector
Java_math_BigInteger_ZERO,
Java_math_BigInteger_useLongRepresentation,
Java_lang_invoke_VarHandle_handleTable,
Java_lang_Integer_value,
Java_lang_Long_value,
Java_lang_Float_value,
Java_lang_Double_value,
Java_lang_Byte_value,
Java_lang_Character_value,
Java_lang_Short_value,
Java_lang_Boolean_value,
assertionsDisabled,
NumRecognizedFields
};
Expand Down
Loading

0 comments on commit 63bd3cc

Please sign in to comment.