Skip to content

Commit

Permalink
Prepare for value objects to be created with new bytecode
Browse files Browse the repository at this point in the history
This change sets up changes to the JIT compiler that are needed to
permit value objects to be created with the new bytecode.  Previously
they could only be created with the aconst_init and withfield bytecode
instructions.  The new bytecode will be translated to the TR::New opcode
in IL, but existing optimizations that create value type instances will
continue to use the TR::newvalue opcode, so optimizations need to be
prepared for both possibilities for now.

Signed-off-by: Theresa Mammarella <[email protected]>
  • Loading branch information
hzongaro authored and theresa-m committed Jul 5, 2024
1 parent ab95037 commit c00260e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions runtime/compiler/compile/J9Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,8 @@ J9::Compilation::canAllocateInline(TR::Node* node, TR_OpaqueClassBlock* &classIn
if (clazz == NULL)
return -1;

// Arrays of primitive value type classes must have all their elements initialized with the
// default value of the component type. For now, prevent inline allocation of them.
// Arrays of null-restricted (a.k.a, primitive value type) classes must have all their elements initialized
// with the default value of the component type. For now, prevent inline allocation of them.
//
if (areValueTypesEnabled && TR::Compiler->cls.isPrimitiveValueTypeClass(reinterpret_cast<TR_OpaqueClassBlock*>(clazz)))
{
Expand Down
15 changes: 9 additions & 6 deletions runtime/compiler/env/J9ObjectModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,23 @@ class ObjectModel : public OMR::ObjectModelConnector
bool mayRequireSpineChecks();

/**
* @brief Whether or not value object is enabled
*/
* @brief Whether or not value object is enabled
*/
bool areValueTypesEnabled();

/**
* @brief Whether or not flattenable value object (aka null restricted) type is enabled
*/
* @brief Whether or not flattenable value object (aka null restricted) type is enabled
*/
bool areFlattenableValueTypesEnabled();

/**
* @brief Whether the check is enabled on monitor object being value based class type
*/
bool areValueBasedMonitorChecksEnabled();

/**
* @brief Whether the array flattening is enabled for value types
*/
* @brief Whether the array flattening is enabled for value types
*/
bool isValueTypeArrayFlatteningEnabled();

int32_t sizeofReferenceField();
Expand Down
6 changes: 6 additions & 0 deletions runtime/compiler/ilgen/Walker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6272,6 +6272,12 @@ TR_J9ByteCodeIlGenerator::genNew(TR::ILOpCodes opCode)
if (!node->getFirstChild()->getSymbolReference()->isUnresolved() && node->getFirstChild()->getSymbol()->isStatic())
{
TR_OpaqueClassBlock *clazz = (TR_OpaqueClassBlock*)node->getFirstChild()->getSymbol()->castToStaticSymbol()->getStaticAddress();

if (TR::Compiler->cls.isValueTypeClass(clazz))
{
node->setIdentityless(true);
}

int32_t len;
char *sig;
sig = TR::Compiler->cls.classSignature_DEPRECATED(comp(), clazz, len, comp()->trMemory());
Expand Down
10 changes: 9 additions & 1 deletion runtime/compiler/optimizer/EscapeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,15 @@ bool TR_EscapeAnalysis::isImmutableObject(TR::Node *node)
return false;
}

char *className = getClassName(node->getFirstChild());
TR::Node *classNode = node->getFirstChild();

TR_OpaqueClassBlock *clazz = (TR_OpaqueClassBlock *)classNode->getSymbol()->getStaticSymbol()->getStaticAddress();
if (TR::Compiler->cls.isValueTypeClass(clazz))
{
return true;
}

char *className = getClassName(classNode);

if (NULL != className &&
!strncmp("java/lang/", className, 10) &&
Expand Down

0 comments on commit c00260e

Please sign in to comment.