diff --git a/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/SystemABI.java b/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CSupport.java
similarity index 76%
rename from src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/SystemABI.java
rename to src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CSupport.java
index 93699306c8b..72b162daabb 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/SystemABI.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/CSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 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
@@ -27,132 +27,79 @@
import jdk.internal.foreign.Utils;
import jdk.internal.foreign.abi.SharedUtils;
-import jdk.internal.foreign.abi.UpcallStubs;
-import jdk.internal.foreign.abi.aarch64.AArch64ABI;
-import jdk.internal.foreign.abi.x64.sysv.SysVx64ABI;
-import jdk.internal.foreign.abi.x64.windows.Windowsx64ABI;
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodType;
import java.nio.ByteOrder;
-import java.util.Optional;
/**
- * This class models a system application binary interface (ABI).
- *
- * Instances of this class can be obtained by calling {@link SystemABI#getSystemABI()}
+ * A set of utilities for working with libraries using the C language/ABI
*/
-public interface SystemABI {
- /**
- * The name of the SysV ABI
- */
- String ABI_SYSV = "SysV";
-
- /**
- * The name of the Windows ABI
- */
- String ABI_WINDOWS = "Windows";
-
- /**
- * The name of the AArch64 ABI
- */
- String ABI_AARCH64 = "AArch64";
-
+public class CSupport {
/**
- * memory layout attribute key for abi native type
- */
- String NATIVE_TYPE = "abi/native-type";
-
- /**
- * Obtain a method handle which can be used to call a given native function.
- *
- * @param symbol downcall symbol.
- * @param type the method type.
- * @param function the function descriptor.
- * @return the downcall method handle.
- */
- MethodHandle downcallHandle(MemoryAddress symbol, MethodType type, FunctionDescriptor function);
-
- /**
- * Allocates a native stub segment which contains executable code to upcall into a given method handle.
- * As such, the base address of the returned stub segment can be passed to other foreign functions
- * (as a function pointer). The returned segment is not thread-confined, and it only features
- * the {@link MemorySegment#CLOSE} access mode. When the returned segment is closed,
- * the corresponding native stub will be deallocated.
- *
- * @param target the target method handle.
- * @param function the function descriptor.
- * @return the native stub segment.
- */
- MemorySegment upcallStub(MethodHandle target, FunctionDescriptor function);
-
- /**
- * Returns the name of this ABI.
- *
- * @return the name
+ * Obtain a linker that uses the de facto C ABI of the current system to do it's linking.
+ *
+ * This method is restricted. Restricted method are unsafe, and, if used incorrectly, their use might crash
+ * the JVM crash or, worse, silently result in memory corruption. Thus, clients should refrain from depending on
+ * restricted methods, and use safe and supported functionalities, where possible.
+ * @return a linker for this system.
+ * @throws IllegalAccessError if the runtime property {@code foreign.restricted} is not set to either
+ * {@code permit}, {@code warn} or {@code debug} (the default value is set to {@code deny}).
*/
- String name();
+ public static ForeignLinker getSystemLinker() {
+ Utils.checkRestrictedAccess("CSupport.getSystemLinker");
+ return SharedUtils.getSystemLinker();
+ }
/**
* The {@code _Bool} native type.
*/
- ValueLayout C_BOOL = Utils.pick(SysV.C_BOOL, Win64.C_BOOL, AArch64.C_BOOL);
-
+ public static final ValueLayout C_BOOL = Utils.pick(SysV.C_BOOL, Win64.C_BOOL, AArch64.C_BOOL);
/**
* The {@code char} native type.
*/
- ValueLayout C_CHAR = Utils.pick(SysV.C_CHAR, Win64.C_CHAR, AArch64.C_CHAR);
-
+ public static final ValueLayout C_CHAR = Utils.pick(SysV.C_CHAR, Win64.C_CHAR, AArch64.C_CHAR);
/**
* The {@code short} native type.
*/
- ValueLayout C_SHORT = Utils.pick(SysV.C_SHORT, Win64.C_SHORT, AArch64.C_SHORT);
-
+ public static final ValueLayout C_SHORT = Utils.pick(SysV.C_SHORT, Win64.C_SHORT, AArch64.C_SHORT);
/**
* The {@code int} native type.
*/
- ValueLayout C_INT = Utils.pick(SysV.C_INT, Win64.C_INT, AArch64.C_INT);
-
+ public static final ValueLayout C_INT = Utils.pick(SysV.C_INT, Win64.C_INT, AArch64.C_INT);
/**
* The {@code long} native type.
*/
- ValueLayout C_LONG = Utils.pick(SysV.C_LONG, Win64.C_LONG, AArch64.C_LONG);
-
+ public static final ValueLayout C_LONG = Utils.pick(SysV.C_LONG, Win64.C_LONG, AArch64.C_LONG);
/**
* The {@code long long} native type.
*/
- ValueLayout C_LONGLONG = Utils.pick(SysV.C_LONGLONG, Win64.C_LONGLONG, AArch64.C_LONGLONG);
-
+ public static final ValueLayout C_LONGLONG = Utils.pick(SysV.C_LONGLONG, Win64.C_LONGLONG, AArch64.C_LONGLONG);
/**
* The {@code float} native type.
*/
- ValueLayout C_FLOAT = Utils.pick(SysV.C_FLOAT, Win64.C_FLOAT, AArch64.C_FLOAT);
-
+ public static final ValueLayout C_FLOAT = Utils.pick(SysV.C_FLOAT, Win64.C_FLOAT, AArch64.C_FLOAT);
/**
* The {@code double} native type.
*/
- ValueLayout C_DOUBLE = Utils.pick(SysV.C_DOUBLE, Win64.C_DOUBLE, AArch64.C_DOUBLE);
-
+ public static final ValueLayout C_DOUBLE = Utils.pick(SysV.C_DOUBLE, Win64.C_DOUBLE, AArch64.C_DOUBLE);
/**
* The {@code long double} native type.
*/
- ValueLayout C_LONGDOUBLE = Utils.pick(SysV.C_LONGDOUBLE, Win64.C_LONGDOUBLE, AArch64.C_LONGDOUBLE);
-
+ public static final ValueLayout C_LONGDOUBLE = Utils.pick(SysV.C_LONGDOUBLE, Win64.C_LONGDOUBLE, AArch64.C_LONGDOUBLE);
/**
* The {@code T*} native type.
*/
- ValueLayout C_POINTER = Utils.pick(SysV.C_POINTER, Win64.C_POINTER, AArch64.C_POINTER);
+ public static final ValueLayout C_POINTER = Utils.pick(SysV.C_POINTER, Win64.C_POINTER, AArch64.C_POINTER);
/**
* This class defines layout constants modelling standard primitive types supported by the x64 SystemV ABI.
*/
- final class SysV {
+ public static final class SysV {
private SysV() {
//just the one
}
/**
- * The name of the SysV ABI
+ * The name of the SysV linker ({@see ForeignLinker#name})
*/
public static final String NAME = "SysV";
@@ -236,14 +183,14 @@ private SysV() {
/**
* This class defines layout constants modelling standard primitive types supported by the x64 Windows ABI.
*/
- final class Win64 {
+ public static final class Win64 {
private Win64() {
//just the one
}
/**
- * The name of the Windows ABI
+ * The name of the Windows linker ({@see ForeignLinker#name})
*/
public final static String NAME = "Windows";
@@ -325,14 +272,14 @@ public static ValueLayout asVarArg(ValueLayout l) {
/**
* This class defines layout constants modelling standard primitive types supported by the AArch64 ABI.
*/
- final class AArch64 {
+ public static final class AArch64 {
private AArch64() {
//just the one
}
/**
- * The name of the AArch64 ABI
+ * The name of the AArch64 linker ({@see ForeignLinker#name})
*/
public final static String NAME = "AArch64";
@@ -404,19 +351,4 @@ private AArch64() {
public static final ValueLayout C_POINTER = MemoryLayouts.BITS_64_LE
.withAttribute(CLASS_ATTRIBUTE_NAME, ArgumentClass.POINTER);
}
-
- /**
- * Obtain an instance of the system ABI.
- *
- * This method is restricted. Restricted method are unsafe, and, if used incorrectly, their use might crash
- * the JVM crash or, worse, silently result in memory corruption. Thus, clients should refrain from depending on
- * restricted methods, and use safe and supported functionalities, where possible.
- * @return system ABI.
- * @throws IllegalAccessError if the runtime property {@code foreign.restricted} is not set to either
- * {@code permit}, {@code warn} or {@code debug} (the default value is set to {@code deny}).
- */
- static SystemABI getSystemABI() {
- Utils.checkRestrictedAccess("SystemABI.getSystemABI");
- return SharedUtils.getSystemABI();
- }
}
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/ForeignLinker.java b/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/ForeignLinker.java
new file mode 100644
index 00000000000..2d7c52a0dd9
--- /dev/null
+++ b/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/ForeignLinker.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2019, 2020, 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.
+ *
+ */
+package jdk.incubator.foreign;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodType;
+
+/**
+ * This class can be used to link native functions as a {@link MethodHandle}, or to link Java
+ * methods as a native function pointer (modelled as a {@link MemorySegment}).
+ *
+ * Instances of this interface can be obtained for instance by calling {@link CSupport#getSystemLinker()}
+ */
+public interface ForeignLinker {
+ /**
+ * Obtain a method handle which can be used to call a given native function.
+ *
+ * @param symbol downcall symbol.
+ * @param type the method type.
+ * @param function the function descriptor.
+ * @return the downcall method handle.
+ */
+ MethodHandle downcallHandle(MemoryAddress symbol, MethodType type, FunctionDescriptor function);
+
+ /**
+ * Allocates a native stub segment which contains executable code to upcall into a given method handle.
+ * As such, the base address of the returned stub segment can be passed to other foreign functions
+ * (as a function pointer). The returned segment is not thread-confined, and it only features
+ * the {@link MemorySegment#CLOSE} access mode. When the returned segment is closed,
+ * the corresponding native stub will be deallocated.
+ *
+ * @param target the target method handle.
+ * @param function the function descriptor.
+ * @return the native stub segment.
+ */
+ MemorySegment upcallStub(MethodHandle target, FunctionDescriptor function);
+
+ /**
+ * Returns the name of this linker.
+ *
+ * @return the name
+ */
+ String name();
+}
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/LibraryLookup.java b/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/LibraryLookup.java
index 894f9fc99b0..6e1927ec05a 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/LibraryLookup.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/LibraryLookup.java
@@ -38,7 +38,7 @@
*
* Memory address instances generated by a library lookup will contain a strong reference to the originating lookup object,
* therefore preventing library unloading; in turn method handle instances obtained from
- * {@link SystemABI#downcallHandle(MemoryAddress, MethodType, FunctionDescriptor)}) also maintain a strong reference
+ * {@link ForeignLinker#downcallHandle(MemoryAddress, MethodType, FunctionDescriptor)}) also maintain a strong reference
* to the memory address parameter used for their construction. This means that there is always a strong reachability chain
* from a native method handle to a lookup object (the one that was used to lookup the native library symbol the method handle
* refers to); this is useful to prevent situations where a native library is unloaded in the middle of a native call.
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayouts.java b/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayouts.java
index 606d9192423..0b1f97a4cb5 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayouts.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/MemoryLayouts.java
@@ -26,15 +26,8 @@
package jdk.incubator.foreign;
-import jdk.internal.foreign.abi.SharedUtils;
-import jdk.internal.foreign.abi.x64.windows.Windowsx64ABI;
-
import java.nio.ByteOrder;
-import static jdk.incubator.foreign.SystemABI.ABI_AARCH64;
-import static jdk.incubator.foreign.SystemABI.ABI_SYSV;
-import static jdk.incubator.foreign.SystemABI.ABI_WINDOWS;
-
/**
* This class defines useful layout constants. Some of the constants defined in this class are explicit in both
* size and byte order (see {@link #BITS_64_BE}), and can therefore be used to explicitly and unambiguously specify the
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/Utils.java b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/Utils.java
index 9ac29d27ad4..360bddb3c76 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/Utils.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/Utils.java
@@ -26,11 +26,11 @@
package jdk.internal.foreign;
-import jdk.incubator.foreign.GroupLayout;
+import jdk.incubator.foreign.CSupport;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryHandles;
import jdk.incubator.foreign.MemoryLayout;
-import jdk.incubator.foreign.SystemABI;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.ValueLayout;
import jdk.internal.access.foreign.MemoryAddressProxy;
import jdk.internal.foreign.abi.SharedUtils;
@@ -107,11 +107,11 @@ private static void throwIllegalAccessError(String value, String method) {
}
public static Z pick(Z sysv, Z win64, Z aarch64) {
- SystemABI abi = SharedUtils.getSystemABI();
+ ForeignLinker abi = SharedUtils.getSystemLinker();
return switch (abi.name()) {
- case SystemABI.SysV.NAME -> sysv;
- case SystemABI.Win64.NAME -> win64;
- case SystemABI.AArch64.NAME -> aarch64;
+ case CSupport.SysV.NAME -> sysv;
+ case CSupport.Win64.NAME -> win64;
+ case CSupport.AArch64.NAME -> aarch64;
default -> throw new ExceptionInInitializerError("Unexpected ABI: " + abi.name());
};
}
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/SharedUtils.java b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/SharedUtils.java
index af27c99ee9d..32889370b40 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/SharedUtils.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/SharedUtils.java
@@ -24,19 +24,19 @@
*/
package jdk.internal.foreign.abi;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.GroupLayout;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment;
import jdk.incubator.foreign.SequenceLayout;
-import jdk.incubator.foreign.SystemABI;
import jdk.incubator.foreign.ValueLayout;
import jdk.internal.foreign.MemoryAddressImpl;
import jdk.internal.foreign.Utils;
-import jdk.internal.foreign.abi.aarch64.AArch64ABI;
-import jdk.internal.foreign.abi.x64.sysv.SysVx64ABI;
-import jdk.internal.foreign.abi.x64.windows.Windowsx64ABI;
+import jdk.internal.foreign.abi.aarch64.AArch64Linker;
+import jdk.internal.foreign.abi.x64.sysv.SysVx64Linker;
+import jdk.internal.foreign.abi.x64.windows.Windowsx64Linker;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
@@ -228,17 +228,17 @@ public static void checkFunctionTypes(MethodType mt, FunctionDescriptor cDesc, l
throw new IllegalArgumentException("Size too large: " + size);
}
- public static SystemABI getSystemABI() {
+ public static ForeignLinker getSystemLinker() {
String arch = System.getProperty("os.arch");
String os = System.getProperty("os.name");
if (arch.equals("amd64") || arch.equals("x86_64")) {
if (os.startsWith("Windows")) {
- return Windowsx64ABI.getInstance();
+ return Windowsx64Linker.getInstance();
} else {
- return SysVx64ABI.getInstance();
+ return SysVx64Linker.getInstance();
}
} else if (arch.equals("aarch64")) {
- return AArch64ABI.getInstance();
+ return AArch64Linker.getInstance();
}
throw new UnsupportedOperationException("Unsupported os or arch: " + os + ", " + arch);
}
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/AArch64ABI.java b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/AArch64Linker.java
similarity index 88%
rename from src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/AArch64ABI.java
rename to src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/AArch64Linker.java
index 78ebdacf658..5c01e50ed06 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/AArch64ABI.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/AArch64Linker.java
@@ -25,28 +25,30 @@
*/
package jdk.internal.foreign.abi.aarch64;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment;
-import jdk.incubator.foreign.SystemABI;
-import jdk.internal.foreign.abi.*;
+import jdk.internal.foreign.abi.UpcallStubs;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;
+import static jdk.incubator.foreign.CSupport.*;
+
/**
* ABI implementation based on ARM document "Procedure Call Standard for
* the ARM 64-bit Architecture".
*/
-public class AArch64ABI implements SystemABI {
- private static AArch64ABI instance;
+public class AArch64Linker implements ForeignLinker {
+ private static AArch64Linker instance;
static final long ADDRESS_SIZE = 64; // bits
- public static AArch64ABI getInstance() {
+ public static AArch64Linker getInstance() {
if (instance == null) {
- instance = new AArch64ABI();
+ instance = new AArch64Linker();
}
return instance;
}
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java
index 56f219bca1f..98822acb86f 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/aarch64/CallArranger.java
@@ -27,10 +27,8 @@
import jdk.incubator.foreign.GroupLayout;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
-import jdk.incubator.foreign.MemoryLayouts;
import jdk.incubator.foreign.MemorySegment;
import jdk.incubator.foreign.SequenceLayout;
-import jdk.incubator.foreign.SystemABI;
import jdk.incubator.foreign.ValueLayout;
import jdk.internal.foreign.Utils;
import jdk.internal.foreign.abi.CallingSequenceBuilder;
@@ -48,6 +46,7 @@
import java.util.List;
import java.util.Optional;
+import static jdk.incubator.foreign.CSupport.*;
import static jdk.internal.foreign.abi.aarch64.AArch64Architecture.*;
/**
@@ -98,7 +97,7 @@
}
public static Bindings getBindings(MethodType mt, FunctionDescriptor cDesc, boolean forUpcall) {
- SharedUtils.checkFunctionTypes(mt, cDesc, AArch64ABI.ADDRESS_SIZE);
+ SharedUtils.checkFunctionTypes(mt, cDesc, AArch64Linker.ADDRESS_SIZE);
CallingSequenceBuilder csb = new CallingSequenceBuilder(forUpcall);
@@ -107,7 +106,7 @@ public static Bindings getBindings(MethodType mt, FunctionDescriptor cDesc, bool
boolean returnInMemory = isInMemoryReturn(cDesc.returnLayout());
if (returnInMemory) {
- csb.addArgumentBindings(MemoryAddress.class, SystemABI.AArch64.C_POINTER,
+ csb.addArgumentBindings(MemoryAddress.class, AArch64.C_POINTER,
argCalc.getIndirectBindings());
} else if (cDesc.returnLayout().isPresent()) {
Class> carrier = mt.returnType();
@@ -163,17 +162,17 @@ private static boolean isInMemoryReturn(Optional returnLayout) {
}
private static TypeClass classifyValueType(ValueLayout type) {
- SystemABI.AArch64.ArgumentClass clazz = AArch64ABI.argumentClassFor(type);
+ AArch64.ArgumentClass clazz = AArch64Linker.argumentClassFor(type);
if (clazz == null) {
//padding not allowed here
throw new IllegalStateException("Unexpected value layout: could not determine ABI class");
}
- if (clazz == SystemABI.AArch64.ArgumentClass.INTEGER) {
+ if (clazz == AArch64.ArgumentClass.INTEGER) {
return TypeClass.INTEGER;
- } else if(clazz == SystemABI.AArch64.ArgumentClass.POINTER) {
+ } else if(clazz == AArch64.ArgumentClass.POINTER) {
return TypeClass.POINTER;
- } else if (clazz == SystemABI.AArch64.ArgumentClass.VECTOR) {
+ } else if (clazz == AArch64.ArgumentClass.VECTOR) {
return TypeClass.FLOAT;
}
throw new IllegalArgumentException("Unknown ABI class: " + clazz);
@@ -198,15 +197,15 @@ static boolean isHomogeneousFloatAggregate(MemoryLayout type) {
if (!(baseType instanceof ValueLayout))
return false;
- SystemABI.AArch64.ArgumentClass baseArgClass = AArch64ABI.argumentClassFor(baseType);
- if (baseArgClass != SystemABI.AArch64.ArgumentClass.VECTOR)
+ AArch64.ArgumentClass baseArgClass = AArch64Linker.argumentClassFor(baseType);
+ if (baseArgClass != AArch64.ArgumentClass.VECTOR)
return false;
for (MemoryLayout elem : groupLayout.memberLayouts()) {
if (!(elem instanceof ValueLayout))
return false;
- SystemABI.AArch64.ArgumentClass argClass = AArch64ABI.argumentClassFor(elem);
+ AArch64.ArgumentClass argClass = AArch64Linker.argumentClassFor(elem);
if (elem.bitSize() != baseType.bitSize() ||
elem.bitAlignment() != baseType.bitAlignment() ||
baseArgClass != argClass) {
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/CallArranger.java b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/CallArranger.java
index f770b6c9f04..b56ca9130a4 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/CallArranger.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/CallArranger.java
@@ -31,7 +31,6 @@
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment;
import jdk.incubator.foreign.SequenceLayout;
-import jdk.incubator.foreign.SystemABI;
import jdk.incubator.foreign.ValueLayout;
import jdk.internal.foreign.Utils;
import jdk.internal.foreign.abi.CallingSequenceBuilder;
@@ -54,11 +53,12 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
+import static jdk.incubator.foreign.CSupport.*;
import static jdk.internal.foreign.abi.Binding.*;
import static jdk.internal.foreign.abi.x64.X86_64Architecture.*;
-import static jdk.internal.foreign.abi.x64.sysv.SysVx64ABI.MAX_INTEGER_ARGUMENT_REGISTERS;
-import static jdk.internal.foreign.abi.x64.sysv.SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS;
-import static jdk.internal.foreign.abi.x64.sysv.SysVx64ABI.argumentClassFor;
+import static jdk.internal.foreign.abi.x64.sysv.SysVx64Linker.MAX_INTEGER_ARGUMENT_REGISTERS;
+import static jdk.internal.foreign.abi.x64.sysv.SysVx64Linker.MAX_VECTOR_ARGUMENT_REGISTERS;
+import static jdk.internal.foreign.abi.x64.sysv.SysVx64Linker.argumentClassFor;
/**
* For the SysV x64 C ABI specifically, this class uses the ProgrammableInvoker API, namely CallingSequenceBuilder2
@@ -93,7 +93,7 @@
}
public static Bindings getBindings(MethodType mt, FunctionDescriptor cDesc, boolean forUpcall) {
- SharedUtils.checkFunctionTypes(mt, cDesc, SysVx64ABI.ADDRESS_SIZE);
+ SharedUtils.checkFunctionTypes(mt, cDesc, SysVx64Linker.ADDRESS_SIZE);
CallingSequenceBuilder csb = new CallingSequenceBuilder(forUpcall);
@@ -103,7 +103,7 @@ public static Bindings getBindings(MethodType mt, FunctionDescriptor cDesc, bool
boolean returnInMemory = isInMemoryReturn(cDesc.returnLayout());
if (returnInMemory) {
Class> carrier = MemoryAddress.class;
- MemoryLayout layout = SystemABI.SysV.C_POINTER;
+ MemoryLayout layout = SysV.C_POINTER;
csb.addArgumentBindings(carrier, layout, argCalc.getBindings(carrier, layout));
} else if (cDesc.returnLayout().isPresent()) {
Class> carrier = mt.returnType();
@@ -119,7 +119,7 @@ public static Bindings getBindings(MethodType mt, FunctionDescriptor cDesc, bool
if (!forUpcall) {
//add extra binding for number of used vector registers (used for variadic calls)
- csb.addArgumentBindings(long.class, SystemABI.SysV.C_LONG,
+ csb.addArgumentBindings(long.class, SysV.C_LONG,
List.of(move(rax, long.class)));
}
@@ -212,7 +212,7 @@ public StorageCalculator(boolean forArguments) {
private int maxRegisterArguments(int type) {
return type == StorageClasses.INTEGER ?
MAX_INTEGER_ARGUMENT_REGISTERS :
- SysVx64ABI.MAX_VECTOR_ARGUMENT_REGISTERS;
+ SysVx64Linker.MAX_VECTOR_ARGUMENT_REGISTERS;
}
VMStorage stackAlloc() {
@@ -427,7 +427,7 @@ private static ArgumentClassImpl classifyValueType(ValueLayout type) {
if (type.byteSize() > 8) {
throw new IllegalStateException("");
}
- ArgumentClassImpl clazz = SysVx64ABI.argumentClassFor(type)
+ ArgumentClassImpl clazz = SysVx64Linker.argumentClassFor(type)
.orElseThrow(() -> new IllegalStateException("Unexpected value layout: could not determine ABI class"));
return clazz;
}
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64ABI.java b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64Linker.java
similarity index 90%
rename from src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64ABI.java
rename to src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64Linker.java
index 3c5f3c83f51..0bf352c9a4b 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64ABI.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVx64Linker.java
@@ -24,34 +24,36 @@
*/
package jdk.internal.foreign.abi.x64.sysv;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment;
-import jdk.incubator.foreign.SystemABI;
-import jdk.internal.foreign.abi.*;
+import jdk.internal.foreign.abi.UpcallStubs;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;
import java.util.Optional;
+import static jdk.incubator.foreign.CSupport.*;
+
/**
* ABI implementation based on System V ABI AMD64 supplement v.0.99.6
*/
-public class SysVx64ABI implements SystemABI {
+public class SysVx64Linker implements ForeignLinker {
public static final int MAX_INTEGER_ARGUMENT_REGISTERS = 6;
public static final int MAX_INTEGER_RETURN_REGISTERS = 2;
public static final int MAX_VECTOR_ARGUMENT_REGISTERS = 8;
public static final int MAX_VECTOR_RETURN_REGISTERS = 2;
public static final int MAX_X87_RETURN_REGISTERS = 2;
- private static SysVx64ABI instance;
+ private static SysVx64Linker instance;
static final long ADDRESS_SIZE = 64; // bits
- public static SysVx64ABI getInstance() {
+ public static SysVx64Linker getInstance() {
if (instance == null) {
- instance = new SysVx64ABI();
+ instance = new SysVx64Linker();
}
return instance;
}
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/CallArranger.java b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/CallArranger.java
index 509758977c6..abc7747110d 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/CallArranger.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/CallArranger.java
@@ -28,7 +28,6 @@
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment;
import jdk.incubator.foreign.SequenceLayout;
-import jdk.incubator.foreign.SystemABI;
import jdk.incubator.foreign.ValueLayout;
import jdk.internal.foreign.Utils;
import jdk.internal.foreign.abi.CallingSequenceBuilder;
@@ -47,7 +46,8 @@
import java.util.List;
import java.util.Optional;
-import static jdk.incubator.foreign.SystemABI.Win64.VARARGS_ATTRIBUTE_NAME;
+import static jdk.incubator.foreign.CSupport.*;
+import static jdk.incubator.foreign.CSupport.Win64.VARARGS_ATTRIBUTE_NAME;
import static jdk.internal.foreign.abi.x64.X86_64Architecture.*;
/**
@@ -83,7 +83,7 @@
}
public static Bindings getBindings(MethodType mt, FunctionDescriptor cDesc, boolean forUpcall) {
- SharedUtils.checkFunctionTypes(mt, cDesc, Windowsx64ABI.ADDRESS_SIZE);
+ SharedUtils.checkFunctionTypes(mt, cDesc, Windowsx64Linker.ADDRESS_SIZE);
class CallingSequenceBuilderHelper {
final CallingSequenceBuilder csb = new CallingSequenceBuilder(forUpcall);
@@ -105,7 +105,7 @@ void setReturnBindings(Class> carrier, MemoryLayout layout) {
boolean returnInMemory = isInMemoryReturn(cDesc.returnLayout());
if (returnInMemory) {
Class> carrier = MemoryAddress.class;
- MemoryLayout layout = SystemABI.Win64.C_POINTER;
+ MemoryLayout layout = Win64.C_POINTER;
csb.addArgumentBindings(carrier, layout);
if (forUpcall) {
csb.setReturnBindings(carrier, layout);
@@ -160,7 +160,7 @@ private static boolean isInMemoryReturn(Optional returnLayout) {
}
private static TypeClass classifyValueType(ValueLayout type) {
- SystemABI.Win64.ArgumentClass clazz = Windowsx64ABI.argumentClassFor(type);
+ Win64.ArgumentClass clazz = Windowsx64Linker.argumentClassFor(type);
if (clazz == null) {
//padding not allowed here
throw new IllegalStateException("Unexpected value layout: could not determine ABI class");
@@ -175,11 +175,11 @@ private static TypeClass classifyValueType(ValueLayout type) {
// but must be considered volatile across function calls."
// https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=vs-2019
- if (clazz == SystemABI.Win64.ArgumentClass.INTEGER) {
+ if (clazz == Win64.ArgumentClass.INTEGER) {
return TypeClass.INTEGER;
- } else if(clazz == SystemABI.Win64.ArgumentClass.POINTER) {
+ } else if(clazz == Win64.ArgumentClass.POINTER) {
return TypeClass.POINTER;
- } else if (clazz == SystemABI.Win64.ArgumentClass.FLOAT) {
+ } else if (clazz == Win64.ArgumentClass.FLOAT) {
if (type.attribute(VARARGS_ATTRIBUTE_NAME)
.map(String.class::cast)
.map(Boolean::parseBoolean).orElse(false)) {
@@ -228,7 +228,7 @@ public StorageCalculator(boolean forArguments) {
}
VMStorage nextStorage(int type, MemoryLayout layout) {
- if (nRegs >= Windowsx64ABI.MAX_REGISTER_ARGUMENTS) {
+ if (nRegs >= Windowsx64Linker.MAX_REGISTER_ARGUMENTS) {
assert forArguments : "no stack returns";
// stack
long alignment = Math.max(SharedUtils.alignment(layout, true), STACK_SLOT_SIZE);
diff --git a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64ABI.java b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64Linker.java
similarity index 88%
rename from src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64ABI.java
rename to src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64Linker.java
index f8a9e664acb..a6a311bff01 100644
--- a/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64ABI.java
+++ b/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/abi/x64/windows/Windowsx64Linker.java
@@ -24,21 +24,22 @@
*/
package jdk.internal.foreign.abi.x64.windows;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment;
-import jdk.incubator.foreign.SystemABI;
-import jdk.internal.foreign.abi.x64.sysv.ArgumentClassImpl;
-import jdk.internal.foreign.abi.*;
+import jdk.internal.foreign.abi.UpcallStubs;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;
+import static jdk.incubator.foreign.CSupport.*;
+
/**
* ABI implementation based on Windows ABI AMD64 supplement v.0.99.6
*/
-public class Windowsx64ABI implements SystemABI {
+public class Windowsx64Linker implements ForeignLinker {
public static final int MAX_INTEGER_ARGUMENT_REGISTERS = 4;
public static final int MAX_INTEGER_RETURN_REGISTERS = 1;
@@ -47,13 +48,13 @@
public static final int MAX_REGISTER_ARGUMENTS = 4;
public static final int MAX_REGISTER_RETURNS = 1;
- private static Windowsx64ABI instance;
+ private static Windowsx64Linker instance;
static final long ADDRESS_SIZE = 64; // bits
- public static Windowsx64ABI getInstance() {
+ public static Windowsx64Linker getInstance() {
if (instance == null) {
- instance = new Windowsx64ABI();
+ instance = new Windowsx64Linker();
}
return instance;
}
diff --git a/test/jdk/java/foreign/CallGeneratorHelper.java b/test/jdk/java/foreign/CallGeneratorHelper.java
index 59ddf13b242..9e1e523b127 100644
--- a/test/jdk/java/foreign/CallGeneratorHelper.java
+++ b/test/jdk/java/foreign/CallGeneratorHelper.java
@@ -38,7 +38,7 @@
import org.testng.annotations.*;
-import static jdk.incubator.foreign.SystemABI.*;
+import static jdk.incubator.foreign.CSupport.*;
import static org.testng.Assert.*;
public class CallGeneratorHelper extends NativeTestHelper {
diff --git a/test/jdk/java/foreign/Cstring.java b/test/jdk/java/foreign/Cstring.java
index 4a1d9fae396..f937bb2ba7f 100644
--- a/test/jdk/java/foreign/Cstring.java
+++ b/test/jdk/java/foreign/Cstring.java
@@ -27,7 +27,7 @@
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment;
-import static jdk.incubator.foreign.SystemABI.C_CHAR;
+import static jdk.incubator.foreign.CSupport.C_CHAR;
public final class Cstring {
// don't create!
diff --git a/test/jdk/java/foreign/NativeTestHelper.java b/test/jdk/java/foreign/NativeTestHelper.java
index c49da9731fb..587945daba8 100644
--- a/test/jdk/java/foreign/NativeTestHelper.java
+++ b/test/jdk/java/foreign/NativeTestHelper.java
@@ -22,33 +22,34 @@
*
*/
+import jdk.incubator.foreign.CSupport;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.MemoryLayout;
-import jdk.incubator.foreign.SystemABI;
import jdk.incubator.foreign.ValueLayout;
public class NativeTestHelper {
- public static final SystemABI ABI = SystemABI.getSystemABI();
+ public static final ForeignLinker ABI = CSupport.getSystemLinker();
public static boolean isIntegral(MemoryLayout layout) {
return switch (ABI.name()) {
- case SystemABI.SysV.NAME -> layout.attribute(SystemABI.SysV.CLASS_ATTRIBUTE_NAME).get() == SystemABI.SysV.ArgumentClass.INTEGER;
- case SystemABI.Win64.NAME -> layout.attribute(SystemABI.Win64.CLASS_ATTRIBUTE_NAME).get() == SystemABI.Win64.ArgumentClass.INTEGER;
- case SystemABI.AArch64.NAME -> layout.attribute(SystemABI.AArch64.CLASS_ATTRIBUTE_NAME).get() == SystemABI.AArch64.ArgumentClass.INTEGER;
+ case CSupport.SysV.NAME -> layout.attribute(CSupport.SysV.CLASS_ATTRIBUTE_NAME).get() == CSupport.SysV.ArgumentClass.INTEGER;
+ case CSupport.Win64.NAME -> layout.attribute(CSupport.Win64.CLASS_ATTRIBUTE_NAME).get() == CSupport.Win64.ArgumentClass.INTEGER;
+ case CSupport.AArch64.NAME -> layout.attribute(CSupport.AArch64.CLASS_ATTRIBUTE_NAME).get() == CSupport.AArch64.ArgumentClass.INTEGER;
default -> throw new AssertionError("unexpected ABI: " + ABI.name());
};
}
public static boolean isPointer(MemoryLayout layout) {
return switch (ABI.name()) {
- case SystemABI.SysV.NAME -> layout.attribute(SystemABI.SysV.CLASS_ATTRIBUTE_NAME).get() == SystemABI.SysV.ArgumentClass.POINTER;
- case SystemABI.Win64.NAME -> layout.attribute(SystemABI.Win64.CLASS_ATTRIBUTE_NAME).get() == SystemABI.Win64.ArgumentClass.POINTER;
- case SystemABI.AArch64.NAME -> layout.attribute(SystemABI.AArch64.CLASS_ATTRIBUTE_NAME).get() == SystemABI.AArch64.ArgumentClass.POINTER;
+ case CSupport.SysV.NAME -> layout.attribute(CSupport.SysV.CLASS_ATTRIBUTE_NAME).get() == CSupport.SysV.ArgumentClass.POINTER;
+ case CSupport.Win64.NAME -> layout.attribute(CSupport.Win64.CLASS_ATTRIBUTE_NAME).get() == CSupport.Win64.ArgumentClass.POINTER;
+ case CSupport.AArch64.NAME -> layout.attribute(CSupport.AArch64.CLASS_ATTRIBUTE_NAME).get() == CSupport.AArch64.ArgumentClass.POINTER;
default -> throw new AssertionError("unexpected ABI: " + ABI.name());
};
}
public static ValueLayout asVarArg(ValueLayout layout) {
- return ABI.name().equals(SystemABI.Win64.NAME) ? SystemABI.Win64.asVarArg(layout) : layout;
+ return ABI.name().equals(CSupport.Win64.NAME) ? CSupport.Win64.asVarArg(layout) : layout;
}
}
diff --git a/test/jdk/java/foreign/StdLibTest.java b/test/jdk/java/foreign/StdLibTest.java
index 59319695c4c..80feae53111 100644
--- a/test/jdk/java/foreign/StdLibTest.java
+++ b/test/jdk/java/foreign/StdLibTest.java
@@ -51,6 +51,8 @@
import java.util.stream.LongStream;
import java.util.stream.Stream;
+import jdk.incubator.foreign.CSupport;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.LibraryLookup;
import jdk.incubator.foreign.MemoryAddress;
@@ -58,16 +60,15 @@
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment;
import jdk.incubator.foreign.SequenceLayout;
-import jdk.incubator.foreign.SystemABI;
import org.testng.annotations.*;
-import static jdk.incubator.foreign.SystemABI.*;
+import static jdk.incubator.foreign.CSupport.*;
import static org.testng.Assert.*;
@Test
public class StdLibTest extends NativeTestHelper {
- final static SystemABI abi = SystemABI.getSystemABI();
+ final static ForeignLinker abi = CSupport.getSystemLinker();
final static VarHandle byteHandle = MemoryHandles.varHandle(byte.class, ByteOrder.nativeOrder());
final static VarHandle intHandle = MemoryHandles.varHandle(int.class, ByteOrder.nativeOrder());
diff --git a/test/jdk/java/foreign/TestCircularInit1.java b/test/jdk/java/foreign/TestCircularInit1.java
index 17724e0e434..00f33dabc81 100644
--- a/test/jdk/java/foreign/TestCircularInit1.java
+++ b/test/jdk/java/foreign/TestCircularInit1.java
@@ -27,7 +27,7 @@
* @run testng/othervm TestCircularInit1
*/
-import jdk.incubator.foreign.SystemABI;
+import jdk.incubator.foreign.CSupport;
import org.testng.annotations.Test;
import static org.testng.Assert.assertNotNull;
@@ -36,8 +36,8 @@
@Test
public void testCircularInit() {
- System.out.println(SystemABI.C_BOOL); // trigger clinit
- assertNotNull(SystemABI.C_BOOL); // should not be null
+ System.out.println(CSupport.C_BOOL); // trigger clinit
+ assertNotNull(CSupport.C_BOOL); // should not be null
}
}
diff --git a/test/jdk/java/foreign/TestCircularInit2.java b/test/jdk/java/foreign/TestCircularInit2.java
index eff0883be5e..e2d89ad740a 100644
--- a/test/jdk/java/foreign/TestCircularInit2.java
+++ b/test/jdk/java/foreign/TestCircularInit2.java
@@ -27,7 +27,7 @@
* @run testng/othervm TestCircularInit2
*/
-import jdk.incubator.foreign.SystemABI;
+import jdk.incubator.foreign.CSupport;
import org.testng.annotations.Test;
import static org.testng.Assert.assertNotNull;
@@ -36,10 +36,10 @@
@Test
public void testCircularInit() {
- System.out.println(SystemABI.C_BOOL); // trigger clinit
- assertNotNull(SystemABI.C_BOOL);
- assertNotNull(SystemABI.C_BOOL);
- assertNotNull(SystemABI.C_BOOL);
+ System.out.println(CSupport.C_BOOL); // trigger clinit
+ assertNotNull(CSupport.C_BOOL);
+ assertNotNull(CSupport.C_BOOL);
+ assertNotNull(CSupport.C_BOOL);
}
}
diff --git a/test/jdk/java/foreign/TestDowncall.java b/test/jdk/java/foreign/TestDowncall.java
index df823c2403b..26e2f37703f 100644
--- a/test/jdk/java/foreign/TestDowncall.java
+++ b/test/jdk/java/foreign/TestDowncall.java
@@ -33,26 +33,25 @@
* @run testng/othervm -Dforeign.restricted=permit TestDowncall
*/
+import jdk.incubator.foreign.CSupport;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.LibraryLookup;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
-import jdk.incubator.foreign.SystemABI;
+import jdk.incubator.foreign.ForeignLinker;
import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import org.testng.annotations.*;
-import static org.testng.Assert.*;
public class TestDowncall extends CallGeneratorHelper {
static LibraryLookup lib = LibraryLookup.ofLibrary("TestDowncall");
- static SystemABI abi = SystemABI.getSystemABI();
+ static ForeignLinker abi = CSupport.getSystemLinker();
@Test(dataProvider="functions", dataProviderClass=CallGeneratorHelper.class)
diff --git a/test/jdk/java/foreign/TestIllegalLink.java b/test/jdk/java/foreign/TestIllegalLink.java
index 1e433cfa169..6accab79038 100644
--- a/test/jdk/java/foreign/TestIllegalLink.java
+++ b/test/jdk/java/foreign/TestIllegalLink.java
@@ -28,25 +28,26 @@
* @run testng/othervm -Dforeign.restricted=permit TestIllegalLink
*/
+import jdk.incubator.foreign.CSupport;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemoryLayouts;
import jdk.incubator.foreign.MemorySegment;
-import jdk.incubator.foreign.SystemABI;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.invoke.MethodType;
-import static jdk.incubator.foreign.SystemABI.C_INT;
+import static jdk.incubator.foreign.CSupport.C_INT;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
public class TestIllegalLink {
private static final MemoryAddress dummyTarget = MemoryAddress.NULL;
- private static final SystemABI ABI = SystemABI.getSystemABI();
+ private static final ForeignLinker ABI = CSupport.getSystemLinker();
@Test(dataProvider = "types")
public void testTypeMismatch(MethodType mt, FunctionDescriptor desc, String expectedExceptionMessage) {
diff --git a/test/jdk/java/foreign/TestUpcall.java b/test/jdk/java/foreign/TestUpcall.java
index 63351190abc..c39523f2d88 100644
--- a/test/jdk/java/foreign/TestUpcall.java
+++ b/test/jdk/java/foreign/TestUpcall.java
@@ -33,13 +33,14 @@
* @run testng/othervm -Dforeign.restricted=permit TestUpcall
*/
+import jdk.incubator.foreign.CSupport;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.GroupLayout;
import jdk.incubator.foreign.LibraryLookup;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
import jdk.incubator.foreign.MemorySegment;
-import jdk.incubator.foreign.SystemABI;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.ValueLayout;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -49,7 +50,6 @@
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.VarHandle;
-import java.lang.ref.Cleaner;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@@ -57,14 +57,14 @@
import java.util.stream.Collectors;
import static java.lang.invoke.MethodHandles.insertArguments;
-import static jdk.incubator.foreign.SystemABI.C_POINTER;
+import static jdk.incubator.foreign.CSupport.C_POINTER;
import static org.testng.Assert.assertEquals;
public class TestUpcall extends CallGeneratorHelper {
static LibraryLookup lib = LibraryLookup.ofLibrary("TestUpcall");
- static SystemABI abi = SystemABI.getSystemABI();
+ static ForeignLinker abi = CSupport.getSystemLinker();
static MethodHandle DUMMY;
static MethodHandle PASS_AND_SAVE;
diff --git a/test/jdk/java/foreign/TestUpcallStubs.java b/test/jdk/java/foreign/TestUpcallStubs.java
index a6f275d5dfa..b6a6de70472 100644
--- a/test/jdk/java/foreign/TestUpcallStubs.java
+++ b/test/jdk/java/foreign/TestUpcallStubs.java
@@ -27,10 +27,11 @@
* @run testng/othervm -Dforeign.restricted=permit TestUpcallStubs
*/
+import jdk.incubator.foreign.CSupport;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemorySegment;
-import jdk.incubator.foreign.SystemABI;
import org.testng.annotations.*;
import java.lang.invoke.MethodHandle;
@@ -43,7 +44,7 @@
public class TestUpcallStubs {
- static final SystemABI abi = SystemABI.getSystemABI();
+ static final ForeignLinker abi = CSupport.getSystemLinker();
static final MethodHandle MH_dummy;
static {
diff --git a/test/jdk/java/foreign/TestVarArgs.java b/test/jdk/java/foreign/TestVarArgs.java
index ba77d9f3bcc..d25681708df 100644
--- a/test/jdk/java/foreign/TestVarArgs.java
+++ b/test/jdk/java/foreign/TestVarArgs.java
@@ -31,27 +31,25 @@
* @run testng/othervm -Dforeign.restricted=permit TestVarArgs
*/
+import jdk.incubator.foreign.CSupport;
+import jdk.incubator.foreign.ForeignLinker;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.LibraryLookup;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
-import jdk.incubator.foreign.MemoryLayouts;
import jdk.incubator.foreign.MemorySegment;
-import jdk.incubator.foreign.SystemABI;
import jdk.incubator.foreign.ValueLayout;
-import jdk.internal.foreign.MemoryAddressImpl;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.VarHandle;
import java.util.ArrayList;
import java.util.List;
+import static jdk.incubator.foreign.CSupport.*;
import static jdk.incubator.foreign.MemoryLayout.PathElement.*;
-import static jdk.incubator.foreign.SystemABI.*;
import static org.testng.Assert.assertEquals;
public class TestVarArgs extends NativeTestHelper {
@@ -65,7 +63,7 @@
static final VarHandle VH_IntArray = MemoryLayout.ofSequence(C_INT).varHandle(int.class, sequenceElement());
- static final SystemABI abi = SystemABI.getSystemABI();
+ static final ForeignLinker abi = CSupport.getSystemLinker();
static final MemoryAddress varargsAddr;
static {
diff --git a/test/jdk/java/foreign/callarranger/TestAarch64CallArranger.java b/test/jdk/java/foreign/callarranger/TestAarch64CallArranger.java
index 8e0151fc1ad..4b21f9c2e60 100644
--- a/test/jdk/java/foreign/callarranger/TestAarch64CallArranger.java
+++ b/test/jdk/java/foreign/callarranger/TestAarch64CallArranger.java
@@ -44,7 +44,7 @@
import java.lang.invoke.MethodType;
-import static jdk.incubator.foreign.SystemABI.AArch64.*;
+import static jdk.incubator.foreign.CSupport.AArch64.*;
import static jdk.internal.foreign.abi.Binding.*;
import static jdk.internal.foreign.abi.aarch64.AArch64Architecture.*;
import static org.testng.Assert.assertEquals;
diff --git a/test/jdk/java/foreign/callarranger/TestSysVCallArranger.java b/test/jdk/java/foreign/callarranger/TestSysVCallArranger.java
index c5debf0bc01..30b5923d7a8 100644
--- a/test/jdk/java/foreign/callarranger/TestSysVCallArranger.java
+++ b/test/jdk/java/foreign/callarranger/TestSysVCallArranger.java
@@ -45,7 +45,7 @@
import java.lang.invoke.MethodType;
-import static jdk.incubator.foreign.SystemABI.SysV.*;
+import static jdk.incubator.foreign.CSupport.SysV.*;
import static jdk.internal.foreign.abi.Binding.*;
import static jdk.internal.foreign.abi.x64.X86_64Architecture.*;
import static org.testng.Assert.assertEquals;
diff --git a/test/jdk/java/foreign/callarranger/TestWindowsCallArranger.java b/test/jdk/java/foreign/callarranger/TestWindowsCallArranger.java
index 6c499356627..d36bcaaf7a6 100644
--- a/test/jdk/java/foreign/callarranger/TestWindowsCallArranger.java
+++ b/test/jdk/java/foreign/callarranger/TestWindowsCallArranger.java
@@ -44,7 +44,7 @@
import java.lang.invoke.MethodType;
-import static jdk.incubator.foreign.SystemABI.Win64.*;
+import static jdk.incubator.foreign.CSupport.Win64.*;
import static jdk.internal.foreign.abi.Binding.*;
import static jdk.internal.foreign.abi.Binding.copy;
import static jdk.internal.foreign.abi.x64.X86_64Architecture.*;
diff --git a/test/micro/org/openjdk/bench/jdk/incubator/foreign/CallOverhead.java b/test/micro/org/openjdk/bench/jdk/incubator/foreign/CallOverhead.java
index 5c5300a1c5f..d98a9375510 100644
--- a/test/micro/org/openjdk/bench/jdk/incubator/foreign/CallOverhead.java
+++ b/test/micro/org/openjdk/bench/jdk/incubator/foreign/CallOverhead.java
@@ -22,9 +22,10 @@
*/
package org.openjdk.bench.jdk.incubator.foreign;
+import jdk.incubator.foreign.CSupport;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.LibraryLookup;
-import jdk.incubator.foreign.SystemABI;
+import jdk.incubator.foreign.ForeignLinker;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
@@ -35,11 +36,10 @@
import org.openjdk.jmh.annotations.Warmup;
import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.concurrent.TimeUnit;
-import static jdk.incubator.foreign.SystemABI.C_INT;
+import static jdk.incubator.foreign.CSupport.C_INT;
@BenchmarkMode(Mode.AverageTime)
@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
@@ -49,7 +49,7 @@
@Fork(3)
public class CallOverhead {
- static final SystemABI abi = SystemABI.getSystemABI();
+ static final ForeignLinker abi = CSupport.getSystemLinker();
static final MethodHandle func;
static final MethodHandle identity;
diff --git a/test/micro/org/openjdk/bench/jdk/incubator/foreign/points/support/PanamaPoint.java b/test/micro/org/openjdk/bench/jdk/incubator/foreign/points/support/PanamaPoint.java
index 622d49f395f..4f85c1e1760 100644
--- a/test/micro/org/openjdk/bench/jdk/incubator/foreign/points/support/PanamaPoint.java
+++ b/test/micro/org/openjdk/bench/jdk/incubator/foreign/points/support/PanamaPoint.java
@@ -22,21 +22,20 @@
*/
package org.openjdk.bench.jdk.incubator.foreign.points.support;
+import jdk.incubator.foreign.CSupport;
import jdk.incubator.foreign.FunctionDescriptor;
import jdk.incubator.foreign.LibraryLookup;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemoryLayout;
-import jdk.incubator.foreign.MemoryLayouts;
import jdk.incubator.foreign.MemorySegment;
-import jdk.incubator.foreign.SystemABI;
+import jdk.incubator.foreign.ForeignLinker;
import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import static java.lang.invoke.MethodType.methodType;
+import static jdk.incubator.foreign.CSupport.*;
import static jdk.incubator.foreign.MemoryLayout.PathElement.groupElement;
-import static jdk.incubator.foreign.SystemABI.*;
public class PanamaPoint implements AutoCloseable {
@@ -52,7 +51,7 @@
static {
try {
- SystemABI abi = SystemABI.getSystemABI();
+ ForeignLinker abi = CSupport.getSystemLinker();
LibraryLookup lookup = LibraryLookup.ofLibrary("Point");
MH_distance = abi.downcallHandle(
lookup.lookup("distance"),