Skip to content

Commit ddf19d5

Browse files
authored
Merge pull request #861 from jerboaa/mandrel-23.1-community-backports-merge-2025-07-01
Merge upstream tag vm-23.1.8 into mandrel/23.1
2 parents 88507f0 + 682b9a0 commit ddf19d5

File tree

51 files changed

+629
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+629
-116
lines changed

compiler/mx.compiler/suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
"groupId" : "org.graalvm.compiler",
77
"version" : "23.1.8.0",
8-
"release" : False,
8+
"release" : True,
99
"url" : "http://www.graalvm.org/",
1010
"developer" : {
1111
"name" : "GraalVM Development",

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/hotspot/aarch64/AArch64HotSpotMove.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
3030
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.HINT;
3131
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.ILLEGAL;
3232
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
33-
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.STACK;
3433

3534
import org.graalvm.compiler.asm.Label;
3635
import org.graalvm.compiler.asm.aarch64.AArch64Assembler;
@@ -52,7 +51,7 @@ public static class LoadHotSpotObjectConstantInline extends AArch64LIRInstructio
5251
public static final LIRInstructionClass<LoadHotSpotObjectConstantInline> TYPE = LIRInstructionClass.create(LoadHotSpotObjectConstantInline.class);
5352

5453
private HotSpotConstant constant;
55-
@Def({REG, STACK}) AllocatableValue result;
54+
@Def({REG}) AllocatableValue result;
5655

5756
public LoadHotSpotObjectConstantInline(HotSpotConstant constant, AllocatableValue result) {
5857
super(TYPE);
@@ -80,6 +79,11 @@ public AllocatableValue getResult() {
8079
public Constant getConstant() {
8180
return constant;
8281
}
82+
83+
@Override
84+
public boolean canRematerializeToStack() {
85+
return false;
86+
}
8387
}
8488

8589
/**

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotMove.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,6 @@
4141
import org.graalvm.compiler.lir.StandardOp.LoadConstantOp;
4242
import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
4343
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
44-
4544
import jdk.vm.ci.code.Register;
4645
import jdk.vm.ci.hotspot.HotSpotMetaspaceConstant;
4746
import jdk.vm.ci.hotspot.HotSpotObjectConstant;
@@ -104,6 +103,16 @@ public Constant getConstant() {
104103
public AllocatableValue getResult() {
105104
return result;
106105
}
106+
107+
@Override
108+
public boolean canRematerializeToStack() {
109+
/*
110+
* This is slightly too lenient, formally we would also need to check if the target
111+
* allows inlining objects. In practice that is always true, and we do not have access
112+
* to the relevant information here.
113+
*/
114+
return input.isCompressed();
115+
}
107116
}
108117

109118
public static final class BaseMove extends AMD64LIRInstruction {
@@ -167,6 +176,11 @@ public Constant getConstant() {
167176
public AllocatableValue getResult() {
168177
return result;
169178
}
179+
180+
@Override
181+
public boolean canRematerializeToStack() {
182+
return input.isCompressed();
183+
}
170184
}
171185

172186
public static void decodeKlassPointer(AMD64MacroAssembler masm, Register register, Register scratch, AMD64Address address, GraalHotSpotVMConfig config) {

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/lir/StandardOp.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -292,6 +292,14 @@ static boolean isLoadConstantOp(LIRInstruction op) {
292292
return op.isLoadConstantOp();
293293
}
294294

295+
/**
296+
* Determine whether this constant load is safe to rematerialize directly to a stack slot.
297+
* Some constant load operations have special semantics or implementations that only allow
298+
* rematerialization to a register. Such operations must implement this method to return
299+
* {@code false}. Simple constant loads that can be implemented using a move-immediate
300+
* instruction to a stack slot, or similar, should return {@code true}.
301+
*/
302+
boolean canRematerializeToStack();
295303
}
296304

297305
/**

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/lir/aarch64/AArch64Move.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -108,6 +108,11 @@ public Constant getConstant() {
108108
public AllocatableValue getResult() {
109109
return result;
110110
}
111+
112+
@Override
113+
public boolean canRematerializeToStack() {
114+
return true;
115+
}
111116
}
112117

113118
@Opcode("MOVE")

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -925,6 +925,15 @@ protected Constant getMaterializedValue(LIRInstruction op, Value operand, Interv
925925
LoadConstantOp move = LoadConstantOp.asLoadConstantOp(op);
926926

927927
if (!allocator.neverSpillConstants()) {
928+
if (!move.canRematerializeToStack()) {
929+
/*
930+
* This allocator cannot ensure that a rematerialized value is always assigned a
931+
* register; sometimes it rematerializes directly to a stack slot. Therefore, we
932+
* must not try to rematerialize constant loads that do not support
933+
* rematerialization to the stack.
934+
*/
935+
return null;
936+
}
928937
/*
929938
* Check if the interval has any uses which would accept an stack location (priority
930939
* == ShouldHaveRegister). Rematerialization of such intervals can result in a

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/lir/amd64/AMD64ArrayIndexOfOp.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,15 @@ public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm) {
354354
case MatchAny:
355355
asm.movSZx(valueSize, ZERO_EXTEND, cmpResult, arrayAddr);
356356
for (int i = 0; i < nValues; i++) {
357-
cmpqAndJcc(crb, asm, cmpResult, searchValue[i], elementWiseFound, ConditionFlag.Equal, true);
357+
cmplAndJcc(crb, asm, cmpResult, searchValue[i], elementWiseFound, ConditionFlag.Equal, true);
358358
}
359359
break;
360360
case MatchRange:
361361
asm.movSZx(valueSize, ZERO_EXTEND, cmpResult, arrayAddr);
362362
for (int i = 0; i < nValues; i += 2) {
363363
Label noMatch = new Label();
364-
cmpqAndJcc(crb, asm, cmpResult, searchValue[i], noMatch, ConditionFlag.Below, true);
365-
cmpqAndJcc(crb, asm, cmpResult, searchValue[i + 1], elementWiseFound, ConditionFlag.BelowEqual, true);
364+
cmplAndJcc(crb, asm, cmpResult, searchValue[i], noMatch, ConditionFlag.Below, true);
365+
cmplAndJcc(crb, asm, cmpResult, searchValue[i + 1], elementWiseFound, ConditionFlag.BelowEqual, true);
366366
asm.bind(noMatch);
367367
}
368368
break;
@@ -433,8 +433,12 @@ public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm) {
433433
asm.addq(index, bulkSize);
434434

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

439443
asm.align(preferredLoopAlignment(crb));
440444
asm.bind(bulkVectorLoop);
@@ -509,11 +513,11 @@ private int getNumberOfVectorsInBulkLoop() {
509513
}
510514
}
511515

512-
private static void cmpqAndJcc(CompilationResultBuilder crb, AMD64MacroAssembler asm, Register src1, Value src2, Label branchTarget, ConditionFlag cc, boolean isShortJmp) {
516+
private static void cmplAndJcc(CompilationResultBuilder crb, AMD64MacroAssembler asm, Register src1, Value src2, Label branchTarget, ConditionFlag cc, boolean isShortJmp) {
513517
if (isStackSlot(src2)) {
514-
asm.cmpqAndJcc(src1, (AMD64Address) crb.asAddress(src2), cc, branchTarget, isShortJmp);
518+
asm.cmplAndJcc(src1, (AMD64Address) crb.asAddress(src2), cc, branchTarget, isShortJmp);
515519
} else {
516-
asm.cmpqAndJcc(src1, asRegister(src2), cc, branchTarget, isShortJmp);
520+
asm.cmplAndJcc(src1, asRegister(src2), cc, branchTarget, isShortJmp);
517521
}
518522
}
519523

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/lir/amd64/AMD64Move.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import jdk.vm.ci.meta.AllocatableValue;
7272
import jdk.vm.ci.meta.Constant;
7373
import jdk.vm.ci.meta.JavaConstant;
74+
import jdk.vm.ci.meta.JavaKind;
7475
import jdk.vm.ci.meta.Value;
7576

7677
public class AMD64Move {
@@ -171,6 +172,14 @@ public Constant getConstant() {
171172
public AllocatableValue getResult() {
172173
return result;
173174
}
175+
176+
@Override
177+
public boolean canRematerializeToStack() {
178+
if (input.getJavaKind() == JavaKind.Object) {
179+
return input.isNull();
180+
}
181+
return true;
182+
}
174183
}
175184

176185
@Opcode("STACKMOVE")

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/lir/amd64/vector/AMD64VectorMove.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -161,13 +161,18 @@ public Constant getConstant() {
161161
public AllocatableValue getResult() {
162162
return result;
163163
}
164+
165+
@Override
166+
public boolean canRematerializeToStack() {
167+
return true;
168+
}
164169
}
165170

166171
@Opcode("VMOVE")
167172
public static class MoveFromArrayConstOp extends AMD64LIRInstruction implements LoadConstantOp {
168173
public static final LIRInstructionClass<MoveFromArrayConstOp> TYPE = LIRInstructionClass.create(MoveFromArrayConstOp.class);
169174

170-
@Def({REG, STACK}) protected AllocatableValue result;
175+
@Def({REG}) protected AllocatableValue result;
171176
private final DataPointerConstant input;
172177

173178
public MoveFromArrayConstOp(AllocatableValue result, DataPointerConstant input) {
@@ -193,6 +198,11 @@ public Constant getConstant() {
193198
public AllocatableValue getResult() {
194199
return result;
195200
}
201+
202+
@Override
203+
public boolean canRematerializeToStack() {
204+
return false;
205+
}
196206
}
197207

198208
@Opcode("VSTACKMOVE")

espresso/mx.espresso/suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"mxversion": "6.44.0",
2525
"name": "espresso",
2626
"version" : "23.1.8.0",
27-
"release" : False,
27+
"release" : True,
2828
"groupId" : "org.graalvm.espresso",
2929
"url" : "https://www.graalvm.org/reference-manual/java-on-truffle/",
3030
"developer" : {

0 commit comments

Comments
 (0)