diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ce4ca820ea74..ecf6f91c483a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -110,7 +110,8 @@ jobs: PRIMARY: "compiler" # /espresso - env: - JDK_VERSION: "21" + JDK_VERSION: "latest" + TOOLS_JDK_VERSION: "21" GATE_TAGS: "style,fullbuild" PRIMARY: "espresso" # /substratevm diff --git a/ci/common.jsonnet b/ci/common.jsonnet index 3d396640b185..613c9f05ff2d 100644 --- a/ci/common.jsonnet +++ b/ci/common.jsonnet @@ -56,7 +56,7 @@ local common_json = import "../common.json"; [name]: jdk_base + common_json.jdks[name] + { jdk_version:: 21 } for name in ["oraclejdk21"] + variants("labsjdk-ce-21") + variants("labsjdk-ee-21") } + { - 'oraclejdk23': jdk_base + common_json.jdks["oraclejdk23"] + { jdk_version:: 23 }, + 'oraclejdk24': jdk_base + common_json.jdks["oraclejdk24"] + { jdk_version:: 24 }, } + { [name]: jdk_base + common_json.jdks[name] + { jdk_version:: parse_labsjdk_version(self), jdk_name:: "jdk-latest"} for name in ["oraclejdk-latest"] + variants("labsjdk-ce-latest") + variants("labsjdk-ee-latest") diff --git a/common.json b/common.json index ba81902ec9b4..2d1601d47b59 100644 --- a/common.json +++ b/common.json @@ -8,7 +8,7 @@ "COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet", "jdks": { - "galahad-jdk": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+23-2725", "platformspecific": true, "extrabundles": ["static-libs"]}, + "galahad-jdk": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+24-2970", "platformspecific": true, "extrabundles": ["static-libs"]}, "oraclejdk17": {"name": "jpg-jdk", "version": "17.0.7", "build_id": "jdk-17.0.7+8", "platformspecific": true, "extrabundles": ["static-libs"]}, "labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.1-b02", "platformspecific": true }, @@ -43,15 +43,15 @@ "labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true }, "graalvm-ee-21": {"name": "graalvm-java21", "version": "23.1.6", "platformspecific": true }, - "oraclejdk23": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+37", "platformspecific": true, "extrabundles": ["static-libs"]}, + "oraclejdk24": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24.0.1+9", "platformspecific": true, "extrabundles": ["static-libs"]}, - "oraclejdk-latest": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+23", "platformspecific": true, "extrabundles": ["static-libs"]}, - "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25+23-jvmci-b01", "platformspecific": true }, - "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25+23-jvmci-b01-debug", "platformspecific": true }, - "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25+23-jvmci-b01-sulong", "platformspecific": true }, - "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25+23-jvmci-b01", "platformspecific": true }, - "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25+23-jvmci-b01-debug", "platformspecific": true }, - "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25+23-jvmci-b01-sulong", "platformspecific": true } + "oraclejdk-latest": {"name": "jpg-jdk", "version": "25", "build_id": "jdk-25+24", "platformspecific": true, "extrabundles": ["static-libs"]}, + "labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-25+24-jvmci-b01", "platformspecific": true }, + "labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-25+24-jvmci-b01-debug", "platformspecific": true }, + "labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-25+24-jvmci-b01-sulong", "platformspecific": true }, + "labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-25+24-jvmci-b01", "platformspecific": true }, + "labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-25+24-jvmci-b01-debug", "platformspecific": true }, + "labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-25+24-jvmci-b01-sulong", "platformspecific": true } }, "eclipse": { diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/asm/aarch64/test/AArch64AddressingModeTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/asm/aarch64/test/AArch64AddressingModeTest.java index 39ed95433bea..36994829028f 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/asm/aarch64/test/AArch64AddressingModeTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/asm/aarch64/test/AArch64AddressingModeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,16 +29,16 @@ import java.util.EnumSet; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + import jdk.graal.compiler.asm.aarch64.AArch64Address; import jdk.graal.compiler.asm.aarch64.AArch64Assembler; import jdk.graal.compiler.asm.aarch64.AArch64MacroAssembler; import jdk.graal.compiler.core.aarch64.test.AArch64TestMacroAssembler; import jdk.graal.compiler.core.common.NumUtil; import jdk.graal.compiler.test.GraalTest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - import jdk.vm.ci.aarch64.AArch64; import jdk.vm.ci.aarch64.AArch64.CPUFeature; import jdk.vm.ci.code.Architecture; @@ -59,16 +59,11 @@ private static EnumSet computeFeatures() { return features; } - private static EnumSet computeFlags() { - EnumSet flags = EnumSet.noneOf(AArch64.Flag.class); - return flags; - } - private static TargetDescription createTarget() { final int stackFrameAlignment = 16; final int implicitNullCheckLimit = 4096; final boolean inlineObjects = true; - Architecture arch = new AArch64(computeFeatures(), computeFlags()); + Architecture arch = new AArch64(computeFeatures()); return new TargetDescription(arch, true, stackFrameAlignment, implicitNullCheckLimit, inlineObjects); } diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/ea/PartialEscapeAnalysisIterationTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/ea/PartialEscapeAnalysisIterationTest.java index c4a66a8380fb..a80e505ae5f7 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/ea/PartialEscapeAnalysisIterationTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/ea/PartialEscapeAnalysisIterationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,13 @@ */ package jdk.graal.compiler.core.test.ea; -import java.lang.ref.WeakReference; import java.util.List; +import java.util.concurrent.atomic.AtomicReference; import org.junit.Assert; import org.junit.Test; +import jdk.graal.compiler.nodes.EndNode; import jdk.graal.compiler.nodes.extended.BoxNode; import jdk.graal.compiler.nodes.extended.UnboxNode; import jdk.graal.compiler.nodes.java.StoreFieldNode; @@ -38,13 +39,9 @@ public class PartialEscapeAnalysisIterationTest extends EATestBase { - // remember boxing nodes from before PEA - private List boxNodes; - @Override protected void canonicalizeGraph() { super.canonicalizeGraph(); - boxNodes = graph.getNodes().filter(BoxNode.class).snapshot(); } private static final class AllocatedObject { @@ -59,6 +56,7 @@ private static final class AllocatedObject { } } + public static int cnt; public static volatile Object obj1; public static volatile Double object1 = (double) 123; public static volatile AllocatedObject object2 = new AllocatedObject(123); @@ -66,7 +64,9 @@ private static final class AllocatedObject { public static String moveIntoBranchBox(int id) { Double box = object1 + 1; if (id == 0) { - obj1 = new WeakReference<>(box); + // Prevent if simplification + cnt++; + obj1 = new AtomicReference<>(box); } return "value"; } @@ -74,7 +74,7 @@ public static String moveIntoBranchBox(int id) { public static String moveIntoBranch(int id) { AllocatedObject box = new AllocatedObject(object2.value + 1); if (id == 0) { - obj1 = new WeakReference<>(box); + obj1 = new AtomicReference<>(box); } return "value"; } @@ -82,7 +82,7 @@ public static String moveIntoBranch(int id) { @Test public void testJMHBlackholePattern() { /* - * The overall number of allocations in this methods does not change during PEA, but the + * The overall number of allocations in these methods does not change during PEA, but the * effects still need to be applied since they move the allocation between blocks. */ @@ -91,7 +91,7 @@ public void testJMHBlackholePattern() { Assert.assertEquals(1, graph.getNodes().filter(UnboxNode.class).count()); Assert.assertEquals(1, graph.getNodes().filter(BoxNode.class).count()); // the boxing needs to be moved into the branch - Assert.assertTrue(graph.getNodes().filter(BoxNode.class).first().next() instanceof StoreFieldNode); + Assert.assertTrue(graph.getNodes().filter(BoxNode.class).first().next() instanceof CommitAllocationNode); // test with a normal object prepareGraph("moveIntoBranch", false); @@ -104,7 +104,7 @@ public static String noLoopIterationBox(int id) { Double box = object1 + 1; for (int i = 0; i < 100; i++) { if (id == i) { - obj1 = new WeakReference<>(box); + obj1 = new AtomicReference<>(box); } } return "value"; @@ -114,7 +114,7 @@ public static String noLoopIteration(int id) { AllocatedObject box = new AllocatedObject(object2.value + 1); for (int i = 0; i < 100; i++) { if (id == i) { - obj1 = new WeakReference<>(box); + obj1 = new AtomicReference<>(box); } } return "value"; @@ -124,7 +124,7 @@ public static String noLoopIterationEmpty(int id) { AllocatedObject box = new AllocatedObject(); for (int i = 0; i < 100; i++) { if (id == i) { - obj1 = new WeakReference<>(box); + obj1 = new AtomicReference<>(box); } } return "value"; @@ -133,14 +133,14 @@ public static String noLoopIterationEmpty(int id) { @Test public void testNoLoopIteration() { /* - * PEA should not apply any effects on this method, since it cannot move the allocation into - * the branch anyway (it needs to stay outside the loop). + * After PEA, the BoxNode stays outside the loop. */ // test with a boxing object prepareGraph("noLoopIterationBox", true); + List boxNodes = graph.getNodes().filter(BoxNode.class).snapshot(); Assert.assertEquals(1, boxNodes.size()); - Assert.assertTrue(boxNodes.get(0).isAlive()); + Assert.assertTrue(boxNodes.getFirst().next() instanceof EndNode); // test with a normal object (needs one iteration to replace NewInstance with // CommitAllocation) @@ -148,8 +148,9 @@ public void testNoLoopIteration() { prepareGraph(name, false); List allocations = graph.getNodes().filter(CommitAllocationNode.class).snapshot(); new PartialEscapePhase(true, false, createCanonicalizerPhase(), null, graph.getOptions()).apply(graph, context); - Assert.assertEquals(1, allocations.size()); + Assert.assertEquals(2, allocations.size()); Assert.assertTrue(allocations.get(0).isAlive()); + Assert.assertTrue(allocations.get(1).isAlive()); } } diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/amd64/test/AMD64HotSpotFrameOmissionTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/amd64/test/AMD64HotSpotFrameOmissionTest.java index 714815d4b403..a379beb1b481 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/amd64/test/AMD64HotSpotFrameOmissionTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/amd64/test/AMD64HotSpotFrameOmissionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,16 +28,14 @@ import java.util.Arrays; -import jdk.graal.compiler.core.test.GraalCompilerTest; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import jdk.graal.compiler.asm.amd64.AMD64Assembler; - +import jdk.graal.compiler.core.test.GraalCompilerTest; import jdk.vm.ci.code.InstalledCode; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; import jdk.vm.ci.meta.JavaKind; @@ -128,7 +126,6 @@ private void testHelper(String name, CodeGenerator gen) { } private Register getArgumentRegister(int index, JavaKind kind) { - RegisterArray regs = getCodeCache().getRegisterConfig().getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, kind); - return regs.get(index); + return getCodeCache().getRegisterConfig().getCallingConventionRegisters(HotSpotCallingConventionType.JavaCall, kind).get(index); } } diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/CompilationFinalWeakReferencePartialEvaluationTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/CompilationFinalWeakReferencePartialEvaluationTest.java index 9f812f2d89c7..94e3737b8920 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/CompilationFinalWeakReferencePartialEvaluationTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/CompilationFinalWeakReferencePartialEvaluationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,19 +69,16 @@ public int getAsInt() { } private static class CompilationFinalWeakReferenceTestNode extends AbstractTestNode { - @CompilationFinal private WeakReference finalWeakRefInteger; @CompilationFinal private WeakReference finalWeakRefNull; @CompilationFinal private WeakReference finalWeakRef; CompilationFinalWeakReferenceTestNode(IntSupplier data) { - this.finalWeakRefInteger = new WeakReference<>(0); this.finalWeakRefNull = new WeakReference<>(null); this.finalWeakRef = new WeakReference<>(data); } @Override public int execute(VirtualFrame frame) { - partialEvaluationConstantAndEquals(finalWeakRefInteger.get(), Integer.valueOf(0)); partialEvaluationConstantAndEquals(finalWeakRefNull.get(), null); IntSupplier supplier = finalWeakRef.get(); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64Assembler.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64Assembler.java index f924e28dac0d..ac533dfc0893 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64Assembler.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64Assembler.java @@ -232,8 +232,10 @@ private enum OpAssertion { } protected boolean checkOperands(AMD64Op op, OperandSize size, Register resultReg, Register inputReg) { - assert resultReg == null || resultCategory.equals(resultReg.getRegisterCategory()) : "invalid result register " + resultReg + " used in " + op; - assert inputReg == null || inputCategory.equals(inputReg.getRegisterCategory()) : "invalid input register " + inputReg + " used in " + op; + GraalError.guarantee(resultReg == null || resultCategory.equals(resultReg.getRegisterCategory()), "invalid result register %s used in %s ", resultReg, op); + GraalError.guarantee(inputReg == null || inputCategory.equals(inputReg.getRegisterCategory()), "invalid input register %s used in %s ", inputReg, op); + GraalError.guarantee(resultReg == null || !inRC(CPU, resultReg) || (resultReg.encoding < 16), "APX register %s used in %s is not yet supported", resultReg, op); + GraalError.guarantee(inputReg == null || !inRC(CPU, inputReg) || (inputReg.encoding < 16), "APX register %s used in %s is not yet supported", inputReg, op); for (OperandSize s : allowedSizes) { if (size == s) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64BaseAssembler.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64BaseAssembler.java index f9506a175e3b..01b891bf5096 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64BaseAssembler.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/asm/amd64/AMD64BaseAssembler.java @@ -584,7 +584,9 @@ protected static int getRXB(Register reg, Register rm) { * There is an SIB byte: In that case, X extends SIB.index and B extends SIB.base. */ protected static int getRXB(Register reg, AMD64Address rm) { - assert !isInvalidEncoding(reg); + GraalError.guarantee(!isInvalidEncoding(reg), "invalid encoding %s", reg); + GraalError.guarantee(rm.getBase() == null || rm.getBase().encoding < 16, "APX register used in %s not yet supported", rm); + GraalError.guarantee(rm.getIndex() == null || rm.getIndex().encoding < 16, "APX register used in %s not yet supported", rm); int rxb = (reg == null ? 0 : reg.encoding & 0x08) >> 1; if (!isInvalidEncoding(rm.getIndex())) { rxb |= (rm.getIndex().encoding & 0x08) >> 2; diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/alloc/RegisterAllocationConfig.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/alloc/RegisterAllocationConfig.java index 0291f170c237..6e24bd2f67b2 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/alloc/RegisterAllocationConfig.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/core/common/alloc/RegisterAllocationConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package jdk.graal.compiler.core.common.alloc; import java.util.Arrays; +import java.util.List; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.Equivalence; @@ -33,7 +34,6 @@ import jdk.graal.compiler.debug.Assertions; import jdk.vm.ci.code.Register; import jdk.vm.ci.code.Register.RegisterCategory; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.meta.PlatformKind; @@ -44,18 +44,18 @@ public class RegisterAllocationConfig { public static final class AllocatableRegisters { - public final Register[] allocatableRegisters; + public final List allocatableRegisters; public final int minRegisterNumber; public final int maxRegisterNumber; - public AllocatableRegisters(RegisterArray allocatableRegisters, int minRegisterNumber, int maxRegisterNumber) { - this.allocatableRegisters = allocatableRegisters.toArray(); + public AllocatableRegisters(List allocatableRegisters, int minRegisterNumber, int maxRegisterNumber) { + this.allocatableRegisters = allocatableRegisters; this.minRegisterNumber = minRegisterNumber; this.maxRegisterNumber = maxRegisterNumber; assert verify(allocatableRegisters, minRegisterNumber, maxRegisterNumber); } - private static boolean verify(RegisterArray allocatableRegisters, int minRegisterNumber, int maxRegisterNumber) { + private static boolean verify(List allocatableRegisters, int minRegisterNumber, int maxRegisterNumber) { int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; for (Register reg : allocatableRegisters) { @@ -79,7 +79,7 @@ private static boolean verify(RegisterArray allocatableRegisters, int minRegiste * after the register name in the {@code spec}. In this case, {@code null} is returned instead * of throwing an exception. */ - private static Register findRegister(String spec, RegisterArray all) { + private static Register findRegister(String spec, List all) { boolean optional = false; String name = spec; if (spec.endsWith("?")) { @@ -97,7 +97,7 @@ private static Register findRegister(String spec, RegisterArray all) { throw new IllegalArgumentException("register " + name + " is not allocatable"); } - protected RegisterArray initAllocatable(RegisterArray registers) { + protected List initAllocatable(List registers) { if (allocationRestrictedTo != null) { Register[] regs = new Register[allocationRestrictedTo.length]; int i = 0; @@ -109,7 +109,7 @@ protected RegisterArray initAllocatable(RegisterArray registers) { regs[i++] = register; } } - return new RegisterArray(regs); + return List.of(regs); } return registers; @@ -118,7 +118,7 @@ protected RegisterArray initAllocatable(RegisterArray registers) { protected final RegisterConfig registerConfig; private final EconomicMap categorized = EconomicMap.create(Equivalence.DEFAULT); private final String[] allocationRestrictedTo; - private RegisterArray cachedRegisters; + private List cachedRegisters; /** * @param allocationRestrictedTo if not {@code null}, register allocation will be restricted to @@ -153,10 +153,10 @@ public AllocatableRegisters getAllocatableRegisters(PlatformKind kind) { * @return {@code null} if there are no allocatable registers for the given kind */ public RegisterCategory getRegisterCategory(PlatformKind kind) { - return getAllocatableRegisters(kind).allocatableRegisters[0].getRegisterCategory(); + return getAllocatableRegisters(kind).allocatableRegisters.get(0).getRegisterCategory(); } - private static AllocatableRegisters createAllocatableRegisters(RegisterArray registers) { + private static AllocatableRegisters createAllocatableRegisters(List registers) { if (registers.size() == 0) { return null; } @@ -177,7 +177,7 @@ private static AllocatableRegisters createAllocatableRegisters(RegisterArray reg /** * Gets the set of registers that can be used by the register allocator. */ - public RegisterArray getAllocatableRegisters() { + public List getAllocatableRegisters() { if (cachedRegisters == null) { cachedRegisters = initAllocatable(registerConfig.getAllocatableRegisters()); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotForeignCallLinkage.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotForeignCallLinkage.java index 50e374dac719..7ab569bf3561 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotForeignCallLinkage.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotForeignCallLinkage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,10 +27,10 @@ import java.util.BitSet; import java.util.List; -import jdk.graal.compiler.core.common.LibGraalSupport; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.EconomicSet; +import jdk.graal.compiler.core.common.LibGraalSupport; import jdk.graal.compiler.core.common.spi.ForeignCallDescriptor.CallSideEffect; import jdk.graal.compiler.core.common.spi.ForeignCallLinkage; import jdk.graal.compiler.core.common.spi.ForeignCallSignature; @@ -54,7 +54,6 @@ import jdk.graal.compiler.serviceprovider.GlobalAtomicLong; import jdk.internal.misc.Unsafe; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.meta.InvokeTarget; /** @@ -290,7 +289,7 @@ enum RegisterEffect { * @param killedRegisters see {@link Stub#getDestroyedCallerRegisters()} */ record CodeInfo(long start, EconomicSet killedRegisters) { - public static CodeInfo fromMemory(long memory, RegisterArray allRegisters) { + public static CodeInfo fromMemory(long memory, List allRegisters) { Unsafe unsafe = Unsafe.getUnsafe(); // @formatter:off int offset = 0; @@ -361,7 +360,7 @@ static HotSpotForeignCallLinkageImpl.CodeInfo getCodeInfo(Stub stub, Backend bac data.set(codeInfo.toMemory()); return codeInfo; } - RegisterArray allRegisters = backend.getCodeCache().getTarget().arch.getRegisters(); + List allRegisters = backend.getCodeCache().getTarget().arch.getRegisters(); return HotSpotForeignCallLinkageImpl.CodeInfo.fromMemory(codeInfoInMemory, allRegisters); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java index 528bc564f187..ee90735dff79 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/JVMCIVersionCheck.java @@ -55,8 +55,8 @@ public final class JVMCIVersionCheck { */ private static final Map> JVMCI_MIN_VERSIONS = Map.of( "25", Map.of( - "Oracle Corporation", createLabsJDKVersion("25+23", 1), - DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("25+23", 1))); + "Oracle Corporation", createLabsJDKVersion("25+24", 1), + DEFAULT_VENDOR_ENTRY, createLabsJDKVersion("25+24", 1))); private static final int NA = 0; /** * Minimum Java release supported by Graal. diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotBackendFactory.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotBackendFactory.java index 49eabf88ce41..48451bd9582c 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotBackendFactory.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotBackendFactory.java @@ -151,7 +151,7 @@ protected HotSpotLoweringProvider createLowerer(HotSpotGraalRuntimeProvider graa @Override protected Value[] createNativeABICallerSaveRegisters(@SuppressWarnings("unused") GraalHotSpotVMConfig config, RegisterConfig regConfig) { - List callerSave = new ArrayList<>(regConfig.getAllocatableRegisters().asList()); + List callerSave = new ArrayList<>(regConfig.getAllocatableRegisters()); // Removing callee-saved registers. /* General Purpose Registers. */ callerSave.remove(AArch64.r19); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java index 1710fbe5807a..b7e65a470a07 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotLIRGenerator.java @@ -343,7 +343,7 @@ public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState state, AArch64SaveRegistersOp save = null; Stub stub = getStub(); if (destroysRegisters && stub != null && stub.getLinkage().getEffect() == HotSpotForeignCallLinkage.RegisterEffect.COMPUTES_REGISTERS_KILLED) { - Register[] savedRegisters = getRegisterConfig().getAllocatableRegisters().toArray(); + Register[] savedRegisters = getRegisterConfig().getAllocatableRegisters().toArray(Register[]::new); save = emitSaveAllRegisters(savedRegisters); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotNodeLIRBuilder.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotNodeLIRBuilder.java index 28cd96c1f17f..179cb2d75bf3 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotNodeLIRBuilder.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotNodeLIRBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,7 @@ protected void emitPrologue(StructuredGraph graph) { Stub stub = result.getStub(); if (stub != null && stub.getLinkage().getEffect() == HotSpotForeignCallLinkage.RegisterEffect.KILLS_NO_REGISTERS) { assert stub.getLinkage().getDescriptor().getTransition() != HotSpotForeignCallDescriptor.Transition.SAFEPOINT : stub; - Register[] savedRegisters = getGen().getRegisterConfig().getAllocatableRegisters().toArray(); + Register[] savedRegisters = getGen().getRegisterConfig().getAllocatableRegisters().toArray(Register[]::new); AArch64SaveRegistersOp saveOp = getGen().emitSaveAllRegisters(savedRegisters); result.setSaveOnEntry(saveOp); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotRegisterAllocationConfig.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotRegisterAllocationConfig.java index 1cd49c55d461..153fefea9634 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotRegisterAllocationConfig.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotRegisterAllocationConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,10 +89,10 @@ import java.util.ArrayList; import java.util.BitSet; +import java.util.List; import jdk.graal.compiler.core.common.alloc.RegisterAllocationConfig; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterConfig; public class AArch64HotSpotRegisterAllocationConfig extends RegisterAllocationConfig { @@ -129,7 +129,7 @@ public AArch64HotSpotRegisterAllocationConfig(RegisterConfig registerConfig, Str } @Override - protected RegisterArray initAllocatable(RegisterArray registers) { + protected List initAllocatable(List registers) { BitSet regMap = new BitSet(registerConfig.getAllocatableRegisters().size()); for (Register reg : registers) { regMap.set(reg.number); @@ -145,6 +145,6 @@ protected RegisterArray initAllocatable(RegisterArray registers) { } } - return super.initAllocatable(new RegisterArray(allocatableRegisters)); + return super.initAllocatable(List.copyOf(allocatableRegisters)); } } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotBackendFactory.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotBackendFactory.java index 3a87145a9535..b605f079ab2f 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotBackendFactory.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotBackendFactory.java @@ -134,7 +134,7 @@ protected HotSpotLoweringProvider createLowerer(HotSpotGraalRuntimeProvider runt @Override protected Value[] createNativeABICallerSaveRegisters(GraalHotSpotVMConfig config, RegisterConfig regConfig) { - List callerSave = new ArrayList<>(regConfig.getAllocatableRegisters().asList()); + List callerSave = new ArrayList<>(regConfig.getAllocatableRegisters()); if (config.osName.equals("windows")) { // http://msdn.microsoft.com/en-us/library/9z1stfyw.aspx callerSave.remove(AMD64.rdi); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java index 82eb85d49705..59b9ab0ea770 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotLIRGenerator.java @@ -90,7 +90,6 @@ import jdk.vm.ci.amd64.AMD64Kind; import jdk.vm.ci.code.CallingConvention; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.RegisterValue; import jdk.vm.ci.meta.AllocatableValue; @@ -378,7 +377,7 @@ public AMD64SaveRegistersOp emitSaveAllRegisters(boolean forSafepoint) { * @param exclude */ protected Register[] getSaveableRegisters(boolean forSafepoint, AllocatableValue exclude) { - RegisterArray allocatableRegisters = getResult().getRegisterAllocationConfig().getAllocatableRegisters(); + List allocatableRegisters = getResult().getRegisterAllocationConfig().getAllocatableRegisters(); ArrayList registers = new ArrayList<>(allocatableRegisters.size()); for (Register reg : allocatableRegisters) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotRegisterAllocationConfig.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotRegisterAllocationConfig.java index 2db4b6a8a76b..4af0ff895d60 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotRegisterAllocationConfig.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/amd64/AMD64HotSpotRegisterAllocationConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,10 +64,10 @@ import java.util.ArrayList; import java.util.BitSet; +import java.util.List; import jdk.graal.compiler.core.common.alloc.RegisterAllocationConfig; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterConfig; class AMD64HotSpotRegisterAllocationConfig extends RegisterAllocationConfig { @@ -84,6 +84,7 @@ class AMD64HotSpotRegisterAllocationConfig extends RegisterAllocationConfig { // @formatter:off static final Register[] registerAllocationOrder = { r10, r11, r8, r9, r12, rcx, rbx, rdi, rdx, rsi, rax, rbp, r13, r14, /*r15,*/ /*rsp,*/ + /* r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, r29, r30, r31, // APX registers */ xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15, k1, k2, k3, k4, k5, k6, k7 @@ -98,7 +99,7 @@ class AMD64HotSpotRegisterAllocationConfig extends RegisterAllocationConfig { } @Override - protected RegisterArray initAllocatable(RegisterArray registers) { + protected List initAllocatable(List registers) { BitSet regMap = new BitSet(registerConfig.getAllocatableRegisters().size()); for (Register reg : registers) { regMap.set(reg.number); @@ -114,6 +115,6 @@ protected RegisterArray initAllocatable(RegisterArray registers) { } } - return super.initAllocatable(new RegisterArray(allocatableRegisters)); + return super.initAllocatable(List.copyOf(allocatableRegisters)); } } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/riscv64/RISCV64HotSpotBackendFactory.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/riscv64/RISCV64HotSpotBackendFactory.java index 0b62a620b916..38a4771d6097 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/riscv64/RISCV64HotSpotBackendFactory.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/riscv64/RISCV64HotSpotBackendFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -150,7 +150,7 @@ protected HotSpotLoweringProvider createLowerer(HotSpotGraalRuntimeProvider graa @Override protected Value[] createNativeABICallerSaveRegisters(@SuppressWarnings("unused") GraalHotSpotVMConfig config, RegisterConfig regConfig) { - List callerSave = new ArrayList<>(regConfig.getAllocatableRegisters().asList()); + List callerSave = new ArrayList<>(regConfig.getAllocatableRegisters()); // Removing callee-saved registers. /* General Purpose Registers. */ callerSave.remove(RISCV64.x2); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/RedundantMoveElimination.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/RedundantMoveElimination.java index 45d283890392..cf9fa3a90c09 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/RedundantMoveElimination.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/RedundantMoveElimination.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.EnumSet; +import java.util.List; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.Equivalence; @@ -50,7 +51,6 @@ import jdk.graal.compiler.lir.gen.LIRGenerationResult; import jdk.graal.compiler.lir.phases.PostAllocationOptimizationPhase; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.RegisterValue; import jdk.vm.ci.code.StackSlot; @@ -110,7 +110,7 @@ private static final class Optimization { EconomicMap, BlockData> blockData = EconomicMap.create(Equivalence.IDENTITY); - RegisterArray callerSaveRegs; + List callerSaveRegs; /** * Contains the register number for registers which can be optimized and -1 for the others. diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64CounterModeAESCryptOp.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64CounterModeAESCryptOp.java index 4798c44c53f9..cbd166217034 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64CounterModeAESCryptOp.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64CounterModeAESCryptOp.java @@ -24,6 +24,10 @@ */ package jdk.graal.compiler.lir.aarch64; +import static jdk.graal.compiler.lir.LIRInstruction.OperandFlag.REG; +import static jdk.graal.compiler.lir.aarch64.AArch64AESEncryptOp.aesecbEncrypt; +import static jdk.graal.compiler.lir.aarch64.AArch64AESEncryptOp.aesencLoadkeys; +import static jdk.graal.compiler.lir.aarch64.AArch64AESEncryptOp.asFloatRegister; import static jdk.vm.ci.aarch64.AArch64.r11; import static jdk.vm.ci.aarch64.AArch64.r12; import static jdk.vm.ci.aarch64.AArch64.r13; @@ -48,12 +52,6 @@ import static jdk.vm.ci.aarch64.AArch64.v9; import static jdk.vm.ci.aarch64.AArch64.zr; import static jdk.vm.ci.code.ValueUtil.asRegister; -import static jdk.graal.compiler.lir.LIRInstruction.OperandFlag.REG; -import static jdk.graal.compiler.lir.aarch64.AArch64AESEncryptOp.aesecbEncrypt; -import static jdk.graal.compiler.lir.aarch64.AArch64AESEncryptOp.aesencLoadkeys; -import static jdk.graal.compiler.lir.aarch64.AArch64AESEncryptOp.asFloatRegister; - -import java.util.Arrays; import jdk.graal.compiler.asm.Label; import jdk.graal.compiler.asm.aarch64.AArch64ASIMDAssembler.ASIMDInstruction; @@ -63,10 +61,9 @@ import jdk.graal.compiler.asm.aarch64.AArch64Assembler.ConditionFlag; import jdk.graal.compiler.asm.aarch64.AArch64MacroAssembler; import jdk.graal.compiler.debug.GraalError; -import jdk.graal.compiler.lir.asm.CompilationResultBuilder; import jdk.graal.compiler.lir.LIRInstructionClass; import jdk.graal.compiler.lir.SyncPort; - +import jdk.graal.compiler.lir.asm.CompilationResultBuilder; import jdk.vm.ci.aarch64.AArch64; import jdk.vm.ci.aarch64.AArch64Kind; import jdk.vm.ci.code.Register; @@ -124,7 +121,7 @@ public AArch64CounterModeAESCryptOp(AllocatableValue inValue, r12.asValue(), r13.asValue(), }; - this.simdTemps = Arrays.stream(AArch64.simdRegisters.toArray()).map(Register::asValue).toArray(Value[]::new); + this.simdTemps = AArch64.simdRegisters.stream().map(Register::asValue).toArray(Value[]::new); } @Override diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64GHASHProcessBlocksOp.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64GHASHProcessBlocksOp.java index 0617641b30d4..7442fbd27fdb 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64GHASHProcessBlocksOp.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/aarch64/AArch64GHASHProcessBlocksOp.java @@ -24,6 +24,11 @@ */ package jdk.graal.compiler.lir.aarch64; +import static jdk.graal.compiler.asm.aarch64.AArch64Address.AddressingMode.IMMEDIATE_PAIR_SIGNED_SCALED; +import static jdk.graal.compiler.asm.aarch64.AArch64Address.AddressingMode.IMMEDIATE_POST_INDEXED; +import static jdk.graal.compiler.asm.aarch64.AArch64Address.AddressingMode.IMMEDIATE_SIGNED_UNSCALED; +import static jdk.graal.compiler.lir.LIRInstruction.OperandFlag.REG; +import static jdk.graal.compiler.lir.aarch64.AArch64AESEncryptOp.asFloatRegister; import static jdk.vm.ci.aarch64.AArch64.v0; import static jdk.vm.ci.aarch64.AArch64.v1; import static jdk.vm.ci.aarch64.AArch64.v2; @@ -38,13 +43,6 @@ import static jdk.vm.ci.aarch64.AArch64.v6; import static jdk.vm.ci.aarch64.AArch64.v7; import static jdk.vm.ci.code.ValueUtil.asRegister; -import static jdk.graal.compiler.asm.aarch64.AArch64Address.AddressingMode.IMMEDIATE_PAIR_SIGNED_SCALED; -import static jdk.graal.compiler.asm.aarch64.AArch64Address.AddressingMode.IMMEDIATE_POST_INDEXED; -import static jdk.graal.compiler.asm.aarch64.AArch64Address.AddressingMode.IMMEDIATE_SIGNED_UNSCALED; -import static jdk.graal.compiler.lir.LIRInstruction.OperandFlag.REG; -import static jdk.graal.compiler.lir.aarch64.AArch64AESEncryptOp.asFloatRegister; - -import java.util.Arrays; import jdk.graal.compiler.asm.Label; import jdk.graal.compiler.asm.aarch64.AArch64ASIMDAssembler.ASIMDSize; @@ -53,11 +51,10 @@ import jdk.graal.compiler.asm.aarch64.AArch64Assembler.ConditionFlag; import jdk.graal.compiler.asm.aarch64.AArch64MacroAssembler; import jdk.graal.compiler.debug.GraalError; -import jdk.graal.compiler.lir.asm.CompilationResultBuilder; import jdk.graal.compiler.lir.LIRInstructionClass; import jdk.graal.compiler.lir.SyncPort; +import jdk.graal.compiler.lir.asm.CompilationResultBuilder; import jdk.graal.compiler.lir.gen.LIRGeneratorTool; - import jdk.vm.ci.aarch64.AArch64; import jdk.vm.ci.aarch64.AArch64Kind; import jdk.vm.ci.code.Register; @@ -101,7 +98,7 @@ public AArch64GHASHProcessBlocksOp(LIRGeneratorTool tool, this.dataValue = tool.newVariable(originalDataValue.getValueKind()); this.blocksValue = tool.newVariable(originalBlocksValue.getValueKind()); - this.temps = Arrays.stream(AArch64.simdRegisters.toArray()).map(Register::asValue).toArray(Value[]::new); + this.temps = AArch64.simdRegisters.stream().map(Register::asValue).toArray(Value[]::new); } @Override diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/SaveCalleeSaveRegisters.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/SaveCalleeSaveRegisters.java index e61fbbdf7ce7..cef0413d2262 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/SaveCalleeSaveRegisters.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/SaveCalleeSaveRegisters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package jdk.graal.compiler.lir.alloc; import java.util.ArrayList; +import java.util.List; import jdk.graal.compiler.core.common.LIRKind; import jdk.graal.compiler.core.common.cfg.BasicBlock; @@ -40,7 +41,6 @@ import jdk.graal.compiler.lir.util.RegisterMap; import jdk.vm.ci.code.Architecture; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterValue; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.meta.PlatformKind; @@ -49,7 +49,7 @@ public class SaveCalleeSaveRegisters extends PreAllocationOptimizationPhase { @Override protected void run(TargetDescription target, LIRGenerationResult lirGenRes, PreAllocationOptimizationContext context) { - RegisterArray calleeSaveRegisters = lirGenRes.getRegisterConfig().getCalleeSaveRegisters(); + List calleeSaveRegisters = lirGenRes.getRegisterConfig().getCalleeSaveRegisters(); if (calleeSaveRegisters == null || calleeSaveRegisters.size() == 0) { return; } @@ -67,7 +67,7 @@ protected void run(TargetDescription target, LIRGenerationResult lirGenRes, PreA } } - private static RegisterMap saveAtEntry(LIR lir, LIRGeneratorTool lirGen, LIRGenerationResult lirGenRes, RegisterArray calleeSaveRegisters, Architecture arch) { + private static RegisterMap saveAtEntry(LIR lir, LIRGeneratorTool lirGen, LIRGenerationResult lirGenRes, List calleeSaveRegisters, Architecture arch) { BasicBlock startBlock = lir.getControlFlowGraph().getStartBlock(); ArrayList instructions = lir.getLIRforBlock(startBlock); int insertionIndex = lirGenRes.getFirstInsertPosition(); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScan.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScan.java index b0ca3bfd9281..947efbe18aa4 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScan.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScan.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; +import java.util.List; import org.graalvm.collections.Pair; @@ -61,7 +62,6 @@ import jdk.graal.compiler.options.OptionType; import jdk.graal.compiler.options.OptionValues; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterAttributes; import jdk.vm.ci.code.RegisterValue; import jdk.vm.ci.code.TargetDescription; @@ -125,8 +125,8 @@ public static class BlockData { private final LIR ir; private final FrameMapBuilder frameMapBuilder; - private final RegisterAttributes[] registerAttributes; - private final RegisterArray registers; + private final List registerAttributes; + private final List registers; private final RegisterAllocationConfig regAllocConfig; private final MoveFactory moveFactory; @@ -328,7 +328,7 @@ public boolean apply(Interval i) { * configuration. */ public RegisterAttributes attributes(Register reg) { - return registerAttributes[reg.number]; + return registerAttributes.get(reg.number); } void assignSpillSlot(Interval interval) { @@ -906,7 +906,7 @@ public int[] sortedBlocks() { return sortedBlocks; } - public RegisterArray getRegisters() { + public List getRegisters() { return registers; } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java index 25abee4ee77c..b7fbcaf3a02b 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.BitSet; import java.util.EnumSet; +import java.util.List; import org.graalvm.collections.EconomicSet; import org.graalvm.collections.Equivalence; @@ -59,7 +60,6 @@ import jdk.graal.compiler.lir.phases.AllocationPhase; import jdk.graal.compiler.lir.util.IndexedValueMap; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.meta.AllocatableValue; @@ -811,7 +811,7 @@ protected void buildIntervals(boolean detailedAsserts) { }; // create a list with all caller-save registers (cpu, fpu, xmm) - RegisterArray callerSaveRegs = allocator.getRegisterAllocationConfig().getRegisterConfig().getCallerSaveRegisters(); + List callerSaveRegs = allocator.getRegisterAllocationConfig().getRegisterConfig().getCallerSaveRegisters(); // iterate all blocks in reverse order for (int i = allocator.blockCount() - 1; i >= 0; i--) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScanWalker.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScanWalker.java index 872e048ea3b1..95550794cedf 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScanWalker.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/alloc/lsra/LinearScanWalker.java @@ -1004,7 +1004,7 @@ void initVarsForAlloc(Interval interval) { if (allocatableRegisters == null) { throw new OutOfRegistersException("There are no allocatable registers for kind " + interval.kind().getPlatformKind() + ", consider assigning fixed registers."); } - availableRegs = allocatableRegisters.allocatableRegisters; + availableRegs = allocatableRegisters.allocatableRegisters.toArray(Register[]::new); minReg = allocatableRegisters.minRegisterNumber; maxReg = allocatableRegisters.maxRegisterNumber; } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64AESEncryptOp.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64AESEncryptOp.java index a1e21f42c86b..3d74df71f601 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64AESEncryptOp.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/amd64/AMD64AESEncryptOp.java @@ -108,7 +108,7 @@ static void loadKey(AMD64MacroAssembler masm, Register xmmDst, Register key, int } static Register asXMMRegister(int index) { - return AMD64.xmmRegistersAVX512[index]; + return AMD64.xmmRegistersAVX512.get(index); } @Override diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/dfa/LocationMarkerPhase.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/dfa/LocationMarkerPhase.java index e90e0d4717f6..3d15111a7445 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/dfa/LocationMarkerPhase.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/dfa/LocationMarkerPhase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,8 @@ import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.meta.Value; +import java.util.List; + /** * Mark all live references for a frame state. The frame state uses this information to build the * {@link ReferenceMap}s. @@ -56,7 +58,7 @@ protected void run(TargetDescription target, LIRGenerationResult lirGenRes, Fina static final class Marker extends LocationMarker { - private final RegisterAttributes[] registerAttributes; + private final List registerAttributes; private Marker(LIR lir, FrameMap frameMap) { super(lir, frameMap); @@ -104,7 +106,7 @@ protected void processState(LIRInstruction op, LIRFrameState info, RegStackValue * configuration. */ private RegisterAttributes attributes(Register reg) { - return registerAttributes[reg.number]; + return registerAttributes.get(reg.number); } } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/LIRGenerator.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/LIRGenerator.java index af3e329ca467..c14564ae8d92 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/LIRGenerator.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/LIRGenerator.java @@ -199,7 +199,7 @@ public RegisterConfig getRegisterConfig() { } public RegisterAttributes attributes(Register register) { - return getRegisterConfig().getAttributesMap()[register.number]; + return getRegisterConfig().getAttributesMap().get(register.number); } @Override @@ -796,7 +796,7 @@ public LIRInstruction createMultiBenchmarkCounter(String[] names, String[] group @Override public LIRInstruction createZapRegisters() { - Register[] zappedRegisters = getResult().getFrameMap().getRegisterConfig().getAllocatableRegisters().toArray(); + Register[] zappedRegisters = getResult().getFrameMap().getRegisterConfig().getAllocatableRegisters().toArray(Register[]::new); return createZapRegisters(zappedRegisters); } diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/MoveFactory.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/MoveFactory.java index a57641afb518..dd2b3bf80140 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/MoveFactory.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/gen/MoveFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,8 @@ */ package jdk.graal.compiler.lir.gen; +import java.util.List; + import org.graalvm.collections.EconomicMap; import org.graalvm.collections.Equivalence; @@ -34,7 +36,6 @@ import jdk.graal.compiler.lir.framemap.FrameMapBuilder; import jdk.vm.ci.code.Architecture; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.meta.AllocatableValue; import jdk.vm.ci.meta.Constant; @@ -107,7 +108,7 @@ public RegisterBackupPair getScratchRegister(PlatformKind kind) { RegisterConfig registerConfig = frameMapBuilder.getRegisterConfig(); - RegisterArray availableRegister = registerConfig.filterAllocatableRegisters(kind, registerConfig.getAllocatableRegisters()); + List availableRegister = registerConfig.filterAllocatableRegisters(kind, registerConfig.getAllocatableRegisters()); assert availableRegister != null; assert availableRegister.size() > 1 : Assertions.errorMessageContext("availableReg", availableRegister); Register scratchRegister = availableRegister.get(0); diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/util/RegisterMap.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/util/RegisterMap.java index 01564897e7f3..589bb50a1bcf 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/util/RegisterMap.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/lir/util/RegisterMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,11 +24,11 @@ */ package jdk.graal.compiler.lir.util; +import java.util.List; import java.util.function.BiConsumer; import jdk.vm.ci.code.Architecture; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; public class RegisterMap { private final Object[] values; @@ -68,7 +68,7 @@ private static int index(Register reg) { } private static boolean checkArchitecture(Architecture arch) { - RegisterArray registers = arch.getRegisters(); + List registers = arch.getRegisters(); for (int i = 0; i < registers.size(); ++i) { assert registers.get(i).number == i : registers.get(i) + ": " + registers.get(i).number + "!=" + i; } diff --git a/docs/reference-manual/embedding/embed-languages.md b/docs/reference-manual/embedding/embed-languages.md index 7a1c443edfac..e81e6c82a64b 100644 --- a/docs/reference-manual/embedding/embed-languages.md +++ b/docs/reference-manual/embedding/embed-languages.md @@ -411,19 +411,20 @@ Polyglot Truffle runtimes can be used on several host virtual machines with vary Runtime optimization of guest application code is crucial for the efficient execution of embedded guest applications. This table shows the level of optimizations the Java runtimes currently provide: -| Java Runtime | Runtime Optimization Level | -|-----------------------------------------------|---------------------------------------------------| -| Oracle GraalVM | Optimized with additional compiler passes | -| GraalVM Community Edition | Optimized | -| Oracle JDK | Optimized if enabled via experimental VM option | -| OpenJDK | Optimized if enabled via experimental VM option | -| JDK without JVMCI capability | No runtime optimizations (interpreter-only) | +| Java Runtime | Runtime Optimization Level | +|-----------------------------------------------|-----------------------------------------------------| +| Oracle GraalVM | Best (includes additional compiler optimizations) | +| GraalVM Community Edition | Optimized | +| Oracle JDK | Optimized via VM option | +| OpenJDK | Optimized via VM option and `--upgrade-module-path` | +| JDK without JVMCI capability | No runtime optimizations (interpreter-only) | ### Explanations * **Optimized:** Executed guest application code can be compiled and executed as highly efficient machine code at run time. * **Optimized with additional compiler passes:** Oracle GraalVM implements additional optimizations performed during runtime compilation. For example, it uses a more advanced inlining heuristic. This typically leads to better runtime performance and memory consumption. -* **Optimized if enabled via experimental VM option:** Optimization is not enabled by default and must be enabled using `-XX:+EnableJVMCI` virtual machine option. In addition, to support compilation, the Graal compiler must be downloaded as a JAR file and put on the `--upgrade-module-path`. In this mode, the compiler runs as a Java application and may negatively affect the execution performance of the host application. +* **Optimized via VM option:** Optimization is enabled by specifying `-XX:+EnableJVMCI` to the `java` launcher. +* **Optimized via VM option and `--upgrade-module-path`:** Optimization is enabled by specifying `-XX:+EnableJVMCI` to the `java` launcher. Additionally, the Graal compiler must be downloaded as a JAR file and specified to the `java` launcher with `--upgrade-module-path`. In this mode, the compiler runs as a Java application and may negatively affect the execution performance of the host application. * **No runtime optimizations:** With no runtime optimizations or if JVMCI is not enabled, the guest application code is executed in interpreter-only mode. * **JVMCI:** Refers to the [Java-Level JVM Compiler Interface](https://openjdk.org/jeps/243) supported by most Java runtimes. diff --git a/espresso/src/com.oracle.truffle.espresso.jvmci/src/com/oracle/truffle/espresso/jvmci/EspressoJVMCIRuntime.java b/espresso/src/com.oracle.truffle.espresso.jvmci/src/com/oracle/truffle/espresso/jvmci/EspressoJVMCIRuntime.java index 42f4397c3506..3912c65f8dc5 100644 --- a/espresso/src/com.oracle.truffle.espresso.jvmci/src/com/oracle/truffle/espresso/jvmci/EspressoJVMCIRuntime.java +++ b/espresso/src/com.oracle.truffle.espresso.jvmci/src/com/oracle/truffle/espresso/jvmci/EspressoJVMCIRuntime.java @@ -76,11 +76,11 @@ private static TargetDescription getHostTarget() { case "x86_64": EnumSet x8664v2 = EnumSet.of(AMD64.CPUFeature.CMOV, AMD64.CPUFeature.CX8, AMD64.CPUFeature.FXSR, AMD64.CPUFeature.MMX, AMD64.CPUFeature.SSE, AMD64.CPUFeature.SSE2, AMD64.CPUFeature.POPCNT, AMD64.CPUFeature.SSE3, AMD64.CPUFeature.SSE4_1, AMD64.CPUFeature.SSE4_2, AMD64.CPUFeature.SSSE3); - arch = new AMD64(x8664v2, EnumSet.of(AMD64.Flag.UseCountLeadingZerosInstruction, AMD64.Flag.UseCountTrailingZerosInstruction)); + arch = new AMD64(x8664v2); break; case "aarch64": case "arm64": - arch = new AArch64(EnumSet.of(AArch64.CPUFeature.FP), EnumSet.noneOf(AArch64.Flag.class)); + arch = new AArch64(EnumSet.of(AArch64.CPUFeature.FP)); break; default: throw JVMCIError.unimplemented(archString); diff --git a/sdk/mx.sdk/mx_sdk.py b/sdk/mx.sdk/mx_sdk.py index 3858093e64c3..30cae70f3222 100644 --- a/sdk/mx.sdk/mx_sdk.py +++ b/sdk/mx.sdk/mx_sdk.py @@ -261,6 +261,16 @@ def jlink_new_jdk(jdk, dst_jdk_dir, module_dists, ignore_dists, default_to_jvmci=default_to_jvmci) class GraalVMJDKConfig(mx.JDKConfig): + + # Oracle JDK includes the libjvmci compiler, allowing it to function as GraalVM. + # However, the Graal compiler is disabled by default and must be explicitly + # enabled using the -XX:+UseGraalJIT option. + libgraal_additional_vm_args = [ + '-XX:+UnlockExperimentalVMOptions', + '-XX:+EnableJVMCI', + '-XX:+UseGraalJIT', + '-XX:-UnlockExperimentalVMOptions' + ] """ A JDKConfig that configures the built GraalVM as a JDK config. """ @@ -270,11 +280,8 @@ def __init__(self): graalvm_home = default_jdk.home additional_vm_args = [] elif GraalVMJDKConfig.is_libgraal_jdk(default_jdk.home): - # Oracle JDK includes the libjvmci compiler, allowing it to function as GraalVM. - # However, the Graal compiler is disabled by default and must be explicitly enabled using the -XX:+UseJVMCICompiler option. graalvm_home = default_jdk.home - # GR-58388: Switch '-XX:+UseJVMCINativeLibrary' to '-XX:+UseGraalJIT' - additional_vm_args = ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:+UseJVMCINativeLibrary', '-XX:-UnlockExperimentalVMOptions'] + additional_vm_args = GraalVMJDKConfig.libgraal_additional_vm_args else: graalvm_home = mx_sdk_vm.graalvm_home(fatalIfMissing=True) additional_vm_args = [] diff --git a/sdk/mx.sdk/mx_sdk_vm.py b/sdk/mx.sdk/mx_sdk_vm.py index e1c23191f9fe..a9cfd429fda4 100644 --- a/sdk/mx.sdk/mx_sdk_vm.py +++ b/sdk/mx.sdk/mx_sdk_vm.py @@ -832,6 +832,9 @@ def _get_image_vm_options(jdk, use_upgrade_module_path, modules, synthetic_modul if default_to_jvmci or 'jdk.graal.compiler' in non_synthetic_modules: threads = get_JVMCIThreadsPerNativeLibraryRuntime(jdk) vm_options.extend(['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCIProduct']) + # -XX:+EnableJVMCI must be explicitly specified to the java launcher to add + # jdk.internal.vm.ci to the root set (JDK-8345826) + vm_options.append('-XX:+EnableJVMCI') if threads is not None and threads != 1: vm_options.append('-XX:JVMCIThreadsPerNativeLibraryRuntime=1') if default_to_jvmci == 'lib': @@ -1039,7 +1042,7 @@ def jlink_new_jdk(jdk, dst_jdk_dir, module_dists, ignore_dists, jlink_persist = [] if jdk_enables_jvmci_by_default(jdk): - # On JDK 9+, +EnableJVMCI forces jdk.internal.vm.ci to be in the root set + # +EnableJVMCI forces jdk.internal.vm.ci to be in the root set jlink += ['-J-XX:-EnableJVMCI', '-J-XX:-UseJVMCICompiler'] jlink.append('--add-modules=' + ','.join(_get_image_root_modules(root_module_names, module_names, jdk_modules.keys(), use_upgrade_module_path))) diff --git a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/AbiUtils.java b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/AbiUtils.java index cb1620ad6782..58b9a1382d98 100644 --- a/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/AbiUtils.java +++ b/substratevm/src/com.oracle.svm.core.foreign/src/com/oracle/svm/core/foreign/AbiUtils.java @@ -931,7 +931,7 @@ public AssignedLocation[] toMemoryAssignment(VMStorage[] argMoves, boolean forRe storages[i++] = switch (move.type()) { case X86_64Architecture.StorageType.PLACEHOLDER -> AssignedLocation.placeholder(); case X86_64Architecture.StorageType.INTEGER -> { - Register reg = AMD64.cpuRegisters[move.indexOrOffset()]; + Register reg = AMD64.cpuRegisters.get(move.indexOrOffset()); assert reg.name.equals(move.debugName()); assert reg.getRegisterCategory().equals(AMD64.CPU); yield AssignedLocation.forRegister(reg, JavaKind.Long); @@ -941,7 +941,7 @@ public AssignedLocation[] toMemoryAssignment(VMStorage[] argMoves, boolean forRe * Only the first four xmm registers should ever be used; in particular, * this means we never need to index in xmmRegistersAVX512 */ - Register reg = AMD64.xmmRegistersSSE[move.indexOrOffset()]; + Register reg = AMD64.xmmRegistersSSE.get(move.indexOrOffset()); assert reg.name.equals(move.debugName()); assert reg.getRegisterCategory().equals(AMD64.XMM); yield AssignedLocation.forRegister(reg, JavaKind.Double); diff --git a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64CalleeSavedRegisters.java b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64CalleeSavedRegisters.java index da79a4c35f65..d73afa4b5cb5 100644 --- a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64CalleeSavedRegisters.java +++ b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64CalleeSavedRegisters.java @@ -66,7 +66,7 @@ public static void createAndRegister() { Register frameRegister = registerConfig.getFrameRegister(); assert frameRegister.equals(AArch64.sp) : "Unexpected frame register " + frameRegister; - List calleeSavedRegisters = new ArrayList<>(registerConfig.getAllocatableRegisters().asList()); + List calleeSavedRegisters = new ArrayList<>(registerConfig.getAllocatableRegisters()); /* * Even though lr is an allocatable register, it is not possible for this register to be diff --git a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64RegisterConfig.java b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64RegisterConfig.java index 58567d68de47..5d5021edd46e 100755 --- a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64RegisterConfig.java +++ b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64RegisterConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,6 +68,7 @@ import java.util.ArrayList; import java.util.HashSet; +import java.util.List; import java.util.Set; import org.graalvm.nativeimage.Platform; @@ -87,7 +88,6 @@ import jdk.vm.ci.code.CallingConvention; import jdk.vm.ci.code.CallingConvention.Type; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterAttributes; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.TargetDescription; @@ -104,11 +104,11 @@ public class SubstrateAArch64RegisterConfig implements SubstrateRegisterConfig { private final TargetDescription target; private final int nativeParamsStackOffset; - private final RegisterArray generalParameterRegs; - private final RegisterArray fpParameterRegs; - private final RegisterArray allocatableRegs; - private final RegisterArray calleeSaveRegisters; - private final RegisterAttributes[] attributesMap; + private final List generalParameterRegs; + private final List fpParameterRegs; + private final List allocatableRegs; + private final List calleeSaveRegisters; + private final List attributesMap; private final MetaAccessProvider metaAccess; private final boolean preserveFramePointer; public static final Register fp = r29; @@ -127,12 +127,12 @@ public SubstrateAArch64RegisterConfig(ConfigKind config, MetaAccessProvider meta * On Windows, when calling a method with variadic args, all fp parameters must be passed on * the stack. Currently, this is unsupported. Adding support is tracked by GR-34188. */ - generalParameterRegs = new RegisterArray(r0, r1, r2, r3, r4, r5, r6, r7); - fpParameterRegs = new RegisterArray(v0, v1, v2, v3, v4, v5, v6, v7); + generalParameterRegs = List.of(r0, r1, r2, r3, r4, r5, r6, r7); + fpParameterRegs = List.of(v0, v1, v2, v3, v4, v5, v6, v7); nativeParamsStackOffset = 0; - ArrayList regs = new ArrayList<>(allRegisters.asList()); + ArrayList regs = new ArrayList<>(allRegisters); regs.remove(ReservedRegisters.singleton().getFrameRegister()); // sp regs.remove(zr); @@ -166,15 +166,15 @@ public SubstrateAArch64RegisterConfig(ConfigKind config, MetaAccessProvider meta if (Platform.includedIn(Platform.DARWIN.class) || Platform.includedIn(Platform.WINDOWS.class) || Platform.includedIn(Platform.ANDROID.class)) { regs.remove(r18); } - allocatableRegs = new RegisterArray(regs); + allocatableRegs = List.copyOf(regs); switch (config) { case NORMAL: - calleeSaveRegisters = new RegisterArray(); + calleeSaveRegisters = List.of(); break; case NATIVE_TO_JAVA: - calleeSaveRegisters = new RegisterArray(r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, + calleeSaveRegisters = List.of(r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, v8, v9, v10, v11, v12, v13, v14, v15); break; @@ -207,17 +207,17 @@ public Register getReturnRegister(JavaKind kind) { } @Override - public RegisterArray getAllocatableRegisters() { + public List getAllocatableRegisters() { return allocatableRegs; } @Override - public RegisterArray getCalleeSaveRegisters() { + public List getCalleeSaveRegisters() { return calleeSaveRegisters; } @Override - public RegisterArray getCallerSaveRegisters() { + public List getCallerSaveRegisters() { return getAllocatableRegisters(); } @@ -227,12 +227,12 @@ public boolean areAllAllocatableRegistersCallerSaved() { } @Override - public RegisterAttributes[] getAttributesMap() { + public List getAttributesMap() { return attributesMap; } @Override - public RegisterArray getCallingConventionRegisters(Type t, JavaKind kind) { + public List getCallingConventionRegisters(Type t, JavaKind kind) { throw VMError.intentionallyUnimplemented(); // ExcludeFromJacocoGeneratedReport } @@ -420,7 +420,7 @@ public CallingConvention getCallingConvention(Type t, JavaType returnType, JavaT } @Override - public RegisterArray filterAllocatableRegisters(PlatformKind kind, RegisterArray registers) { + public List filterAllocatableRegisters(PlatformKind kind, List registers) { ArrayList list = new ArrayList<>(); for (Register reg : registers) { if (target.arch.canStoreValue(reg.getRegisterCategory(), kind)) { @@ -428,10 +428,10 @@ public RegisterArray filterAllocatableRegisters(PlatformKind kind, RegisterArray } } - return new RegisterArray(list); + return List.copyOf(list); } - public RegisterArray getJavaGeneralParameterRegs() { + public List getJavaGeneralParameterRegs() { return generalParameterRegs; } } diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64CalleeSavedRegisters.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64CalleeSavedRegisters.java index 85b91532dee0..7a2736aa9bd4 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64CalleeSavedRegisters.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64CalleeSavedRegisters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,7 +90,7 @@ public static void createAndRegister() { SubstrateRegisterConfig registerConfig = new SubstrateAMD64RegisterConfig(SubstrateRegisterConfig.ConfigKind.NORMAL, null, target, SubstrateOptions.PreserveFramePointer.getValue()); Register frameRegister = registerConfig.getFrameRegister(); - List calleeSavedRegisters = new ArrayList<>(registerConfig.getAllocatableRegisters().asList()); + List calleeSavedRegisters = new ArrayList<>(registerConfig.getAllocatableRegisters()); List calleeSavedXMMRegisters = new ArrayList<>(); List calleeSavedMaskRegisters = new ArrayList<>(); diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64InterpreterStubs.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64InterpreterStubs.java index 7fbcfd719cc0..032c6a04794b 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64InterpreterStubs.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64InterpreterStubs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,19 @@ */ package com.oracle.svm.core.graal.amd64; +import static jdk.vm.ci.amd64.AMD64.rax; +import static jdk.vm.ci.amd64.AMD64.rsp; +import static jdk.vm.ci.amd64.AMD64.xmm0; + +import java.util.List; + +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.c.struct.RawField; +import org.graalvm.nativeimage.c.struct.RawStructure; +import org.graalvm.nativeimage.c.struct.SizeOf; +import org.graalvm.word.Pointer; +import org.graalvm.word.PointerBase; + import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.c.struct.OffsetOf; import com.oracle.svm.core.config.ConfigurationValues; @@ -32,6 +45,7 @@ import com.oracle.svm.core.graal.meta.SubstrateRegisterConfig; import com.oracle.svm.core.meta.SharedMethod; import com.oracle.svm.core.util.VMError; + import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.asm.Label; import jdk.graal.compiler.asm.amd64.AMD64Address; @@ -43,20 +57,9 @@ import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.CallingConvention; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterValue; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.meta.AllocatableValue; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.c.struct.RawField; -import org.graalvm.nativeimage.c.struct.RawStructure; -import org.graalvm.nativeimage.c.struct.SizeOf; -import org.graalvm.word.Pointer; -import org.graalvm.word.PointerBase; - -import static jdk.vm.ci.amd64.AMD64.rax; -import static jdk.vm.ci.amd64.AMD64.rsp; -import static jdk.vm.ci.amd64.AMD64.xmm0; public class AMD64InterpreterStubs { @@ -92,7 +95,7 @@ public void enter(CompilationResultBuilder crb) { /* sp points to InterpreterData struct */ masm.movq(createAddress(offsetAbiSpReg()), spCopy); - RegisterArray gps = getRegisterConfig().getJavaGeneralParameterRegs(); + List gps = getRegisterConfig().getJavaGeneralParameterRegs(); VMError.guarantee(gps.size() == 6); masm.movq(createAddress(offsetAbiGp0()), gps.get(0)); @@ -102,7 +105,7 @@ public void enter(CompilationResultBuilder crb) { masm.movq(createAddress(offsetAbiGp4()), gps.get(4)); masm.movq(createAddress(offsetAbiGp5()), gps.get(5)); - RegisterArray fps = getRegisterConfig().getFloatingPointParameterRegs(); + List fps = getRegisterConfig().getFloatingPointParameterRegs(); masm.movq(createAddress(offsetAbiFpArg0()), fps.get(0)); masm.movq(createAddress(offsetAbiFpArg1()), fps.get(1)); @@ -154,7 +157,7 @@ public InterpreterLeaveStubContext(SharedMethod method, CallingConvention callin public void enter(CompilationResultBuilder crb) { super.enter(crb); AMD64MacroAssembler masm = (AMD64MacroAssembler) crb.asm; - RegisterArray gps = getRegisterConfig().getJavaGeneralParameterRegs(); + List gps = getRegisterConfig().getJavaGeneralParameterRegs(); /* sp points to four reserved stack slots for this stub */ @@ -175,8 +178,8 @@ public void enter(CompilationResultBuilder crb) { @Override public void leave(CompilationResultBuilder crb) { AMD64MacroAssembler masm = (AMD64MacroAssembler) crb.asm; - RegisterArray gps = getRegisterConfig().getJavaGeneralParameterRegs(); - RegisterArray fps = getRegisterConfig().getFloatingPointParameterRegs(); + List gps = getRegisterConfig().getJavaGeneralParameterRegs(); + List fps = getRegisterConfig().getFloatingPointParameterRegs(); /* Save call target */ Register callTarget = AMD64.r10; diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Backend.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Backend.java index 281575486ee3..0375999edf1a 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Backend.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Backend.java @@ -44,6 +44,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; +import java.util.List; import java.util.function.BiConsumer; import org.graalvm.collections.EconomicMap; @@ -203,7 +204,6 @@ import jdk.vm.ci.code.CompilationRequest; import jdk.vm.ci.code.CompiledCode; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterAttributes; import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.RegisterValue; @@ -1721,7 +1721,7 @@ int getFramePointerSaveAreaOffset() { } private static boolean isCalleeSaved(Register register, RegisterConfig config, SharedMethod method) { - RegisterAttributes registerAttributes = config.getAttributesMap()[register.number]; + RegisterAttributes registerAttributes = config.getAttributesMap().get(register.number); return registerAttributes.isCalleeSave() || registerAttributes.isAllocatable() && method.hasCalleeSavedRegisters(); } @@ -2021,12 +2021,12 @@ static class SubstrateAMD64RegisterAllocationConfig extends RegisterAllocationCo private boolean initialized; @Override - protected RegisterArray initAllocatable(RegisterArray registers) { + protected List initAllocatable(List registers) { initialized = true; if (preserveFramePointer) { - var allocatableRegisters = new ArrayList<>(registers.asList()); + var allocatableRegisters = new ArrayList<>(registers); allocatableRegisters.remove(rbp); - return super.initAllocatable(new RegisterArray(allocatableRegisters)); + return super.initAllocatable(List.copyOf(allocatableRegisters)); } return super.initAllocatable(registers); } diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64RegisterConfig.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64RegisterConfig.java index 271d30fdf601..a8b3a0986d43 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64RegisterConfig.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64RegisterConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,6 +46,7 @@ import static jdk.vm.ci.amd64.AMD64.rdi; import static jdk.vm.ci.amd64.AMD64.rdx; import static jdk.vm.ci.amd64.AMD64.rsi; +import static jdk.vm.ci.amd64.AMD64.valueRegistersAVX512; import static jdk.vm.ci.amd64.AMD64.valueRegistersSSE; import static jdk.vm.ci.amd64.AMD64.xmm0; import static jdk.vm.ci.amd64.AMD64.xmm1; @@ -67,6 +68,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Set; import org.graalvm.nativeimage.Platform; @@ -88,7 +90,6 @@ import jdk.vm.ci.code.CallingConvention; import jdk.vm.ci.code.CallingConvention.Type; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterAttributes; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.TargetDescription; @@ -105,16 +106,16 @@ public class SubstrateAMD64RegisterConfig implements SubstrateRegisterConfig { private final TargetDescription target; private final int nativeParamsStackOffset; - private final RegisterArray javaGeneralParameterRegs; - private final RegisterArray nativeGeneralParameterRegs; - private final RegisterArray xmmParameterRegs; - private final RegisterArray allocatableRegs; - private final RegisterArray calleeSaveRegisters; - private final RegisterAttributes[] attributesMap; + private final List javaGeneralParameterRegs; + private final List nativeGeneralParameterRegs; + private final List xmmParameterRegs; + private final List allocatableRegs; + private final List calleeSaveRegisters; + private final List attributesMap; private final MetaAccessProvider metaAccess; private final boolean useBasePointer; - private static final RegisterArray MASK_REGISTERS = new RegisterArray(k1, k2, k3, k4, k5, k6, k7); + private static final List MASK_REGISTERS = List.of(k1, k2, k3, k4, k5, k6, k7); @SuppressWarnings("this-escape") public SubstrateAMD64RegisterConfig(ConfigKind config, MetaAccessProvider metaAccess, TargetDescription target, boolean useBasePointer) { @@ -130,14 +131,16 @@ public SubstrateAMD64RegisterConfig(ConfigKind config, MetaAccessProvider metaAc * and EVEX encoded instructions, and the VEX variants cannot address the extended * AVX-512 registers (XMM16-31). For now, limit ourselves to XMM0-15. */ - regs = new ArrayList<>(valueRegistersSSE.asList()); - regs.addAll(MASK_REGISTERS.asList()); + regs = new ArrayList<>(); + regs.addAll(valueRegistersAVX512); + regs.addAll(MASK_REGISTERS); } else { - regs = new ArrayList<>(valueRegistersSSE.asList()); + regs = new ArrayList<>(); + regs.addAll(valueRegistersSSE); if (SubstrateUtil.HOSTED && RuntimeCompilation.isEnabled()) { // The stub calling convention must be able to generate runtime checked code for // saving and restoring mask registers. - regs.addAll(MASK_REGISTERS.asList()); + regs.addAll(MASK_REGISTERS); } } @@ -145,10 +148,10 @@ public SubstrateAMD64RegisterConfig(ConfigKind config, MetaAccessProvider metaAc // This is the Windows 64-bit ABI for parameters. // Note that float parameters also "consume" a general register and vice versa in the // native ABI. - nativeGeneralParameterRegs = new RegisterArray(rcx, rdx, r8, r9); + nativeGeneralParameterRegs = List.of(rcx, rdx, r8, r9); - javaGeneralParameterRegs = new RegisterArray(rdx, r8, r9, rdi, rsi, rcx); - xmmParameterRegs = new RegisterArray(xmm0, xmm1, xmm2, xmm3); + javaGeneralParameterRegs = List.of(rdx, r8, r9, rdi, rsi, rcx); + xmmParameterRegs = List.of(xmm0, xmm1, xmm2, xmm3); // Windows reserves space on the stack for first 4 native parameters // even though they are passed in registers. @@ -161,12 +164,12 @@ public SubstrateAMD64RegisterConfig(ConfigKind config, MetaAccessProvider metaAc regs.remove(ReservedRegisters.singleton().getHeapBaseRegister()); regs.remove(ReservedRegisters.singleton().getThreadRegister()); regs.remove(ReservedRegisters.singleton().getCodeBaseRegister()); - allocatableRegs = new RegisterArray(regs); + allocatableRegs = List.copyOf(regs); } else { // This is the Linux 64-bit ABI for parameters. - javaGeneralParameterRegs = new RegisterArray(rdi, rsi, rdx, rcx, r8, r9); + javaGeneralParameterRegs = List.of(rdi, rsi, rdx, rcx, r8, r9); nativeGeneralParameterRegs = javaGeneralParameterRegs; - xmmParameterRegs = new RegisterArray(xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7); + xmmParameterRegs = List.of(xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7); nativeParamsStackOffset = 0; @@ -177,12 +180,12 @@ public SubstrateAMD64RegisterConfig(ConfigKind config, MetaAccessProvider metaAc regs.remove(ReservedRegisters.singleton().getHeapBaseRegister()); regs.remove(ReservedRegisters.singleton().getThreadRegister()); regs.remove(ReservedRegisters.singleton().getCodeBaseRegister()); - allocatableRegs = new RegisterArray(regs); + allocatableRegs = List.copyOf(regs); } switch (config) { case NORMAL: - calleeSaveRegisters = new RegisterArray(); + calleeSaveRegisters = List.of(); break; case NATIVE_TO_JAVA: @@ -191,10 +194,10 @@ public SubstrateAMD64RegisterConfig(ConfigKind config, MetaAccessProvider metaAc * return address. */ if (Platform.includedIn(Platform.WINDOWS.class)) { - calleeSaveRegisters = new RegisterArray(rbx, rdi, rsi, r12, r13, r14, r15, rbp, + calleeSaveRegisters = List.of(rbx, rdi, rsi, r12, r13, r14, r15, rbp, xmm6, xmm7, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15); } else { - calleeSaveRegisters = new RegisterArray(rbx, r12, r13, r14, r15, rbp); + calleeSaveRegisters = List.of(rbx, r12, r13, r14, r15, rbp); } break; @@ -227,17 +230,17 @@ public Register getReturnRegister(JavaKind kind) { } @Override - public RegisterArray getAllocatableRegisters() { + public List getAllocatableRegisters() { return allocatableRegs; } @Override - public RegisterArray getCalleeSaveRegisters() { + public List getCalleeSaveRegisters() { return calleeSaveRegisters; } @Override - public RegisterArray getCallerSaveRegisters() { + public List getCallerSaveRegisters() { return getAllocatableRegisters(); } @@ -247,12 +250,12 @@ public boolean areAllAllocatableRegistersCallerSaved() { } @Override - public RegisterAttributes[] getAttributesMap() { + public List getAttributesMap() { return attributesMap; } @Override - public RegisterArray getCallingConventionRegisters(Type t, JavaKind kind) { + public List getCallingConventionRegisters(Type t, JavaKind kind) { throw VMError.intentionallyUnimplemented(); // ExcludeFromJacocoGeneratedReport } @@ -326,7 +329,7 @@ public CallingConvention getCallingConvention(Type t, JavaType returnType, JavaT case Int: case Long: case Object: - RegisterArray registers = type.nativeABI() ? nativeGeneralParameterRegs : javaGeneralParameterRegs; + List registers = type.nativeABI() ? nativeGeneralParameterRegs : javaGeneralParameterRegs; if (currentGeneral < registers.size()) { register = registers.get(currentGeneral++); } @@ -424,7 +427,7 @@ public CallingConvention getCallingConvention(Type t, JavaType returnType, JavaT } @Override - public RegisterArray filterAllocatableRegisters(PlatformKind kind, RegisterArray registers) { + public List filterAllocatableRegisters(PlatformKind kind, List registers) { ArrayList list = new ArrayList<>(); for (Register reg : registers) { if (target.arch.canStoreValue(reg.getRegisterCategory(), kind)) { @@ -432,14 +435,14 @@ public RegisterArray filterAllocatableRegisters(PlatformKind kind, RegisterArray } } - return new RegisterArray(list); + return List.copyOf(list); } - public RegisterArray getJavaGeneralParameterRegs() { + public List getJavaGeneralParameterRegs() { return javaGeneralParameterRegs; } - public RegisterArray getFloatingPointParameterRegs() { + public List getFloatingPointParameterRegs() { return xmmParameterRegs; } } diff --git a/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/SubstrateRISCV64RegisterConfig.java b/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/SubstrateRISCV64RegisterConfig.java index 5f10e9821bc5..786eec95aca6 100644 --- a/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/SubstrateRISCV64RegisterConfig.java +++ b/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/SubstrateRISCV64RegisterConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,6 +74,7 @@ import static jdk.vm.ci.riscv64.RISCV64.x9; import java.util.ArrayList; +import java.util.List; import org.graalvm.nativeimage.Platform; @@ -88,7 +89,6 @@ import jdk.vm.ci.code.CallingConvention; import jdk.vm.ci.code.CallingConvention.Type; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterAttributes; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.TargetDescription; @@ -105,11 +105,11 @@ public class SubstrateRISCV64RegisterConfig implements SubstrateRegisterConfig { private final TargetDescription target; private final int nativeParamsStackOffset; - private final RegisterArray generalParameterRegs; - private final RegisterArray fpParameterRegs; - private final RegisterArray allocatableRegs; - private final RegisterArray calleeSaveRegisters; - private final RegisterAttributes[] attributesMap; + private final List generalParameterRegs; + private final List fpParameterRegs; + private final List allocatableRegs; + private final List calleeSaveRegisters; + private final List attributesMap; private final MetaAccessProvider metaAccess; @SuppressWarnings("this-escape") @@ -117,12 +117,12 @@ public SubstrateRISCV64RegisterConfig(ConfigKind config, MetaAccessProvider meta this.target = target; this.metaAccess = metaAccess; - generalParameterRegs = new RegisterArray(x10, x11, x12, x13, x14, x15, x16, x17); - fpParameterRegs = new RegisterArray(f10, f11, f12, f13, f14, f15, f16, f17); + generalParameterRegs = List.of(x10, x11, x12, x13, x14, x15, x16, x17); + fpParameterRegs = List.of(f10, f11, f12, f13, f14, f15, f16, f17); nativeParamsStackOffset = 0; - ArrayList regs = new ArrayList<>(allRegisters.asList()); + ArrayList regs = new ArrayList<>(allRegisters); regs.remove(x2); // sp regs.remove(x0); // zero if (preserveFramePointer) { @@ -137,15 +137,15 @@ public SubstrateRISCV64RegisterConfig(ConfigKind config, MetaAccessProvider meta regs.remove(ReservedRegisters.singleton().getCodeBaseRegister()); regs.remove(x1); // ra regs.remove(x3); // gp - allocatableRegs = new RegisterArray(regs); + allocatableRegs = List.copyOf(regs); switch (config) { case NORMAL: - calleeSaveRegisters = new RegisterArray(); + calleeSaveRegisters = List.of(); break; case NATIVE_TO_JAVA: - calleeSaveRegisters = new RegisterArray(x2, x8, x9, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, + calleeSaveRegisters = List.of(x2, x8, x9, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, f8, f9, f18, f19, f20, f21, f22, f23, f24, f25, f26, f27); break; @@ -179,17 +179,17 @@ public Register getReturnRegister(JavaKind kind) { } @Override - public RegisterArray getAllocatableRegisters() { + public List getAllocatableRegisters() { return allocatableRegs; } @Override - public RegisterArray getCalleeSaveRegisters() { + public List getCalleeSaveRegisters() { return calleeSaveRegisters; } @Override - public RegisterArray getCallerSaveRegisters() { + public List getCallerSaveRegisters() { return getAllocatableRegisters(); } @@ -199,12 +199,12 @@ public boolean areAllAllocatableRegistersCallerSaved() { } @Override - public RegisterAttributes[] getAttributesMap() { + public List getAttributesMap() { return attributesMap; } @Override - public RegisterArray getCallingConventionRegisters(Type t, JavaKind kind) { + public List getCallingConventionRegisters(Type t, JavaKind kind) { throw VMError.intentionallyUnimplemented(); // ExcludeFromJacocoGeneratedReport } @@ -295,7 +295,7 @@ public CallingConvention getCallingConvention(Type t, JavaType returnType, JavaT } @Override - public RegisterArray filterAllocatableRegisters(PlatformKind kind, RegisterArray registers) { + public List filterAllocatableRegisters(PlatformKind kind, List registers) { throw intentionallyUnimplemented(); // ExcludeFromJacocoGeneratedReport } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64CPUFeatureAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64CPUFeatureAccess.java index 859550ff4cf3..2db4b88dfc2e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64CPUFeatureAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64CPUFeatureAccess.java @@ -113,7 +113,7 @@ public void enableFeatures(Architecture runtimeArchitecture) { architecture.getFeatures().addAll(features); // update largest storable kind - AMD64Kind largestStorableKind = (new AMD64(features, EnumSet.noneOf(AMD64.Flag.class))).getLargestStorableKind(AMD64.XMM); + AMD64Kind largestStorableKind = new AMD64(features).getLargestStorableKind(AMD64.XMM); JVMCISubstitutions.updateLargestStorableKind(architecture, largestStorableKind); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java index 5cfc922accae..ed5266b961bf 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/ContainerLibrary.java @@ -60,7 +60,7 @@ @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/cgroupV2Subsystem_linux.hpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/osContainer_linux.cpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/osContainer_linux.hpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/os/linux/os_linux.cpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+24/src/hotspot/os/linux/os_linux.cpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/os_linux.hpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/linux/os_linux.inline.hpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/os/posix/include/jvm_md.h") @@ -85,7 +85,7 @@ // The following annotations are for files in `src/svm`, which are completely customized for SVM @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/logging/log.hpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+23/src/hotspot/share/memory/allocation.cpp") -@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+22/src/hotspot/share/runtime/globals.hpp") +@BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+24/src/hotspot/share/runtime/globals.hpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+21/src/hotspot/share/utilities/debug.cpp") @BasedOnJDKFile("https://github.com/openjdk/jdk/blob/jdk-25+18/src/hotspot/share/utilities/debug.hpp") public class ContainerLibrary { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/AccessControllerUtil.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/PrivilegedStack.java similarity index 100% rename from substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/AccessControllerUtil.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/PrivilegedStack.java diff --git a/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/UpcallStub.java b/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/UpcallStub.java index 8c8faf1d6cc7..92ac68ba0252 100644 --- a/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/UpcallStub.java +++ b/substratevm/src/com.oracle.svm.hosted.foreign/src/com/oracle/svm/hosted/foreign/UpcallStub.java @@ -90,7 +90,7 @@ import jdk.graal.compiler.replacements.nodes.CStringConstant; import jdk.graal.compiler.replacements.nodes.WriteRegisterNode; import jdk.vm.ci.code.BytecodeFrame; -import jdk.vm.ci.code.RegisterArray; +import jdk.vm.ci.code.Register; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.MetaAccessProvider; @@ -138,7 +138,7 @@ protected UpcallStub(JavaEntryPointInfo jep, MethodType methodType, MetaAccessPr */ final class LowLevelUpcallStub extends UpcallStub implements CustomCallingConventionMethod { private final ResolvedJavaMethod highLevelStub; - private final RegisterArray savedRegisters; + private final List savedRegisters; private final AssignedLocation[] parametersAssignment; static LowLevelUpcallStub make(JavaEntryPointInfo jep, AnalysisUniverse universe, MetaAccessProvider metaAccess) { @@ -194,8 +194,8 @@ public StructuredGraph buildGraph(DebugContext debug, AnalysisMethod method, Hos * Saving the callee-save registers is necessary because the invocation of the high-level * stub uses the Java calling convention which may interfere with those registers. */ - assert !savedRegisters.asList().contains(registers.methodHandle()); - assert !savedRegisters.asList().contains(registers.isolate()); + assert !savedRegisters.contains(registers.methodHandle()); + assert !savedRegisters.contains(registers.isolate()); ValueNode enterResult = kit.append(CEntryPointEnterNode.attachThread(isolate, false, true)); kit.startIf(IntegerEqualsNode.create(enterResult, ConstantNode.forInt(CEntryPointErrors.NO_ERROR, kit.getGraph()), NodeView.DEFAULT), diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java index 612607274003..eb77278d89f2 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeImageGenerator.java @@ -468,25 +468,19 @@ public static SubstrateTargetDescription createTarget(Platform platform) { } } } - // Graal backend does not use the second argument `flags' passed to the AMD64 - // constructor. Instead, it tests CPU feature directly. - AMD64 architecture = new AMD64(features, null); + AMD64 architecture = new AMD64(features); return new SubstrateTargetDescription(architecture, true, 16, 0, runtimeCheckedFeatures); } else if (includedIn(platform, Platform.AARCH64.class)) { EnumSet features = CPUTypeAArch64.getSelectedFeatures(); features.addAll(parseCSVtoEnum(AArch64.CPUFeature.class, NativeImageOptions.CPUFeatures.getValue().values(), AArch64.CPUFeature.values())); - // Graal backend does not use the second argument `flags' passed to the AArch64 - // constructor. Instead, it tests CPU feature directly. - AArch64 architecture = new AArch64(features, null); + AArch64 architecture = new AArch64(features); // runtime checked features are the same as static features on AArch64 for now EnumSet runtimeCheckedFeatures = architecture.getFeatures().clone(); return new SubstrateTargetDescription(architecture, true, 16, 0, runtimeCheckedFeatures); } else if (includedIn(platform, Platform.RISCV64.class)) { EnumSet features = CPUTypeRISCV64.getSelectedFeatures(); features.addAll(parseCSVtoEnum(RISCV64.CPUFeature.class, NativeImageOptions.CPUFeatures.getValue().values(), RISCV64.CPUFeature.values())); - // Graal backend does not use the second argument `flags' passed to the RISCV64 - // constructor. Instead, it tests CPU feature directly. - RISCV64 architecture = new RISCV64(features, null); + RISCV64 architecture = new RISCV64(features); // runtime checked features are the same as static features on RISCV64 for now EnumSet runtimeCheckedFeatures = architecture.getFeatures().clone(); return new SubstrateTargetDescription(architecture, true, 16, 0, runtimeCheckedFeatures); diff --git a/truffle/ci/ci.jsonnet b/truffle/ci/ci.jsonnet index de6c3c0aceac..ac7ca13a25de 100644 --- a/truffle/ci/ci.jsonnet +++ b/truffle/ci/ci.jsonnet @@ -163,7 +163,8 @@ linux_amd64 + graalVMCELatest + simple_tool_maven_project_gate, # Truffle JVM gate linux_amd64 + common.graalvmee21 + truffle_jvm_gate, - linux_amd64 + common.oraclejdk23 + truffle_jvm_gate, + # GR-65191 + # linux_amd64 + common.oraclejdk24 + truffle_jvm_gate, linux_amd64 + graalVMCELatest + truffle_jvm_gate, # Truffle Native gate linux_amd64 + common.graalvmee21 + truffle_native_gate, diff --git a/truffle/mx.truffle/mx_truffle.py b/truffle/mx.truffle/mx_truffle.py index 58d9481aee2a..0c6db8db0ba1 100644 --- a/truffle/mx.truffle/mx_truffle.py +++ b/truffle/mx.truffle/mx_truffle.py @@ -499,7 +499,7 @@ def _truffle_gate_runner(args, tasks): def gate_truffle_jvm(tasks): if mx_sdk.GraalVMJDKConfig.is_libgraal_jdk(mx.get_jdk(tag='default').home): - additional_jvm_args = ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:+UseJVMCINativeLibrary', '-XX:-UnlockExperimentalVMOptions'] + additional_jvm_args = mx_sdk.GraalVMJDKConfig.libgraal_additional_vm_args else: additional_jvm_args = [] # GR-62632: Debug VM exception translation failure diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/codegen/WebImageNoRegisterConfig.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/codegen/WebImageNoRegisterConfig.java index a64b1a66b830..04d6d76ece28 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/codegen/WebImageNoRegisterConfig.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/codegen/WebImageNoRegisterConfig.java @@ -29,13 +29,14 @@ import jdk.vm.ci.code.CallingConvention; import jdk.vm.ci.code.Register; -import jdk.vm.ci.code.RegisterArray; import jdk.vm.ci.code.RegisterAttributes; import jdk.vm.ci.code.ValueKindFactory; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.PlatformKind; +import java.util.List; + public class WebImageNoRegisterConfig implements SubstrateRegisterConfig { @Override public Register getReturnRegister(JavaKind kind) { @@ -48,32 +49,32 @@ public CallingConvention getCallingConvention(CallingConvention.Type type, JavaT } @Override - public RegisterArray getCallingConventionRegisters(CallingConvention.Type type, JavaKind kind) { + public List getCallingConventionRegisters(CallingConvention.Type type, JavaKind kind) { throw VMError.shouldNotReachHereAtRuntime(); } @Override - public RegisterArray getAllocatableRegisters() { + public List getAllocatableRegisters() { throw VMError.shouldNotReachHereAtRuntime(); } @Override - public RegisterArray filterAllocatableRegisters(PlatformKind kind, RegisterArray registers) { + public List filterAllocatableRegisters(PlatformKind kind, List registers) { throw VMError.shouldNotReachHereAtRuntime(); } @Override - public RegisterArray getCallerSaveRegisters() { + public List getCallerSaveRegisters() { throw VMError.shouldNotReachHereAtRuntime(); } @Override - public RegisterArray getCalleeSaveRegisters() { + public List getCalleeSaveRegisters() { throw VMError.shouldNotReachHereAtRuntime(); } @Override - public RegisterAttributes[] getAttributesMap() { + public List getAttributesMap() { throw VMError.shouldNotReachHereAtRuntime(); }