Skip to content

Commit

Permalink
[FFI/JDK21] Unify the linker code on Power
Browse files Browse the repository at this point in the history
The changes aim to unify the linker related code on AIX
and pLinux by leveraging the latest FFI specific code on
pLinux in OpenJDK to avoid any conflicts from upstream
in the future.

Fixes: #eclipse-openj9/openj9/issues/17884

Signed-off-by: ChengJin01 <[email protected]>
  • Loading branch information
ChengJin01 committed Aug 14, 2023
1 parent a5672ac commit f178b97
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 207 deletions.
11 changes: 4 additions & 7 deletions src/java.base/share/classes/jdk/internal/foreign/CABI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -91,12 +94,6 @@ private static CABI computeCurrent() {
if (OperatingSystem.isLinux()) {
return LINUX_RISCV_64;
}
} else if (arch.startsWith("ppc64")) {
if (OperatingSystem.isLinux()) {
return SYS_V_PPC_64LE;
} else {
return AIX_PPC_64;
}
} else if (arch.equals("s390x") && OperatingSystem.isLinux()) {
return SYS_V_S390X;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit f178b97

Please sign in to comment.