Skip to content

Commit

Permalink
Read Barrier for CompareAndSwapObject
Browse files Browse the repository at this point in the history
Compare-And-Swap on object reference, while primarily is a store
operation, it is also an implicit read (it reads the existing value to
be compared with a provided compare value, before the store itself),
hence needs a read barrier.

This change is an extension of eclipse-openj9#1573 with JIT support.

Signed-off-by: Filip Jeremic <fjeremic@ca.ibm.com>
  • Loading branch information
fjeremic committed May 22, 2018
1 parent 17cb8ff commit aad7323
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions runtime/compiler/trj9/z/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9747,6 +9747,20 @@ static TR::Register *VMinlineCompareAndSwap(
}
}

if (TR::Compiler->om.shouldGenerateReadBarriersForFieldLoads() && isObj)
{
TR::Register* tempReadBarrier = cg->allocateRegister();

auto guardedLoadMnemonic = usingCompressedPointers ? TR::InstOpCode::LLGFSG : TR::InstOpCode::LGG;

// Compare-And-Swap on object reference, while primarily is a store operation, it is also an implicit read (it
// reads the existing value to be compared with a provided compare value, before the store itself), hence needs
// a read barrier
generateRXYInstruction(cg, guardedLoadMnemonic, node, tempReadBarrier, generateS390MemoryReference(*casMemRef, 0, cg));

cg->stopUsingRegister(tempReadBarrier);
}

// Compare and swap
//
generateRSInstruction(cg, casOp, node, oldVReg, newVReg, casMemRef);
Expand Down

0 comments on commit aad7323

Please sign in to comment.