From 1a188cf07a10acfbcbb5b9b3aef65b90dcb25906 Mon Sep 17 00:00:00 2001 From: Vivek Deshpande Date: Fri, 26 Aug 2016 12:20:09 -0700 Subject: [PATCH 1/5] 8154122: Intrinsify fused mac operations Added FMA intrinsics on x86 Reviewed-by: kvn, aph, darcy --- jdk/src/java.base/share/classes/java/lang/Math.java | 4 ++-- jdk/test/java/lang/Math/FusedMultiplyAddTests.java | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/Math.java b/jdk/src/java.base/share/classes/java/lang/Math.java index 37a9d8573c5..911267d5956 100644 --- a/jdk/src/java.base/share/classes/java/lang/Math.java +++ b/jdk/src/java.base/share/classes/java/lang/Math.java @@ -1626,7 +1626,7 @@ public final class Math { * * @since 9 */ - // @HotSpotIntrinsicCandidate + @HotSpotIntrinsicCandidate public static double fma(double a, double b, double c) { /* * Infinity and NaN arithmetic is not quite the same with two @@ -1743,7 +1743,7 @@ public final class Math { * * @since 9 */ - // @HotSpotIntrinsicCandidate + @HotSpotIntrinsicCandidate public static float fma(float a, float b, float c) { /* * Since the double format has more than twice the precision diff --git a/jdk/test/java/lang/Math/FusedMultiplyAddTests.java b/jdk/test/java/lang/Math/FusedMultiplyAddTests.java index b8ed3ab69f3..f4cd6518db0 100644 --- a/jdk/test/java/lang/Math/FusedMultiplyAddTests.java +++ b/jdk/test/java/lang/Math/FusedMultiplyAddTests.java @@ -221,6 +221,9 @@ public class FusedMultiplyAddTests { {Double.MIN_VALUE, -0.0, +0.0, +0.0}, + + {1.0+Math.ulp(1.0), 1.0+Math.ulp(1.0), -1.0-2.0*Math.ulp(1.0), + Math.ulp(1.0)*Math.ulp(1.0)}, }; for (double[] testCase: testCases) @@ -344,6 +347,9 @@ public class FusedMultiplyAddTests { {Float.MAX_VALUE, 2.0f, 1.0f, InfinityF}, + + {1.0f+Math.ulp(1.0f), 1.0f+Math.ulp(1.0f), -1.0f-2.0f*Math.ulp(1.0f), + Math.ulp(1.0f)*Math.ulp(1.0f)}, }; for (float[] testCase: testCases) From b339daff4b0f9b728c6a3201a1b4526efac3b357 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Tue, 20 Sep 2016 10:37:32 -0700 Subject: [PATCH 2/5] 8164011: --patch-module support for CDS Exports the ZIP_FreeEntry function Reviewed-by: iklam, dcubed, lfoltan --- jdk/make/lib/CoreLibraries.gmk | 2 +- jdk/make/mapfiles/libzip/mapfile-vers | 3 ++- jdk/src/java.base/share/native/libzip/zip_util.c | 2 +- jdk/src/java.base/share/native/libzip/zip_util.h | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/jdk/make/lib/CoreLibraries.gmk b/jdk/make/lib/CoreLibraries.gmk index bfe94de4d6a..bec09c78db1 100644 --- a/jdk/make/lib/CoreLibraries.gmk +++ b/jdk/make/lib/CoreLibraries.gmk @@ -218,7 +218,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBZIP, \ $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_windows := -export:ZIP_Open -export:ZIP_Close -export:ZIP_FindEntry \ -export:ZIP_ReadEntry -export:ZIP_GetNextEntry \ - -export:ZIP_InflateFully -export:ZIP_CRC32, \ + -export:ZIP_InflateFully -export:ZIP_CRC32 -export:ZIP_FreeEntry, \ LIBS_unix := -ljvm -ljava $(LIBZ), \ LIBS_solaris := -lc, \ LIBS_windows := jvm.lib $(WIN_JAVA_LIB), \ diff --git a/jdk/make/mapfiles/libzip/mapfile-vers b/jdk/make/mapfiles/libzip/mapfile-vers index c1ab48c10cf..d711d8e17f4 100644 --- a/jdk/make/mapfiles/libzip/mapfile-vers +++ b/jdk/make/mapfiles/libzip/mapfile-vers @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 2016, 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 @@ -49,6 +49,7 @@ SUNWprivate_1.1 { Java_java_util_zip_Inflater_setDictionary; ZIP_Close; ZIP_CRC32; + ZIP_FreeEntry; ZIP_FindEntry; ZIP_GetEntry; ZIP_GetNextEntry; diff --git a/jdk/src/java.base/share/native/libzip/zip_util.c b/jdk/src/java.base/share/native/libzip/zip_util.c index 01c7f05ef59..f6064a469ab 100644 --- a/jdk/src/java.base/share/native/libzip/zip_util.c +++ b/jdk/src/java.base/share/native/libzip/zip_util.c @@ -1094,7 +1094,7 @@ newEntry(jzfile *zip, jzcell *zc, AccessHint accessHint) * jzentry for each zip. This optimizes a common access pattern. */ -void +void JNICALL ZIP_FreeEntry(jzfile *jz, jzentry *ze) { jzentry *last; diff --git a/jdk/src/java.base/share/native/libzip/zip_util.h b/jdk/src/java.base/share/native/libzip/zip_util.h index 1f5f3bd6cab..de6b197bb00 100644 --- a/jdk/src/java.base/share/native/libzip/zip_util.h +++ b/jdk/src/java.base/share/native/libzip/zip_util.h @@ -270,7 +270,8 @@ jzentry * ZIP_GetEntry(jzfile *zip, char *name, jint ulen); void ZIP_Lock(jzfile *zip); void ZIP_Unlock(jzfile *zip); jint ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len); -void ZIP_FreeEntry(jzfile *zip, jzentry *ze); +void JNICALL +ZIP_FreeEntry(jzfile *zip, jzentry *ze); jlong ZIP_GetEntryDataOffset(jzfile *zip, jzentry *entry); jzentry * ZIP_GetEntry2(jzfile *zip, char *name, jint ulen, jboolean addSlash); From 89744d775f9a591246388f128261a38aca38fd20 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Wed, 21 Sep 2016 08:10:48 -0400 Subject: [PATCH 3/5] 8160987: JDWP ClassType.InvokeMethod doesn't validate class Add code to validate class in JDWP instead of relying on JNI to do the check. Reviewed-by: dholmes, dcubed, sspitsyn, dsamersoff --- .../share/native/libjdwp/invoker.c | 38 ++++++++++++++++++- .../com/sun/jdi/InterfaceMethodsTest.java | 30 +++++++++------ 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c index c6078a79d78..c048c759d19 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c +++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, 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 @@ -343,6 +343,35 @@ invoker_enableInvokeRequests(jthread thread) debugMonitorExit(invokerLock); } +/* + * Check that method is in the specified clazz or one of its super classes. + * We have to enforce this check at the JDWP layer because the JNI layer + * has different requirements. + */ +static jvmtiError check_methodClass(JNIEnv *env, jclass clazz, jmethodID method) +{ + jclass containing_class = NULL; + jvmtiError error; + + error = JVMTI_FUNC_PTR(gdata->jvmti,GetMethodDeclaringClass) + (gdata->jvmti, method, &containing_class); + if (error != JVMTI_ERROR_NONE) { + return JVMTI_ERROR_NONE; /* Bad jmethodID ? This will be handled elsewhere */ + } + + if (JNI_FUNC_PTR(env,IsSameObject)(env, clazz, containing_class)) { + return JVMTI_ERROR_NONE; + } + + // If not the same class then check that containing_class is a superclass of + // clazz (not a superinterface). + if (JNI_FUNC_PTR(env,IsAssignableFrom)(env, clazz, containing_class) && + referenceTypeTag(containing_class) != JDWP_TYPE_TAG(INTERFACE)) { + return JVMTI_ERROR_NONE; + } + return JVMTI_ERROR_INVALID_METHODID; +} + jvmtiError invoker_requestInvoke(jbyte invokeType, jbyte options, jint id, jthread thread, jclass clazz, jmethodID method, @@ -353,6 +382,13 @@ invoker_requestInvoke(jbyte invokeType, jbyte options, jint id, InvokeRequest *request; jvmtiError error = JVMTI_ERROR_NONE; + if (invokeType == INVOKE_STATIC) { + error = check_methodClass(env, clazz, method); + if (error != JVMTI_ERROR_NONE) { + return error; + } + } + debugMonitorEnter(invokerLock); request = threadControl_getInvokeRequest(thread); if (request != NULL) { diff --git a/jdk/test/com/sun/jdi/InterfaceMethodsTest.java b/jdk/test/com/sun/jdi/InterfaceMethodsTest.java index 3ff435fe35e..73a05dbf98e 100644 --- a/jdk/test/com/sun/jdi/InterfaceMethodsTest.java +++ b/jdk/test/com/sun/jdi/InterfaceMethodsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -197,14 +197,18 @@ public class InterfaceMethodsTest extends TestScaffold { // invoke interface static method A testInvokePos(ifaceClass, null, "staticMethodA", "()I", vm().mirrorOf(RESULT_A)); - // try to invoke static method A on the instance - testInvokePos(ifaceClass, ref, "staticMethodA", "()I", vm().mirrorOf(RESULT_A)); + // invoking static method A on the instance fails because static method A is + // not inherited by TargetClass. + testInvokeNeg(ifaceClass, ref, "staticMethodA", "()I", vm().mirrorOf(RESULT_A), + "Invalid MethodID"); // invoke interface static method B testInvokePos(ifaceClass, null, "staticMethodB", "()I", vm().mirrorOf(RESULT_A)); - // try to invoke static method B on the instance - testInvokePos(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_A)); + // invoking static method B on the instance fails because static method B is + // not inherited by TargetClass. + testInvokeNeg(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_A), + "Invalid MethodID"); // try to invoke a virtual method testInvokePos(ifaceClass, ref, "implementedMethod", "()I", vm().mirrorOf(RESULT_A), true); @@ -239,21 +243,25 @@ public class InterfaceMethodsTest extends TestScaffold { testInvokeNeg(ifaceClass, null, "staticMethodA", "()I", vm().mirrorOf(RESULT_A), "Static interface methods are not inheritable"); - // however it is possible to call "staticMethodA" on the actual instance + // "staticMethodA" is not inherited by InterfaceB even from an actual instance testInvokeNeg(ifaceClass, ref, "staticMethodA", "()I", vm().mirrorOf(RESULT_A), "Static interface methods are not inheritable"); - // "staticMethodB" is overridden in InterfaceB + // "staticMethodB" is re-defined in InterfaceB testInvokePos(ifaceClass, null, "staticMethodB", "()I", vm().mirrorOf(RESULT_B)); - // the instance invokes the overriden form of "staticMethodB" from InterfaceB - testInvokePos(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_B)); + // the instance fails to invoke the re-defined form of "staticMethodB" from + // InterfaceB because staticMethodB is not inherited by TargetClass + testInvokeNeg(ifaceClass, ref, "staticMethodB", "()I", vm().mirrorOf(RESULT_B), + "Invalid MethodID"); // "staticMethodC" is present only in InterfaceB testInvokePos(ifaceClass, null, "staticMethodC", "()I", vm().mirrorOf(RESULT_B)); - // "staticMethodC" should be reachable from the instance too - testInvokePos(ifaceClass, ref, "staticMethodC", "()I", vm().mirrorOf(RESULT_B)); + // "staticMethodC" is not reachable from the instance because staticMethodC + // is not inherited by TargetClass. + testInvokeNeg(ifaceClass, ref, "staticMethodC", "()I", vm().mirrorOf(RESULT_B), + "Invalid MethodID"); } private void testImplementationClass(ReferenceType targetClass, ObjectReference thisObject) { From 7f563f156702725e6802df8c6f372377bbd5266f Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Wed, 21 Sep 2016 12:53:07 -0700 Subject: [PATCH 4/5] 8161225: Assert failure in JVMTI GetNamedModule at JPLISAgent.c line: 792 Made the assert less restrictive. Reviewed-by: dholmes, dcubed, sspitsyn --- .../java.instrument/share/native/libinstrument/JPLISAgent.c | 3 ++- jdk/test/ProblemList.txt | 2 -- .../lang/instrument/DaemonThread/TestDaemonThreadLauncher.java | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c index 12f2a451e49..fa1341f414b 100644 --- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c +++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c @@ -790,9 +790,10 @@ getModuleObject(jvmtiEnv* jvmti, pkg_name_buf[len] = '\0'; err = (*jvmti)->GetNamedModule(jvmti, loaderObject, pkg_name_buf, &moduleObject); + free((void*)pkg_name_buf); + check_phase_ret_blob(err, NULL); jplis_assert_msg(err == JVMTI_ERROR_NONE, "error in the JVMTI GetNamedModule"); - free((void*)pkg_name_buf); return moduleObject; } diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index f2e96cacf20..04b610714bb 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -134,8 +134,6 @@ java/lang/instrument/RetransformBigClass.sh 8065756 generic- java/lang/instrument/BootClassPath/BootClassPathTest.sh 8072130 macosx-all -java/lang/instrument/DaemonThread/TestDaemonThread.java 8161225 generic-all - java/lang/management/MemoryMXBean/Pending.java 8158837 generic-all java/lang/management/MemoryMXBean/PendingAllGC.sh 8158760 generic-all diff --git a/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java b/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java index 419cfb3bbbd..579db8d6e75 100644 --- a/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java +++ b/jdk/test/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java @@ -1,6 +1,6 @@ /* * Copyright 2014 Goldman Sachs. - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -32,6 +32,7 @@ public class TestDaemonThreadLauncher { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-javaagent:DummyAgent.jar", "TestDaemonThread", "."); OutputAnalyzer analyzer = ProcessTools.executeProcess(pb); analyzer.shouldNotContain("ASSERTION FAILED"); + analyzer.shouldHaveExitValue(0); } } } From 644dc8b4e97257ebb3bb6655eca02c671ed43af7 Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Wed, 28 Sep 2016 08:22:54 -0700 Subject: [PATCH 5/5] 8166045: jdk/internal/misc/Unsafe tests fail due to timeout Only run the memory hungry tests on large machines Reviewed-by: dholmes, ctornqvi --- .../jdk/internal/misc/Unsafe/CopyMemory.java | 2 - .../internal/misc/Unsafe/CopyMemoryLarge.java | 58 +++++++++++++++++++ .../jdk/internal/misc/Unsafe/CopySwap.java | 2 - .../internal/misc/Unsafe/CopySwapLarge.java | 58 +++++++++++++++++++ 4 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 jdk/test/jdk/internal/misc/Unsafe/CopyMemoryLarge.java create mode 100644 jdk/test/jdk/internal/misc/Unsafe/CopySwapLarge.java diff --git a/jdk/test/jdk/internal/misc/Unsafe/CopyMemory.java b/jdk/test/jdk/internal/misc/Unsafe/CopyMemory.java index d4879e603f1..12362d387fd 100644 --- a/jdk/test/jdk/internal/misc/Unsafe/CopyMemory.java +++ b/jdk/test/jdk/internal/misc/Unsafe/CopyMemory.java @@ -22,7 +22,6 @@ */ import jdk.internal.misc.Unsafe; -import java.lang.reflect.Field; /* * @test @@ -40,7 +39,6 @@ public class CopyMemory extends CopyCommon { */ private void testPositive() { testSmallCopy(false); - testLargeCopy(false); } /** diff --git a/jdk/test/jdk/internal/misc/Unsafe/CopyMemoryLarge.java b/jdk/test/jdk/internal/misc/Unsafe/CopyMemoryLarge.java new file mode 100644 index 00000000000..e8c6f0d76ef --- /dev/null +++ b/jdk/test/jdk/internal/misc/Unsafe/CopyMemoryLarge.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +import jdk.internal.misc.Unsafe; + +/* + * @test + * @summary Test Unsafe.copyMemory + * @modules java.base/jdk.internal.misc + * @requires os.maxMemory > 8G + */ +public class CopyMemoryLarge extends CopyCommon { + private CopyMemoryLarge() { + } + + /** + * Run positive tests + * + * @throws RuntimeException if an error is found + */ + private void testPositive() { + testLargeCopy(false); + } + + /** + * Run all tests + * + * @throws RuntimeException if an error is found + */ + private void test() { + testPositive(); + } + + public static void main(String[] args) { + CopyMemoryLarge cs = new CopyMemoryLarge(); + cs.test(); + } +} diff --git a/jdk/test/jdk/internal/misc/Unsafe/CopySwap.java b/jdk/test/jdk/internal/misc/Unsafe/CopySwap.java index 4cbd8b709d2..99371f01142 100644 --- a/jdk/test/jdk/internal/misc/Unsafe/CopySwap.java +++ b/jdk/test/jdk/internal/misc/Unsafe/CopySwap.java @@ -22,7 +22,6 @@ */ import jdk.internal.misc.Unsafe; -import java.lang.reflect.Field; /* * @test @@ -40,7 +39,6 @@ public class CopySwap extends CopyCommon { */ private void testPositive() { testSmallCopy(true); - testLargeCopy(true); } /** diff --git a/jdk/test/jdk/internal/misc/Unsafe/CopySwapLarge.java b/jdk/test/jdk/internal/misc/Unsafe/CopySwapLarge.java new file mode 100644 index 00000000000..818a35367f3 --- /dev/null +++ b/jdk/test/jdk/internal/misc/Unsafe/CopySwapLarge.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016, 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. + * + * 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. + */ + +import jdk.internal.misc.Unsafe; + +/* + * @test + * @summary Test Unsafe.copySwapMemory + * @modules java.base/jdk.internal.misc + * @requires os.maxMemory > 8G + */ +public class CopySwapLarge extends CopyCommon { + private CopySwapLarge() { + } + + /** + * Run positive tests + * + * @throws RuntimeException if an error is found + */ + private void testPositive() { + testLargeCopy(true); + } + + /** + * Run all tests + * + * @throws RuntimeException if an error is found + */ + private void test() { + testPositive(); + } + + public static void main(String[] args) { + CopySwapLarge cs = new CopySwapLarge(); + cs.test(); + } +}