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 24, 2023
1 parent af7ec3c commit 9128833
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 38 deletions.
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 @@ -154,15 +154,16 @@ public Bindings getBindings(MethodType mt, FunctionDescriptor cDesc, boolean for
}

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

/* Replace UpcallLinker in OpenJDK with the implementation of UpcallLinker specific to OpenJ9 */
public MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope 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 @@ -26,7 +26,7 @@

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

Expand All @@ -36,25 +36,28 @@
import java.lang.invoke.MethodType;

import jdk.internal.foreign.abi.DowncallLinker;
import jdk.internal.foreign.abi.LinkerOptions;
import jdk.internal.foreign.abi.UpcallLinker;

import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.MemorySession;
import java.lang.foreign.SegmentScope;

/**
* 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) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
public static MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc, LinkerOptions options) {
// 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, MemorySession session) {
return UpcallLinker.make(target, mt, cDesc, session);
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
// return UpcallLinker.make(target, mt, cDesc, session);
return null;
}
}
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 All @@ -36,25 +36,28 @@
import java.lang.invoke.MethodType;

import jdk.internal.foreign.abi.DowncallLinker;
import jdk.internal.foreign.abi.LinkerOptions;
import jdk.internal.foreign.abi.UpcallLinker;

import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.MemorySession;
import java.lang.foreign.SegmentScope;

/**
* 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) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
public static MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc, LinkerOptions options) {
// 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, MemorySession session) {
return UpcallLinker.make(target, mt, cDesc, session);
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
// return UpcallLinker.make(target, mt, cDesc, session);
return null;
}
}
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 All @@ -36,25 +36,28 @@
import java.lang.invoke.MethodType;

import jdk.internal.foreign.abi.DowncallLinker;
import jdk.internal.foreign.abi.LinkerOptions;
import jdk.internal.foreign.abi.UpcallLinker;

import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.MemorySegment;
import java.lang.foreign.MemorySession;
import java.lang.foreign.SegmentScope;

/**
* S390x 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) {
MethodHandle handle = DowncallLinker.getBoundMethodHandle(mt, cDesc);
return handle;
public static MethodHandle arrangeDowncall(MethodType mt, FunctionDescriptor cDesc, LinkerOptions options) {
// 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, MemorySession session) {
return UpcallLinker.make(target, mt, cDesc, session);
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
// return UpcallLinker.make(target, mt, cDesc, session);
return null;
}
}
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 @@ -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 scope) {
return UpcallLinker.make(target, mt, cDesc, session);
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope 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 @@ -25,7 +25,7 @@

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

Expand Down 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 scope) {
return UpcallLinker.make(target, mt, cDesc, session);
public static MemorySegment arrangeUpcall(MethodHandle target, MethodType mt, FunctionDescriptor cDesc, SegmentScope session) {
// return UpcallLinker.make(target, mt, cDesc, session);
return null;
}

private static boolean isInMemoryReturn(Optional<MemoryLayout> returnLayout) {
Expand Down

0 comments on commit 9128833

Please sign in to comment.