Skip to content

Commit

Permalink
Merge pull request #6873 from hzongaro/spinechk-folding
Browse files Browse the repository at this point in the history
Branch to snippet unconditionally for array known to be discontiguous
  • Loading branch information
andrewcraik committed Aug 30, 2019
2 parents 41b062d + 856cad3 commit 9b0a027
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions runtime/compiler/x/codegen/J9TreeEvaluator.cpp
Expand Up @@ -3012,11 +3012,35 @@ TR::Register *J9::X86::TreeEvaluator::BNDCHKwithSpineCHKEvaluator(TR::Node *node
}
else
{
// Check the bounds.
//
TR::TreeEvaluator::compareIntegersForOrder(node, indexChild, arrayLengthChild, cg);
branchOpCode = JAE4;
faultingInstruction = cg->getImplicitExceptionPoint();
TR::DataType dt = loadOrStoreChild->getDataType();
int32_t elementSize = (dt == TR::Address) ? TR::Compiler->om.sizeofReferenceField()
: TR::Symbol::convertTypeToSize(dt);

if (TR::Compiler->om.isDiscontiguousArray(arrayLengthChild->getInt(), elementSize))
{
// Create real check failure snippet if we can prove the spine check
// will always fail
//
branchOpCode = JMP4;
cg->decReferenceCount(arrayLengthChild);
if (!indexChild->getOpCode().isLoadConst())
{
cg->evaluate(indexChild);
}
else
{
cg->decReferenceCount(indexChild);
}
faultingInstruction = cg->getImplicitExceptionPoint();
}
else
{
// Check the bounds.
//
TR::TreeEvaluator::compareIntegersForOrder(node, indexChild, arrayLengthChild, cg);
branchOpCode = JAE4;
faultingInstruction = cg->getImplicitExceptionPoint();
}
}
}
else
Expand Down

0 comments on commit 9b0a027

Please sign in to comment.