diff --git a/common.json b/common.json index 828554281b8c..3fcd333566b8 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-2946", "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 }, 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..5606b15befdc 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 @@ -24,8 +24,8 @@ */ 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; @@ -66,7 +66,7 @@ private static final class AllocatedObject { public static String moveIntoBranchBox(int id) { Double box = object1 + 1; if (id == 0) { - obj1 = new WeakReference<>(box); + 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"; } @@ -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"; 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/aarch64/AArch64HotSpotBackendFactory.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/aarch64/AArch64HotSpotBackendFactory.java index e9fcdcae6a51..09a2a41fc659 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -147,7 +147,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 d979e5f84cde..7fe5a759960d 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 @@ -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 @@ -130,7 +130,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/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 a24e3d7fec43..fe51aa39694e 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 @@ -929,7 +929,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); @@ -939,7 +939,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 5d2e64acbb2c..2130917e0a2f 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; @@ -197,7 +198,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; @@ -1714,7 +1714,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(); } @@ -1943,12 +1943,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.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 a5022e3189f0..b61bbf68b5c4 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 5f6e5f986b3e..f8e3cb6712bc 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 @@ -470,25 +470,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);