Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
[FFI] Disable FFI related code in OpenJDK for JDK20
Browse files Browse the repository at this point in the history
The change is to disable all downcall & upcall code
specific to FFI in OpenJDK for the moment to ensure
it gets compiled in JDK20 as we have been working
on the changes in OpenJDK & OpenJ9 to deal with
the latest APIs intended for JEP434.

Signed-off-by: ChengJin01 <jincheng@ca.ibm.com>
  • Loading branch information
ChengJin01 committed Jan 25, 2023
1 parent 69b40f9 commit 501a63b
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/foreign/VaList.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved
* (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved
* ===========================================================================
*/

Expand Down Expand Up @@ -115,7 +115,7 @@
*/
@PreviewFeature(feature=PreviewFeature.Feature.FOREIGN)
public sealed interface VaList permits WinVaList, SysVVaList, LinuxAArch64VaList, MacOsAArch64VaList,
SysVPPC64leVaList, SysVS390xVaList, AixPPC64VaList, SharedUtils.EmptyVaList {
SysVPPC64leVaList, SysVS390xVaList, AixPPC64VaList, SharedUtils.EmptyVaList {

/**
* Reads the next value as an {@code int} and advances this variable argument list's position. The behavior of this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ public Bindings getBindings(MethodType mt, FunctionDescriptor cDesc, boolean for

/* Replace DowncallLinker in OpenJDK with the implementation of DowncallLinker specific to OpenJ9 */
public static MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc, LinkerOptions options) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
// MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc, options);
// return handle;
return null;
}

/* Replace UpcallLinker in OpenJDK with the implementation of UpcallLinker specific to OpenJ9 */
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
// return UpcallLinker.make(target, mt, cDesc, session);
return null;
}

private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static VaList newVaList(Consumer<VaList.Builder> actions, SegmentScope sc
return builder.build();
}

public static VaList newVaListOfAddress(long addr, SegmentScope scope) {
return AixPPC64VaList.ofAddress(addr, scope);
public static VaList newVaListOfAddress(long address, SegmentScope scope) {
return AixPPC64VaList.ofAddress(address, scope);
}

public static VaList emptyVaList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ 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) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
// MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc, options);
// return handle;
return null;
}

/* Replace UpcallLinker in OpenJDK with the implementation of UpcallLinker specific to OpenJ9 */
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
return UpcallLinker.make(target, mt, cDesc, session);
// return UpcallLinker.make(target, mt, cDesc, session);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ 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) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
// MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc, options);
// return handle;
return null;
}

/* Replace UpcallLinker in OpenJDK with the implementation of UpcallLinker specific to OpenJ9 */
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
return UpcallLinker.make(target, mt, cDesc, session);
// return UpcallLinker.make(target, mt, cDesc, session);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static VaList newVaList(Consumer<VaList.Builder> actions, SegmentScope sc
return builder.build();
}

public static VaList newVaListOfAddress(long addr, SegmentScope scope) {
return SysVPPC64leVaList.ofAddress(addr, scope);
public static VaList newVaListOfAddress(long address, SegmentScope scope) {
return SysVPPC64leVaList.ofAddress(address, scope);
}

public static VaList emptyVaList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ 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) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
// MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc, options);
// return handle;
return null;
}

/* Replace UpcallLinker in OpenJDK with the implementation of UpcallLinker specific to OpenJ9 */
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
return UpcallLinker.make(target, mt, cDesc, session);
// return UpcallLinker.make(target, mt, cDesc, session);
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static VaList newVaList(Consumer<VaList.Builder> actions, SegmentScope sc
return builder.build();
}

public static VaList newVaListOfAddress(long addr, SegmentScope scope) {
return SysVS390xVaList.ofAddress(addr, scope);
public static VaList newVaListOfAddress(long address, SegmentScope scope) {
return SysVS390xVaList.ofAddress(address, scope);
}

public static VaList emptyVaList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ public static Bindings getBindings(MethodType mt, FunctionDescriptor cDesc, bool

/* Replace DowncallLinker in OpenJDK with the implementation of DowncallLinker specific to OpenJ9 */
public static MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc, LinkerOptions options) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
// MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc, options);
// return handle;
return null;
}

/* Replace UpcallLinker in OpenJDK with the implementation of UpcallLinker specific to OpenJ9 */
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
return UpcallLinker.make(target, mt, cDesc, session);
// return UpcallLinker.make(target, mt, cDesc, session);
return null;
}

private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ void setReturnBindings(Class<?> carrier, MemoryLayout layout) {

/* Replace DowncallLinker in OpenJDK with the implementation of DowncallLinker specific to OpenJ9 */
public static MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc, LinkerOptions options) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
// MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc, options);
// return handle;
return null;
}

/* Replace UpcallLinker in OpenJDK with the implementation of UpcallLinker specific to OpenJ9 */
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
return UpcallLinker.make(target, mt, cDesc, session);
// return UpcallLinker.make(target, mt, cDesc, session);
return null;
}

private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/foreign/TestVarArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved
* (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved
* ===========================================================================
*/

Expand Down Expand Up @@ -140,7 +140,7 @@ private static void check(int index, MemorySegment ptr, List<Arg> args) {
/* Vararg float is promoted to double (8 bytes) in native (See libVarArgs.c)
* in which case float must be converted back from double at the same memory
* address in java on the Big-Endian(BE) platforms such as AIX.
*/
*/
if (isAixOS && (layout instanceof ValueLayout) && (((ValueLayout)layout).carrier() == float.class)) {
MemorySegment doubleSegmt = MemorySegment.ofAddress(ptr, JAVA_DOUBLE.byteSize(), session);
seg.set(JAVA_FLOAT, 0, (float)doubleSegmt.get(JAVA_DOUBLE, 0));
Expand Down
4 changes: 2 additions & 2 deletions test/jdk/java/foreign/valist/VaListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved
* (c) Copyright IBM Corp. 2022, 2023 All Rights Reserved
* ===========================================================================
*/

Expand All @@ -45,7 +45,7 @@
* java.base/jdk.internal.foreign.abi.aarch64.windows
* java.base/jdk.internal.foreign.abi.ppc64.aix
* java.base/jdk.internal.foreign.abi.ppc64.sysv
* java.base/jdk.internal.foreign.abi.s390x.sysv
* java.base/jdk.internal.foreign.abi.s390x.sysv
* @run testng/othervm --enable-native-access=ALL-UNNAMED VaListTest
*/

Expand Down

0 comments on commit 501a63b

Please sign in to comment.