Skip to content

Commit 155b6f3

Browse files
committed
[GR-63358] AMD64ArrayIndexOfOp: Fix short jump across unknown alignment.
PullRequest: graal/20361
2 parents 56a6556 + 15877a2 commit 155b6f3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64ArrayIndexOfOp.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
*/
2525
package jdk.graal.compiler.lir.amd64;
2626

27+
import static jdk.graal.compiler.asm.amd64.AMD64MacroAssembler.ExtendMode.ZERO_EXTEND;
2728
import static jdk.vm.ci.amd64.AMD64.r8;
2829
import static jdk.vm.ci.amd64.AMD64.rax;
2930
import static jdk.vm.ci.amd64.AMD64.rcx;
@@ -33,7 +34,6 @@
3334
import static jdk.vm.ci.code.ValueUtil.asRegister;
3435
import static jdk.vm.ci.code.ValueUtil.isRegister;
3536
import static jdk.vm.ci.code.ValueUtil.isStackSlot;
36-
import static jdk.graal.compiler.asm.amd64.AMD64MacroAssembler.ExtendMode.ZERO_EXTEND;
3737

3838
import java.util.EnumSet;
3939

@@ -56,7 +56,6 @@
5656
import jdk.graal.compiler.lir.Opcode;
5757
import jdk.graal.compiler.lir.asm.CompilationResultBuilder;
5858
import jdk.graal.compiler.lir.gen.LIRGeneratorTool;
59-
6059
import jdk.vm.ci.amd64.AMD64.CPUFeature;
6160
import jdk.vm.ci.amd64.AMD64Kind;
6261
import jdk.vm.ci.code.Register;
@@ -431,8 +430,12 @@ public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm) {
431430
asm.addq(index, bulkSize);
432431

433432
boolean bulkLoopShortJmp = !((variant == LIRGeneratorTool.ArrayIndexOfVariant.MatchRange && nValues == 4 || variant == LIRGeneratorTool.ArrayIndexOfVariant.Table) && stride.value > 1);
434-
// check if there are enough array slots remaining for the bulk loop
435-
asm.cmpqAndJcc(index, arrayLength, ConditionFlag.Greater, skipBulkVectorLoop, bulkLoopShortJmp);
433+
/*
434+
* Check if there are enough array slots remaining for the bulk loop. Note: The alignment
435+
* following the cmpAndJcc can lead to a jump distance > 127. This prevents safely using a
436+
* short jump.
437+
*/
438+
asm.cmpqAndJcc(index, arrayLength, ConditionFlag.Greater, skipBulkVectorLoop, false);
436439

437440
asm.align(preferredLoopAlignment(crb));
438441
asm.bind(bulkVectorLoop);

0 commit comments

Comments
 (0)