Skip to content

Commit

Permalink
Prevent commoning of l2a operations in localCSE
Browse files Browse the repository at this point in the history
An l2a operation might be used to convert the result of a compressed
reference sequence to an address, but it is also used in other
circumstances - for instance, if an Int64 value holds the address of a
j9class or a j9method.  The l2aEvaluators assume that l2a is used for
compressed references or accessing arraylets.  If the node is not
accessing an arraylet and compressed references are enabled, the
evaluator will mark the source register as containing a collected
reference under the assumption that it's working with a compressed
reference.  However, if the l2a is being used for a j9class, j9method,
etc., the register that holds it should not be marked as a collected
reference.

As an interim fix, this change will prevent commoning of l2a operations.
The various OMR::<CPU>::MemoryReference::populateMemoryReference
code generation methods will skip evaluation of an l2a that has a
reference count of one, so that prevents the register containing the
operand of the l2a from being marked as a collected reference.

In the longer term, OMR issue 6508 proposes introducing a new opcode -
l2gcref - that would be used to mark explicitly the result of a
conversion from long to an address as holding a collected reference.
Once implemented, the change implemented by this commit can be reverted.
  • Loading branch information
hzongaro committed Jan 6, 2024
1 parent 787725a commit 782146b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/optimizer/OMRLocalCSE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,9 @@ bool OMR::LocalCSE::canBeAvailable(TR::Node *parent, TR::Node *node, TR_BitVecto
if (node->getOpCodeValue() == TR::allocationFence)
return false;

if (node->getOpCodeValue() == TR::l2a)
return false;

if (node->getOpCode().isLoadReg() || node->getOpCode().isStoreReg() || (node->getOpCodeValue() == TR::PassThrough && parent->getOpCodeValue() != TR::GlRegDeps) || (node->getOpCodeValue() == TR::GlRegDeps))
return false;

Expand Down

0 comments on commit 782146b

Please sign in to comment.