Skip to content

Commit

Permalink
Merge pull request #30 from ChengJin01/ffi_unify_linker_code_power_jdk21
Browse files Browse the repository at this point in the history
[FFI/JDK21] Unify the linker code on Power
  • Loading branch information
keithc-ca authored Aug 15, 2023
2 parents a5672ac + ddc6828 commit 440eb6c
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 207 deletions.
13 changes: 6 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,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
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 440eb6c

Please sign in to comment.