OpenJDK / jdk / hs
changeset 42678:9873beb737e9
Merge
author | jwilhelm |
---|---|
date | Wed, 09 Nov 2016 13:37:19 +0100 |
parents | d2c15c981e72 12edcce2cb80 |
children | 25fec8839946 |
files | hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EmptyEventProvider.java hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EventProvider.java hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotJVMCICompilerFactory.java hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/services/JVMCICompilerFactory.java hotspot/src/share/vm/logging/log.cpp hotspot/src/share/vm/utilities/resourceHash.cpp hotspot/test/compiler/floatingpoint/Test15FloatJNIArgs.java hotspot/test/compiler/floatingpoint/libTest15FloatJNIArgs.c hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.hotspot.services.HotSpotVMEventListener hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.JVMCICompiler hotspot/test/compiler/jvmci/common/services/jdk.vm.ci.runtime.services.JVMCICompilerFactory jdk/make/GenerateClasslist.gmk jdk/src/java.base/share/classes/jdk/internal/module/ConfigurableModuleFinder.java jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java jdk/src/java.base/share/classes/sun/util/locale/provider/DictionaryBasedBreakIterator.java jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java jdk/src/java.base/share/native/include/jvmti.h jdk/src/java.base/share/native/libjava/StackFrameInfo.c jdk/src/java.base/windows/native/libnet/icmp.h jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSPrintInfo.java jdk/src/java.desktop/share/classes/com/sun/media/sound/SunCodec.java jdk/test/ProblemList.txt jdk/test/java/awt/Modal/InvisibleParentTest/InvisibleParentTest.html jdk/test/java/lang/module/ModuleReader/MultiReleaseJarTest.java jdk/test/java/net/URLPermission/nstest/lookup.sh jdk/test/java/util/ResourceBundle/modules/basic/src/asiabundles/jdk/test/resources/MyResources_ja_JP.properties jdk/test/java/util/stream/bootlib/java.base/java/util/stream/ThowableHelper.java jdk/test/sun/reflect/ReflectionFactory/NewConstructorForSerialization.java jdk/test/sun/security/tools/keytool/readjar.sh langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/EditPad.java langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ExternalEditor.java langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIDefaultExecutionControl.java langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIEventHandler.java langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIExecutionControl.java langtools/src/jdk.jshell/share/classes/jdk/jshell/execution/JDIInitiator.java langtools/test/jdk/jshell/EditorPadTest.java langtools/test/jdk/jshell/JDILaunchingExecutionControlTest.java langtools/test/jdk/jshell/JDIListeningExecutionControlTest.java langtools/test/jdk/jshell/JDIListeningLocalhostExecutionControlTest.java langtools/test/jdk/jshell/UserJDIUserRemoteTest.java langtools/test/tools/javac/T8029102/WarnSerializableLambdaTest.java langtools/test/tools/javac/T8029102/WarnSerializableLambdaTest.out langtools/test/tools/javac/diags/examples/CantFindModule/CantFindModule.java langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/ServiceDefinitionInner.java langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/module-info.java langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/p1/C1.java langtools/test/tools/javac/diags/examples/ServiceDefinitionInner/modulesourcepath/m/p2/C2.java langtools/test/tools/javac/diags/examples/XaddexportsMalformedEntry.java langtools/test/tools/javac/diags/examples/XaddexportsTooMany.java langtools/test/tools/javac/diags/examples/XaddreadsMalformedEntry.java langtools/test/tools/javac/diags/examples/XaddreadsTooMany.java nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/CompositeOperation.java |
diffstat | 1580 files changed, 58499 insertions(+), 22407 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Mon Nov 14 12:05:26 2016 +0530 +++ b/.hgtags Wed Nov 09 13:37:19 2016 +0100 @@ -383,3 +383,6 @@ d273dfe9a126d3bffe92072547fef2cd1361b0eb jdk-9+138 65477538bec32963dc41153d89c4417eb46c45fc jdk-9+139 0875007901f7d364a08220b052f0c81003e9c8c5 jdk-9+140 +9aadd2163b568d76f8969ad2fb404a63733da359 jdk-9+141 +df0e03e3ca0ed1307793017dfc1a054c8726131c jdk-9+142 +d62173b931bf5b6bffc6e80a9060bb2e8b8efc75 jdk-9+143
--- a/.hgtags-top-repo Mon Nov 14 12:05:26 2016 +0530 +++ b/.hgtags-top-repo Wed Nov 09 13:37:19 2016 +0100 @@ -383,3 +383,6 @@ 67c4388142bdf58aec8fefa4475faaa8a5d7380c jdk-9+138 7dcf453eacae79ee86a6bcc75fd0b546fc99b48a jdk-9+139 a5815c6098a241d3a1df64d22b84b3524e4a77df jdk-9+140 +f64afae7f1a5608e438585bbf0bc23785e69cba0 jdk-9+141 +2b3e5caafe3594ea507c37675c4d3086f415dc64 jdk-9+142 +1fc62b1c629fb80fdaa639d3b59452a184f0d705 jdk-9+143
--- a/common/autoconf/flags.m4 Mon Nov 14 12:05:26 2016 +0530 +++ b/common/autoconf/flags.m4 Wed Nov 09 13:37:19 2016 +0100 @@ -280,7 +280,7 @@ else # Default works for linux, might work on other platforms as well. SHARED_LIBRARY_FLAGS='-shared' - SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1' + SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1' SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN" SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1' SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1' @@ -305,7 +305,7 @@ # Default works for linux, might work on other platforms as well. PICFLAG='-fPIC' SHARED_LIBRARY_FLAGS='-shared' - SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1' + SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1' SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN" SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1' SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1' @@ -315,7 +315,7 @@ C_FLAG_REORDER='-xF' CXX_FLAG_REORDER='-xF' SHARED_LIBRARY_FLAGS="-G" - SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1' + SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN[$]1' SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN" SET_SHARED_LIBRARY_NAME='-h [$]1' SET_SHARED_LIBRARY_MAPFILE='-M[$]1' @@ -759,6 +759,10 @@ # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing" ;; + s390 ) + $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer -mbackchain -march=z10" + $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing" + ;; * ) $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer" $2CFLAGS_JDK="${$2CFLAGS_JDK} -fno-strict-aliasing" @@ -895,7 +899,7 @@ elif test "x$OPENJDK_$1_OS" = xsolaris; then $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSOLARIS" $2JVM_CFLAGS="[$]$2JVM_CFLAGS -template=no%extdef -features=no%split_init \ - -D_Crun_inline_placement -library=%none -KPIC -mt -xwe -features=no%except" + -D_Crun_inline_placement -library=%none -KPIC -mt -features=no%except" elif test "x$OPENJDK_$1_OS" = xmacosx; then $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" $2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_ALLBSD_SOURCE" @@ -940,6 +944,10 @@ # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI. $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mcpu=power7 -mtune=power8" fi + elif test "x$OPENJDK_$1_CPU" = xs390x; then + if test "x$OPENJDK_$1_OS" = xlinux; then + $2JVM_CFLAGS="[$]$2JVM_CFLAGS -mbackchain -march=z10" + fi fi if test "x$OPENJDK_$1_CPU_ENDIAN" = xlittle; then @@ -999,6 +1007,7 @@ # Setup some hard coded includes $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \ + -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ -I${JDK_TOPDIR}/src/java.base/share/native/include \ -I${JDK_TOPDIR}/src/java.base/$OPENJDK_$1_OS/native/include \ -I${JDK_TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/include \
--- a/common/autoconf/generated-configure.sh Mon Nov 14 12:05:26 2016 +0530 +++ b/common/autoconf/generated-configure.sh Wed Nov 09 13:37:19 2016 +0100 @@ -5093,7 +5093,7 @@ #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1476275292 +DATE_WHEN_GENERATED=1478524503 ############################################################################### # @@ -49070,7 +49070,7 @@ else # Default works for linux, might work on other platforms as well. SHARED_LIBRARY_FLAGS='-shared' - SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN$1' + SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN$1' SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN" SET_SHARED_LIBRARY_NAME='-Wl,-soname=$1' SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=$1' @@ -49095,7 +49095,7 @@ # Default works for linux, might work on other platforms as well. PICFLAG='-fPIC' SHARED_LIBRARY_FLAGS='-shared' - SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN$1' + SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN$1' SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN" SET_SHARED_LIBRARY_NAME='-Wl,-soname=$1' SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=$1' @@ -49105,7 +49105,7 @@ C_FLAG_REORDER='-xF' CXX_FLAG_REORDER='-xF' SHARED_LIBRARY_FLAGS="-G" - SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN$1' + SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN$1' SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN" SET_SHARED_LIBRARY_NAME='-h $1' SET_SHARED_LIBRARY_MAPFILE='-M$1' @@ -49840,6 +49840,10 @@ # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" ;; + s390 ) + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer -mbackchain -march=z10" + CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" + ;; * ) COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer" CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" @@ -50077,7 +50081,7 @@ elif test "x$OPENJDK_TARGET_OS" = xsolaris; then JVM_CFLAGS="$JVM_CFLAGS -DSOLARIS" JVM_CFLAGS="$JVM_CFLAGS -template=no%extdef -features=no%split_init \ - -D_Crun_inline_placement -library=%none -KPIC -mt -xwe -features=no%except" + -D_Crun_inline_placement -library=%none -KPIC -mt -features=no%except" elif test "x$OPENJDK_TARGET_OS" = xmacosx; then COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" JVM_CFLAGS="$JVM_CFLAGS -D_ALLBSD_SOURCE" @@ -50122,6 +50126,10 @@ # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI. JVM_CFLAGS="$JVM_CFLAGS -mcpu=power7 -mtune=power8" fi + elif test "x$OPENJDK_TARGET_CPU" = xs390x; then + if test "x$OPENJDK_TARGET_OS" = xlinux; then + JVM_CFLAGS="$JVM_CFLAGS -mbackchain -march=z10" + fi fi if test "x$OPENJDK_TARGET_CPU_ENDIAN" = xlittle; then @@ -50270,6 +50278,7 @@ # Setup some hard coded includes COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \ + -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ -I${JDK_TOPDIR}/src/java.base/share/native/include \ -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS/native/include \ -I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/include \ @@ -50655,6 +50664,10 @@ # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing OPENJDK_BUILD_CFLAGS_JDK="${OPENJDK_BUILD_CFLAGS_JDK} -fno-strict-aliasing" ;; + s390 ) + OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer -mbackchain -march=z10" + OPENJDK_BUILD_CFLAGS_JDK="${OPENJDK_BUILD_CFLAGS_JDK} -fno-strict-aliasing" + ;; * ) OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer" OPENJDK_BUILD_CFLAGS_JDK="${OPENJDK_BUILD_CFLAGS_JDK} -fno-strict-aliasing" @@ -50892,7 +50905,7 @@ elif test "x$OPENJDK_BUILD_OS" = xsolaris; then OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -DSOLARIS" OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -template=no%extdef -features=no%split_init \ - -D_Crun_inline_placement -library=%none -KPIC -mt -xwe -features=no%except" + -D_Crun_inline_placement -library=%none -KPIC -mt -features=no%except" elif test "x$OPENJDK_BUILD_OS" = xmacosx; then OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -D_ALLBSD_SOURCE" @@ -50937,6 +50950,10 @@ # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI. OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -mcpu=power7 -mtune=power8" fi + elif test "x$OPENJDK_BUILD_CPU" = xs390x; then + if test "x$OPENJDK_BUILD_OS" = xlinux; then + OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -mbackchain -march=z10" + fi fi if test "x$OPENJDK_BUILD_CPU_ENDIAN" = xlittle; then @@ -51085,6 +51102,7 @@ # Setup some hard coded includes OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK \ + -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ -I${JDK_TOPDIR}/src/java.base/share/native/include \ -I${JDK_TOPDIR}/src/java.base/$OPENJDK_BUILD_OS/native/include \ -I${JDK_TOPDIR}/src/java.base/$OPENJDK_BUILD_OS_TYPE/native/include \
--- a/common/autoconf/spec.gmk.in Mon Nov 14 12:05:26 2016 +0530 +++ b/common/autoconf/spec.gmk.in Wed Nov 09 13:37:19 2016 +0100 @@ -265,6 +265,10 @@ BUNDLES_OUTPUTDIR=$(BUILD_OUTPUT)/bundles TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/test-make MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/make-support + +# By default, output javadoc directly into image +JAVADOC_OUTPUTDIR = $(DOCS_IMAGE_DIR) + # This does not get overridden in a bootcycle build CONFIGURESUPPORT_OUTPUTDIR:=@CONFIGURESUPPORT_OUTPUTDIR@ BUILDJDK_OUTPUTDIR=$(BUILD_OUTPUT)/buildjdk @@ -784,11 +788,12 @@ SYMBOLS_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(SYMBOLS_IMAGE_SUBDIR) # Interim image +INTERIM_JMODS_DIR := $(SUPPORT_OUTPUTDIR)/interim-jmods INTERIM_IMAGE_DIR := $(SUPPORT_OUTPUTDIR)/interim-image # Docs image DOCS_IMAGE_SUBDIR := docs -DOCS_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(DOCS_IMAGE_SUBDIR) +DOCS_IMAGE_DIR = $(IMAGES_OUTPUTDIR)/$(DOCS_IMAGE_SUBDIR) # Macosx bundles directory definitions JDK_MACOSX_BUNDLE_SUBDIR=jdk-bundle
--- a/corba/.hgtags Mon Nov 14 12:05:26 2016 +0530 +++ b/corba/.hgtags Wed Nov 09 13:37:19 2016 +0100 @@ -383,3 +383,6 @@ 27bb44be32076861a0951bcefb07a1d92509a4b6 jdk-9+138 8c9da7fc5b07c606afd571c7012441b77dda83b2 jdk-9+139 9f3fc931bc230f44f2a58d75f7f6360af98bb113 jdk-9+140 +b32f998da32b488ec7c4e9dbb3c750841b48e74d jdk-9+141 +408c9c621938ca028e20bced0459f815de47eba8 jdk-9+142 +6211236ef15ec796806357608b1dd1b70c258ece jdk-9+143
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Mon Nov 14 12:05:26 2016 +0530 +++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Wed Nov 09 13:37:19 2016 +0100 @@ -31,22 +31,17 @@ package com.sun.corba.se.impl.io; -import java.io.InputStream; import java.io.IOException; import java.io.StreamCorruptedException; import java.io.ObjectInputValidation; import java.io.NotActiveException; import java.io.InvalidObjectException; import java.io.InvalidClassException; -import java.io.DataInputStream; import java.io.OptionalDataException; -import java.io.WriteAbortedException; import java.io.Externalizable; import java.io.EOFException; import java.lang.reflect.*; import java.util.Vector; -import java.util.Stack; -import java.util.Hashtable; import java.util.Enumeration; import sun.corba.Bridge ; @@ -54,7 +49,6 @@ import java.security.AccessController ; import java.security.PrivilegedAction ; -import com.sun.corba.se.impl.io.ObjectStreamClass; import com.sun.corba.se.impl.util.Utility; import org.omg.CORBA.portable.ValueInputStream; @@ -71,14 +65,12 @@ import com.sun.org.omg.CORBA.ValueDefPackage.FullValueDescription; import com.sun.org.omg.SendingContext.CodeBase; -import javax.rmi.PortableRemoteObject; import javax.rmi.CORBA.Util; import javax.rmi.CORBA.ValueHandler; import java.security.*; import java.util.*; -import com.sun.corba.se.impl.orbutil.ObjectUtility ; import com.sun.corba.se.impl.logging.OMGSystemException ; import com.sun.corba.se.impl.logging.UtilSystemException ; @@ -182,75 +174,6 @@ private byte streamFormatVersion; - // Since java.io.OptionalDataException's constructors are - // package private, but we need to throw it in some special - // cases, we try to do it by reflection. - private static final Constructor OPT_DATA_EXCEPTION_CTOR; - - private Object[] readObjectArgList = { this } ; - - static { - OPT_DATA_EXCEPTION_CTOR = getOptDataExceptionCtor(); - } - - // Grab the OptionalDataException boolean ctor and make - // it accessible. Note that any exceptions - // will be wrapped in ExceptionInInitializerErrors. - private static Constructor getOptDataExceptionCtor() { - - try { - - Constructor result = - - (Constructor) AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public java.lang.Object run() - throws NoSuchMethodException, - SecurityException { - - Constructor boolCtor - = OptionalDataException.class.getDeclaredConstructor( - new Class[] { - Boolean.TYPE }); - - boolCtor.setAccessible(true); - - return boolCtor; - }}); - - if (result == null) - // XXX I18N, logging needed. - throw new Error("Unable to find OptionalDataException constructor"); - - return result; - - } catch (Exception ex) { - // XXX I18N, logging needed. - throw new ExceptionInInitializerError(ex); - } - } - - // Create a new OptionalDataException with the EOF marker - // set to true. See handleOptionalDataMarshalException. - private OptionalDataException createOptionalDataException() { - try { - OptionalDataException result - = (OptionalDataException) - OPT_DATA_EXCEPTION_CTOR.newInstance(new Object[] { - Boolean.TRUE }); - - if (result == null) - // XXX I18N, logging needed. - throw new Error("Created null OptionalDataException"); - - return result; - - } catch (Exception ex) { - // XXX I18N, logging needed. - throw new Error("Couldn't create OptionalDataException", ex); - } - } - // Return the stream format version currently being used // to deserialize an object protected byte getStreamFormatVersion() { @@ -395,7 +318,6 @@ int offset) /* throws OptionalDataException, ClassNotFoundException, IOException */ { - /* Save the current state and get ready to read an object. */ Object prevObject = currentObject; ObjectStreamClass prevClassDesc = currentClassDesc; @@ -947,7 +869,7 @@ if (!objectRead) result = new EOFException("No more optional data"); else - result = createOptionalDataException(); + result = bridge.newOptionalDataExceptionForSerialization(true); result.initCause(marshalException); @@ -1230,8 +1152,7 @@ readObjectState.beginUnmarshalCustomValue(this, calledDefaultWriteObject, - (currentClassDesc.readObjectMethod - != null)); + currentClassDesc.hasReadObject()); } else { if (currentClassDesc.hasReadObject()) setState(IN_READ_OBJECT_REMOTE_NOT_CUSTOM_MARSHALED); @@ -1556,8 +1477,7 @@ readObjectState.beginUnmarshalCustomValue(this, calledDefaultWriteObject, - (currentClassDesc.readObjectMethod - != null)); + currentClassDesc.hasReadObject()); } boolean usedReadObject = false; @@ -1714,13 +1634,8 @@ throws InvalidClassException, StreamCorruptedException, ClassNotFoundException, IOException { - if (osc.readObjectMethod == null) { - return false; - } - try { - osc.readObjectMethod.invoke( obj, readObjectArgList ) ; - return true; + return osc.invokeReadObject( obj, this ) ; } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof ClassNotFoundException) @@ -1734,8 +1649,6 @@ else // XXX I18N, logging needed. throw new Error("internal error"); - } catch (IllegalAccessException e) { - return false; } }
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPOutputStream.java Mon Nov 14 12:05:26 2016 +0530 +++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/IIOPOutputStream.java Wed Nov 09 13:37:19 2016 +0100 @@ -31,33 +31,23 @@ package com.sun.corba.se.impl.io; -import org.omg.CORBA.INTERNAL; import org.omg.CORBA.portable.OutputStream; import java.security.AccessController ; import java.security.PrivilegedAction ; import java.io.IOException; -import java.io.DataOutputStream; -import java.io.Serializable; import java.io.InvalidClassException; -import java.io.StreamCorruptedException; import java.io.Externalizable; -import java.io.ObjectStreamException; import java.io.NotSerializableException; import java.io.NotActiveException; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Field; - -import java.util.Stack; import javax.rmi.CORBA.Util; -import javax.rmi.CORBA.ValueHandlerMultiFormat; import sun.corba.Bridge ; -import com.sun.corba.se.impl.io.ObjectStreamClass; import com.sun.corba.se.impl.util.Utility; import com.sun.corba.se.impl.util.RepositoryId; @@ -621,7 +611,7 @@ writeObjectState.enterWriteObject(this); // writeObject(obj, c, this); - osc.writeObjectMethod.invoke( obj, writeObjectArgList ) ; + osc.invokeWriteObject( obj, this ) ; writeObjectState.exitWriteObject(this); @@ -636,8 +626,6 @@ else // XXX I18N, Logging needed. throw new Error("invokeObjectWriter internal error",e); - } catch (IllegalAccessException e) { - // cannot happen } } @@ -761,59 +749,52 @@ */ private void outputClassFields(Object o, Class cl, ObjectStreamField[] fields) - throws IOException, InvalidClassException { + throws IOException { for (int i = 0; i < fields.length; i++) { if (fields[i].getField() == null) - // XXX I18N, Logging needed. throw new InvalidClassException(cl.getName(), "Nonexistent field " + fields[i].getName()); - - try { - switch (fields[i].getTypeCode()) { - case 'B': - byte byteValue = fields[i].getField().getByte( o ) ; - orbStream.write_octet(byteValue); - break; - case 'C': - char charValue = fields[i].getField().getChar( o ) ; - orbStream.write_wchar(charValue); - break; - case 'F': - float floatValue = fields[i].getField().getFloat( o ) ; - orbStream.write_float(floatValue); - break; - case 'D' : - double doubleValue = fields[i].getField().getDouble( o ) ; - orbStream.write_double(doubleValue); - break; - case 'I': - int intValue = fields[i].getField().getInt( o ) ; - orbStream.write_long(intValue); - break; - case 'J': - long longValue = fields[i].getField().getLong( o ) ; - orbStream.write_longlong(longValue); - break; - case 'S': - short shortValue = fields[i].getField().getShort( o ) ; - orbStream.write_short(shortValue); - break; - case 'Z': - boolean booleanValue = fields[i].getField().getBoolean( o ) ; - orbStream.write_boolean(booleanValue); - break; - case '[': - case 'L': - Object objectValue = fields[i].getField().get( o ) ; - writeObjectField(fields[i], objectValue); - break; - default: - // XXX I18N, Logging needed. - throw new InvalidClassException(cl.getName()); - } - } catch (IllegalAccessException exc) { - throw wrapper.illegalFieldAccess( exc, fields[i].getName() ) ; + switch (fields[i].getTypeCode()) { + case 'B': + byte byteValue = bridge.getByte(o, fields[i].getFieldID()) ; + orbStream.write_octet(byteValue); + break; + case 'C': + char charValue = bridge.getChar(o, fields[i].getFieldID()) ; + orbStream.write_wchar(charValue); + break; + case 'F': + float floatValue = bridge.getFloat(o, fields[i].getFieldID()) ; + orbStream.write_float(floatValue); + break; + case 'D' : + double doubleValue = bridge.getDouble(o, fields[i].getFieldID()) ; + orbStream.write_double(doubleValue); + break; + case 'I': + int intValue = bridge.getInt(o, fields[i].getFieldID()) ; + orbStream.write_long(intValue); + break; + case 'J': + long longValue = bridge.getLong(o, fields[i].getFieldID()) ; + orbStream.write_longlong(longValue); + break; + case 'S': + short shortValue = bridge.getShort(o, fields[i].getFieldID()) ; + orbStream.write_short(shortValue); + break; + case 'Z': + boolean booleanValue = bridge.getBoolean(o, fields[i].getFieldID()) ; + orbStream.write_boolean(booleanValue); + break; + case '[': + case 'L': + Object objectValue = bridge.getObject(o, fields[i].getFieldID()) ; + writeObjectField(fields[i], objectValue); + break; + default: + throw new InvalidClassException(cl.getName()); } } }
--- a/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java Mon Nov 14 12:05:26 2016 +0530 +++ b/corba/src/java.corba/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java Wed Nov 09 13:37:19 2016 +0100 @@ -31,16 +31,16 @@ package com.sun.corba.se.impl.io; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.lang.invoke.MethodHandle; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.DigestOutputStream; import java.security.AccessController; -import java.security.PrivilegedExceptionAction; -import java.security.PrivilegedActionException; import java.security.PrivilegedAction; import java.lang.reflect.Modifier; -import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Member; import java.lang.reflect.Method; @@ -80,9 +80,6 @@ public static final long kDefaultUID = -1; - private static Object noArgsList[] = {}; - private static Class<?> noTypesList[] = {}; - /** true if represents enum type */ private boolean isEnum; @@ -311,12 +308,37 @@ return null; } + public final boolean invokeWriteObject(Object obj, ObjectOutputStream ois) throws InvocationTargetException { + if (!hasWriteObject()) { + return false; + } + try { + writeObjectMethod.invoke(obj, ois); + } catch (Throwable t) { + throw new InvocationTargetException(t, "writeObject"); + } + return true; + } + + public final boolean invokeReadObject(Object obj, ObjectInputStream ois) throws InvocationTargetException { + if (hasReadObject()) { + try { + readObjectMethod.invoke(obj, ois); + return true; + } catch (Throwable t) { + throw new InvocationTargetException(t, "readObject"); + } + } else { + return false; + } + } + public Serializable writeReplace(Serializable value) { if (writeReplaceObjectMethod != null) { try { - return (Serializable) writeReplaceObjectMethod.invoke(value,noArgsList); - } catch(Throwable t) { - throw new RuntimeException(t); + return (Serializable) writeReplaceObjectMethod.invoke(value); + } catch (Throwable t) { + throw new InternalError("unexpected error", t); } } else return value; @@ -325,9 +347,9 @@ public Object readResolve(Object value) { if (readResolveObjectMethod != null) { try { - return readResolveObjectMethod.invoke(value,noArgsList); - } catch(Throwable t) { - throw new RuntimeException(t); + return readResolveObjectMethod.invoke(value); + } catch (Throwable t) { + throw new InternalError("unexpected error", t); } } else return value; @@ -382,31 +404,34 @@ */ } - private static final class PersistentFieldsValue + static final class PersistentFieldsValue extends ClassValue<ObjectStreamField[]> { PersistentFieldsValue() { } protected ObjectStreamField[] computeValue(Class<?> type) { try { + bridge.ensureClassInitialized(type); Field pf = type.getDeclaredField("serialPersistentFields"); int mods = pf.getModifiers(); if (Modifier.isPrivate(mods) && Modifier.isStatic(mods) && Modifier.isFinal(mods)) { - pf.setAccessible(true); + long offset = bridge.staticFieldOffset(pf); java.io.ObjectStreamField[] fields = - (java.io.ObjectStreamField[])pf.get(type); + (java.io.ObjectStreamField[])bridge.getObject(type, offset); return translateFields(fields); } - } catch (NoSuchFieldException | IllegalAccessException | + } catch (NoSuchFieldException | IllegalArgumentException | ClassCastException e) { } return null; } - private static ObjectStreamField[] translateFields( - java.io.ObjectStreamField[] fields) { + private static ObjectStreamField[] translateFields(java.io.ObjectStreamField[] fields) { + if (fields == null) { + return null; + } ObjectStreamField[] translation = - new ObjectStreamField[fields.length]; + new ObjectStreamField[fields.length]; for (int i = 0; i < fields.length; i++) { translation[i] = new ObjectStreamField(fields[i].getName(), fields[i].getType()); @@ -450,13 +475,11 @@ * If it is declared, use the declared serialPersistentFields. * Otherwise, extract the fields from the class itself. */ - fields = persistentFieldsValue.get(cl); + fields = persistentFieldsValue.get(cl); if (fields == null) { - /* Get all of the declared fields for this - * Class. setAccessible on all fields so they - * can be accessed later. Create a temporary - * ObjectStreamField array to hold each + /* Get all of the declared fields for this Class. + * Create a temporary ObjectStreamField array to hold each * non-static, non-transient field. Then copy the * temporary array into an array of the correct * size once the number of fields is known. @@ -471,7 +494,6 @@ int modifiers = fld.getModifiers(); if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)) { - fld.setAccessible(true) ; tempFields[numFields++] = new ObjectStreamField(fld); } } @@ -487,7 +509,6 @@ try { Field reflField = cl.getDeclaredField(fields[j].getName()); if (fields[j].getType() == reflField.getType()) { - reflField.setAccessible(true); fields[j].setField(reflField); } } catch (NoSuchFieldException e) { @@ -527,8 +548,8 @@ int mods = f.getModifiers(); // SerialBug 5: static final SUID should be read if (Modifier.isStatic(mods) && Modifier.isFinal(mods) ) { - f.setAccessible(true); - suid = f.getLong(cl); + long offset = bridge.staticFieldOffset(f); + suid = bridge.getLong(cl, offset); // SerialBug 2: should be computed after writeObject // actualSuid = computeStructuralUID(cl); } else { @@ -540,16 +561,12 @@ suid = _computeSerialVersionUID(cl); // SerialBug 2: should be computed after writeObject // actualSuid = computeStructuralUID(cl); - } catch (IllegalAccessException ex) { - suid = _computeSerialVersionUID(cl); } } - writeReplaceObjectMethod = ObjectStreamClass.getInheritableMethod(cl, - "writeReplace", noTypesList, Object.class); + writeReplaceObjectMethod = bridge.writeReplaceForSerialization(cl); - readResolveObjectMethod = ObjectStreamClass.getInheritableMethod(cl, - "readResolve", noTypesList, Object.class); + readResolveObjectMethod = bridge.readResolveForSerialization(cl); if (externalizable) cons = getExternalizableConstructor(cl) ; @@ -557,14 +574,8 @@ cons = getSerializableConstructor(cl) ; if (serializable && !forProxyClass) { - /* Look for the writeObject method - * Set the accessible flag on it here. ObjectOutputStream - * will call it as necessary. - */ - writeObjectMethod = getPrivateMethod( cl, "writeObject", - new Class<?>[] { java.io.ObjectOutputStream.class }, Void.TYPE ) ; - readObjectMethod = getPrivateMethod( cl, "readObject", - new Class<?>[] { java.io.ObjectInputStream.class }, Void.TYPE ) ; + writeObjectMethod = bridge.writeObjectForSerialization(cl) ; + readObjectMethod = bridge.readObjectForSerialization(cl); } return null; } @@ -585,27 +596,6 @@ } } - /** - * Returns non-static private method with given signature defined by given - * class, or null if none found. Access checks are disabled on the - * returned method (if any). - */ - private static Method getPrivateMethod(Class<?> cl, String name, - Class<?>[] argTypes, - Class<?> returnType) - { - try { - Method meth = cl.getDeclaredMethod(name, argTypes); - meth.setAccessible(true); - int mods = meth.getModifiers(); - return ((meth.getReturnType() == returnType) && - ((mods & Modifier.STATIC) == 0) && - ((mods & Modifier.PRIVATE) != 0)) ? meth : null; - } catch (NoSuchMethodException ex) { - return null; - } - } - // Specific to RMI-IIOP /** * Java to IDL ptc-02-01-12 1.5.1 @@ -849,6 +839,22 @@ } /** + * Returns true if represented class is serializable or externalizable and + * defines a conformant writeReplace method. Otherwise, returns false. + */ + boolean hasWriteReplaceMethod() { + return (writeReplaceObjectMethod != null); + } + + /** + * Returns true if represented class is serializable or externalizable and + * defines a conformant readResolve method. Otherwise, returns false. + */ + boolean hasReadResolveMethod() { + return (readResolveObjectMethod != null); + } + + /** * Returns when or not this class should be custom * marshaled (use chunking). This should happen if * it is Externalizable OR if it or @@ -904,7 +910,7 @@ { if (cons != null) { try { - return cons.newInstance(new Object[0]); + return cons.newInstance(); } catch (IllegalAccessException ex) { // should not occur, as access checks have been suppressed InternalError ie = new InternalError(); @@ -912,7 +918,7 @@ throw ie ; } } else { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException("no constructor for " + ofClass); } } @@ -921,15 +927,8 @@ * Access checks are disabled on the returned constructor (if any), since * the defining class may still be non-public. */ - private static Constructor getExternalizableConstructor(Class<?> cl) { - try { - Constructor cons = cl.getDeclaredConstructor(new Class<?>[0]); - cons.setAccessible(true); - return ((cons.getModifiers() & Modifier.PUBLIC) != 0) ? - cons : null; - } catch (NoSuchMethodException ex) { - return null; - } + private static Constructor<?> getExternalizableConstructor(Class<?> cl) { + return bridge.newConstructorForExternalization(cl); } /** @@ -937,28 +936,8 @@ * superclass, or null if none found. Access checks are disabled on the * returned constructor (if any). */ - private static Constructor getSerializableConstructor(Class<?> cl) { - Class<?> initCl = cl; - while (Serializable.class.isAssignableFrom(initCl)) { - if ((initCl = initCl.getSuperclass()) == null) { - return null; - } - } - try { - Constructor cons = initCl.getDeclaredConstructor(new Class<?>[0]); - int mods = cons.getModifiers(); - if ((mods & Modifier.PRIVATE) != 0 || - ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 && - !packageEquals(cl, initCl))) - { - return null; - } - cons = bridge.newConstructorForSerialization(cl, cons); - cons.setAccessible(true); - return cons; - } catch (NoSuchMethodException ex) { - return null; - } + private static Constructor<?> getSerializableConstructor(Class<?> cl) { + return bridge.newConstructorForSerialization(cl); } /* @@ -1522,11 +1501,11 @@ * @since JDK 1.2 */ private boolean hasExternalizableBlockData; - Method writeObjectMethod; - Method readObjectMethod; - private transient Method writeReplaceObjectMethod; - private transient Method readResolveObjectMethod; - private Constructor cons ; + private transient MethodHandle writeObjectMethod; + private transient MethodHandle readObjectMethod; + private transient MethodHandle writeReplaceObjectMethod; + private transient MethodHandle readResolveObjectMethod; + private transient Constructor<?> cons; /** * Beginning in Java to IDL ptc/02-01-12, RMI-IIOP has a @@ -1543,44 +1522,12 @@ */ private ObjectStreamClass localClassDesc; - /* Find out if the class has a static class initializer <clinit> */ - private static Method hasStaticInitializerMethod = null; /** * Returns true if the given class defines a static initializer method, * false otherwise. */ private static boolean hasStaticInitializer(Class<?> cl) { - if (hasStaticInitializerMethod == null) { - Class<?> classWithThisMethod = null; - - try { - if (classWithThisMethod == null) - classWithThisMethod = java.io.ObjectStreamClass.class; - - hasStaticInitializerMethod = - classWithThisMethod.getDeclaredMethod("hasStaticInitializer", - new Class<?>[] { Class.class }); - } catch (NoSuchMethodException ex) { - } - - if (hasStaticInitializerMethod == null) { - // XXX I18N, logging needed - throw new InternalError("Can't find hasStaticInitializer method on " - + classWithThisMethod.getName()); - } - hasStaticInitializerMethod.setAccessible(true); - } - - try { - Boolean retval = (Boolean) - hasStaticInitializerMethod.invoke(null, new Object[] { cl }); - return retval.booleanValue(); - } catch (Exception ex) { - // XXX I18N, logging needed - InternalError ie = new InternalError( "Error invoking hasStaticInitializer" ) ; - ie.initCause( ex ) ; - throw ie ; - } + return bridge.hasStaticInitializerForSerialization(cl); } @@ -1754,7 +1701,6 @@ if ((meth == null) || (meth.getReturnType() != returnType)) { return null; } - meth.setAccessible(true); int mods = meth.getModifiers(); if ((mods & (Modifier.STATIC | Modifier.ABSTRACT)) != 0) { return null;
--- a/corba/src/java.corba/share/classes/module-info.java Mon Nov 14 12:05:26 2016 +0530 +++ b/corba/src/java.corba/share/classes/module-info.java Wed Nov 09 13:37:19 2016 +0100 @@ -32,6 +32,7 @@ requires java.logging; requires java.naming; requires java.transaction; + requires jdk.unsupported; exports javax.activity; exports javax.rmi;
--- a/corba/src/java.corba/share/classes/sun/corba/Bridge.java Mon Nov 14 12:05:26 2016 +0530 +++ b/corba/src/java.corba/share/classes/sun/corba/Bridge.java Wed Nov 09 13:37:19 2016 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -25,25 +25,24 @@ package sun.corba ; +import java.io.OptionalDataException; +import java.lang.invoke.MethodHandle; import java.lang.reflect.Field ; -import java.lang.reflect.Method ; import java.lang.reflect.Constructor ; -import java.lang.reflect.InvocationTargetException ; - -import java.io.ObjectInputStream ; import java.security.AccessController; import java.security.Permission; import java.security.PrivilegedAction; -import jdk.internal.misc.Unsafe ; -import jdk.internal.reflect.ReflectionFactory; +import sun.misc.Unsafe; +import sun.reflect.ReflectionFactory; /** This class provides the methods for fundamental JVM operations * needed in the ORB that are not part of the public Java API. This includes: * <ul> * <li>throwException, which can throw undeclared checked exceptions. - * This is needed to handle throwing arbitrary exceptions across a standardized OMG interface that (incorrectly) does not specify appropriate exceptions.</li> + * This is needed to handle throwing arbitrary exceptions across a standardized + * OMG interface that (incorrectly) does not specify appropriate exceptions.</li> * <li>putXXX/getXXX methods that allow unchecked access to fields of objects. * This is used for setting uninitialzed non-static final fields (which is * impossible with reflection) and for speed.</li> @@ -71,88 +70,28 @@ */ public final class Bridge { - private static final Class[] NO_ARGS = new Class[] {}; private static final Permission getBridgePermission = - new BridgePermission( "getBridge" ) ; + new BridgePermission("getBridge"); private static Bridge bridge = null ; - // latestUserDefinedLoader() is a private static method - // in ObjectInputStream in JDK 1.3 through 1.5. - // We use reflection in a doPrivileged block to get a - // Method reference and make it accessible. - private final Method latestUserDefinedLoaderMethod ; - private final Unsafe unsafe ; - private final ReflectionFactory reflectionFactory ; + /** Access to Unsafe to read/write fields. */ + private static final Unsafe unsafe = AccessController.doPrivileged( + (PrivilegedAction<Unsafe>)() -> { + try { + Field field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + return (Unsafe)field.get(null); - private Method getLatestUserDefinedLoaderMethod() - { - return (Method) AccessController.doPrivileged( - new PrivilegedAction() - { - public Object run() - { - Method result = null; - - try { - Class io = ObjectInputStream.class; - result = io.getDeclaredMethod( - "latestUserDefinedLoader", NO_ARGS); - result.setAccessible(true); - } catch (NoSuchMethodException nsme) { - Error err = new Error( "java.io.ObjectInputStream" + - " latestUserDefinedLoader " + nsme ); - err.initCause(nsme) ; - throw err ; - } - - return result; + } catch (NoSuchFieldException |IllegalAccessException ex) { + throw new InternalError("Unsafe.theUnsafe field not available", ex); } } - ); - } - - private Unsafe getUnsafe() { - Field fld = (Field)AccessController.doPrivileged( - new PrivilegedAction() - { - public Object run() - { - Field fld = null ; + ) ; - try { - Class unsafeClass = jdk.internal.misc.Unsafe.class ; - fld = unsafeClass.getDeclaredField( "theUnsafe" ) ; - fld.setAccessible( true ) ; - return fld ; - } catch (NoSuchFieldException exc) { - Error err = new Error( "Could not access Unsafe" ) ; - err.initCause( exc ) ; - throw err ; - } - } - } - ) ; - - Unsafe unsafe = null; + private final ReflectionFactory reflectionFactory ; - try { - unsafe = (Unsafe)(fld.get( null )) ; - } catch (Throwable t) { - Error err = new Error( "Could not access Unsafe" ) ; - err.initCause( t ) ; - throw err ; - } - - return unsafe ; - } - - - private Bridge() - { - latestUserDefinedLoaderMethod = getLatestUserDefinedLoaderMethod(); - unsafe = getUnsafe() ; - reflectionFactory = (ReflectionFactory)AccessController.doPrivileged( - new ReflectionFactory.GetReflectionFactoryAction()); + private Bridge() { + reflectionFactory = ReflectionFactory.getReflectionFactory(); } /** Fetch the Bridge singleton. This requires the following @@ -182,23 +121,8 @@ /** Obtain the latest user defined ClassLoader from the call stack. * This is required by the RMI-IIOP specification. */ - public final ClassLoader getLatestUserDefinedLoader() - { - try { - // Invoke the ObjectInputStream.latestUserDefinedLoader method - return (ClassLoader)latestUserDefinedLoaderMethod.invoke(null, - (Object[])NO_ARGS); - } catch (InvocationTargetException ite) { - Error err = new Error( - "sun.corba.Bridge.latestUserDefinedLoader: " + ite ) ; - err.initCause( ite ) ; - throw err ; - } catch (IllegalAccessException iae) { - Error err = new Error( - "sun.corba.Bridge.latestUserDefinedLoader: " + iae ) ; - err.initCause( iae ) ; - throw err ; - } + public final ClassLoader getLatestUserDefinedLoader() { + return jdk.internal.misc.VM.latestUserDefinedLoader(); } /** @@ -345,6 +269,23 @@ return unsafe.objectFieldOffset( f ) ; } + /** + * Returns the offset of a static field. + */ + public final long staticFieldOffset(Field f) + { + return unsafe.staticFieldOffset( f ) ; + } + + /** + * Ensure that the class has been initalized. + * @param cl the class to ensure is initialized + */ + public final void ensureClassInitialized(Class<?> cl) { + unsafe.ensureClassInitialized(cl); + } + + /** Throw the exception. * The exception may be an undeclared checked exception. */ @@ -353,16 +294,55 @@ unsafe.throwException( ee ) ; } - /** Obtain a constructor for Class cl using constructor cons which - * may be the constructor defined in a superclass of cl. This is - * used to create a constructor for Serializable classes that - * constructs an instance of the Serializable class using the + /** + * Obtain a constructor for Class cl. + * This is used to create a constructor for Serializable classes that + * construct an instance of the Serializable class using the * no args constructor of the first non-Serializable superclass * of the Serializable class. */ - public final Constructor newConstructorForSerialization( Class cl, - Constructor cons ) - { - return reflectionFactory.newConstructorForSerialization( cl, cons ) ; + public final Constructor<?> newConstructorForSerialization( Class<?> cl ) { + return reflectionFactory.newConstructorForSerialization( cl ) ; + } + + public final Constructor<?> newConstructorForExternalization(Class<?> cl) { + return reflectionFactory.newConstructorForExternalization( cl ) ; + } + + /** + * Returns true if the given class defines a static initializer method, + * false otherwise. + */ + public final boolean hasStaticInitializerForSerialization(Class<?> cl) { + return reflectionFactory.hasStaticInitializerForSerialization(cl); + } + + public final MethodHandle writeObjectForSerialization(Class<?> cl) { + return reflectionFactory.writeObjectForSerialization(cl); + } + + public final MethodHandle readObjectForSerialization(Class<?> cl) { + return reflectionFactory.readObjectForSerialization(cl); } + + public final MethodHandle readObjectNoDataForSerialization(Class<?> cl) { + return reflectionFactory.readObjectNoDataForSerialization(cl); + } + + public final MethodHandle readResolveForSerialization(Class<?> cl) { + return reflectionFactory.readResolveForSerialization(cl); + } + + public final MethodHandle writeReplaceForSerialization(Class<?> cl) { + return reflectionFactory.writeReplaceForSerialization(cl); + } + + /** + * Return a new OptionalDataException instance. + * @return a new OptionalDataException instance + */ + public final OptionalDataException newOptionalDataExceptionForSerialization(boolean bool) { + return reflectionFactory.newOptionalDataExceptionForSerialization(bool); + } + }
--- a/corba/src/java.corba/share/classes/sun/corba/SharedSecrets.java Mon Nov 14 12:05:26 2016 +0530 +++ b/corba/src/java.corba/share/classes/sun/corba/SharedSecrets.java Wed Nov 09 13:37:19 2016 +0100 @@ -25,13 +25,13 @@ package sun.corba; -import com.sun.corba.se.impl.io.ValueUtility; -import jdk.internal.misc.Unsafe; - import java.lang.reflect.Field; import java.security.AccessController; import java.security.PrivilegedAction; +import com.sun.corba.se.impl.io.ValueUtility; +import sun.misc.Unsafe; + /** A repository of "shared secrets", which are a mechanism for calling implementation-private methods in another package without using reflection. A package-private class implements a public @@ -43,22 +43,22 @@ // SharedSecrets cloned in corba repo to avoid build issues public class SharedSecrets { - private static final Unsafe unsafe = getUnsafe(); - private static JavaCorbaAccess javaCorbaAccess; - private static Unsafe getUnsafe() { - PrivilegedAction<Unsafe> pa = () -> { - Class<?> unsafeClass = jdk.internal.misc.Unsafe.class ; - try { - Field f = unsafeClass.getDeclaredField("theUnsafe"); - f.setAccessible(true); - return (Unsafe) f.get(null); - } catch (Exception e) { - throw new Error(e); - } - }; - return AccessController.doPrivileged(pa); - } + /** Access to Unsafe to read/write fields. */ + private static final Unsafe unsafe = AccessController.doPrivileged( + (PrivilegedAction<Unsafe>)() -> { + try { + Field field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + return (Unsafe)field.get(null); + + } catch (NoSuchFieldException |IllegalAccessException ex) { + throw new InternalError("Unsafe.theUnsafe field not available", ex); + } + } + ); + + private static JavaCorbaAccess javaCorbaAccess; public static JavaCorbaAccess getJavaCorbaAccess() { if (javaCorbaAccess == null) {
--- a/hotspot/.hgtags Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/.hgtags Wed Nov 09 13:37:19 2016 +0100 @@ -543,3 +543,6 @@ fc0956308c7a586267c5dd35dff74f773aa9c3eb jdk-9+138 08492e67bf3226784dab3bf9ae967382ddbc1af5 jdk-9+139 fec31089c2ef5a12dd64f401b0bf2e00f56ee0d0 jdk-9+140 +160a00bc6ed0af1fdf8418fc65e6bddbbc0c536d jdk-9+141 +7b48d63dfd6b8e2657288de3d7b1f153dee02d7e jdk-9+142 +d87d5d430c42342f0320ca7f5cbe0cbd1f9d62ba jdk-9+143
--- a/hotspot/make/gensrc/GensrcJvmti.gmk Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/make/gensrc/GensrcJvmti.gmk Wed Nov 09 13:37:19 2016 +0100 @@ -135,14 +135,14 @@ # Copy jvmti.h to include dir # The file is the same regardless of jvm variant. Only let one do the copy. -#ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS))) -# $(eval $(call SetupCopyFiles, COPY_JVMTI_H, \ -# DEST := $(SUPPORT_OUTPUTDIR)/modules_include/java.base, \ -# FILES := $(JVMTI_OUTPUTDIR)/jvmti.h, \ -# )) +ifeq ($(JVM_VARIANT), $(firstword $(JVM_VARIANTS))) + $(eval $(call SetupCopyFiles, COPY_JVMTI_H, \ + DEST := $(SUPPORT_OUTPUTDIR)/modules_include/java.base, \ + FILES := $(JVMTI_OUTPUTDIR)/jvmti.h, \ + )) -# TARGETS += $(COPY_JVMTI_H) -#endif + TARGETS += $(COPY_JVMTI_H) +endif ################################################################################ # Create trace files in gensrc/tracefiles
--- a/hotspot/make/lib/CompileJvm.gmk Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/make/lib/CompileJvm.gmk Wed Nov 09 13:37:19 2016 +0100 @@ -176,6 +176,11 @@ JVM_OPTIMIZATION ?= HIGHEST_JVM +# Need to set JVM_STRIPFLAGS to the default value from SPEC since the STRIPFLAGS +# parameter to SetupNativeCompilation allows an empty value to override the +# default. +JVM_STRIPFLAGS ?= $(STRIPFLAGS) + ################################################################################ # Now set up the actual compilation of the main hotspot native library @@ -204,6 +209,7 @@ OBJECT_DIR := $(JVM_OUTPUTDIR)/objs, \ MAPFILE := $(JVM_MAPFILE), \ USE_MAPFILE_FOR_SYMBOLS := true, \ + STRIPFLAGS := $(JVM_STRIPFLAGS), \ EMBED_MANIFEST := true, \ RC_FLAGS := $(JVM_RCFLAGS), \ VERSIONINFO_RESOURCE := $(HOTSPOT_TOPDIR)/src/os/windows/vm/version.rc, \
--- a/hotspot/make/lib/JvmFeatures.gmk Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/make/lib/JvmFeatures.gmk Wed Nov 09 13:37:19 2016 +0100 @@ -59,6 +59,10 @@ ifeq ($(call check-jvm-feature, minimal), true) JVM_CFLAGS_FEATURES += -DMINIMAL_JVM -DVMTYPE=\"Minimal\" + ifeq ($(OPENJDK_TARGET_OS), linux) + # Override the default -g with a more liberal strip policy for the minimal JVM + JVM_STRIPFLAGS := --strip-unneeded + endif endif ifeq ($(call check-jvm-feature, dtrace), true)
--- a/hotspot/make/symbols/symbols-unix Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/make/symbols/symbols-unix Wed Nov 09 13:37:19 2016 +0100 @@ -125,7 +125,6 @@ JVM_GetProtectionDomain JVM_GetSimpleBinaryName JVM_GetStackAccessControlContext -JVM_GetStackTraceElements JVM_GetSystemPackage JVM_GetSystemPackages JVM_GetTemporaryDirectory @@ -135,6 +134,8 @@ JVM_HoldsLock JVM_IHashCode JVM_InitProperties +JVM_InitStackTraceElement +JVM_InitStackTraceElementArray JVM_InternString JVM_Interrupt JVM_InvokeMethod @@ -178,7 +179,6 @@ JVM_StopThread JVM_SupportsCX8 JVM_SuspendThread -JVM_ToStackTraceElement JVM_TotalMemory JVM_UnloadLibrary JVM_WaitForReferencePendingList
--- a/hotspot/make/test/JtregNative.gmk Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/make/test/JtregNative.gmk Wed Nov 09 13:37:19 2016 +0100 @@ -45,6 +45,7 @@ $(HOTSPOT_TOPDIR)/test/runtime/jni/8025979 \ $(HOTSPOT_TOPDIR)/test/runtime/jni/8033445 \ $(HOTSPOT_TOPDIR)/test/runtime/jni/checked \ + $(HOTSPOT_TOPDIR)/test/runtime/jni/PrivateInterfaceMethods \ $(HOTSPOT_TOPDIR)/test/runtime/jni/ToStringInInterfaceTest \ $(HOTSPOT_TOPDIR)/test/runtime/modules/getModuleJNI \ $(HOTSPOT_TOPDIR)/test/runtime/SameObject \
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad Wed Nov 09 13:37:19 2016 +0100 @@ -3496,6 +3496,16 @@ return false; } +bool Matcher::const_oop_prefer_decode() { + // Prefer ConN+DecodeN over ConP in simple compressed oops mode. + return Universe::narrow_oop_base() == NULL; +} + +bool Matcher::const_klass_prefer_decode() { + // Prefer ConNKlass+DecodeNKlass over ConP in simple compressed klass mode. + return Universe::narrow_klass_base() == NULL; +} + // Is it better to copy float constants, or load them directly from // memory? Intel can load a float constant from a direct address, // requiring no extra registers. Most RISCs will have to materialize @@ -15502,6 +15512,24 @@ ins_pipe(pipe_class_memory); %} +instruct string_indexofU_char(iRegP_R1 str1, iRegI_R2 cnt1, iRegI_R3 ch, + iRegI_R0 result, iRegI tmp1, iRegI tmp2, + iRegI tmp3, rFlagsReg cr) +%{ + match(Set result (StrIndexOfChar (Binary str1 cnt1) ch)); + effect(USE_KILL str1, USE_KILL cnt1, USE_KILL ch, + TEMP tmp1, TEMP tmp2, TEMP tmp3, KILL cr); + + format %{ "String IndexOf char[] $str1,$cnt1,$ch -> $result" %} + + ins_encode %{ + __ string_indexof_char($str1$$Register, $cnt1$$Register, $ch$$Register, + $result$$Register, $tmp1$$Register, $tmp2$$Register, + $tmp3$$Register); + %} + ins_pipe(pipe_class_memory); +%} + instruct string_equalsL(iRegP_R1 str1, iRegP_R3 str2, iRegI_R4 cnt, iRegI_R0 result, rFlagsReg cr) %{
--- a/hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/aarch64/vm/interpreterRT_aarch64.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -130,8 +130,8 @@ if (_num_fp_args < Argument::n_float_register_parameters_c) { __ ldrs(as_FloatRegister(_num_fp_args++), src); } else { - __ ldrh(r0, src); - __ strh(r0, Address(to(), _stack_offset)); + __ ldrw(r0, src); + __ strw(r0, Address(to(), _stack_offset)); _stack_offset += wordSize; _num_fp_args++; } @@ -349,7 +349,7 @@ _num_fp_args++; } else { *_to++ = from_obj; - _num_int_args++; + _num_fp_args++; } } @@ -364,7 +364,7 @@ _num_fp_args++; } else { *_to++ = from_obj; - _num_int_args++; + _num_fp_args++; } }
--- a/hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -60,12 +60,12 @@ void CodeInstaller::pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS) { address pc = _instructions->start() + pc_offset; if (HotSpotMetaspaceConstantImpl::compressed(constant)) { - narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK); + narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK); TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop); Unimplemented(); } else { NativeMovConstReg* move = nativeMovConstReg_at(pc); - void* reference = record_metadata_reference(constant, CHECK); + void* reference = record_metadata_reference(_instructions, pc, constant, CHECK); move->set_data((intptr_t) reference); TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference)); }
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -4508,6 +4508,67 @@ typedef void (MacroAssembler::* chr_insn)(Register Rt, const Address &adr); typedef void (MacroAssembler::* uxt_insn)(Register Rd, Register Rn); +void MacroAssembler::string_indexof_char(Register str1, Register cnt1, + Register ch, Register result, + Register tmp1, Register tmp2, Register tmp3) +{ + Label CH1_LOOP, HAS_ZERO, DO1_SHORT, DO1_LOOP, MATCH, NOMATCH, DONE; + Register cnt1_neg = cnt1; + Register ch1 = rscratch1; + Register result_tmp = rscratch2; + + cmp(cnt1, 4); + br(LT, DO1_SHORT); + + orr(ch, ch, ch, LSL, 16); + orr(ch, ch, ch, LSL, 32); + + sub(cnt1, cnt1, 4); + mov(result_tmp, cnt1); + lea(str1, Address(str1, cnt1, Address::uxtw(1))); + sub(cnt1_neg, zr, cnt1, LSL, 1); + + mov(tmp3, 0x0001000100010001); + + BIND(CH1_LOOP); + ldr(ch1, Address(str1, cnt1_neg)); + eor(ch1, ch, ch1); + sub(tmp1, ch1, tmp3); + orr(tmp2, ch1, 0x7fff7fff7fff7fff); + bics(tmp1, tmp1, tmp2); + br(NE, HAS_ZERO); + adds(cnt1_neg, cnt1_neg, 8); + br(LT, CH1_LOOP); + + cmp(cnt1_neg, 8); + mov(cnt1_neg, 0); + br(LT, CH1_LOOP); + b(NOMATCH); + + BIND(HAS_ZERO); + rev(tmp1, tmp1); + clz(tmp1, tmp1); + add(cnt1_neg, cnt1_neg, tmp1, LSR, 3); + b(MATCH); + + BIND(DO1_SHORT); + mov(result_tmp, cnt1); + lea(str1, Address(str1, cnt1, Address::uxtw(1))); + sub(cnt1_neg, zr, cnt1, LSL, 1); + BIND(DO1_LOOP); + ldrh(ch1, Address(str1, cnt1_neg)); + cmpw(ch, ch1); + br(EQ, MATCH); + adds(cnt1_neg, cnt1_neg, 2); + br(LT, DO1_LOOP); + BIND(NOMATCH); + mov(result, -1); + b(DONE); + BIND(MATCH); + add(result, result_tmp, cnt1_neg, ASR, 1); + BIND(DONE); +} + // Compare strings. void MacroAssembler::string_compare(Register str1, Register str2, Register cnt1, Register cnt2, Register result,
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp Wed Nov 09 13:37:19 2016 +0100 @@ -1229,6 +1229,9 @@ Register tmp1, Register tmp2, Register tmp3, Register tmp4, int int_cnt1, Register result, int ae); + void string_indexof_char(Register str1, Register cnt1, + Register ch, Register result, + Register tmp1, Register tmp2, Register tmp3); private: void add2_with_carry(Register final_dest_hi, Register dest_hi, Register dest_lo, Register src1, Register src2);
--- a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -989,7 +989,16 @@ // A float arg may have to do float reg int reg conversion static void float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) { - if (src.first() != dst.first()) { + assert(src.first()->is_stack() && dst.first()->is_stack() || + src.first()->is_reg() && dst.first()->is_reg(), "Unexpected error"); + if (src.first()->is_stack()) { + if (dst.first()->is_stack()) { + __ ldrw(rscratch1, Address(rfp, reg2offset_in(src.first()))); + __ strw(rscratch1, Address(sp, reg2offset_out(dst.first()))); + } else { + ShouldNotReachHere(); + } + } else if (src.first() != dst.first()) { if (src.is_single_phys_reg() && dst.is_single_phys_reg()) __ fmovs(dst.first()->as_FloatRegister(), src.first()->as_FloatRegister()); else @@ -1023,7 +1032,16 @@ // A double move static void double_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) { - if (src.first() != dst.first()) { + assert(src.first()->is_stack() && dst.first()->is_stack() || + src.first()->is_reg() && dst.first()->is_reg(), "Unexpected error"); + if (src.first()->is_stack()) { + if (dst.first()->is_stack()) { + __ ldr(rscratch1, Address(rfp, reg2offset_in(src.first()))); + __ str(rscratch1, Address(sp, reg2offset_out(dst.first()))); + } else { + ShouldNotReachHere(); + } + } else if (src.first() != dst.first()) { if (src.is_single_phys_reg() && dst.is_single_phys_reg()) __ fmovd(dst.first()->as_FloatRegister(), src.first()->as_FloatRegister()); else
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -2743,7 +2743,7 @@ __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_encryptAESCrypt"); - Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52; + Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52, _L_finish; const Register from = c_rarg0; // source array address const Register to = c_rarg1; // destination array address @@ -2754,9 +2754,12 @@ const Register keylen = rscratch1; address start = __ pc(); + __ enter(); - __ mov(rscratch2, len_reg); + __ subsw(rscratch2, len_reg, zr); + __ br(Assembler::LE, _L_finish); + __ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); __ ld1(v0, __ T16B, rvec); @@ -2814,11 +2817,13 @@ __ eor(v0, __ T16B, v0, v31); __ st1(v0, __ T16B, __ post(to, 16)); - __ sub(len_reg, len_reg, 16); - __ cbnz(len_reg, L_aes_loop); + + __ subw(len_reg, len_reg, 16); + __ cbnzw(len_reg, L_aes_loop); __ st1(v0, __ T16B, rvec); + __ BIND(_L_finish); __ mov(r0, rscratch2); __ leave(); @@ -2844,7 +2849,7 @@ __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_decryptAESCrypt"); - Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52; + Label L_loadkeys_44, L_loadkeys_52, L_aes_loop, L_rounds_44, L_rounds_52, _L_finish; const Register from = c_rarg0; // source array address const Register to = c_rarg1; // destination array address @@ -2855,9 +2860,12 @@ const Register keylen = rscratch1; address start = __ pc(); + __ enter(); - __ mov(rscratch2, len_reg); + __ subsw(rscratch2, len_reg, zr); + __ br(Assembler::LE, _L_finish); + __ ldrw(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); __ ld1(v2, __ T16B, rvec); @@ -2920,11 +2928,12 @@ __ st1(v0, __ T16B, __ post(to, 16)); __ orr(v2, __ T16B, v1, v1); - __ sub(len_reg, len_reg, 16); - __ cbnz(len_reg, L_aes_loop); + __ subw(len_reg, len_reg, 16); + __ cbnzw(len_reg, L_aes_loop); __ st1(v2, __ T16B, rvec); + __ BIND(_L_finish); __ mov(r0, rscratch2); __ leave();
--- a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -454,8 +454,9 @@ __ str(zr, Address(rfp, frame::interpreter_frame_last_sp_offset * wordSize)); #if INCLUDE_JVMCI - // Check if we need to take lock at entry of synchronized method. - if (UseJVMCICompiler) { + // Check if we need to take lock at entry of synchronized method. This can + // only occur on method entry so emit it only for vtos with step 0. + if (UseJVMCICompiler && state == vtos && step == 0) { Label L; __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset())); __ cbz(rscratch1, L); @@ -464,8 +465,17 @@ // Take lock. lock_method(); __ bind(L); + } else { +#ifdef ASSERT + if (UseJVMCICompiler) { + Label L; + __ ldr(rscratch1, Address(rthread, Thread::pending_exception_offset())); + __ cbz(rscratch1, L); + __ stop("unexpected pending monitor in deopt entry"); + __ bind(L); + } +#endif } -#endif // handle exceptions { Label L;
--- a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -3717,19 +3717,15 @@ // allocate one if there's no free slot { - Label entry, loop, no_adjust; + Label entry, loop; // 1. compute new pointers // rsp: old expression stack top __ ldr(c_rarg1, monitor_block_bot); // c_rarg1: old expression stack bottom - __ sub(esp, esp, entry_size); // move expression stack top + __ sub(esp, esp, entry_size); // move expression stack top __ sub(c_rarg1, c_rarg1, entry_size); // move expression stack bottom __ mov(c_rarg3, esp); // set start value for copy loop __ str(c_rarg1, monitor_block_bot); // set new monitor block bottom - __ cmp(sp, c_rarg3); // Check if we need to move sp - __ br(Assembler::LO, no_adjust); // to allow more stack space - // for our new esp - __ sub(sp, sp, 2 * wordSize); - __ bind(no_adjust); + __ sub(sp, sp, entry_size); // make room for the monitor __ b(entry); // 2. move expression stack contents
--- a/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -1894,6 +1894,22 @@ __ beq(combined_check, slow); } + if (flags & LIR_OpArrayCopy::type_check) { + if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) { + __ load_klass(tmp, dst); + __ lwz(tmp2, in_bytes(Klass::layout_helper_offset()), tmp); + __ cmpwi(CCR0, tmp2, Klass::_lh_neutral_value); + __ bge(CCR0, slow); + } + + if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) { + __ load_klass(tmp, src); + __ lwz(tmp2, in_bytes(Klass::layout_helper_offset()), tmp); + __ cmpwi(CCR0, tmp2, Klass::_lh_neutral_value); + __ bge(CCR0, slow); + } + } + // Higher 32bits must be null. __ extsw(length, length);
--- a/hotspot/src/cpu/ppc/vm/c1_MacroAssembler_ppc.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/ppc/vm/c1_MacroAssembler_ppc.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -64,17 +64,16 @@ void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) { + // Avoid stack bang as first instruction. It may get overwritten by patch_verified_entry. + const Register return_pc = R20; + mflr(return_pc); + + // Make sure there is enough stack space for this method's activation. assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect"); - // Make sure there is enough stack space for this method's activation. generate_stack_overflow_check(bang_size_in_bytes); - // Create the frame. - const Register return_pc = R0; - - mflr(return_pc); - // Get callers sp. - std(return_pc, _abi(lr), R1_SP); // SP->lr = return_pc - push_frame(frame_size_in_bytes, R0); // SP -= frame_size_in_bytes + std(return_pc, _abi(lr), R1_SP); // SP->lr = return_pc + push_frame(frame_size_in_bytes, R0); // SP -= frame_size_in_bytes }
--- a/hotspot/src/cpu/ppc/vm/ppc.ad Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/ppc/vm/ppc.ad Wed Nov 09 13:37:19 2016 +0100 @@ -1097,21 +1097,19 @@ // No entry point given, use the current pc. if (entry_point == NULL) entry_point = __ pc(); - if (!Compile::current()->in_scratch_emit_size()) { - // Put the entry point as a constant into the constant pool. - const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); - if (entry_point_toc_addr == NULL) { - ciEnv::current()->record_out_of_memory_failure(); - return offsets; - } - const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); - - // Emit the trampoline stub which will be related to the branch-and-link below. - CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, offsets.insts_call_instruction_offset); - if (ciEnv::current()->failing()) { return offsets; } // Code cache may be full. - __ relocate(rtype); + // Put the entry point as a constant into the constant pool. + const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); + if (entry_point_toc_addr == NULL) { + ciEnv::current()->record_out_of_memory_failure(); + return offsets; } - + const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); + + // Emit the trampoline stub which will be related to the branch-and-link below. + CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, offsets.insts_call_instruction_offset); + if (ciEnv::current()->failing()) { return offsets; } // Code cache may be full. + __ relocate(rtype); + // Note: At this point we do not have the address of the trampoline // stub, and the entry point might be too far away for bl, so __ pc() // serves as dummy and the bl will be patched later. @@ -2166,6 +2164,16 @@ return false; } +bool Matcher::const_oop_prefer_decode() { + // Prefer ConN+DecodeN over ConP in simple compressed oops mode. + return Universe::narrow_oop_base() == NULL; +} + +bool Matcher::const_klass_prefer_decode() { + // Prefer ConNKlass+DecodeNKlass over ConP in simple compressed klass mode. + return Universe::narrow_klass_base() == NULL; +} + // Is it better to copy float constants, or load them directly from memory? // Intel can load a float constant from a direct address, requiring no // extra registers. Most RISCs will have to materialize an address into a @@ -2424,23 +2432,21 @@ MacroAssembler _masm(&cbuf); int toc_offset = 0; - if (!ra_->C->in_scratch_emit_size()) { - address const_toc_addr; - // Create a non-oop constant, no relocation needed. - // If it is an IC, it has a virtual_call_Relocation. - const_toc_addr = __ long_constant((jlong)$src$$constant); - if (const_toc_addr == NULL) { - ciEnv::current()->record_out_of_memory_failure(); - return; - } - - // Get the constant's TOC offset. - toc_offset = __ offset_to_method_toc(const_toc_addr); - - // Keep the current instruction offset in mind. - ((loadConLNode*)this)->_cbuf_insts_offset = __ offset(); - } - + address const_toc_addr; + // Create a non-oop constant, no relocation needed. + // If it is an IC, it has a virtual_call_Relocation. + const_toc_addr = __ long_constant((jlong)$src$$constant); + if (const_toc_addr == NULL) { + ciEnv::current()->record_out_of_memory_failure(); + return; + } + + // Get the constant's TOC offset. + toc_offset = __ offset_to_method_toc(const_toc_addr); + + // Keep the current instruction offset in mind. + ((loadConLNode*)this)->_cbuf_insts_offset = __ offset(); + __ ld($dst$$Register, toc_offset, $toc$$Register); %} @@ -2576,31 +2582,29 @@ MacroAssembler _masm(&cbuf); int toc_offset = 0; - if (!ra_->C->in_scratch_emit_size()) { - intptr_t val = $src$$constant; - relocInfo::relocType constant_reloc = $src->constant_reloc(); // src - address const_toc_addr; - if (constant_reloc == relocInfo::oop_type) { - // Create an oop constant and a corresponding relocation. - AddressLiteral a = __ allocate_oop_address((jobject)val); - const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none); - __ relocate(a.rspec()); - } else if (constant_reloc == relocInfo::metadata_type) { - AddressLiteral a = __ constant_metadata_address((Metadata *)val); - const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none); - __ relocate(a.rspec()); - } else { - // Create a non-oop constant, no relocation needed. - const_toc_addr = __ long_constant((jlong)$src$$constant); - } - - if (const_toc_addr == NULL) { - ciEnv::current()->record_out_of_memory_failure(); - return; - } - // Get the constant's TOC offset. - toc_offset = __ offset_to_method_toc(const_toc_addr); - } + intptr_t val = $src$$constant; + relocInfo::relocType constant_reloc = $src->constant_reloc(); // src + address const_toc_addr; + if (constant_reloc == relocInfo::oop_type) { + // Create an oop constant and a corresponding relocation. + AddressLiteral a = __ allocate_oop_address((jobject)val); + const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none); + __ relocate(a.rspec()); + } else if (constant_reloc == relocInfo::metadata_type) { + AddressLiteral a = __ constant_metadata_address((Metadata *)val); + const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none); + __ relocate(a.rspec()); + } else { + // Create a non-oop constant, no relocation needed. + const_toc_addr = __ long_constant((jlong)$src$$constant); + } + + if (const_toc_addr == NULL) { + ciEnv::current()->record_out_of_memory_failure(); + return; + } + // Get the constant's TOC offset. + toc_offset = __ offset_to_method_toc(const_toc_addr); __ ld($dst$$Register, toc_offset, $toc$$Register); %} @@ -3272,28 +3276,26 @@ } else { // Remember the offset not the address. const int start_offset = __ offset(); + // The trampoline stub. - if (!Compile::current()->in_scratch_emit_size()) { - // No entry point given, use the current pc. - // Make sure branch fits into - if (entry_point == 0) entry_point = __ pc(); - - // Put the entry point as a constant into the constant pool. - const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); - if (entry_point_toc_addr == NULL) { - ciEnv::current()->record_out_of_memory_failure(); - return; - } - const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); - - - // Emit the trampoline stub which will be related to the branch-and-link below. - CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); - if (ciEnv::current()->failing()) { return; } // Code cache may be full. - int method_index = resolved_method_index(cbuf); - __ relocate(_optimized_virtual ? opt_virtual_call_Relocation::spec(method_index) - : static_call_Relocation::spec(method_index)); + // No entry point given, use the current pc. + // Make sure branch fits into + if (entry_point == 0) entry_point = __ pc(); + + // Put the entry point as a constant into the constant pool. + const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); + if (entry_point_toc_addr == NULL) { + ciEnv::current()->record_out_of_memory_failure(); + return; } + const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); + + // Emit the trampoline stub which will be related to the branch-and-link below. + CallStubImpl::emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); + if (ciEnv::current()->failing()) { return; } // Code cache may be full. + int method_index = resolved_method_index(cbuf); + __ relocate(_optimized_virtual ? opt_virtual_call_Relocation::spec(method_index) + : static_call_Relocation::spec(method_index)); // The real call. // Note: At this point we do not have the address of the trampoline
--- a/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/ppc/vm/templateTable_ppc_64.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -2550,7 +2550,7 @@ __ lbzx(R17_tos, Rclass_or_obj, Roffset); __ extsb(R17_tos, R17_tos); __ push(ztos); - if (!is_static) { + if (!is_static && rc == may_rewrite) { // use btos rewriting, no truncating to t/f bit is needed for getfield. patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch); } @@ -2874,7 +2874,9 @@ if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1. __ andi(R17_tos, R17_tos, 0x1); __ stbx(R17_tos, Rclass_or_obj, Roffset); - if (!is_static) { patch_bytecode(Bytecodes::_fast_zputfield, Rbc, Rscratch, true, byte_no); } + if (!is_static && rc == may_rewrite) { + patch_bytecode(Bytecodes::_fast_zputfield, Rbc, Rscratch, true, byte_no); + } if (!support_IRIW_for_not_multiple_copy_atomic_cpu) { __ beq(CR_is_vol, Lvolatile); // Volatile? }
--- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -2034,6 +2034,27 @@ __ delayed()->nop(); } + // If the compiler was not able to prove that exact type of the source or the destination + // of the arraycopy is an array type, check at runtime if the source or the destination is + // an instance type. + if (flags & LIR_OpArrayCopy::type_check) { + if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) { + __ load_klass(dst, tmp); + __ lduw(tmp, in_bytes(Klass::layout_helper_offset()), tmp2); + __ cmp(tmp2, Klass::_lh_neutral_value); + __ br(Assembler::greaterEqual, false, Assembler::pn, *stub->entry()); + __ delayed()->nop(); + } + + if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) { + __ load_klass(src, tmp); + __ lduw(tmp, in_bytes(Klass::layout_helper_offset()), tmp2); + __ cmp(tmp2, Klass::_lh_neutral_value); + __ br(Assembler::greaterEqual, false, Assembler::pn, *stub->entry()); + __ delayed()->nop(); + } + } + if (flags & LIR_OpArrayCopy::src_pos_positive_check) { // test src_pos register __ cmp_zero_and_br(Assembler::less, src_pos, *stub->entry());
--- a/hotspot/src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -71,7 +71,7 @@ if (HotSpotMetaspaceConstantImpl::compressed(constant)) { #ifdef _LP64 NativeMovConstReg32* move = nativeMovConstReg32_at(pc); - narrowKlass narrowOop = record_narrow_metadata_reference(constant, CHECK); + narrowKlass narrowOop = record_narrow_metadata_reference(_instructions, pc, constant, CHECK); move->set_data((intptr_t)narrowOop); TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/0x%x", p2i(pc), narrowOop); #else @@ -79,7 +79,7 @@ #endif } else { NativeMovConstReg* move = nativeMovConstReg_at(pc); - void* reference = record_metadata_reference(constant, CHECK); + void* reference = record_metadata_reference(_instructions, pc, constant, CHECK); move->set_data((intptr_t)reference); TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference)); }
--- a/hotspot/src/cpu/sparc/vm/sparc.ad Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/sparc/vm/sparc.ad Wed Nov 09 13:37:19 2016 +0100 @@ -2003,6 +2003,20 @@ return false; } +bool Matcher::const_oop_prefer_decode() { + // TODO: Check if loading ConP from TOC in heap-based mode is better: + // Prefer ConN+DecodeN over ConP in simple compressed oops mode. + // return Universe::narrow_oop_base() == NULL; + return true; +} + +bool Matcher::const_klass_prefer_decode() { + // TODO: Check if loading ConP from TOC in heap-based mode is better: + // Prefer ConNKlass+DecodeNKlass over ConP in simple compressed klass mode. + // return Universe::narrow_klass_base() == NULL; + return true; +} + // Is it better to copy float constants, or load them directly from memory? // Intel can load a float constant from a direct address, requiring no // extra registers. Most RISCs will have to materialize an address into a
--- a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -384,8 +384,9 @@ address entry = __ pc(); __ get_constant_pool_cache(LcpoolCache); // load LcpoolCache #if INCLUDE_JVMCI - // Check if we need to take lock at entry of synchronized method. - if (UseJVMCICompiler) { + // Check if we need to take lock at entry of synchronized method. This can + // only occur on method entry so emit it only for vtos with step 0. + if (UseJVMCICompiler && state == vtos && step == 0) { Label L; Address pending_monitor_enter_addr(G2_thread, JavaThread::pending_monitorenter_offset()); __ ldbool(pending_monitor_enter_addr, Gtemp); // Load if pending monitor enter @@ -395,6 +396,17 @@ // Take lock. lock_method(); __ bind(L); + } else { +#ifdef ASSERT + if (UseJVMCICompiler) { + Label L; + Address pending_monitor_enter_addr(G2_thread, JavaThread::pending_monitorenter_offset()); + __ ldbool(pending_monitor_enter_addr, Gtemp); // Load if pending monitor enter + __ cmp_and_br_short(Gtemp, G0, Assembler::equal, Assembler::pn, L); + __ stop("unexpected pending monitor in deopt entry"); + __ bind(L); + } +#endif } #endif { Label L;
--- a/hotspot/src/cpu/sparc/vm/vmStructs_sparc.hpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/sparc/vm/vmStructs_sparc.hpp Wed Nov 09 13:37:19 2016 +0100 @@ -84,7 +84,6 @@ declare_constant(VM_Version::sun4v_m) \ declare_constant(VM_Version::blk_init_instructions_m) \ declare_constant(VM_Version::fmaf_instructions_m) \ - declare_constant(VM_Version::fmau_instructions_m) \ declare_constant(VM_Version::sparc64_family_m) \ declare_constant(VM_Version::M_family_m) \ declare_constant(VM_Version::T_family_m) \
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -179,7 +179,7 @@ assert((OptoLoopAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size"); char buf[512]; - jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", (has_v9() ? ", v9" : (has_v8() ? ", v8" : "")), (has_hardware_popc() ? ", popc" : ""), (has_vis1() ? ", vis1" : ""), @@ -193,6 +193,7 @@ (has_sha512() ? ", sha512" : ""), (has_crc32c() ? ", crc32c" : ""), (is_ultra3() ? ", ultra3" : ""), + (has_sparc5_instr() ? ", sparc5" : ""), (is_sun4v() ? ", sun4v" : ""), (is_niagara_plus() ? ", niagara_plus" : (is_niagara() ? ", niagara" : "")), (is_sparc64() ? ", sparc64" : ""), @@ -487,16 +488,11 @@ if (strstr(impl, "SPARC-T1") != NULL) { features |= T1_model_m; } + } else if (strstr(impl, "SUN4V-CPU") != NULL) { + // Generic or migration class LDOM + features |= T_family_m; } else { - if (strstr(impl, "SPARC") == NULL) { -#ifndef PRODUCT - // kstat on Solaris 8 virtual machines (branded zones) - // returns "(unsupported)" implementation. Solaris 8 is not - // supported anymore, but include this check to be on the - // safe side. - warning("Can't parse CPU implementation = '%s', assume generic SPARC", impl); -#endif - } + log_info(os, cpu)("Failed to parse CPU implementation = '%s'", impl); } os::free((void*)impl); return features;
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp Wed Nov 09 13:37:19 2016 +0100 @@ -34,30 +34,29 @@ protected: enum Feature_Flag { - v8_instructions = 0, - hardware_mul32 = 1, - hardware_div32 = 2, - hardware_fsmuld = 3, - hardware_popc = 4, - v9_instructions = 5, - vis1_instructions = 6, - vis2_instructions = 7, - sun4v_instructions = 8, + v8_instructions = 0, + hardware_mul32 = 1, + hardware_div32 = 2, + hardware_fsmuld = 3, + hardware_popc = 4, + v9_instructions = 5, + vis1_instructions = 6, + vis2_instructions = 7, + sun4v_instructions = 8, blk_init_instructions = 9, - fmaf_instructions = 10, - fmau_instructions = 11, - vis3_instructions = 12, - cbcond_instructions = 13, - sparc64_family = 14, - M_family = 15, - T_family = 16, - T1_model = 17, - sparc5_instructions = 18, - aes_instructions = 19, - sha1_instruction = 20, - sha256_instruction = 21, - sha512_instruction = 22, - crc32c_instruction = 23 + fmaf_instructions = 10, + vis3_instructions = 11, + cbcond_instructions = 12, + sparc64_family = 13, + M_family = 14, + T_family = 15, + T1_model = 16, + sparc5_instructions = 17, + aes_instructions = 18, + sha1_instruction = 19, + sha256_instruction = 20, + sha512_instruction = 21, + crc32c_instruction = 22 }; enum Feature_Flag_Set { @@ -75,7 +74,6 @@ sun4v_m = 1 << sun4v_instructions, blk_init_instructions_m = 1 << blk_init_instructions, fmaf_instructions_m = 1 << fmaf_instructions, - fmau_instructions_m = 1 << fmau_instructions, vis3_instructions_m = 1 << vis3_instructions, cbcond_instructions_m = 1 << cbcond_instructions, sparc64_family_m = 1 << sparc64_family,
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -3146,6 +3146,23 @@ __ jcc(Assembler::zero, *stub->entry()); } + // If the compiler was not able to prove that exact type of the source or the destination + // of the arraycopy is an array type, check at runtime if the source or the destination is + // an instance type. + if (flags & LIR_OpArrayCopy::type_check) { + if (!(flags & LIR_OpArrayCopy::dst_objarray)) { + __ load_klass(tmp, dst); + __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value); + __ jcc(Assembler::greaterEqual, *stub->entry()); + } + + if (!(flags & LIR_OpArrayCopy::src_objarray)) { + __ load_klass(tmp, src); + __ cmpl(Address(tmp, in_bytes(Klass::layout_helper_offset())), Klass::_lh_neutral_value); + __ jcc(Assembler::greaterEqual, *stub->entry()); + } + } + // check if negative if (flags & LIR_OpArrayCopy::src_pos_positive_check) { __ testl(src_pos, src_pos);
--- a/hotspot/src/cpu/x86/vm/jvmciCodeInstaller_x86.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/x86/vm/jvmciCodeInstaller_x86.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -89,14 +89,14 @@ if (HotSpotMetaspaceConstantImpl::compressed(constant)) { #ifdef _LP64 address operand = Assembler::locate_operand(pc, Assembler::narrow_oop_operand); - *((narrowKlass*) operand) = record_narrow_metadata_reference(constant, CHECK); + *((narrowKlass*) operand) = record_narrow_metadata_reference(_instructions, operand, constant, CHECK); TRACE_jvmci_3("relocating (narrow metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand)); #else JVMCI_ERROR("compressed Klass* on 32bit"); #endif } else { address operand = Assembler::locate_operand(pc, Assembler::imm_operand); - *((void**) operand) = record_metadata_reference(constant, CHECK); + *((void**) operand) = record_metadata_reference(_instructions, operand, constant, CHECK); TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand)); } }
--- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -254,8 +254,9 @@ const Register thread = NOT_LP64(rcx) LP64_ONLY(r15_thread); NOT_LP64(__ get_thread(thread)); #if INCLUDE_JVMCI - // Check if we need to take lock at entry of synchronized method. - if (UseJVMCICompiler) { + // Check if we need to take lock at entry of synchronized method. This can + // only occur on method entry so emit it only for vtos with step 0. + if (UseJVMCICompiler && state == vtos && step == 0) { Label L; __ cmpb(Address(thread, JavaThread::pending_monitorenter_offset()), 0); __ jcc(Assembler::zero, L); @@ -266,6 +267,16 @@ // Take lock. lock_method(); __ bind(L); + } else { +#ifdef ASSERT + if (UseJVMCICompiler) { + Label L; + __ cmpb(Address(r15_thread, JavaThread::pending_monitorenter_offset()), 0); + __ jccb(Assembler::zero, L); + __ stop("unexpected pending monitor in deopt entry"); + __ bind(L); + } +#endif } #endif // handle exceptions
--- a/hotspot/src/cpu/x86/vm/x86_32.ad Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/x86/vm/x86_32.ad Wed Nov 09 13:37:19 2016 +0100 @@ -1452,6 +1452,15 @@ return true; } +bool Matcher::const_oop_prefer_decode() { + ShouldNotCallThis(); + return true; +} + +bool Matcher::const_klass_prefer_decode() { + ShouldNotCallThis(); + return true; +} // Is it better to copy float constants, or load them directly from memory? // Intel can load a float constant from a direct address, requiring no
--- a/hotspot/src/cpu/x86/vm/x86_64.ad Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/cpu/x86/vm/x86_64.ad Wed Nov 09 13:37:19 2016 +0100 @@ -1660,6 +1660,19 @@ return (LogKlassAlignmentInBytes <= 3); } +bool Matcher::const_oop_prefer_decode() { + // Prefer ConN+DecodeN over ConP. + return true; +} + +bool Matcher::const_klass_prefer_decode() { + // TODO: Either support matching DecodeNKlass (heap-based) in operand + // or condisider the following: + // Prefer ConNKlass+DecodeNKlass over ConP in simple compressed klass mode. + //return Universe::narrow_klass_base() == NULL; + return true; +} + // Is it better to copy float constants, or load them directly from // memory? Intel can load a float constant from a direct address, // requiring no extra registers. Most RISCs will have to materialize
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotJVMCIBackendFactory.java Wed Nov 09 13:37:19 2016 +0100 @@ -96,9 +96,6 @@ if ((config.vmVersionFeatures & config.sparcFmafInstructions) != 0) { features.add(CPUFeature.FMAF); } - if ((config.vmVersionFeatures & config.sparcFmauInstructions) != 0) { - features.add(CPUFeature.FMAU); - } if ((config.vmVersionFeatures & config.sparcSparc64Family) != 0) { features.add(CPUFeature.SPARC64_FAMILY); }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot.sparc/src/jdk/vm/ci/hotspot/sparc/SPARCHotSpotVMConfig.java Wed Nov 09 13:37:19 2016 +0100 @@ -55,7 +55,6 @@ final int sparcSun4v = getConstant("VM_Version::sun4v_m", Integer.class); final int sparcBlkInitInstructions = getConstant("VM_Version::blk_init_instructions_m", Integer.class); final int sparcFmafInstructions = getConstant("VM_Version::fmaf_instructions_m", Integer.class); - final int sparcFmauInstructions = getConstant("VM_Version::fmau_instructions_m", Integer.class); final int sparcSparc64Family = getConstant("VM_Version::sparc64_family_m", Integer.class); final int sparcMFamily = getConstant("VM_Version::M_family_m", Integer.class); final int sparcTFamily = getConstant("VM_Version::T_family_m", Integer.class);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/EmptyEventProvider.java Wed Nov 09 13:37:19 2016 +0100 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2014, 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. + */ +package jdk.vm.ci.hotspot; + +/** + * An empty implementation for {@link EventProvider}. This implementation is used when no logging is + * requested. + */ +final class EmptyEventProvider implements EventProvider { + + static InternalError shouldNotReachHere() { + throw new InternalError("should not reach here"); + } + + @Override + public CompilationEvent newCompilationEvent() { + return new EmptyCompilationEvent(); + } + + static class EmptyCompilationEvent implements CompilationEvent { + public void commit() { + throw shouldNotReachHere(); + } + + public boolean shouldWrite() { + // Events of this class should never been written. + return false; + } + + public void begin() { + } + + public void end() { + } + + public void setMethod(String method) { + throw shouldNotReachHere(); + } + + public void setCompileId(int compileId) { + throw shouldNotReachHere(); + } + + public void setCompileLevel(int compileLevel) { + throw shouldNotReachHere(); + } + + public void setSucceeded(boolean succeeded) { + throw shouldNotReachHere(); + } + + public void setIsOsr(boolean isOsr) { + throw shouldNotReachHere(); + } + + public void setCodeSize(int codeSize) { + throw shouldNotReachHere(); + } + + public void setInlinedBytes(int inlinedBytes) { + throw shouldNotReachHere(); + } + } + + @Override + public CompilerFailureEvent newCompilerFailureEvent() { + return new EmptyCompilerFailureEvent(); + } + + static class EmptyCompilerFailureEvent implements CompilerFailureEvent { + public void commit() { + throw shouldNotReachHere(); + } + + public boolean shouldWrite() { + // Events of this class should never been written. + return false; + } + + public void setCompileId(int compileId) { + throw shouldNotReachHere(); + } + + public void setMessage(String message) { + throw shouldNotReachHere(); + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/EventProvider.java Wed Nov 09 13:37:19 2016 +0100 @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2014, 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. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.hotspot.EmptyEventProvider.EmptyCompilationEvent; +import jdk.vm.ci.hotspot.EmptyEventProvider.EmptyCompilerFailureEvent; +import jdk.vm.ci.services.JVMCIPermission; + +/** + * Service-provider class for logging compiler related events. + */ +public interface EventProvider { + + /** + * Creates and returns an empty implementation for {@link EventProvider}. This implementation + * can be used when no logging is requested. + */ + static EventProvider createEmptyEventProvider() { + return new EmptyEventProvider(); + } + + /** + * Creates and returns an empty implementation for {@link CompilationEvent}. + */ + static CompilationEvent createEmptyCompilationEvent() { + return new EmptyCompilationEvent(); + } + + /** + * Creates and returns an empty implementation for {@link CompilationEvent}. + */ + static CompilerFailureEvent createEmptyCompilerFailureEvent() { + return new EmptyCompilerFailureEvent(); + } + + /** + * An instant event is an event that is not considered to have taken any time. + */ + public interface InstantEvent { + /** + * Commits the event. + */ + void commit(); + + /** + * Determines if this particular event instance would be committed to the data stream right + * now if application called {@link #commit()}. This in turn depends on whether the event is + * enabled and possible other factors. + * + * @return if this event would be committed on a call to {@link #commit()}. + */ + boolean shouldWrite(); + } + + /** + * Timed events describe an operation that somehow consumes time. + */ + public interface TimedEvent extends InstantEvent { + /** + * Starts the timing for this event. + */ + void begin(); + + /** + * Ends the timing period for this event. + */ + void end(); + } + + /** + * Creates a new {@link CompilationEvent}. + * + * @return a compilation event + */ + public abstract CompilationEvent newCompilationEvent(); + + /** + * A compilation event. + */ + public interface CompilationEvent extends TimedEvent { + void setMethod(String method); + + void setCompileId(int compileId); + + void setCompileLevel(int compileLevel); + + void setSucceeded(boolean succeeded); + + void setIsOsr(boolean isOsr); + + void setCodeSize(int codeSize); + + void setInlinedBytes(int inlinedBytes); + } + + /** + * Creates a new {@link CompilerFailureEvent}. + * + * @return a compiler failure event + */ + public abstract CompilerFailureEvent newCompilerFailureEvent(); + + /** + * A compiler failure event. + */ + public interface CompilerFailureEvent extends InstantEvent { + void setCompileId(int compileId); + + void setMessage(String message); + } +}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerConfig.java Wed Nov 09 13:37:19 2016 +0100 @@ -26,8 +26,10 @@ import jdk.vm.ci.common.JVMCIError; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.Option; import jdk.vm.ci.runtime.JVMCICompiler; +import jdk.vm.ci.runtime.JVMCICompilerFactory; import jdk.vm.ci.runtime.JVMCIRuntime; -import jdk.vm.ci.runtime.services.JVMCICompilerFactory; +import jdk.vm.ci.services.JVMCIServiceLocator; +import jdk.vm.ci.services.JVMCIPermission; import jdk.vm.ci.services.Services; final class HotSpotJVMCICompilerConfig { @@ -37,7 +39,7 @@ * to perform a compilation. This allows the reflective parts of the JVMCI API to be used * without requiring a compiler implementation to be available. */ - private static class DummyCompilerFactory extends JVMCICompilerFactory implements JVMCICompiler { + private static class DummyCompilerFactory implements JVMCICompilerFactory, JVMCICompiler { public HotSpotCompilationRequestResult compileMethod(CompilationRequest request) { throw new JVMCIError("no JVMCI compiler selected"); @@ -63,15 +65,16 @@ * Gets the selected system compiler factory. * * @return the selected system compiler factory + * @throws SecurityException if a security manager is present and it denies + * {@link JVMCIPermission} for any {@link JVMCIServiceLocator} loaded by this method */ static JVMCICompilerFactory getCompilerFactory() { if (compilerFactory == null) { JVMCICompilerFactory factory = null; String compilerName = Option.Compiler.getString(); if (compilerName != null) { - for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) { + for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) { if (f.getCompilerName().equals(compilerName)) { - Services.exportJVMCITo(f.getClass()); factory = f; } } @@ -80,8 +83,9 @@ } } else { // Auto select a single available compiler - for (JVMCICompilerFactory f : Services.load(JVMCICompilerFactory.class)) { + for (JVMCICompilerFactory f : JVMCIServiceLocator.getProviders(JVMCICompilerFactory.class)) { if (factory == null) { + Services.exportJVMCITo(f.getClass()); factory = f; } else { // Multiple factories seen - cancel auto selection
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCICompilerFactory.java Wed Nov 09 13:37:19 2016 +0100 @@ -0,0 +1,94 @@ +/* + * 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. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.runtime.JVMCICompilerFactory; + +/** + * HotSpot extensions to {@link JVMCICompilerFactory}. + */ +public abstract class HotSpotJVMCICompilerFactory implements JVMCICompilerFactory { + + /** + * Gets 0 or more prefixes identifying classes that should by compiled by C1 in simple mode + * (i.e., {@code CompLevel_simple}) when HotSpot is running with tiered compilation. The + * prefixes should be class or package names using "/" as the separator, e.g. "jdk/vm/ci". + * + * @return 0 or more Strings identifying packages that should by compiled by the first tier only + * or null if no redirection to C1 should be performed. + */ + public String[] getTrivialPrefixes() { + return null; + } + + public enum CompilationLevelAdjustment { + /** + * No adjustment. + */ + None, + + /** + * Adjust based on declaring class of method. + */ + ByHolder, + + /** + * Adjust based on declaring class, name and signature of method. + */ + ByFullSignature + } + + /** + * Determines if this object may want to adjust the compilation level for a method that is being + * scheduled by the VM for compilation. + */ + public CompilationLevelAdjustment getCompilationLevelAdjustment() { + return CompilationLevelAdjustment.None; + } + + public enum CompilationLevel { + None, + Simple, + LimitedProfile, + FullProfile, + FullOptimization + } + + /** + * Potentially modifies the compilation level currently selected by the VM compilation policy + * for a method. + * + * @param declaringClass the class in which the method is declared + * @param name the name of the method or {@code null} depending on the value that was returned + * by {@link #getCompilationLevelAdjustment()} + * @param signature the signature of the method or {@code null} depending on the value that was + * returned by {@link #getCompilationLevelAdjustment()} + * @param isOsr specifies if the compilation being scheduled in an OSR compilation + * @param level the compilation level currently selected by the VM compilation policy + * @return the compilation level to use for the compilation being scheduled (must be a valid + * {@code CompLevel} enum value) + */ + public CompilationLevel adjustCompilationLevel(Class<?> declaringClass, String name, String signature, boolean isOsr, CompilationLevel level) { + throw new InternalError("Should not reach here"); + } +}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntime.java Wed Nov 09 13:37:19 2016 +0100 @@ -27,13 +27,11 @@ import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.ServiceLoader; import java.util.TreeMap; import jdk.internal.misc.VM; @@ -43,16 +41,15 @@ import jdk.vm.ci.code.InstalledCode; import jdk.vm.ci.common.InitTimer; import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory; -import jdk.vm.ci.hotspot.services.HotSpotJVMCICompilerFactory.CompilationLevel; -import jdk.vm.ci.hotspot.services.HotSpotVMEventListener; +import jdk.vm.ci.hotspot.HotSpotJVMCICompilerFactory.CompilationLevel; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ResolvedJavaType; import jdk.vm.ci.runtime.JVMCI; import jdk.vm.ci.runtime.JVMCIBackend; import jdk.vm.ci.runtime.JVMCICompiler; -import jdk.vm.ci.runtime.services.JVMCICompilerFactory; +import jdk.vm.ci.runtime.JVMCICompilerFactory; +import jdk.vm.ci.services.JVMCIServiceLocator; import jdk.vm.ci.services.Services; /** @@ -90,14 +87,17 @@ * A list of all supported JVMCI options. */ public enum Option { + // @formatter:off Compiler(String.class, null, "Selects the system compiler."), // Note: The following one is not used (see InitTimer.ENABLED). It is added here - // so that -Djvmci.PrintFlags=true shows the option. - InitTimer(boolean.class, false, "Specifies if initialization timing is enabled."), - PrintConfig(boolean.class, false, "Prints VM configuration available via JVMCI and exits."), - PrintFlags(boolean.class, false, "Prints all JVMCI flags and exits."), - ShowFlags(boolean.class, false, "Prints all JVMCI flags and continues."), - TraceMethodDataFilter(String.class, null, ""); + // so that -XX:+JVMCIPrintProperties shows the option. + InitTimer(Boolean.class, false, "Specifies if initialization timing is enabled."), + PrintConfig(Boolean.class, false, "Prints VM configuration available via JVMCI."), + TraceMethodDataFilter(String.class, null, + "Enables tracing of profiling info when read by JVMCI.", + "Empty value: trace all methods", + "Non-empty value: trace methods whose fully qualified name contains the value."); + // @formatter:on /** * The prefix for system properties that are JVMCI options. @@ -113,25 +113,25 @@ private Object value; private final Object defaultValue; private boolean isDefault; - private final String help; + private final String[] helpLines; - Option(Class<?> type, Object defaultValue, String help) { + Option(Class<?> type, Object defaultValue, String... helpLines) { assert Character.isUpperCase(name().charAt(0)) : "Option name must start with upper-case letter: " + name(); this.type = type; this.value = UNINITIALIZED; this.defaultValue = defaultValue; - this.help = help; + this.helpLines = helpLines; } @SuppressFBWarnings(value = "ES_COMPARING_STRINGS_WITH_EQ", justification = "sentinel must be String since it's a static final in an enum") private Object getValue() { if (value == UNINITIALIZED) { - String propertyValue = VM.getSavedProperty(JVMCI_OPTION_PROPERTY_PREFIX + name()); + String propertyValue = VM.getSavedProperty(getPropertyName()); if (propertyValue == null) { this.value = defaultValue; this.isDefault = true; } else { - if (type == boolean.class) { + if (type == Boolean.class) { this.value = Boolean.parseBoolean(propertyValue); } else if (type == String.class) { this.value = propertyValue; @@ -147,6 +147,13 @@ } /** + * Gets the name of system property from which this option gets its value. + */ + public String getPropertyName() { + return JVMCI_OPTION_PROPERTY_PREFIX + name(); + } + + /** * Returns the option's value as boolean. * * @return option's value @@ -165,16 +172,31 @@ } /** - * Prints all option flags to {@code out}. + * Prints a description of the properties used to configure shared JVMCI code. * * @param out stream to print to */ - public static void printFlags(PrintStream out) { - out.println("[List of JVMCI options]"); - for (Option option : values()) { + public static void printProperties(PrintStream out) { + out.println("[JVMCI properties]"); + int typeWidth = 0; + int nameWidth = 0; + Option[] values = values(); + for (Option option : values) { + typeWidth = Math.max(typeWidth, option.type.getSimpleName().length()); + nameWidth = Math.max(nameWidth, option.getPropertyName().length()); + } + for (Option option : values) { Object value = option.getValue(); - String assign = option.isDefault ? ":=" : " ="; - out.printf("%9s %-40s %s %-14s %s%n", option.type.getSimpleName(), option, assign, value, option.help); + if (value instanceof String) { + value = '"' + String.valueOf(value) + '"'; + } + String assign = option.isDefault ? " =" : ":="; + String format = "%" + (typeWidth + 1) + "s %-" + (nameWidth + 1) + "s %s %s%n"; + out.printf(format, option.type.getSimpleName(), option.getPropertyName(), assign, value); + String helpFormat = "%" + (typeWidth + 1) + "s %s%n"; + for (String line : option.helpLines) { + out.printf(helpFormat, "", line); + } } } } @@ -221,11 +243,7 @@ if (vmEventListeners == null) { synchronized (this) { if (vmEventListeners == null) { - List<HotSpotVMEventListener> listeners = new ArrayList<>(); - for (HotSpotVMEventListener vmEventListener : ServiceLoader.load(HotSpotVMEventListener.class)) { - listeners.add(vmEventListener); - } - vmEventListeners = listeners; + vmEventListeners = JVMCIServiceLocator.getProviders(HotSpotVMEventListener.class); } } } @@ -239,7 +257,6 @@ @SuppressWarnings("unused") private final String[] trivialPrefixes; @SuppressWarnings("try") - @SuppressFBWarnings(value = "DM_EXIT", justification = "PrintFlags is meant to exit the VM") private HotSpotJVMCIRuntime() { compilerToVm = new CompilerToVM(); @@ -261,20 +278,6 @@ metaAccessContext = new HotSpotJVMCIMetaAccessContext(); - boolean printFlags = Option.PrintFlags.getBoolean(); - boolean showFlags = Option.ShowFlags.getBoolean(); - if (printFlags || showFlags) { - Option.printFlags(System.out); - if (printFlags) { - System.exit(0); - } - } - - if (Option.PrintConfig.getBoolean()) { - printConfig(configStore, compilerToVm); - System.exit(0); - } - compilerFactory = HotSpotJVMCICompilerConfig.getCompilerFactory(); if (compilerFactory instanceof HotSpotJVMCICompilerFactory) { hsCompilerFactory = (HotSpotJVMCICompilerFactory) compilerFactory; @@ -298,6 +301,16 @@ trivialPrefixes = null; compilationLevelAdjustment = config.compLevelAdjustmentNone; } + + if (config.getFlag("JVMCIPrintProperties", Boolean.class)) { + PrintStream out = new PrintStream(getLogStream()); + Option.printProperties(out); + compilerFactory.printProperties(out); + } + + if (Option.PrintConfig.getBoolean()) { + printConfig(configStore, compilerToVm); + } } private JVMCIBackend registerBackend(JVMCIBackend backend) {
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java Wed Nov 09 13:37:19 2016 +0100 @@ -53,9 +53,9 @@ * Reference to the C++ MethodData object. */ final long metaspaceMethodData; - @SuppressWarnings("unused") private final HotSpotResolvedJavaMethodImpl method; + private final HotSpotResolvedJavaMethodImpl method; - public HotSpotMethodData(long metaspaceMethodData, HotSpotResolvedJavaMethodImpl method) { + HotSpotMethodData(long metaspaceMethodData, HotSpotResolvedJavaMethodImpl method) { this.metaspaceMethodData = metaspaceMethodData; this.method = method; } @@ -107,6 +107,18 @@ return UNSAFE.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + config.deoptReasonOSROffset + reasonIndex) & 0xFF; } + public int getDecompileCount() { + return UNSAFE.getInt(metaspaceMethodData + config.methodDataDecompiles); + } + + public int getOverflowRecompileCount() { + return UNSAFE.getInt(metaspaceMethodData + config.methodDataOverflowRecompiles); + } + + public int getOverflowTrapCount() { + return UNSAFE.getInt(metaspaceMethodData + config.methodDataOverflowTraps); + } + public HotSpotMethodDataAccessor getNormalData(int position) { if (position >= normalDataSize()) { return null; @@ -214,6 +226,12 @@ StringBuilder sb = new StringBuilder(); String nl = String.format("%n"); String nlIndent = String.format("%n%38s", ""); + sb.append("Raw method data for "); + sb.append(method.format("%H.%n(%p)")); + sb.append(":"); + sb.append(nl); + sb.append(String.format("nof_decompiles(%d) nof_overflow_recompiles(%d) nof_overflow_traps(%d)%n", + getDecompileCount(), getOverflowRecompileCount(), getOverflowTrapCount())); if (hasNormalData()) { int pos = 0; HotSpotMethodDataAccessor data; @@ -427,6 +445,10 @@ protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position); + public int getNonprofiledCount(HotSpotMethodData data, int position) { + return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET); + } + private JavaTypeProfile createTypeProfile(TriState nullSeen, RawItemProfile<ResolvedJavaType> profile) { if (profile.entries <= 0 || profile.totalCount <= 0) { return null; @@ -462,7 +484,7 @@ TriState nullSeen = getNullSeen(data, pos); TriState exceptionSeen = getExceptionSeen(data, pos); sb.append(format("count(%d) null_seen(%s) exception_seen(%s) nonprofiled_count(%d) entries(%d)", getCounterValue(data, pos), nullSeen, exceptionSeen, - getTypesNotRecordedExecutionCount(data, pos), profile.entries)); + getNonprofiledCount(data, pos), profile.entries)); for (int i = 0; i < profile.entries; i++) { long count = profile.counts[i]; sb.append(format("%n %s (%d, %4.2f)", profile.items[i].toJavaName(), count, (double) count / profile.totalCount)); @@ -490,7 +512,7 @@ @Override protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) { - return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET); + return getNonprofiledCount(data, position); } } @@ -788,7 +810,8 @@ @Override public StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos) { - return null; + sb.append("unknown profile data with tag: " + tag); + return sb; } } @@ -822,10 +845,10 @@ private static boolean checkAccessorTags() { int expectedTag = 0; for (HotSpotMethodDataAccessor accessor : PROFILE_DATA_ACCESSORS) { - if (expectedTag ==0 ) { + if (expectedTag == 0) { assert accessor == null; } else { - assert accessor.tag == expectedTag: expectedTag + " != " + accessor.tag + " " + accessor; + assert accessor.tag == expectedTag : expectedTag + " != " + accessor.tag + " " + accessor; } expectedTag++; }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotProfilingInfo.java Wed Nov 09 13:37:19 2016 +0100 @@ -57,6 +57,18 @@ return method.getCodeSize(); } + public int getDecompileCount() { + return methodData.getDecompileCount(); + } + + public int getOverflowRecompileCount() { + return methodData.getOverflowRecompileCount(); + } + + public int getOverflowTrapCount() { + return methodData.getOverflowTrapCount(); + } + @Override public JavaTypeProfile getTypeProfile(int bci) { if (!isMature) {
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java Wed Nov 09 13:37:19 2016 +0100 @@ -434,7 +434,6 @@ methodData = new HotSpotMethodData(metaspaceMethodData, this); String methodDataFilter = Option.TraceMethodDataFilter.getString(); if (methodDataFilter != null && this.format("%H.%n").contains(methodDataFilter)) { - System.out.println("Raw method data for " + this.format("%H.%n(%p)") + ":"); System.out.println(methodData.toString()); } }
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Wed Nov 09 13:37:19 2016 +0100 @@ -160,6 +160,10 @@ final int methodDataOopTrapHistoryOffset = getFieldOffset("MethodData::_trap_hist._array[0]", Integer.class, "u1"); final int methodDataIRSizeOffset = getFieldOffset("MethodData::_jvmci_ir_size", Integer.class, "int"); + final int methodDataDecompiles = getFieldOffset("MethodData::_nof_decompiles", Integer.class, "uint"); + final int methodDataOverflowRecompiles = getFieldOffset("MethodData::_nof_overflow_recompiles", Integer.class, "uint"); + final int methodDataOverflowTraps = getFieldOffset("MethodData::_nof_overflow_traps", Integer.class, "uint"); + final int nmethodCompLevelOffset = getFieldOffset("nmethod::_comp_level", Integer.class, "int"); final int compilationLevelNone = getConstant("CompLevel_none", Integer.class);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMEventListener.java Wed Nov 09 13:37:19 2016 +0100 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2015, 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. + */ +package jdk.vm.ci.hotspot; + +import jdk.vm.ci.code.CompiledCode; +import jdk.vm.ci.code.InstalledCode; + +/** + * Listener for responding to VM events. + */ +public interface HotSpotVMEventListener { + + /** + * Notifies this client that the VM is shutting down. + */ + default void notifyShutdown() { + } + + /** + * Notify on successful install into the code cache. + * + * @param hotSpotCodeCacheProvider the code cache into which the code was installed + * @param installedCode the code that was installed + * @param compiledCode the compiled code from which {@code installedCode} was produced + */ + default void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { + } + + /** + * Notify on completion of a bootstrap. + */ + default void notifyBootstrapFinished() { + } +}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EmptyEventProvider.java Mon Nov 14 12:05:26 2016 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ -package jdk.vm.ci.hotspot.services; - -/** - * An empty implementation for {@link EventProvider}. This implementation is used when no logging is - * requested. - */ -final class EmptyEventProvider extends EventProvider { - - EmptyEventProvider() { - super(null); - } - - static InternalError shouldNotReachHere() { - throw new InternalError("should not reach here"); - } - - @Override - public CompilationEvent newCompilationEvent() { - return new EmptyCompilationEvent(); - } - - static class EmptyCompilationEvent implements CompilationEvent { - public void commit() { - throw shouldNotReachHere(); - } - - public boolean shouldWrite() { - // Events of this class should never been written. - return false; - } - - public void begin() { - } - - public void end() { - } - - public void setMethod(String method) { - throw shouldNotReachHere(); - } - - public void setCompileId(int compileId) { - throw shouldNotReachHere(); - } - - public void setCompileLevel(int compileLevel) { - throw shouldNotReachHere(); - } - - public void setSucceeded(boolean succeeded) { - throw shouldNotReachHere(); - } - - public void setIsOsr(boolean isOsr) { - throw shouldNotReachHere(); - } - - public void setCodeSize(int codeSize) { - throw shouldNotReachHere(); - } - - public void setInlinedBytes(int inlinedBytes) { - throw shouldNotReachHere(); - } - } - - @Override - public CompilerFailureEvent newCompilerFailureEvent() { - return new EmptyCompilerFailureEvent(); - } - - static class EmptyCompilerFailureEvent implements CompilerFailureEvent { - public void commit() { - throw shouldNotReachHere(); - } - - public boolean shouldWrite() { - // Events of this class should never been written. - return false; - } - - public void setCompileId(int compileId) { - throw shouldNotReachHere(); - } - - public void setMessage(String message) { - throw shouldNotReachHere(); - } - } - -}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/EventProvider.java Mon Nov 14 12:05:26 2016 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2014, 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. - */ -package jdk.vm.ci.hotspot.services; - -import jdk.vm.ci.hotspot.services.EmptyEventProvider.EmptyCompilationEvent; -import jdk.vm.ci.hotspot.services.EmptyEventProvider.EmptyCompilerFailureEvent; -import jdk.vm.ci.services.JVMCIPermission; - -/** - * Service-provider class for logging compiler related events. - */ -public abstract class EventProvider { - - private static Void checkPermission() { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new JVMCIPermission()); - } - return null; - } - - @SuppressWarnings("unused") - EventProvider(Void ignore) { - } - - /** - * Initializes a new instance of this class. - * - * @throws SecurityException if a security manager has been installed and it denies - * {@link JVMCIPermission} - */ - protected EventProvider() { - this(checkPermission()); - } - - /** - * Creates and returns an empty implementation for {@link EventProvider}. This implementation - * can be used when no logging is requested. - */ - public static EventProvider createEmptyEventProvider() { - return new EmptyEventProvider(); - } - - /** - * Creates and returns an empty implementation for {@link CompilationEvent}. - */ - public static CompilationEvent createEmptyCompilationEvent() { - return new EmptyCompilationEvent(); - } - - /** - * Creates and returns an empty implementation for {@link CompilationEvent}. - */ - public static CompilerFailureEvent createEmptyCompilerFailureEvent() { - return new EmptyCompilerFailureEvent(); - } - - /** - * An instant event is an event that is not considered to have taken any time. - */ - public interface InstantEvent { - /** - * Commits the event. - */ - void commit(); - - /** - * Determines if this particular event instance would be committed to the data stream right - * now if application called {@link #commit()}. This in turn depends on whether the event is - * enabled and possible other factors. - * - * @return if this event would be committed on a call to {@link #commit()}. - */ - boolean shouldWrite(); - } - - /** - * Timed events describe an operation that somehow consumes time. - */ - public interface TimedEvent extends InstantEvent { - /** - * Starts the timing for this event. - */ - void begin(); - - /** - * Ends the timing period for this event. - */ - void end(); - } - - /** - * Creates a new {@link CompilationEvent}. - * - * @return a compilation event - */ - public abstract CompilationEvent newCompilationEvent(); - - /** - * A compilation event. - */ - public interface CompilationEvent extends TimedEvent { - void setMethod(String method); - - void setCompileId(int compileId); - - void setCompileLevel(int compileLevel); - - void setSucceeded(boolean succeeded); - - void setIsOsr(boolean isOsr); - - void setCodeSize(int codeSize); - - void setInlinedBytes(int inlinedBytes); - } - - /** - * Creates a new {@link CompilerFailureEvent}. - * - * @return a compiler failure event - */ - public abstract CompilerFailureEvent newCompilerFailureEvent(); - - /** - * A compiler failure event. - */ - public interface CompilerFailureEvent extends InstantEvent { - void setCompileId(int compileId); - - void setMessage(String message); - } -}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotJVMCICompilerFactory.java Mon Nov 14 12:05:26 2016 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,94 +0,0 @@ -/* - * 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. - */ -package jdk.vm.ci.hotspot.services; - -import jdk.vm.ci.runtime.services.JVMCICompilerFactory; - -/** - * HotSpot extensions to {@link JVMCICompilerFactory}. - */ -public abstract class HotSpotJVMCICompilerFactory extends JVMCICompilerFactory { - - /** - * Gets 0 or more prefixes identifying classes that should by compiled by C1 in simple mode - * (i.e., {@code CompLevel_simple}) when HotSpot is running with tiered compilation. The - * prefixes should be class or package names using "/" as the separator, e.g. "jdk/vm/ci". - * - * @return 0 or more Strings identifying packages that should by compiled by the first tier only - * or null if no redirection to C1 should be performed. - */ - public String[] getTrivialPrefixes() { - return null; - } - - public enum CompilationLevelAdjustment { - /** - * No adjustment. - */ - None, - - /** - * Adjust based on declaring class of method. - */ - ByHolder, - - /** - * Adjust based on declaring class, name and signature of method. - */ - ByFullSignature - } - - /** - * Determines if this object may want to adjust the compilation level for a method that is being - * scheduled by the VM for compilation. - */ - public CompilationLevelAdjustment getCompilationLevelAdjustment() { - return CompilationLevelAdjustment.None; - } - - public enum CompilationLevel { - None, - Simple, - LimitedProfile, - FullProfile, - FullOptimization - } - - /** - * Potentially modifies the compilation level currently selected by the VM compilation policy - * for a method. - * - * @param declaringClass the class in which the method is declared - * @param name the name of the method or {@code null} depending on the value that was returned - * by {@link #getCompilationLevelAdjustment()} - * @param signature the signature of the method or {@code null} depending on the value that was - * returned by {@link #getCompilationLevelAdjustment()} - * @param isOsr specifies if the compilation being scheduled in an OSR compilation - * @param level the compilation level currently selected by the VM compilation policy - * @return the compilation level to use for the compilation being scheduled (must be a valid - * {@code CompLevel} enum value) - */ - public CompilationLevel adjustCompilationLevel(Class<?> declaringClass, String name, String signature, boolean isOsr, CompilationLevel level) { - throw new InternalError("Should not reach here"); - } -}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/services/HotSpotVMEventListener.java Mon Nov 14 12:05:26 2016 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2015, 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. - */ -package jdk.vm.ci.hotspot.services; - -import jdk.vm.ci.code.CompiledCode; -import jdk.vm.ci.code.InstalledCode; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; -import jdk.vm.ci.services.JVMCIPermission; - -/** - * Service-provider class for responding to VM events. - */ -public abstract class HotSpotVMEventListener { - - private static Void checkPermission() { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new JVMCIPermission()); - } - return null; - } - - @SuppressWarnings("unused") - HotSpotVMEventListener(Void ignore) { - } - - /** - * Initializes a new instance of this class. - * - * @throws SecurityException if a security manager has been installed and it denies - * {@link JVMCIPermission} - */ - protected HotSpotVMEventListener() { - this(checkPermission()); - } - - /** - * Notifies this client that the VM is shutting down. - */ - public void notifyShutdown() { - } - - /** - * Notify on successful install into the code cache. - * - * @param hotSpotCodeCacheProvider - * @param installedCode - * @param compiledCode - */ - public void notifyInstall(HotSpotCodeCacheProvider hotSpotCodeCacheProvider, InstalledCode installedCode, CompiledCode compiledCode) { - } - - /** - * Notify on completion of a bootstrap. - */ - public void notifyBootstrapFinished() { - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/JVMCICompilerFactory.java Wed Nov 09 13:37:19 2016 +0100 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015, 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. + */ +package jdk.vm.ci.runtime; + +import java.io.PrintStream; + +/** + * Factory for creating JVMCI compilers. + */ +public interface JVMCICompilerFactory { + + /** + * Get the name of this compiler. The name is used by JVMCI to determine which factory to use. + */ + String getCompilerName(); + + /** + * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime) + * create} a compiler and it should now perform any heavy weight initialization that it deferred + * during construction. + */ + default void onSelection() { + } + + /** + * Create a new instance of a {@link JVMCICompiler}. + */ + JVMCICompiler createCompiler(JVMCIRuntime runtime); + + /** + * Prints a description of the properties used to configure this compiler. + * + * @param out where to print the message + */ + default void printProperties(PrintStream out) { + } +}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.runtime/src/jdk/vm/ci/runtime/services/JVMCICompilerFactory.java Mon Nov 14 12:05:26 2016 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2015, 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. - */ -package jdk.vm.ci.runtime.services; - -import jdk.vm.ci.runtime.JVMCICompiler; -import jdk.vm.ci.runtime.JVMCIRuntime; -import jdk.vm.ci.services.JVMCIPermission; - -/** - * Service-provider class for creating JVMCI compilers. - */ -public abstract class JVMCICompilerFactory { - - private static Void checkPermission() { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new JVMCIPermission()); - } - return null; - } - - @SuppressWarnings("unused") - private JVMCICompilerFactory(Void ignore) { - } - - /** - * Initializes a new instance of this class. - * - * @throws SecurityException if a security manager has been installed and it denies - * {@link JVMCIPermission} - */ - protected JVMCICompilerFactory() { - this(checkPermission()); - } - - /** - * Get the name of this compiler. The name is used by JVMCI to determine which factory to use. - */ - public abstract String getCompilerName(); - - /** - * Notifies this object that it has been selected to {@linkplain #createCompiler(JVMCIRuntime) - * create} a compiler and it should now perform any heavy weight initialization that it deferred - * during construction. - */ - public void onSelection() { - } - - /** - * Create a new instance of a {@link JVMCICompiler}. - */ - public abstract JVMCICompiler createCompiler(JVMCIRuntime runtime); -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/JVMCIServiceLocator.java Wed Nov 09 13:37:19 2016 +0100 @@ -0,0 +1,83 @@ +/* + * 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. + */ +package jdk.vm.ci.services; + +import java.util.ArrayList; +import java.util.List; + +/** + * Service-provider class for the runtime to locate providers of JVMCI services where the latter are + * not in packages exported by the JVMCI module. As part of instantiating + * {@link JVMCIServiceLocator}, all JVMCI packages will be {@linkplain Services#exportJVMCITo(Class) + * exported} to the module defining the class of the instantiated object. + * + * While the {@link #getProvider(Class)} method can be used directly, it's usually easier to use + * {@link #getProviders(Class)}. + */ +public abstract class JVMCIServiceLocator { + + private static Void checkPermission() { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new JVMCIPermission()); + } + return null; + } + + @SuppressWarnings("unused") + private JVMCIServiceLocator(Void ignore) { + } + + /** + * Creates a capability for accessing JVMCI. Once successfully instantiated, JVMCI exports all + * its packages to the module defining the type of this object. + * + * @throws SecurityException if a security manager has been installed and it denies + * {@link JVMCIPermission} + */ + protected JVMCIServiceLocator() { + this(checkPermission()); + Services.exportJVMCITo(getClass()); + } + + /** + * Gets the provider of the service defined by {@code service} or {@code null} if this object + * does not have a provider for {@code service}. + */ + public abstract <S> S getProvider(Class<S> service); + + /** + * Gets the providers of the service defined by {@code service} by querying the + * {@link JVMCIServiceLocator} providers obtained by {@link Services#load(Class)}. + */ + public static <S> List<S> getProviders(Class<S> service) { + List<S> providers = new ArrayList<>(); + for (JVMCIServiceLocator access : Services.load(JVMCIServiceLocator.class)) { + S provider = access.getProvider(service); + if (provider != null) { + providers.add(provider); + } + } + return providers; + } +}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARC.java Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.sparc/src/jdk/vm/ci/sparc/SPARC.java Wed Nov 09 13:37:19 2016 +0100 @@ -349,7 +349,6 @@ SUN4V, BLK_INIT_INSTRUCTIONS, FMAF, - FMAU, SPARC64_FAMILY, M_FAMILY, T_FAMILY,
--- a/hotspot/src/jdk.vm.ci/share/classes/module-info.java Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/jdk.vm.ci/share/classes/module-info.java Wed Nov 09 13:37:19 2016 +0100 @@ -25,12 +25,9 @@ module jdk.vm.ci { exports jdk.vm.ci.services; - exports jdk.vm.ci.runtime.services; - exports jdk.vm.ci.hotspot.services; - uses jdk.vm.ci.hotspot.services.HotSpotVMEventListener; + uses jdk.vm.ci.services.JVMCIServiceLocator; uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; - uses jdk.vm.ci.runtime.services.JVMCICompilerFactory; provides jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory with jdk.vm.ci.hotspot.aarch64.AArch64HotSpotJVMCIBackendFactory;
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -2563,7 +2563,7 @@ uint64_t outdata[2]; uint_t validity = 0; - if (os::Solaris::meminfo(&addr, 1, info_types, 2, outdata, &validity) < 0) { + if (meminfo(&addr, 1, info_types, 2, outdata, &validity) < 0) { return false; } @@ -2601,7 +2601,7 @@ addrs_count++; } - if (os::Solaris::meminfo(addrs, addrs_count, info_types, types, outdata, validity) < 0) { + if (meminfo(addrs, addrs_count, info_types, types, outdata, validity) < 0) { return NULL; } @@ -4160,9 +4160,6 @@ void report_error(const char* file_name, int line_no, const char* title, const char* format, ...); -// (Static) wrapper for getisax(2) call. -os::Solaris::getisax_func_t os::Solaris::_getisax = 0; - // (Static) wrappers for the liblgrp API os::Solaris::lgrp_home_func_t os::Solaris::_lgrp_home; os::Solaris::lgrp_init_func_t os::Solaris::_lgrp_init; @@ -4174,9 +4171,6 @@ os::Solaris::lgrp_cookie_stale_func_t os::Solaris::_lgrp_cookie_stale; os::Solaris::lgrp_cookie_t os::Solaris::_lgrp_cookie = 0; -// (Static) wrapper for meminfo() call. -os::Solaris::meminfo_func_t os::Solaris::_meminfo = 0; - static address resolve_symbol_lazy(const char* name) { address addr = (address) dlsym(RTLD_DEFAULT, name); if (addr == NULL) { @@ -4300,27 +4294,6 @@ return false; } -void os::Solaris::misc_sym_init() { - address func; - - // getisax - func = resolve_symbol_lazy("getisax"); - if (func != NULL) { - os::Solaris::_getisax = CAST_TO_FN_PTR(getisax_func_t, func); - } - - // meminfo - func = resolve_symbol_lazy("meminfo"); - if (func != NULL) { - os::Solaris::set_meminfo(CAST_TO_FN_PTR(meminfo_func_t, func)); - } -} - -uint_t os::Solaris::getisax(uint32_t* array, uint_t n) { - assert(_getisax != NULL, "_getisax not set"); - return _getisax(array, n); -} - // int pset_getloadavg(psetid_t pset, double loadavg[], int nelem); typedef long (*pset_getloadavg_type)(psetid_t pset, double loadavg[], int nelem); static pset_getloadavg_type pset_getloadavg_ptr = NULL; @@ -4351,10 +4324,6 @@ Solaris::initialize_system_info(); - // Initialize misc. symbols as soon as possible, so we can use them - // if we need them. - Solaris::misc_sym_init(); - int fd = ::open("/dev/zero", O_RDWR); if (fd < 0) { fatal("os::init: cannot open /dev/zero (%s)", os::strerror(errno));
--- a/hotspot/src/os/solaris/vm/os_solaris.hpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/os/solaris/vm/os_solaris.hpp Wed Nov 09 13:37:19 2016 +0100 @@ -73,8 +73,6 @@ LGRP_VIEW_OS // what's available to operating system } lgrp_view_t; - typedef uint_t (*getisax_func_t)(uint32_t* array, uint_t n); - typedef lgrp_id_t (*lgrp_home_func_t)(idtype_t idtype, id_t id); typedef lgrp_cookie_t (*lgrp_init_func_t)(lgrp_view_t view); typedef int (*lgrp_fini_func_t)(lgrp_cookie_t cookie); @@ -86,11 +84,6 @@ lgrp_rsrc_t type); typedef int (*lgrp_nlgrps_func_t)(lgrp_cookie_t cookie); typedef int (*lgrp_cookie_stale_func_t)(lgrp_cookie_t cookie); - typedef int (*meminfo_func_t)(const uint64_t inaddr[], int addr_count, - const uint_t info_req[], int info_count, - uint64_t outdata[], uint_t validity[]); - - static getisax_func_t _getisax; static lgrp_home_func_t _lgrp_home; static lgrp_init_func_t _lgrp_init; @@ -102,8 +95,6 @@ static lgrp_cookie_stale_func_t _lgrp_cookie_stale; static lgrp_cookie_t _lgrp_cookie; - static meminfo_func_t _meminfo; - // Large Page Support static bool is_valid_page_size(size_t bytes); static size_t page_size_for_alignment(size_t alignment); @@ -191,8 +182,6 @@ static void libthread_init(); static void synchronization_init(); static bool liblgrp_init(); - // Load miscellaneous symbols. - static void misc_sym_init(); // This boolean allows users to forward their own non-matching signals // to JVM_handle_solaris_signal, harmlessly. static bool signal_handlers_are_installed; @@ -272,17 +261,6 @@ } static lgrp_cookie_t lgrp_cookie() { return _lgrp_cookie; } - static bool supports_getisax() { return _getisax != NULL; } - static uint_t getisax(uint32_t* array, uint_t n); - - static void set_meminfo(meminfo_func_t func) { _meminfo = func; } - static int meminfo (const uint64_t inaddr[], int addr_count, - const uint_t info_req[], int info_count, - uint64_t outdata[], uint_t validity[]) { - return _meminfo != NULL ? _meminfo(inaddr, addr_count, info_req, info_count, - outdata, validity) : -1; - } - static sigset_t* unblocked_signals(); static sigset_t* vm_signals(); static sigset_t* allowdebug_blocked_signals();
--- a/hotspot/src/os/windows/vm/os_windows.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/os/windows/vm/os_windows.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -784,7 +784,7 @@ __try { RaiseException (MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (const ULONG_PTR*)&info ); - } __except(EXCEPTION_CONTINUE_EXECUTION) {} + } __except(EXCEPTION_EXECUTE_HANDLER) {} } bool os::distribute_processes(uint length, uint* distribution) {
--- a/hotspot/src/os/windows/vm/perfMemory_windows.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/os/windows/vm/perfMemory_windows.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -1404,12 +1404,14 @@ objectname); /* name for object */ if (fmh == NULL) { + DWORD lasterror = GetLastError(); if (PrintMiscellaneous && Verbose) { warning("OpenFileMapping failed for shared memory object %s:" - " lasterror = %d\n", objectname, GetLastError()); + " lasterror = %d\n", objectname, lasterror); } - THROW_MSG_(vmSymbols::java_lang_Exception(), - "Could not open PerfMemory", INVALID_HANDLE_VALUE); + THROW_MSG_(vmSymbols::java_lang_IllegalArgumentException(), + err_msg("Could not open PerfMemory, error %d", lasterror), + INVALID_HANDLE_VALUE); } return fmh;;
--- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -343,8 +343,15 @@ #define _SC_L2CACHE_LINESZ 527 /* Size of L2 cache line */ #endif +// Hardware capability bits that appeared after Solaris 11.1 +#ifndef AV_SPARC_FMAF +#define AV_SPARC_FMAF 0x00000100 /* Fused Multiply-Add */ +#endif +#ifndef AV2_SPARC_SPARC5 +#define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */ +#endif + int VM_Version::platform_features(int features) { - assert(os::Solaris::supports_getisax(), "getisax() must be available"); // Check 32-bit architecture. if (Sysinfo(SI_ARCHITECTURE_32).match("sparc")) { @@ -357,119 +364,75 @@ } // Extract valid instruction set extensions. - uint_t avs[2]; - uint_t avn = os::Solaris::getisax(avs, 2); - assert(avn <= 2, "should return two or less av's"); - uint_t av = avs[0]; - - log_info(os, cpu)("getisax(2) returned: " PTR32_FORMAT, av); - if (avn > 1) { - log_info(os, cpu)(" " PTR32_FORMAT, avs[1]); - } + uint_t avs[AV_HW2_IDX + 1]; + uint_t avn = getisax(avs, ARRAY_SIZE(avs)); - if (av & AV_SPARC_MUL32) features |= hardware_mul32_m; - if (av & AV_SPARC_DIV32) features |= hardware_div32_m; - if (av & AV_SPARC_FSMULD) features |= hardware_fsmuld_m; - if (av & AV_SPARC_V8PLUS) features |= v9_instructions_m; - if (av & AV_SPARC_POPC) features |= hardware_popc_m; - if (av & AV_SPARC_VIS) features |= vis1_instructions_m; - if (av & AV_SPARC_VIS2) features |= vis2_instructions_m; - if (avn > 1) { - uint_t av2 = avs[1]; -#ifndef AV2_SPARC_SPARC5 -#define AV2_SPARC_SPARC5 0x00000008 /* The 29 new fp and sub instructions */ -#endif - if (av2 & AV2_SPARC_SPARC5) features |= sparc5_instructions_m; + log_info(os, cpu)("getisax(2) returned %d words:", avn); + for (int i = 0; i < avn; i++) { + log_info(os, cpu)(" word %d: " PTR32_FORMAT, i, avs[i]); } - // We only build on Solaris 10 and up, but some of the values below - // are not defined on all versions of Solaris 10, so we define them, - // if necessary. -#ifndef AV_SPARC_ASI_BLK_INIT -#define AV_SPARC_ASI_BLK_INIT 0x0080 /* ASI_BLK_INIT_xxx ASI */ -#endif - if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m; - -#ifndef AV_SPARC_FMAF -#define AV_SPARC_FMAF 0x0100 /* Fused Multiply-Add */ -#endif - if (av & AV_SPARC_FMAF) features |= fmaf_instructions_m; - -#ifndef AV_SPARC_FMAU -#define AV_SPARC_FMAU 0x0200 /* Unfused Multiply-Add */ -#endif - if (av & AV_SPARC_FMAU) features |= fmau_instructions_m; - -#ifndef AV_SPARC_VIS3 -#define AV_SPARC_VIS3 0x0400 /* VIS3 instruction set extensions */ -#endif - if (av & AV_SPARC_VIS3) features |= vis3_instructions_m; + uint_t av1 = avs[AV_HW1_IDX]; + if (av1 & AV_SPARC_MUL32) features |= hardware_mul32_m; + if (av1 & AV_SPARC_DIV32) features |= hardware_div32_m; + if (av1 & AV_SPARC_FSMULD) features |= hardware_fsmuld_m; + if (av1 & AV_SPARC_V8PLUS) features |= v9_instructions_m; + if (av1 & AV_SPARC_POPC) features |= hardware_popc_m; + if (av1 & AV_SPARC_VIS) features |= vis1_instructions_m; + if (av1 & AV_SPARC_VIS2) features |= vis2_instructions_m; + if (av1 & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m; + if (av1 & AV_SPARC_FMAF) features |= fmaf_instructions_m; + if (av1 & AV_SPARC_VIS3) features |= vis3_instructions_m; + if (av1 & AV_SPARC_CBCOND) features |= cbcond_instructions_m; + if (av1 & AV_SPARC_CRC32C) features |= crc32c_instruction_m; + if (av1 & AV_SPARC_AES) features |= aes_instructions_m; + if (av1 & AV_SPARC_SHA1) features |= sha1_instruction_m; + if (av1 & AV_SPARC_SHA256) features |= sha256_instruction_m; + if (av1 & AV_SPARC_SHA512) features |= sha512_instruction_m; -#ifndef AV_SPARC_CBCOND -#define AV_SPARC_CBCOND 0x10000000 /* compare and branch instrs supported */ -#endif - if (av & AV_SPARC_CBCOND) features |= cbcond_instructions_m; - -#ifndef AV_SPARC_CRC32C -#define AV_SPARC_CRC32C 0x20000000 /* crc32c instruction supported */ -#endif - if (av & AV_SPARC_CRC32C) features |= crc32c_instruction_m; - -#ifndef AV_SPARC_AES -#define AV_SPARC_AES 0x00020000 /* aes instrs supported */ -#endif - if (av & AV_SPARC_AES) features |= aes_instructions_m; - -#ifndef AV_SPARC_SHA1 -#define AV_SPARC_SHA1 0x00400000 /* sha1 instruction supported */ -#endif - if (av & AV_SPARC_SHA1) features |= sha1_instruction_m; - -#ifndef AV_SPARC_SHA256 -#define AV_SPARC_SHA256 0x00800000 /* sha256 instruction supported */ -#endif - if (av & AV_SPARC_SHA256) features |= sha256_instruction_m; - -#ifndef AV_SPARC_SHA512 -#define AV_SPARC_SHA512 0x01000000 /* sha512 instruction supported */ -#endif - if (av & AV_SPARC_SHA512) features |= sha512_instruction_m; + if (avn > AV_HW2_IDX) { + uint_t av2 = avs[AV_HW2_IDX]; + if (av2 & AV2_SPARC_SPARC5) features |= sparc5_instructions_m; + } // Determine the machine type. if (Sysinfo(SI_MACHINE).match("sun4v")) { features |= sun4v_m; } - bool use_solaris_12_api = false; - Sysinfo impl(SI_CPUBRAND); - if (impl.valid()) { - // If SI_CPUBRAND works, that means Solaris 12 API to get the cache line sizes - // is available to us as well - use_solaris_12_api = true; - features |= parse_features(impl.value()); + // If SI_CPUBRAND works, that means Solaris 12 API to get the cache line sizes + // is available to us as well + Sysinfo cpu_info(SI_CPUBRAND); + bool use_solaris_12_api = cpu_info.valid(); + const char* impl; + int impl_m = 0; + if (use_solaris_12_api) { + impl = cpu_info.value(); + log_info(os, cpu)("Parsing CPU implementation from %s", impl); + impl_m = parse_features(impl); } else { // Otherwise use kstat to determine the machine type. kstat_ctl_t* kc = kstat_open(); - kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL); - const char* implementation; - bool has_implementation = false; - if (ksp != NULL) { - if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) { - kstat_named_t* knm = (kstat_named_t *)ksp->ks_data; - for (int i = 0; i < ksp->ks_ndata; i++) { - if (strcmp((const char*)&(knm[i].name),"implementation") == 0) { - implementation = KSTAT_NAMED_STR_PTR(&knm[i]); - has_implementation = true; - log_info(os, cpu)("cpu_info.implementation: %s", implementation); - features |= parse_features(implementation); - break; + if (kc != NULL) { + kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL); + if (ksp != NULL) { + if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) { + kstat_named_t* knm = (kstat_named_t *)ksp->ks_data; + for (int i = 0; i < ksp->ks_ndata; i++) { + if (strcmp((const char*)&(knm[i].name), "implementation") == 0) { + impl = KSTAT_NAMED_STR_PTR(&knm[i]); + log_info(os, cpu)("Parsing CPU implementation from %s", impl); + impl_m = parse_features(impl); + break; + } } - } // for( + } } + kstat_close(kc); } - assert(has_implementation, "unknown cpu info (changed kstat interface?)"); - kstat_close(kc); } + assert(impl_m != 0, "Unknown CPU implementation %s", impl); + features |= impl_m; bool is_sun4v = (features & sun4v_m) != 0; if (use_solaris_12_api && is_sun4v) {
--- a/hotspot/src/share/vm/asm/assembler.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/share/vm/asm/assembler.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -153,6 +153,8 @@ void Label::add_patch_at(CodeBuffer* cb, int branch_loc) { assert(_loc == -1, "Label is unbound"); + // Don't add patch locations during scratch emit. + if (cb->insts()->scratch_emit()) { return; } if (_patch_index < PatchCacheSize) { _patches[_patch_index] = branch_loc; } else {
--- a/hotspot/src/share/vm/asm/codeBuffer.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/share/vm/asm/codeBuffer.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -331,6 +331,8 @@ } void CodeSection::relocate(address at, RelocationHolder const& spec, int format) { + // Do not relocate in scratch buffers. + if (scratch_emit()) { return; } Relocation* reloc = spec.reloc(); relocInfo::relocType rtype = (relocInfo::relocType) reloc->type(); if (rtype == relocInfo::none) return;
--- a/hotspot/src/share/vm/asm/codeBuffer.hpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/share/vm/asm/codeBuffer.hpp Wed Nov 09 13:37:19 2016 +0100 @@ -92,6 +92,7 @@ address _locs_point; // last relocated position (grows upward) bool _locs_own; // did I allocate the locs myself? bool _frozen; // no more expansion of this section + bool _scratch_emit; // Buffer is used for scratch emit, don't relocate. char _index; // my section number (SECT_INST, etc.) CodeBuffer* _outer; // enclosing CodeBuffer @@ -108,6 +109,7 @@ _locs_point = NULL; _locs_own = false; _frozen = false; + _scratch_emit = false; debug_only(_index = (char)-1); debug_only(_outer = (CodeBuffer*)badAddress); } @@ -166,6 +168,10 @@ bool is_frozen() const { return _frozen; } bool has_locs() const { return _locs_end != NULL; } + // Mark scratch buffer. + void set_scratch_emit() { _scratch_emit = true; } + bool scratch_emit() { return _scratch_emit; } + CodeBuffer* outer() const { return _outer; } // is a given address in this section? (2nd version is end-inclusive)
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Mon Nov 14 12:05:26 2016 +0530 +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Wed Nov 09 13:37:19 2016 +0100 @@ -1493,6 +1493,21 @@ // Check to see whether we are inlining. If so, Return // instructions become Gotos to the continuation point. if (continuation() != NULL) { + + int invoke_bci = state()->caller_state()->bci(); + + if (x != NULL && !ignore_return) { + ciMethod* caller = state()->scope()->caller()->method(); + Bytecodes::Code invoke_raw_bc = caller->raw_code_at_bci(invoke_bci); + if (invoke_raw_bc == Bytecodes::_invokehandle || invoke_raw_bc == Bytecodes::_invokedynamic) { + ciType* declared_ret_type = caller->get_declared_signature_at_bci(invoke_bci)->return_type(); + if (declared_ret_type->is_klass() && x->exact_type() == NULL && + x->declared_type() != declared_ret_type && declared_ret_type != compilation()->env()->Object_klass()) { + x = append(new TypeCast(declared_ret_type->as_klass(), x, copy_state_before())); + } + } + } + assert(!method()->is_synchronized() || InlineSynchronizedMethods, "can not inline synchronized methods yet"); if (compilation()->env()->dtrace_method_probes()) { @@ -1516,7 +1531,6 @@ // State at end of inlined method is the state of the caller // without the method parameters on stack, including the // return value, if any, of the inlined method on operand stack. - int invoke_bci = state()->caller_state()->bci(); set_state(state()->caller_state()->copy_for_parsing()); if (x != NULL) { if (!ignore_return) { @@ -1929,7 +1943,7 @@ // number of implementors for decl_interface is 0 or 1. If // it's 0 then no class implements decl_interface and there's // no point in inlining.<