@Override
@SuppressWarnings("try")
public void simplify(SimplifierTool tool) {
if (hasNoUsages()) {
NodeView view = NodeView.from(tool);
Stamp lengthStamp = length().stamp(view);
if (lengthStamp instanceof IntegerStamp) {
IntegerStamp lengthIntegerStamp = (IntegerStamp) lengthStamp;
if (lengthIntegerStamp.isPositive()) {
GraphUtil.removeFixedWithUnusedInputs(this);
return;
}
}
if (graph().getGuardsStage().allowsFloatingGuards()) {
try (DebugCloseable context = this.withNodeSourcePosition()) {
LogicNode lengthNegativeCondition = CompareNode.createCompareNode(graph(), CanonicalCondition.LT, length(), ConstantNode.forInt(0, graph()), tool.getConstantReflection(), view);
FixedGuardNode guard = graph().add(new FixedGuardNode(lengthNegativeCondition, DeoptimizationReason.RuntimeConstraint, DeoptimizationAction.None, true));
graph().replaceFixedWithFixed(this, guard);
}
}
}
}
}