Skip to content

Commit

Permalink
Merge pull request #19 from JasonFengJ9/mergetmp
Browse files Browse the repository at this point in the history
Merge master jdk-19+33 into openj9-staging
  • Loading branch information
keithc-ca authored Aug 3, 2022
2 parents 9c96aae + d0066a9 commit c2c80f7
Show file tree
Hide file tree
Showing 17 changed files with 127 additions and 157 deletions.
9 changes: 1 addition & 8 deletions closed/autoconf/custom-hook.m4
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,7 @@ AC_DEFUN([OPENJ9_CONFIGURE_CMAKE],
fi
],
[
case "$OPENJ9_PLATFORM_CODE" in
ap64|oa64|or64|wa64|xa64|xl64|xr64|xz64)
with_cmake=cmake
;;
*)
with_cmake=no
;;
esac
with_cmake=cmake
])
# at this point with_cmake should either be no, or the name of the cmake command
if test "x$with_cmake" = xno ; then
Expand Down
2 changes: 1 addition & 1 deletion closed/openjdk-tag.gmk
Original file line number Diff line number Diff line change
@@ -1 +1 @@
OPENJDK_TAG := jdk-19+32
OPENJDK_TAG := jdk-19+33
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

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

package java.lang.invoke;

import jdk.internal.foreign.AbstractMemorySegmentImpl;
Expand All @@ -42,8 +35,6 @@ import java.util.Objects;

import static java.lang.invoke.MethodHandleStatics.UNSAFE;

import sun.security.action.GetPropertyAction;

#warn

final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
Expand All @@ -56,8 +47,6 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {

static final VarForm FORM = new VarForm(VarHandleSegmentAs$Type$s.class, MemorySegment.class, $type$.class, long.class);

static final boolean isAixOS = GetPropertyAction.privilegedGetProperty("os.name").startsWith("AIX") ? true : false;

VarHandleSegmentAs$Type$s(boolean be, long length, long alignmentMask, boolean exact) {
super(FORM, be, length, alignmentMask, exact);
}
Expand Down Expand Up @@ -117,36 +106,20 @@ final class VarHandleSegmentAs$Type$s extends VarHandleSegmentViewBase {
@ForceInline
static long offset(AbstractMemorySegmentImpl bb, long offset, long alignmentMask) {
long address = offsetNoVMAlignCheck(bb, offset, alignmentMask);
#if[floatingPoint]
/* Ignore the alignement check for float/double on AIX/PPC to handle the case of [float/int, double]
* given the size of [float/int, double] on AIX/PPC 64-bit is 12 bytes without padding while the
* same struct is 16 bytes with padding on other platforms
*/
if (!isAixOS) {
if ((address & VM_ALIGN) != 0) {
throw VarHandleSegmentViewBase.newIllegalArgumentExceptionForMisalignedAccess(address);
}
if ((address & VM_ALIGN) != 0) {
throw VarHandleSegmentViewBase.newIllegalArgumentExceptionForMisalignedAccess(address);
}
#end[floatingPoint]
return address;
}

@ForceInline
static long offsetNoVMAlignCheck(AbstractMemorySegmentImpl bb, long offset, long alignmentMask) {
long base = bb.unsafeGetOffset();
long address = base + offset;
#if[floatingPoint]
/* Ignore the alignement check for float/double on AIX/PPC to handle the case of [float/int, double]
* given the size of [float/int, double] on AIX/PPC 64-bit is 12 bytes without padding while the
* same struct is 16 bytes with padding on other platforms
*/
if (!isAixOS) {
long maxAlignMask = bb.maxAlignMask();
if (((address | maxAlignMask) & alignmentMask) != 0) {
throw VarHandleSegmentViewBase.newIllegalArgumentExceptionForMisalignedAccess(address);
}
long maxAlignMask = bb.maxAlignMask();
if (((address | maxAlignMask) & alignmentMask) != 0) {
throw VarHandleSegmentViewBase.newIllegalArgumentExceptionForMisalignedAccess(address);
}
#end[floatingPoint]
return address;
}

Expand Down
51 changes: 29 additions & 22 deletions src/java.base/share/classes/jdk/internal/foreign/CABI.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,49 @@ public enum CABI {
SysVS390x,
AIX;

private static final CABI current;
private static final CABI ABI;
private static final String ARCH;
private static final String OS;
private static final long ADDRESS_SIZE;

static {
String arch = privilegedGetProperty("os.arch");
String os = privilegedGetProperty("os.name");
long addressSize = ADDRESS.bitSize();
ARCH = privilegedGetProperty("os.arch");
OS = privilegedGetProperty("os.name");
ADDRESS_SIZE = ADDRESS.bitSize();
// might be running in a 32-bit VM on a 64-bit platform.
// addressSize will be correctly 32
if ((arch.equals("amd64") || arch.equals("x86_64")) && addressSize == 64) {
if (os.startsWith("Windows")) {
current = Win64;
if ((ARCH.equals("amd64") || ARCH.equals("x86_64")) && ADDRESS_SIZE == 64) {
if (OS.startsWith("Windows")) {
ABI = Win64;
} else {
current = SysV;
ABI = SysV;
}
} else if (arch.equals("aarch64")) {
if (os.startsWith("Mac")) {
current = MacOsAArch64;
} else if (ARCH.equals("aarch64")) {
if (OS.startsWith("Mac")) {
ABI = MacOsAArch64;
} else {
// The Linux ABI follows the standard AAPCS ABI
current = LinuxAArch64;
ABI = LinuxAArch64;
}
} else if (arch.startsWith("ppc64")) {
if (os.startsWith("Linux")) {
current = SysVPPC64le;
} else if (ARCH.startsWith("ppc64")) {
if (OS.startsWith("Linux")) {
ABI = SysVPPC64le;
} else {
current = AIX;
ABI = AIX;
}
} else if (arch.equals("s390x") && os.startsWith("Linux")) {
current = SysVS390x;
} else {
throw new UnsupportedOperationException(
"Unsupported os, arch, or address size: " + os + ", " + arch + ", " + addressSize);
} else if (ARCH.equals("s390x") && OS.startsWith("Linux")) {
ABI = SysVS390x;
} else {
// unsupported
ABI = null;
}
}

public static CABI current() {
return current;
if (ABI == null) {
throw new UnsupportedOperationException(
"Unsupported os, arch, or address size: " + OS + ", " + ARCH + ", " + ADDRESS_SIZE);
}
return ABI;
}
}
20 changes: 1 addition & 19 deletions src/java.base/share/classes/jdk/internal/foreign/LayoutPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@
* questions.
*
*/

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

package jdk.internal.foreign;

import jdk.internal.vm.annotation.ForceInline;
Expand All @@ -47,8 +40,6 @@
import java.util.Objects;
import java.util.function.UnaryOperator;

import sun.security.action.GetPropertyAction;

/**
* This class provide support for constructing layout paths; that is, starting from a root path (see {@link #rootPath(MemoryLayout)},
* a path can be constructed by selecting layout elements using the selector methods provided by this class
Expand All @@ -61,7 +52,6 @@ public class LayoutPath {

private static final MethodHandle MH_ADD_SCALED_OFFSET;
private static final MethodHandle MH_SLICE;
private static final boolean isAixOS = GetPropertyAction.privilegedGetProperty("os.name").startsWith("AIX") ? true : false;

static {
try {
Expand Down Expand Up @@ -153,15 +143,7 @@ public VarHandle dereferenceHandle() {
if (!(layout instanceof ValueLayout valueLayout)) {
throw new IllegalArgumentException("Path does not select a value layout");
}

/* Ignore the alignement check for float/double on AIX/PPC to handle the case of [float/int, double]
* given the size of [float/int, double] on AIX/PPC 64-bit is 12 bytes without padding while the
* same struct is 16 bytes with padding on other platforms
*/
Class<?> javaType = valueLayout.carrier();
if (!isAixOS || ((javaType != float.class) && (javaType != double.class))) {
checkAlignment(this);
}
checkAlignment(this);

VarHandle handle = Utils.makeSegmentViewVarHandle(valueLayout);
for (int i = strides.length - 1; i >= 0; i--) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@
import java.lang.foreign.ValueLayout;

public class PlatformLayouts {
public static <Z extends MemoryLayout> Z pick(Z sysv, Z win64, Z aarch64, Z sysvppc64le, Z sysvs390x, Z aix) {
return switch (CABI.current()) {
case SysV -> sysv;
case Win64 -> win64;
case LinuxAArch64, MacOsAArch64 -> aarch64;
case SysVPPC64le -> sysvppc64le;
case SysVS390x -> sysvs390x;
case AIX -> aix;
};
}

/**
* This class defines layout constants modelling standard primitive types supported by the x64 SystemV ABI.
Expand Down Expand Up @@ -379,7 +369,7 @@ private AIX() {
/**
* The {@code long long} native type.
*/
public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG.withBitAlignment(64);
public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG.withBitAlignment(32);

/**
* The {@code float} native type.
Expand All @@ -389,12 +379,12 @@ private AIX() {
/**
* The {@code double} native type.
*/
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE.withBitAlignment(64);
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE.withBitAlignment(32);

/**
* The {@code T*} native type.
*/
public static final ValueLayout.OfAddress C_POINTER = ValueLayout.ADDRESS.withBitAlignment(64);
public static final ValueLayout.OfAddress C_POINTER = ValueLayout.ADDRESS.withBitAlignment(32);

/**
* The {@code va_list} native type, as it is passed to a function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import jdk.internal.loader.NativeLibrary;
import jdk.internal.loader.NativeLibraries;
import jdk.internal.loader.NativeLibrary;
import jdk.internal.loader.RawNativeLibraries;
import sun.security.action.GetPropertyAction;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* ===========================================================================
*/


package jdk.internal.foreign.abi.x64.windows;

import jdk.internal.foreign.Utils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* questions.
*/


/*
* ===========================================================================
* (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved
Expand Down
10 changes: 5 additions & 5 deletions src/java.base/share/native/libjava/NativeLibraries.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Java_jdk_internal_loader_NativeLibraries_findBuiltinLib
return NULL;
}

#ifdef _AIX
#if defined(_AIX)
/*
* Class: jdk_internal_loader_NativeLibraries
* Method: findEntryInProcess
Expand All @@ -318,20 +318,20 @@ JNIEXPORT jlong JNICALL
Java_jdk_internal_loader_NativeLibraries_findEntryInProcess
(JNIEnv *env, jclass cls, jstring name)
{
const char *cname;
jlong res;
const char *cname = NULL;
jlong res = 0;

if (!initIDs(env)) {
return jlong_zero;
}

cname = (*env)->GetStringUTFChars(env, name, 0);
if (0 == cname) {
if (NULL == cname) {
return jlong_zero;
}

res = ptr_to_jlong(findEntryInProcess(cname));
(*env)->ReleaseStringUTFChars(env, name, cname);
return res;
}
#endif /* _AIX */
#endif /* defined(_AIX) */
6 changes: 3 additions & 3 deletions src/java.base/share/native/libjava/jni_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ void* getProcessHandle();
void buildJniFunctionName(const char *sym, const char *cname,
char *jniEntryName);

#ifdef _AIX
void* findEntryInProcess(const char* name);
#endif /* _AIX */
#if defined(_AIX)
void *findEntryInProcess(const char *name);
#endif /* defined(_AIX) */

JNIEXPORT size_t JNICALL
getLastErrorString(char *buf, size_t len);
Expand Down
7 changes: 4 additions & 3 deletions src/java.base/unix/native/libjava/jni_util_md.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ void buildJniFunctionName(const char *sym, const char *cname,
}
}

#ifdef _AIX
void* findEntryInProcess(const char* name) {
#if defined(_AIX)
void *findEntryInProcess(const char *name)
{
return JVM_FindLibraryEntry(RTLD_DEFAULT, name);
}
#endif /* _AIX */
#endif /* defined(_AIX) */

JNIEXPORT size_t JNICALL
getLastErrorString(char *buf, size_t len)
Expand Down
14 changes: 11 additions & 3 deletions test/jdk/java/foreign/NativeTestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
*
*/

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

import java.lang.foreign.Addressable;
import java.lang.foreign.FunctionDescriptor;
import java.lang.foreign.Linker;
Expand All @@ -34,6 +40,8 @@

public class NativeTestHelper {

private static final boolean isAixOS = System.getProperty("os.name").startsWith("AIX");

public static boolean isIntegral(MemoryLayout layout) {
return layout instanceof ValueLayout valueLayout && isIntegral(valueLayout.carrier());
}
Expand Down Expand Up @@ -69,19 +77,19 @@ public static boolean isPointer(MemoryLayout layout) {
/**
* The layout for the {@code long long} C type.
*/
public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG.withBitAlignment(64);
public static final ValueLayout.OfLong C_LONG_LONG = ValueLayout.JAVA_LONG.withBitAlignment(isAixOS ? 32 : 64);
/**
* The layout for the {@code float} C type
*/
public static final ValueLayout.OfFloat C_FLOAT = ValueLayout.JAVA_FLOAT.withBitAlignment(32);
/**
* The layout for the {@code double} C type
*/
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE.withBitAlignment(64);
public static final ValueLayout.OfDouble C_DOUBLE = ValueLayout.JAVA_DOUBLE.withBitAlignment(isAixOS ? 32 : 64);
/**
* The {@code T*} native type.
*/
public static final ValueLayout.OfAddress C_POINTER = ValueLayout.ADDRESS.withBitAlignment(64);
public static final ValueLayout.OfAddress C_POINTER = ValueLayout.ADDRESS.withBitAlignment(isAixOS ? 32 : 64);

private static Linker LINKER = Linker.nativeLinker();

Expand Down
Loading

0 comments on commit c2c80f7

Please sign in to comment.