src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.aarch64/src/org/graalvm/compiler/lir/aarch64/AArch64ArrayEqualsOp.java
equal
deleted
inserted
replaced
23 package org.graalvm.compiler.lir.aarch64; |
23 package org.graalvm.compiler.lir.aarch64; |
24 |
24 |
25 import static jdk.vm.ci.aarch64.AArch64.zr; |
25 import static jdk.vm.ci.aarch64.AArch64.zr; |
26 import static jdk.vm.ci.code.ValueUtil.asRegister; |
26 import static jdk.vm.ci.code.ValueUtil.asRegister; |
27 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG; |
27 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG; |
28 |
|
29 import java.lang.reflect.Array; |
|
30 import java.lang.reflect.Field; |
|
31 |
28 |
32 import org.graalvm.compiler.asm.Label; |
29 import org.graalvm.compiler.asm.Label; |
33 import org.graalvm.compiler.asm.aarch64.AArch64Address; |
30 import org.graalvm.compiler.asm.aarch64.AArch64Address; |
34 import org.graalvm.compiler.asm.aarch64.AArch64Assembler.ConditionFlag; |
31 import org.graalvm.compiler.asm.aarch64.AArch64Assembler.ConditionFlag; |
35 import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler; |
32 import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler; |
41 import org.graalvm.compiler.lir.gen.LIRGeneratorTool; |
38 import org.graalvm.compiler.lir.gen.LIRGeneratorTool; |
42 |
39 |
43 import jdk.vm.ci.code.Register; |
40 import jdk.vm.ci.code.Register; |
44 import jdk.vm.ci.meta.JavaKind; |
41 import jdk.vm.ci.meta.JavaKind; |
45 import jdk.vm.ci.meta.Value; |
42 import jdk.vm.ci.meta.Value; |
46 import sun.misc.Unsafe; |
|
47 |
43 |
48 /** |
44 /** |
49 * Emits code which compares two arrays of the same length. If the CPU supports any vector |
45 * Emits code which compares two arrays of the same length. If the CPU supports any vector |
50 * instructions specialized code is emitted to leverage these instructions. |
46 * instructions specialized code is emitted to leverage these instructions. |
51 */ |
47 */ |
70 super(TYPE); |
66 super(TYPE); |
71 |
67 |
72 assert !kind.isNumericFloat() : "Float arrays comparison (bitwise_equal || both_NaN) isn't supported"; |
68 assert !kind.isNumericFloat() : "Float arrays comparison (bitwise_equal || both_NaN) isn't supported"; |
73 this.kind = kind; |
69 this.kind = kind; |
74 |
70 |
75 Class<?> arrayClass = Array.newInstance(kind.toJavaClass(), 0).getClass(); |
71 this.arrayBaseOffset = tool.getProviders().getArrayOffsetProvider().arrayBaseOffset(kind); |
76 this.arrayBaseOffset = UNSAFE.arrayBaseOffset(arrayClass); |
72 this.arrayIndexScale = tool.getProviders().getArrayOffsetProvider().arrayScalingFactor(kind); |
77 this.arrayIndexScale = UNSAFE.arrayIndexScale(arrayClass); |
|
78 |
73 |
79 this.resultValue = result; |
74 this.resultValue = result; |
80 this.array1Value = array1; |
75 this.array1Value = array1; |
81 this.array2Value = array2; |
76 this.array2Value = array2; |
82 this.lengthValue = length; |
77 this.lengthValue = length; |
216 } |
211 } |
217 } |
212 } |
218 masm.bind(end); |
213 masm.bind(end); |
219 masm.mov(64, rscratch1, zr); |
214 masm.mov(64, rscratch1, zr); |
220 } |
215 } |
221 |
|
222 private static final Unsafe UNSAFE = initUnsafe(); |
|
223 |
|
224 private static Unsafe initUnsafe() { |
|
225 try { |
|
226 return Unsafe.getUnsafe(); |
|
227 } catch (SecurityException se) { |
|
228 try { |
|
229 Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); |
|
230 theUnsafe.setAccessible(true); |
|
231 return (Unsafe) theUnsafe.get(Unsafe.class); |
|
232 } catch (Exception e) { |
|
233 throw new RuntimeException("exception while trying to get Unsafe", e); |
|
234 } |
|
235 } |
|
236 } |
|
237 } |
216 } |