@Override
public void simplify(SimplifierTool tool) {
if (tool.allUsagesAvailable() && hasNoUsages()) {
NodeView view = NodeView.from(tool);
ValueNode arrayLength = ArrayLengthNode.create(array, tool.getConstantReflection());
LogicNode boundsCheck = CompareNode.createCompareNode(CanonicalCondition.BT, index, arrayLength, tool.getConstantReflection(), view);
if (boundsCheck.isTautology()) {
return;
}
if (graph().getGuardsStage().allowsGuardInsertion()) {
if (!arrayLength.isAlive()) {
arrayLength = graph().addOrUniqueWithInputs(arrayLength);
if (arrayLength instanceof FixedWithNextNode) {
FixedWithNextNode fixedArrayLength = (FixedWithNextNode) arrayLength;
graph().addBeforeFixed(this, fixedArrayLength);
}
}
boundsCheck = graph().addOrUniqueWithInputs(boundsCheck);
FixedGuardNode fixedGuard = new FixedGuardNode(boundsCheck, DeoptimizationReason.BoundsCheckException, DeoptimizationAction.InvalidateReprofile, false, getNodeSourcePosition());
graph().replaceFixedWithFixed(this, graph().add(fixedGuard));
}
}
}