diff --git a/src/java.base/share/classes/jdk/internal/foreign/CABI.java b/src/java.base/share/classes/jdk/internal/foreign/CABI.java index 5a3470cd565..d05ca535a49 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/CABI.java +++ b/src/java.base/share/classes/jdk/internal/foreign/CABI.java @@ -48,7 +48,6 @@ public enum CABI { WIN_AARCH_64, LINUX_PPC_64_LE, LINUX_RISCV_64, - SYS_V_PPC_64LE, SYS_V_S390X, AIX_PPC_64, FALLBACK, @@ -83,6 +82,10 @@ private static CABI computeCurrent() { // The Linux ABI follows the standard AAPCS ABI return LINUX_AARCH_64; } + } else if (arch.equals("ppc64")) { + if (OperatingSystem.isAix()) { + return AIX_PPC_64; + } } else if (arch.equals("ppc64le")) { if (OperatingSystem.isLinux()) { return LINUX_PPC_64_LE; @@ -91,14 +94,10 @@ private static CABI computeCurrent() { if (OperatingSystem.isLinux()) { return LINUX_RISCV_64; } - } else if (arch.startsWith("ppc64")) { + } else if (arch.equals("s390x")) { if (OperatingSystem.isLinux()) { - return SYS_V_PPC_64LE; - } else { - return AIX_PPC_64; + return SYS_V_S390X; } - } else if (arch.equals("s390x") && OperatingSystem.isLinux()) { - return SYS_V_S390X; } } else if (FallbackLinker.isSupported()) { return FALLBACK; // fallback linker diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java index 9b4d4be3427..574b58ba605 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java @@ -39,7 +39,6 @@ import jdk.internal.foreign.abi.fallback.FallbackLinker; import jdk.internal.foreign.abi.ppc64.aix.AixPPC64Linker; import jdk.internal.foreign.abi.ppc64.linux.LinuxPPC64leLinker; -import jdk.internal.foreign.abi.ppc64.sysv.SysVPPC64leLinker; import jdk.internal.foreign.abi.riscv64.linux.LinuxRISCV64Linker; import jdk.internal.foreign.abi.s390x.sysv.SysVS390xLinker; import jdk.internal.foreign.abi.x64.sysv.SysVx64Linker; @@ -68,7 +67,7 @@ import java.util.Set; public abstract sealed class AbstractLinker implements Linker permits LinuxAArch64Linker, MacOsAArch64Linker, - AixPPC64Linker, SysVPPC64leLinker, SysVS390xLinker, + AixPPC64Linker, SysVS390xLinker, SysVx64Linker, WindowsAArch64Linker, Windowsx64Linker, LinuxPPC64leLinker, LinuxRISCV64Linker, FallbackLinker { diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java b/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java index a2c2eee96d8..053882aeadf 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/SharedUtils.java @@ -42,7 +42,6 @@ import jdk.internal.foreign.abi.fallback.FallbackLinker; import jdk.internal.foreign.abi.ppc64.aix.AixPPC64Linker; import jdk.internal.foreign.abi.ppc64.linux.LinuxPPC64leLinker; -import jdk.internal.foreign.abi.ppc64.sysv.SysVPPC64leLinker; import jdk.internal.foreign.abi.riscv64.linux.LinuxRISCV64Linker; import jdk.internal.foreign.abi.s390x.sysv.SysVS390xLinker; import jdk.internal.foreign.abi.x64.sysv.SysVx64Linker; @@ -252,7 +251,6 @@ public static Linker getSystemLinker() { case WIN_AARCH_64 -> WindowsAArch64Linker.getInstance(); case LINUX_PPC_64_LE -> LinuxPPC64leLinker.getInstance(); case LINUX_RISCV_64 -> LinuxRISCV64Linker.getInstance(); - case SYS_V_PPC_64LE -> SysVPPC64leLinker.getInstance(); case SYS_V_S390X -> SysVS390xLinker.getInstance(); case AIX_PPC_64 -> AixPPC64Linker.getInstance(); case FALLBACK -> FallbackLinker.getInstance(); diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/aix/AixPPC64Linker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/aix/AixPPC64Linker.java index bf12ddafaf4..aa97515d657 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/aix/AixPPC64Linker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/aix/AixPPC64Linker.java @@ -33,6 +33,7 @@ import jdk.internal.foreign.abi.AbstractLinker; import jdk.internal.foreign.abi.LinkerOptions; +import jdk.internal.foreign.abi.ppc64.CallArranger; import java.lang.foreign.FunctionDescriptor; import java.lang.invoke.MethodHandle; @@ -61,12 +62,12 @@ private AixPPC64Linker() { @Override protected MethodHandle arrangeDowncall(MethodType inferredMethodType, FunctionDescriptor function, LinkerOptions options) { - return CallArranger.arrangeDowncall(inferredMethodType, function, options); + return CallArranger.ABIv2.arrangeDowncall(inferredMethodType, function, options); } @Override protected UpcallStubFactory arrangeUpcall(MethodType targetType, FunctionDescriptor function, LinkerOptions options) { - return CallArranger.arrangeUpcall(targetType, function, options); + return CallArranger.ABIv2.arrangeUpcall(targetType, function, options); } @Override diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/aix/CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/aix/CallArranger.java deleted file mode 100644 index fdff8b71d0c..00000000000 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/aix/CallArranger.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2020, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -/* - * =========================================================================== - * (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved - * =========================================================================== - */ - -package jdk.internal.foreign.abi.ppc64.aix; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodType; - -import jdk.internal.foreign.abi.AbstractLinker.UpcallStubFactory; -import jdk.internal.foreign.abi.DowncallLinker; -import jdk.internal.foreign.abi.LinkerOptions; -import jdk.internal.foreign.abi.UpcallLinker; - -import java.lang.foreign.FunctionDescriptor; - -/** - * PPC64 CallArranger specialized for AIX C ABI - */ -public class CallArranger { - - /* Replace DowncallLinker in OpenJDK with the implementation of DowncallLinker specific to OpenJ9 */ - public static MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc, LinkerOptions options) { - return DowncallLinker.getBoundMethodHandle(mt, cDesc, options); - } - - /* Replace UpcallLinker in OpenJDK with the implementation of UpcallLinker specific to OpenJ9 */ - public static UpcallStubFactory arrangeUpcall(MethodType mt, FunctionDescriptor cDesc, LinkerOptions options) { - return UpcallLinker.makeFactory(mt, cDesc, options); - } -} diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/sysv/CallArranger.java b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/sysv/CallArranger.java deleted file mode 100644 index 2f42ff951e9..00000000000 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/sysv/CallArranger.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2020, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -/* - * =========================================================================== - * (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved - * =========================================================================== - */ - -package jdk.internal.foreign.abi.ppc64.sysv; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodType; - -import jdk.internal.foreign.abi.AbstractLinker.UpcallStubFactory; -import jdk.internal.foreign.abi.DowncallLinker; -import jdk.internal.foreign.abi.LinkerOptions; -import jdk.internal.foreign.abi.UpcallLinker; - -import java.lang.foreign.FunctionDescriptor; - -/** - * PPC64LE CallArranger specialized for SysV C ABI - */ -public class CallArranger { - - /* Replace DowncallLinker in OpenJDK with the implementation of DowncallLinker specific to OpenJ9 */ - public static MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc, LinkerOptions options) { - return DowncallLinker.getBoundMethodHandle(mt, cDesc, options); - } - - /* Replace UpcallLinker in OpenJDK with the implementation of UpcallLinker specific to OpenJ9 */ - public static UpcallStubFactory arrangeUpcall(MethodType mt, FunctionDescriptor cDesc, LinkerOptions options) { - return UpcallLinker.makeFactory(mt, cDesc, options); - } -} diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/sysv/SysVPPC64leLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/sysv/SysVPPC64leLinker.java deleted file mode 100644 index 030939bff07..00000000000 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/ppc64/sysv/SysVPPC64leLinker.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2020, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * =========================================================================== - * (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved - * =========================================================================== - */ - -package jdk.internal.foreign.abi.ppc64.sysv; - -import jdk.internal.foreign.abi.AbstractLinker; -import jdk.internal.foreign.abi.LinkerOptions; - -import java.lang.foreign.FunctionDescriptor; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodType; -import java.nio.ByteOrder; - -/** - * ABI implementation based on System V ABI PPC64LE - * - * Note: This file is copied from x64/sysv with modification to - * accommodate the specifics on Linux/ppc64le. - */ -public final class SysVPPC64leLinker extends AbstractLinker { - - public static SysVPPC64leLinker getInstance() { - final class Holder { - private static final SysVPPC64leLinker INSTANCE = new SysVPPC64leLinker(); - } - - return Holder.INSTANCE; - } - - private SysVPPC64leLinker() { - /* Ensure there is only one instance. */ - } - - @Override - protected MethodHandle arrangeDowncall(MethodType inferredMethodType, FunctionDescriptor function, LinkerOptions options) { - return CallArranger.arrangeDowncall(inferredMethodType, function, options); - } - - @Override - protected UpcallStubFactory arrangeUpcall(MethodType targetType, FunctionDescriptor function, LinkerOptions options) { - return CallArranger.arrangeUpcall(targetType, function, options); - } - - @Override - protected ByteOrder linkerByteOrder() { - return ByteOrder.LITTLE_ENDIAN; - } -}