@Override public ValueNode canonical(CanonicalizerTool tool, ValueNode forValue) { ValueNode length = readArrayLength(forValue, tool.getConstantReflection()); if (length != null) { return length; } return this; }
public static ValueNode create(ValueNode forValue, ConstantReflectionProvider constantReflection) { if (forValue instanceof NewArrayNode) { NewArrayNode newArray = (NewArrayNode) forValue; return newArray.length(); } ValueNode length = readArrayLength(forValue, constantReflection); if (length != null) { return length; } return new ArrayLengthNode(forValue); }
private ValueNode readOrCreateArrayLength(AccessIndexedNode n, ValueNode array, LoweringTool tool, StructuredGraph graph) { ValueNode arrayLength = readArrayLength(array, tool.getConstantReflection()); if (arrayLength == null) { arrayLength = createReadArrayLength(array, n, tool); } else { arrayLength = arrayLength.isAlive() ? arrayLength : graph.addOrUniqueWithInputs(arrayLength); } return arrayLength; }