84 this.array1 = array1; |
84 this.array1 = array1; |
85 this.array2 = array2; |
85 this.array2 = array2; |
86 this.length = length; |
86 this.length = length; |
87 } |
87 } |
88 |
88 |
89 public ValueNode getArray1() { |
|
90 return array1; |
|
91 } |
|
92 |
|
93 public ValueNode getArray2() { |
|
94 return array2; |
|
95 } |
|
96 |
|
97 public ValueNode getLength() { |
|
98 return length; |
|
99 } |
|
100 |
|
101 private static boolean isNaNFloat(JavaConstant constant) { |
89 private static boolean isNaNFloat(JavaConstant constant) { |
102 JavaKind kind = constant.getJavaKind(); |
90 JavaKind kind = constant.getJavaKind(); |
103 return (kind == JavaKind.Float && Float.isNaN(constant.asFloat())) || (kind == JavaKind.Double && Double.isNaN(constant.asDouble())); |
91 return (kind == JavaKind.Float && Float.isNaN(constant.asFloat())) || (kind == JavaKind.Double && Double.isNaN(constant.asDouble())); |
104 } |
92 } |
105 |
93 |
155 if (entry1 != entry2) { |
143 if (entry1 != entry2) { |
156 if (entry1 instanceof ConstantNode && entry2 instanceof ConstantNode) { |
144 if (entry1 instanceof ConstantNode && entry2 instanceof ConstantNode) { |
157 // Float NaN constants are different constant nodes but treated as |
145 // Float NaN constants are different constant nodes but treated as |
158 // equal in Arrays.equals([F[F) or Arrays.equals([D[D). |
146 // equal in Arrays.equals([F[F) or Arrays.equals([D[D). |
159 if (entry1.getStackKind() == JavaKind.Float && entry2.getStackKind() == JavaKind.Float) { |
147 if (entry1.getStackKind() == JavaKind.Float && entry2.getStackKind() == JavaKind.Float) { |
160 float value1 = ((JavaConstant) ((ConstantNode) entry1).asConstant()).asFloat(); |
148 float value1 = ((JavaConstant) entry1.asConstant()).asFloat(); |
161 float value2 = ((JavaConstant) ((ConstantNode) entry2).asConstant()).asFloat(); |
149 float value2 = ((JavaConstant) entry2.asConstant()).asFloat(); |
162 if (Float.floatToIntBits(value1) != Float.floatToIntBits(value2)) { |
150 if (Float.floatToIntBits(value1) != Float.floatToIntBits(value2)) { |
163 allEqual = false; |
151 allEqual = false; |
164 } |
152 } |
165 } else if (entry1.getStackKind() == JavaKind.Double && entry2.getStackKind() == JavaKind.Double) { |
153 } else if (entry1.getStackKind() == JavaKind.Double && entry2.getStackKind() == JavaKind.Double) { |
166 double value1 = ((JavaConstant) ((ConstantNode) entry1).asConstant()).asDouble(); |
154 double value1 = ((JavaConstant) entry1.asConstant()).asDouble(); |
167 double value2 = ((JavaConstant) ((ConstantNode) entry2).asConstant()).asDouble(); |
155 double value2 = ((JavaConstant) entry2.asConstant()).asDouble(); |
168 if (Double.doubleToLongBits(value1) != Double.doubleToLongBits(value2)) { |
156 if (Double.doubleToLongBits(value1) != Double.doubleToLongBits(value2)) { |
169 allEqual = false; |
157 allEqual = false; |
170 } |
158 } |
171 } else { |
159 } else { |
172 allEqual = false; |
160 allEqual = false; |
224 return equals(array1, array2, length, JavaKind.Double); |
212 return equals(array1, array2, length, JavaKind.Double); |
225 } |
213 } |
226 |
214 |
227 @Override |
215 @Override |
228 public void generate(NodeLIRBuilderTool gen) { |
216 public void generate(NodeLIRBuilderTool gen) { |
229 Value result = gen.getLIRGeneratorTool().emitArrayEquals(kind, gen.operand(array1), gen.operand(array2), gen.operand(length)); |
217 int constantLength = -1; |
|
218 if (length.isConstant()) { |
|
219 constantLength = length.asJavaConstant().asInt(); |
|
220 } |
|
221 Value result = gen.getLIRGeneratorTool().emitArrayEquals(kind, gen.operand(array1), gen.operand(array2), gen.operand(length), constantLength, false); |
230 gen.setResult(this, result); |
222 gen.setResult(this, result); |
231 } |
223 } |
232 |
224 |
233 @Override |
225 @Override |
234 public LocationIdentity getLocationIdentity() { |
226 public LocationIdentity getLocationIdentity() { |