APIdia Launch Partner
Top Fields Constructors Methods
jdk.internal.foreign.abi

public final Class SharedUtils

extends Object
Class Inheritance
Imports
jdk.internal.access.JavaLangInvokeAccess, .SharedSecrets, jdk.internal.foreign.BufferStack, .CABI, jdk.internal.foreign.abi.AbstractLinker.UpcallStubFactory, jdk.internal.foreign.abi.aarch64.linux.LinuxAArch64Linker, jdk.internal.foreign.abi.aarch64.macos.MacOsAArch64Linker, jdk.internal.foreign.abi.aarch64.windows.WindowsAArch64Linker, jdk.internal.foreign.abi.fallback.FallbackLinker, jdk.internal.foreign.abi.ppc64.aix.AixPPC64Linker, jdk.internal.foreign.abi.ppc64.linux.LinuxPPC64Linker, .LinuxPPC64leLinker, jdk.internal.foreign.abi.riscv64.linux.LinuxRISCV64Linker, jdk.internal.foreign.abi.s390.linux.LinuxS390Linker, jdk.internal.foreign.abi.x64.sysv.SysVx64Linker, jdk.internal.foreign.abi.x64.windows.Windowsx64Linker, jdk.internal.vm.annotation.ForceInline, java.lang.foreign.AddressLayout, .Arena, .FunctionDescriptor, .GroupLayout, .Linker, .MemoryLayout, .MemorySegment, .MemorySegment.Scope, .SegmentAllocator, .ValueLayout, java.lang.invoke.MethodHandle, .MethodHandles, .MethodType, java.lang.ref.Reference, java.nio.ByteOrder, java.util.Arrays, .Map, .Objects, java.util.stream.Collectors, .IntStream

Field Summary

Modifier and TypeField and Description
public static final AddressLayout
public static final Arena
private static final JavaLangInvokeAccess
private static final BufferStack
private static final int
private static final MethodHandle
private static final MethodHandle
private static final MethodHandle
public static final MethodHandle
private static final MethodHandle
public static final SegmentAllocator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static MethodHandle

Returns:

the adapted handle
adaptDowncallForIMR
(MethodHandle
the target handle to adapt
handle
,
FunctionDescriptor
the function descriptor of the native function (with actual return layout)
cDesc
,
CallingSequence sequence)

Takes a MethodHandle that takes an input buffer as a first argument (a MemorySegment), and returns nothing, and adapts it to return a MemorySegment, by allocating a MemorySegment for the input buffer, calling the target MethodHandle, and then returning the allocated MemorySegment.

private static MethodHandle

Returns:

the adapted handle
adaptUpcallForIMR
(MethodHandle
the target handle to adapt
target
,
boolean dropReturn)

Takes a MethodHandle that returns a MemorySegment, and adapts it to take an input buffer as a first argument (a MemorySegment), and upon invocation, copies the contents of the returned MemorySegment into the input buffer passed as the first argument.

public static long
alignUp(long addr, long alignment)

public static AbstractLinker.UpcallStubFactory
arrangeUpcallHelper(MethodType targetType, boolean isInMemoryReturn, boolean dropReturn, ABIDescriptor abi, CallingSequence callingSequence)

private static MemorySegment
public static Map<String, MemoryLayout>
canonicalLayouts(ValueLayout longLayout, ValueLayout sizetLayout, ValueLayout wchartLayout)

public static MemorySegment
public static void
public static void
public static void
pack-priv static void
checkType(Class<?> actualType, Class<?> expectedType)

public static Linker
public static void
pack-priv static Map<VMStorage, Integer>
public static boolean
isPowerOfTwo(int width)

public static MethodHandle
public static MethodHandle
pack-priv static MethodHandle
mergeArguments(MethodHandle mh, int sourceIndex, int destIndex)

public static Arena
newBoundedArena(long size)

public static Arena
pack-priv static long
pickChunkOffset(long chunkOffset, long byteWidth, int chunkWidth)

public static Class<?>
primitiveCarrierForSize(long size, boolean useFloat)

public static ValueLayout
primitiveLayoutForSize(long size, boolean useFloat)

private static MethodHandle
pack-priv static Object
read(MemorySegment ptr, long offset, Class<?> type)

public static long
remainsToAlignment(long addr, long alignment)

public static MethodHandle
swapArguments(MethodHandle mh, int firstArg, int secondArg)

public static long
public static int
pack-priv static void
write(MemorySegment ptr, long offset, Class<?> type, Object o)

pack-priv static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

C_POINTERback to summary
public static final AddressLayout C_POINTER
Annotations
@SuppressWarnings:restricted
DUMMY_ARENAback to summary
public static final Arena DUMMY_ARENA
JLIAback to summary
private static final JavaLangInvokeAccess JLIA
LINKER_STACKback to summary
private static final BufferStack LINKER_STACK
LINKER_STACK_SIZEback to summary
private static final int LINKER_STACK_SIZE
MH_ALLOC_BUFFERback to summary
private static final MethodHandle MH_ALLOC_BUFFER
MH_BUFFER_COPYback to summary
private static final MethodHandle MH_BUFFER_COPY
MH_CHECK_CAPTURE_SEGMENTback to summary
private static final MethodHandle MH_CHECK_CAPTURE_SEGMENT
MH_CHECK_SYMBOLback to summary
public static final MethodHandle MH_CHECK_SYMBOL
MH_REACHABILITY_FENCEback to summary
private static final MethodHandle MH_REACHABILITY_FENCE
THROWING_ALLOCATORback to summary
public static final SegmentAllocator THROWING_ALLOCATOR

Constructor Detail

SharedUtilsback to summary
private SharedUtils()

Method Detail

adaptDowncallForIMRback to summary
public static MethodHandle adaptDowncallForIMR(MethodHandle handle, FunctionDescriptor cDesc, CallingSequence sequence)

Takes a MethodHandle that takes an input buffer as a first argument (a MemorySegment), and returns nothing, and adapts it to return a MemorySegment, by allocating a MemorySegment for the input buffer, calling the target MethodHandle, and then returning the allocated MemorySegment. This allows viewing a MethodHandle that makes use of in memory return (IMR) as a MethodHandle that just returns a MemorySegment without requiring a pre-allocated buffer as an explicit input.

Parameters
handle:MethodHandle

the target handle to adapt

cDesc:FunctionDescriptor

the function descriptor of the native function (with actual return layout)

Returns:MethodHandle

the adapted handle

adaptUpcallForIMRback to summary
private static MethodHandle adaptUpcallForIMR(MethodHandle target, boolean dropReturn)

Takes a MethodHandle that returns a MemorySegment, and adapts it to take an input buffer as a first argument (a MemorySegment), and upon invocation, copies the contents of the returned MemorySegment into the input buffer passed as the first argument.

Parameters
target:MethodHandle

the target handle to adapt

Returns:MethodHandle

the adapted handle

alignUpback to summary
public static long alignUp(long addr, long alignment)
arrangeUpcallHelperback to summary
public static AbstractLinker.UpcallStubFactory arrangeUpcallHelper(MethodType targetType, boolean isInMemoryReturn, boolean dropReturn, ABIDescriptor abi, CallingSequence callingSequence)
bufferCopyback to summary
private static MemorySegment bufferCopy(MemorySegment dest, MemorySegment buffer)
canonicalLayoutsback to summary
public static Map<String, MemoryLayout> canonicalLayouts(ValueLayout longLayout, ValueLayout sizetLayout, ValueLayout wchartLayout)
checkCaptureSegmentback to summary
public static MemorySegment checkCaptureSegment(MemorySegment captureSegment)
Annotations
@ForceInline
checkExceptionsback to summary
public static void checkExceptions(MethodHandle target)
checkNativeback to summary
public static void checkNative(MemorySegment segment)
checkSymbolback to summary
public static void checkSymbol(MemorySegment symbol)
Annotations
@ForceInline
checkTypeback to summary
pack-priv static void checkType(Class<?> actualType, Class<?> expectedType)
getSystemLinkerback to summary
public static Linker getSystemLinker()
handleUncaughtExceptionback to summary
public static void handleUncaughtException(Throwable t)
indexMapback to summary
pack-priv static Map<VMStorage, Integer> indexMap(Binding.Move[] moves)
isPowerOfTwoback to summary
public static boolean isPowerOfTwo(int width)
maybeCheckCaptureSegmentback to summary
public static MethodHandle maybeCheckCaptureSegment(MethodHandle handle, LinkerOptions options)
maybeInsertAllocatorback to summary
public static MethodHandle maybeInsertAllocator(FunctionDescriptor descriptor, MethodHandle handle)
mergeArgumentsback to summary
pack-priv static MethodHandle mergeArguments(MethodHandle mh, int sourceIndex, int destIndex)
newBoundedArenaback to summary
public static Arena newBoundedArena(long size)
Annotations
@ForceInline
newEmptyArenaback to summary
public static Arena newEmptyArena()
pickChunkOffsetback to summary
pack-priv static long pickChunkOffset(long chunkOffset, long byteWidth, int chunkWidth)
primitiveCarrierForSizeback to summary
public static Class<?> primitiveCarrierForSize(long size, boolean useFloat)
primitiveLayoutForSizeback to summary
public static ValueLayout primitiveLayoutForSize(long size, boolean useFloat)
reachabilityFenceHandleback to summary
private static MethodHandle reachabilityFenceHandle(Class<?> type)
readback to summary
pack-priv static Object read(MemorySegment ptr, long offset, Class<?> type)
remainsToAlignmentback to summary
public static long remainsToAlignment(long addr, long alignment)
swapArgumentsback to summary
public static MethodHandle swapArguments(MethodHandle mh, int firstArg, int secondArg)
unboxSegmentback to summary
public static long unboxSegment(MemorySegment segment)
Annotations
@ForceInline
unboxSegment32back to summary
public static int unboxSegment32(MemorySegment segment)
Annotations
@ForceInline
writeback to summary
pack-priv static void write(MemorySegment ptr, long offset, Class<?> type, Object o)
writeOverSizedback to summary
pack-priv static void writeOverSized(MemorySegment ptr, Class<?> type, Object o)