src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir.sparc/src/org/graalvm/compiler/lir/sparc/SPARCArrayEqualsOp.java
equal
deleted
inserted
replaced
34 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag.Equal; |
34 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag.Equal; |
35 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag.Less; |
35 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag.Less; |
36 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag.NotEqual; |
36 import static org.graalvm.compiler.asm.sparc.SPARCAssembler.ConditionFlag.NotEqual; |
37 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG; |
37 import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG; |
38 |
38 |
39 import java.lang.reflect.Array; |
|
40 import java.lang.reflect.Field; |
|
41 |
|
42 import org.graalvm.compiler.asm.Label; |
39 import org.graalvm.compiler.asm.Label; |
43 import org.graalvm.compiler.asm.sparc.SPARCAddress; |
40 import org.graalvm.compiler.asm.sparc.SPARCAddress; |
44 import org.graalvm.compiler.asm.sparc.SPARCMacroAssembler; |
41 import org.graalvm.compiler.asm.sparc.SPARCMacroAssembler; |
45 import org.graalvm.compiler.core.common.LIRKind; |
42 import org.graalvm.compiler.core.common.LIRKind; |
46 import org.graalvm.compiler.lir.LIRInstructionClass; |
43 import org.graalvm.compiler.lir.LIRInstructionClass; |
50 |
47 |
51 import jdk.vm.ci.code.Register; |
48 import jdk.vm.ci.code.Register; |
52 import jdk.vm.ci.meta.AllocatableValue; |
49 import jdk.vm.ci.meta.AllocatableValue; |
53 import jdk.vm.ci.meta.JavaKind; |
50 import jdk.vm.ci.meta.JavaKind; |
54 import jdk.vm.ci.sparc.SPARCKind; |
51 import jdk.vm.ci.sparc.SPARCKind; |
55 import sun.misc.Unsafe; |
|
56 |
52 |
57 /** |
53 /** |
58 * Emits code which compares two arrays of the same length. |
54 * Emits code which compares two arrays of the same length. |
59 */ |
55 */ |
60 @Opcode("ARRAY_EQUALS") |
56 @Opcode("ARRAY_EQUALS") |
80 super(TYPE, SIZE); |
76 super(TYPE, SIZE); |
81 |
77 |
82 assert !kind.isNumericFloat() : "Float arrays comparison (bitwise_equal || both_NaN) isn't supported"; |
78 assert !kind.isNumericFloat() : "Float arrays comparison (bitwise_equal || both_NaN) isn't supported"; |
83 this.kind = kind; |
79 this.kind = kind; |
84 |
80 |
85 Class<?> arrayClass = Array.newInstance(kind.toJavaClass(), 0).getClass(); |
81 this.arrayBaseOffset = tool.getProviders().getArrayOffsetProvider().arrayBaseOffset(kind); |
86 this.arrayBaseOffset = UNSAFE.arrayBaseOffset(arrayClass); |
82 this.arrayIndexScale = tool.getProviders().getArrayOffsetProvider().arrayScalingFactor(kind); |
87 this.arrayIndexScale = UNSAFE.arrayIndexScale(arrayClass); |
|
88 |
83 |
89 this.resultValue = result; |
84 this.resultValue = result; |
90 this.array1Value = array1; |
85 this.array1Value = array1; |
91 this.array2Value = array2; |
86 this.array2Value = array2; |
92 this.lengthValue = length; |
87 this.lengthValue = length; |
245 } else { |
240 } else { |
246 masm.bind(compare2Bytes); |
241 masm.bind(compare2Bytes); |
247 } |
242 } |
248 } |
243 } |
249 } |
244 } |
250 |
|
251 private static final Unsafe UNSAFE = initUnsafe(); |
|
252 |
|
253 private static Unsafe initUnsafe() { |
|
254 try { |
|
255 return Unsafe.getUnsafe(); |
|
256 } catch (SecurityException se) { |
|
257 try { |
|
258 Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); |
|
259 theUnsafe.setAccessible(true); |
|
260 return (Unsafe) theUnsafe.get(Unsafe.class); |
|
261 } catch (Exception e) { |
|
262 throw new RuntimeException("exception while trying to get Unsafe", e); |
|
263 } |
|
264 } |
|
265 } |
|
266 } |
245 } |