diff --git a/.hgtags b/.hgtags index 0990efaad3b..d13de9187bc 100644 --- a/.hgtags +++ b/.hgtags @@ -234,3 +234,5 @@ af9a674e12a16da1a4bd53e4990ddb1121a21ef1 jdk8-b109 b5d2bf482a3ea1cca08c994512804ffbc73de0a1 jdk8-b110 b9a0f6c693f347a6f4b9bb994957f4eaa05bdedd jdk8-b111 ad67c34f79c28a8e755f4a49f313868619d6702c jdk8-b112 +4a4dbcf7cb7d3e1a81beaa3b11cd909f69ebc79a jdk8-b113 +dfa34ab293faad9b543a24646dbb381bc3ab5586 jdk8-b114 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 8814acccf94..bc18620853e 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -234,3 +234,5 @@ b7e64be81c8a7690703df5711f4fc2375da8a9cb jdk8-b103 4faa09c7fe555de086dd9048d3c5cc92317d6f45 jdk8-b110 d086227bfc45d124f09b3bd72a07956b4073bf71 jdk8-b111 547316ea137d83d9c63083a9b83db64198fe0c81 jdk8-b112 +6ba4c7cb623ec612031e05cf8bf279d8f407bd1e jdk8-b113 +4f2011496393a26dcfd7b1f7787a3673ddd32599 jdk8-b114 diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 74eb88ad814..92d755af35f 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -514,7 +514,7 @@ AC_DEFUN([BASIC_CHECK_MAKE_VERSION], if test "x$IS_GNU_MAKE" = x; then AC_MSG_NOTICE([Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring.]) else - IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '\(3\.8[[12]]\)\|\(4\.\)'` + IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP -e '3\.8[[12]]' -e '4\.'` if test "x$IS_MODERN_MAKE" = x; then AC_MSG_NOTICE([Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring.]) else @@ -656,7 +656,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS], fi if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then - BASIC_REQUIRE_PROG(DSYMUTIL, dsymutil) + BASIC_REQUIRE_PROG(DSYMUTIL, dsymutil) BASIC_REQUIRE_PROG(XATTR, xattr) AC_PATH_PROG(CODESIGN, codesign) if test "x$CODESIGN" != "x"; then diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 0c43de65644..edac17dcbc6 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -869,6 +869,7 @@ SRC_ROOT ZERO_ARCHDEF DEFINE_CROSS_COMPILE_ARCH LP64 +OPENJDK_TARGET_OS_EXPORT_DIR OPENJDK_TARGET_OS_API_DIR OPENJDK_TARGET_CPU_JLI_CFLAGS OPENJDK_TARGET_CPU_OSARCH @@ -3864,7 +3865,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1382540536 +DATE_WHEN_GENERATED=1383151988 ############################################################################### # @@ -7149,6 +7150,13 @@ $as_echo "$COMPILE_TYPE" >&6; } fi + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + OPENJDK_TARGET_OS_EXPORT_DIR=macosx + else + OPENJDK_TARGET_OS_EXPORT_DIR=${OPENJDK_TARGET_OS_API_DIR} + fi + + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then A_LP64="LP64:=" # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in @@ -8315,7 +8323,7 @@ $as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRI { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 $as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;} else - IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '\(3\.8[12]\)\|\(4\.\)'` + IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP -e '3\.8[12]' -e '4\.'` if test "x$IS_MODERN_MAKE" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;} @@ -8672,7 +8680,7 @@ $as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRI { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 $as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;} else - IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '\(3\.8[12]\)\|\(4\.\)'` + IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP -e '3\.8[12]' -e '4\.'` if test "x$IS_MODERN_MAKE" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;} @@ -9026,7 +9034,7 @@ $as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRI { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 $as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;} else - IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '\(3\.8[12]\)\|\(4\.\)'` + IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP -e '3\.8[12]' -e '4\.'` if test "x$IS_MODERN_MAKE" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;} @@ -9385,7 +9393,7 @@ $as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRI { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 $as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;} else - IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '\(3\.8[12]\)\|\(4\.\)'` + IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP -e '3\.8[12]' -e '4\.'` if test "x$IS_MODERN_MAKE" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;} @@ -9738,7 +9746,7 @@ $as_echo "$as_me: Testing potential make at $MAKE_CANDIDATE, found using $DESCRI { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&5 $as_echo "$as_me: Found potential make at $MAKE_CANDIDATE, however, this is not GNU Make. Ignoring." >&6;} else - IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP '\(3\.8[12]\)\|\(4\.\)'` + IS_MODERN_MAKE=`$ECHO $MAKE_VERSION_STRING | $GREP -e '3\.8[12]' -e '4\.'` if test "x$IS_MODERN_MAKE" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&5 $as_echo "$as_me: Found GNU make at $MAKE_CANDIDATE, however this is not version 3.81 or later. (it is: $MAKE_VERSION_STRING). Ignoring." >&6;} @@ -29638,7 +29646,7 @@ fi -I${JDK_OUTPUTDIR}/include \ -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \ -I${JDK_TOPDIR}/src/share/javavm/export \ - -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/javavm/export \ + -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \ -I${JDK_TOPDIR}/src/share/native/common \ -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common" @@ -29905,11 +29913,11 @@ $as_echo_n "checking if we should generate debug symbols... " >&6; } elif test "x$enable_debug_symbols" = "xno"; then ENABLE_DEBUG_SYMBOLS=false else - # Default is on if objcopy is found - if test "x$OBJCOPY" != x; then - ENABLE_DEBUG_SYMBOLS=true - # MacOS X and Windows don't use objcopy but default is on for those OSes - elif test "x$OPENJDK_TARGET_OS" = xmacosx || test "x$OPENJDK_TARGET_OS" = xwindows; then + # Default is on if objcopy is found + if test "x$OBJCOPY" != x; then + ENABLE_DEBUG_SYMBOLS=true + # MacOS X and Windows don't use objcopy but default is on for those OSes + elif test "x$OPENJDK_TARGET_OS" = xmacosx || test "x$OPENJDK_TARGET_OS" = xwindows; then ENABLE_DEBUG_SYMBOLS=true else ENABLE_DEBUG_SYMBOLS=false @@ -34245,10 +34253,10 @@ ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ex ac_compiler_gnu=$ac_cv_cxx_compiler_gnu PREV_CXXCFLAGS="$CXXFLAGS" - PREV_LDFLAGS="$LDFLAGS" + PREV_LIBS="$LIBS" PREV_CXX="$CXX" CXXFLAGS="$CXXFLAGS $FREETYPE_CFLAGS" - LDFLAGS="$LDFLAGS $FREETYPE_LIBS" + LIBS="$LIBS $FREETYPE_LIBS" CXX="$FIXPATH $CXX" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -34315,7 +34323,7 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext CXXCFLAGS="$PREV_CXXFLAGS" - LDFLAGS="$PREV_LDFLAGS" + LIBS="$PREV_LIBS" CXX="$PREV_CXX" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index 126ab49c637..4397fb81123 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -516,11 +516,11 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS], elif test "x$enable_debug_symbols" = "xno"; then ENABLE_DEBUG_SYMBOLS=false else - # Default is on if objcopy is found - if test "x$OBJCOPY" != x; then - ENABLE_DEBUG_SYMBOLS=true - # MacOS X and Windows don't use objcopy but default is on for those OSes - elif test "x$OPENJDK_TARGET_OS" = xmacosx || test "x$OPENJDK_TARGET_OS" = xwindows; then + # Default is on if objcopy is found + if test "x$OBJCOPY" != x; then + ENABLE_DEBUG_SYMBOLS=true + # MacOS X and Windows don't use objcopy but default is on for those OSes + elif test "x$OPENJDK_TARGET_OS" = xmacosx || test "x$OPENJDK_TARGET_OS" = xwindows; then ENABLE_DEBUG_SYMBOLS=true else ENABLE_DEBUG_SYMBOLS=false diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 index c41da30a70b..c2cc3794429 100644 --- a/common/autoconf/libraries.m4 +++ b/common/autoconf/libraries.m4 @@ -481,10 +481,10 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE], AC_MSG_CHECKING([if we can compile and link with freetype]) AC_LANG_PUSH(C++) PREV_CXXCFLAGS="$CXXFLAGS" - PREV_LDFLAGS="$LDFLAGS" + PREV_LIBS="$LIBS" PREV_CXX="$CXX" CXXFLAGS="$CXXFLAGS $FREETYPE_CFLAGS" - LDFLAGS="$LDFLAGS $FREETYPE_LIBS" + LIBS="$LIBS $FREETYPE_LIBS" CXX="$FIXPATH $CXX" AC_LINK_IFELSE([AC_LANG_SOURCE([[ #include @@ -508,7 +508,7 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE], ] ) CXXCFLAGS="$PREV_CXXFLAGS" - LDFLAGS="$PREV_LDFLAGS" + LIBS="$PREV_LIBS" CXX="$PREV_CXX" AC_LANG_POP(C++) diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 index 40c32526ca4..757bf227e78 100644 --- a/common/autoconf/platform.m4 +++ b/common/autoconf/platform.m4 @@ -327,6 +327,13 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS], fi AC_SUBST(OPENJDK_TARGET_OS_API_DIR) + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + OPENJDK_TARGET_OS_EXPORT_DIR=macosx + else + OPENJDK_TARGET_OS_EXPORT_DIR=${OPENJDK_TARGET_OS_API_DIR} + fi + AC_SUBST(OPENJDK_TARGET_OS_EXPORT_DIR) + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then A_LP64="LP64:=" # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index a8cc664c178..3b08c6dc588 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -92,6 +92,7 @@ OPENJDK_TARGET_CPU_LEGACY_LIB:=@OPENJDK_TARGET_CPU_LEGACY_LIB@ OPENJDK_TARGET_CPU_OSARCH:=@OPENJDK_TARGET_CPU_OSARCH@ OPENJDK_TARGET_CPU_JLI_CFLAGS:=@OPENJDK_TARGET_CPU_JLI_CFLAGS@ OPENJDK_TARGET_OS_API_DIR:=@OPENJDK_TARGET_OS_API_DIR@ +OPENJDK_TARGET_OS_EXPORT_DIR:=@OPENJDK_TARGET_OS_EXPORT_DIR@ # We are building on this build system. # When not cross-compiling, it is the same as the target. diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index 5ad404d4fdd..c7cb93f2736 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -942,7 +942,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_COMPILER_FLAGS_FOR_JDK], -I${JDK_OUTPUTDIR}/include \ -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \ -I${JDK_TOPDIR}/src/share/javavm/export \ - -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/javavm/export \ + -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_EXPORT_DIR/javavm/export \ -I${JDK_TOPDIR}/src/share/native/common \ -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common" diff --git a/common/makefiles/JavaCompilation.gmk b/common/makefiles/JavaCompilation.gmk index 009aba801d9..065bbbc34b0 100644 --- a/common/makefiles/JavaCompilation.gmk +++ b/common/makefiles/JavaCompilation.gmk @@ -506,30 +506,30 @@ define SetupJavaCompilation $$($1_BIN)/javac_state: $$($1_SRCS) $$($1_DEPENDS) $(MKDIR) -p $$(@D) - $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp) + $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp) $(ECHO) Compiling $1 ($$($1_JVM) $$($1_SJAVAC) \ $$($1_REMOTE) \ -j $(JOBS) \ --permit-unidentified-artifacts \ --permit-sources-without-package \ - --compare-found-sources $$($1_BIN)/_the.batch.tmp \ + --compare-found-sources $$($1_BIN)/_the.$1_batch.tmp \ --log=$(LOG_LEVEL) \ $$($1_SJAVAC_ARGS) \ $$($1_FLAGS) \ $$($1_HEADERS_ARG) \ -d $$($1_BIN) && \ - $(MV) $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch) + $(MV) $$($1_BIN)/_the.$1_batch.tmp $$($1_BIN)/_the.$1_batch) else # Using plain javac to batch compile everything. - $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/_the.batch + $1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_BIN)/_the.$1_batch # When building in batch, put headers in a temp dir to filter out those that actually # changed before copying them to the real header dir. ifneq (,$$($1_HEADERS)) $1_HEADERS_ARG := -h $$($1_HEADERS).tmp - $$($1_HEADERS)/_the.headers: $$($1_BIN)/_the.batch + $$($1_HEADERS)/_the.$1_headers: $$($1_BIN)/_the.$1_batch $(MKDIR) -p $$(@D) for f in `ls $$($1_HEADERS).tmp`; do \ if [ ! -f "$$($1_HEADERS)/$$$$f" ] || [ "`$(DIFF) $$($1_HEADERS)/$$$$f $$($1_HEADERS).tmp/$$$$f`" != "" ]; then \ @@ -539,19 +539,19 @@ define SetupJavaCompilation $(RM) -r $$($1_HEADERS).tmp $(TOUCH) $$@ - $1 += $$($1_HEADERS)/_the.headers + $1 += $$($1_HEADERS)/_the.$1_headers endif # When not using sjavac, pass along all sources to javac using an @file. - $$($1_BIN)/_the.batch: $$($1_SRCS) $$($1_DEPENDS) + $$($1_BIN)/_the.$1_batch: $$($1_SRCS) $$($1_DEPENDS) $(MKDIR) -p $$(@D) - $(RM) $$($1_BIN)/_the.batch $$($1_BIN)/_the.batch.tmp - $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp) - $(ECHO) Compiling `$(WC) $$($1_BIN)/_the.batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1 + $(RM) $$($1_BIN)/_the.$1_batch $$($1_BIN)/_the.$1_batch.tmp + $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.$1_batch.tmp) + $(ECHO) Compiling `$(WC) $$($1_BIN)/_the.$1_batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files for $1 ($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) \ -implicit:none -sourcepath "$$($1_SRCROOTSC)" \ - -d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.batch.tmp && \ - $(MV) $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch) + -d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.$1_batch.tmp && \ + $(MV) $$($1_BIN)/_the.$1_batch.tmp $$($1_BIN)/_the.$1_batch) endif diff --git a/common/makefiles/NativeCompilation.gmk b/common/makefiles/NativeCompilation.gmk index 3c9a0a1a490..6ee497f5262 100644 --- a/common/makefiles/NativeCompilation.gmk +++ b/common/makefiles/NativeCompilation.gmk @@ -435,36 +435,36 @@ define SetupNativeCompilation $(CP) $$< $$@ endif - ifneq ($(OPENJDK_TARGET_OS), macosx) # OBJCOPY is not used on MacOS X - ifneq ($(OPENJDK_TARGET_OS), windows) # nor on Windows - ifeq ($(OPENJDK_TARGET_OS), solaris) - # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. - # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from - # empty section headers until a fixed $(OBJCOPY) is available. - # An empty section header has sh_addr == 0 and sh_size == 0. - # This problem has only been seen on Solaris X64, but we call this tool - # on all Solaris builds just in case. - # - # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. - # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. - $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) \ - $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) - $(RM) $$@ - $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< - $(OBJCOPY) --only-keep-debug $$< $$@ - $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< - else # not solaris - $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) - $(RM) $$@ - $(OBJCOPY) --only-keep-debug $$< $$@ - $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< - endif # Touch to not retrigger rule on rebuild + ifneq ($(OPENJDK_TARGET_OS), macosx) # OBJCOPY is not used on MacOS X + ifneq ($(OPENJDK_TARGET_OS), windows) # nor on Windows + ifeq ($(OPENJDK_TARGET_OS), solaris) + # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. + # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from + # empty section headers until a fixed $(OBJCOPY) is available. + # An empty section header has sh_addr == 0 and sh_size == 0. + # This problem has only been seen on Solaris X64, but we call this tool + # on all Solaris builds just in case. + # + # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. + # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. + $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) \ + $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) + $(RM) $$@ + $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< + $(OBJCOPY) --only-keep-debug $$< $$@ + $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< + else # not solaris + $$($1_OBJECT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo : $$($1_TARGET) + $(RM) $$@ + $(OBJCOPY) --only-keep-debug $$< $$@ + $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< + endif # Touch to not retrigger rule on rebuild $(TOUCH) $$@ - endif # !windows - endif # !macosx + endif # !windows + endif # !macosx ifeq ($(ZIP_DEBUGINFO_FILES), true) - ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet +ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).diz ifeq ($(OPENJDK_TARGET_OS), windows) @@ -477,12 +477,12 @@ define SetupNativeCompilation $(CD) $$($1_OBJECT_DIR) \ && $(ZIP) -q $$@ $$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo endif - endif # no MacOS X support yet +endif # no MacOS X support yet else ifeq ($(OPENJDK_TARGET_OS), windows) $1 += $$($1_OUTPUT_DIR)/$$($1_LIBRARY).map \ $$($1_OUTPUT_DIR)/$$($1_LIBRARY).pdb - else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files + else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files $1 += $$($1_OUTPUT_DIR)/$$(LIBRARY_PREFIX)$$($1_LIBRARY).debuginfo endif endif @@ -519,36 +519,36 @@ define SetupNativeCompilation $(CP) $$< $$@ endif - ifneq ($(OPENJDK_TARGET_OS), macosx) # OBJCOPY is not used on MacOS X - ifneq ($(OPENJDK_TARGET_OS), windows) # nor on Windows - ifeq ($(OPENJDK_TARGET_OS), solaris) - # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. - # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from - # empty section headers until a fixed $(OBJCOPY) is available. - # An empty section header has sh_addr == 0 and sh_size == 0. - # This problem has only been seen on Solaris X64, but we call this tool - # on all Solaris builds just in case. - # - # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. - # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. - $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) \ - $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) - $(RM) $$@ - $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< - $(OBJCOPY) --only-keep-debug $$< $$@ - $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< - else # not solaris - $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) - $(RM) $$@ - $(OBJCOPY) --only-keep-debug $$< $$@ - $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< - endif - $(TOUCH) $$@ - endif # !windows - endif # !macosx + ifneq ($(OPENJDK_TARGET_OS), macosx) # OBJCOPY is not used on MacOS X + ifneq ($(OPENJDK_TARGET_OS), windows) # nor on Windows + ifeq ($(OPENJDK_TARGET_OS), solaris) + # gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set. + # Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from + # empty section headers until a fixed $(OBJCOPY) is available. + # An empty section header has sh_addr == 0 and sh_size == 0. + # This problem has only been seen on Solaris X64, but we call this tool + # on all Solaris builds just in case. + # + # $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections. + # Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available. + $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) \ + $(FIX_EMPTY_SEC_HDR_FLAGS) $(ADD_GNU_DEBUGLINK) + $(RM) $$@ + $(FIX_EMPTY_SEC_HDR_FLAGS) $(LOG_INFO) $$< + $(OBJCOPY) --only-keep-debug $$< $$@ + $(CD) $$(@D) && $(ADD_GNU_DEBUGLINK) $(LOG_INFO) $$(@F) $$< + else # not solaris + $$($1_OBJECT_DIR)/$$($1_PROGRAM).debuginfo : $$($1_TARGET) + $(RM) $$@ + $(OBJCOPY) --only-keep-debug $$< $$@ + $(CD) $$(@D) && $(OBJCOPY) --add-gnu-debuglink=$$(@F) $$< + endif + $(TOUCH) $$@ + endif # !windows + endif # !macosx ifeq ($(ZIP_DEBUGINFO_FILES), true) - ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet +ifneq ($(OPENJDK_TARGET_OS), macosx) # no MacOS X support yet $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).diz ifeq ($(OPENJDK_TARGET_OS), windows) @@ -561,12 +561,12 @@ define SetupNativeCompilation $(CD) $$($1_OBJECT_DIR) \ && $(ZIP) -q $$@ $$($1_PROGRAM).debuginfo endif - endif # no MacOS X support yet +endif # no MacOS X support yet else ifeq ($(OPENJDK_TARGET_OS), windows) $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).map \ $$($1_OUTPUT_DIR)/$$($1_PROGRAM).pdb - else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files + else ifneq ($(OPENJDK_TARGET_OS), macosx) # MacOS X does not use .debuginfo files $1 += $$($1_OUTPUT_DIR)/$$($1_PROGRAM).debuginfo endif endif diff --git a/corba/.hgtags b/corba/.hgtags index 3b352004341..132a2d9acf4 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -234,3 +234,5 @@ a4bb3b4500164748a9c33b2283cfda76d89f25ab jdk8-b108 3d2b7ce93c5c2e3db748f29c3d29620a8b3b748a jdk8-b110 85c1c94e723582f9a1dd0251502c42b73d6deea7 jdk8-b111 43cec76d1d62587a07af07e2d9bec93aba2a506b jdk8-b112 +a259ff3e42d91da68f4d4f09d7eb9dc22bc024fc jdk8-b113 +0bbccf77c23e566170b88b52c2cf28e5d31ce927 jdk8-b114 diff --git a/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java b/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java index 3018cdef99e..1b03be02dd1 100644 --- a/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java +++ b/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java @@ -580,7 +580,7 @@ public class AnyImpl extends Any java.lang.Object[] objholder = new java.lang.Object[1]; objholder[0] = object; long[] longholder = new long[1]; - TCUtility.unmarshalIn(in, typeCode, longholder, objholder); + TCUtility.unmarshalIn(in, realType(), longholder, objholder); value = longholder[0]; object = objholder[0]; stream = null; diff --git a/corba/src/share/classes/javax/rmi/CORBA/Stub.java b/corba/src/share/classes/javax/rmi/CORBA/Stub.java index 72f9434c99f..227e28992b6 100644 --- a/corba/src/share/classes/javax/rmi/CORBA/Stub.java +++ b/corba/src/share/classes/javax/rmi/CORBA/Stub.java @@ -61,13 +61,11 @@ public abstract class Stub extends ObjectImpl private transient StubDelegate stubDelegate = null; private static Class stubDelegateClass = null; private static final String StubClassKey = "javax.rmi.CORBA.StubClass"; - private static final String defaultStubImplName = "com.sun.corba.se.impl.javax.rmi.CORBA.StubDelegateImpl"; static { - Object stubDelegateInstance = (Object) createDelegateIfSpecified(StubClassKey, defaultStubImplName); + Object stubDelegateInstance = createDelegate(StubClassKey); if (stubDelegateInstance != null) stubDelegateClass = stubDelegateInstance.getClass(); - } @@ -207,7 +205,7 @@ public abstract class Stub extends ObjectImpl // are in different packages and the visibility needs to be package for // security reasons. If you know a better solution how to share this code // then remove it from PortableRemoteObject. Also in Util.java - private static Object createDelegateIfSpecified(String classKey, String defaultClassName) { + private static Object createDelegate(String classKey) { String className = (String) AccessController.doPrivileged(new GetPropertyAction(classKey)); if (className == null) { @@ -218,7 +216,7 @@ public abstract class Stub extends ObjectImpl } if (className == null) { - className = defaultClassName; + return new com.sun.corba.se.impl.javax.rmi.CORBA.StubDelegateImpl(); } try { diff --git a/corba/src/share/classes/javax/rmi/CORBA/Util.java b/corba/src/share/classes/javax/rmi/CORBA/Util.java index 449788afa62..65df15f1a27 100644 --- a/corba/src/share/classes/javax/rmi/CORBA/Util.java +++ b/corba/src/share/classes/javax/rmi/CORBA/Util.java @@ -60,14 +60,11 @@ import com.sun.corba.se.impl.orbutil.GetPropertyAction; public class Util { // This can only be set at static initialization time (no sync necessary). - private static javax.rmi.CORBA.UtilDelegate utilDelegate = null; + private static final javax.rmi.CORBA.UtilDelegate utilDelegate; private static final String UtilClassKey = "javax.rmi.CORBA.UtilClass"; - private static final String defaultUtilImplName = -"com.sun.corba.se.impl.javax.rmi.CORBA.Util"; static { - utilDelegate = (javax.rmi.CORBA.UtilDelegate) - createDelegateIfSpecified(UtilClassKey, defaultUtilImplName); + utilDelegate = (javax.rmi.CORBA.UtilDelegate)createDelegate(UtilClassKey); } private Util(){} @@ -338,9 +335,7 @@ Tie#deactivate} // are in different packages and the visibility needs to be package for // security reasons. If you know a better solution how to share this code // then remove it from PortableRemoteObject. Also in Stub.java - private static Object createDelegateIfSpecified(String classKey, - String defaultClassName) - { + private static Object createDelegate(String classKey) { String className = (String) AccessController.doPrivileged(new GetPropertyAction(classKey)); if (className == null) { @@ -351,7 +346,7 @@ Tie#deactivate} } if (className == null) { - className = defaultClassName; + return new com.sun.corba.se.impl.javax.rmi.CORBA.Util(); } try { diff --git a/corba/src/share/classes/javax/rmi/PortableRemoteObject.java b/corba/src/share/classes/javax/rmi/PortableRemoteObject.java index cbd6df25510..951f06cb477 100644 --- a/corba/src/share/classes/javax/rmi/PortableRemoteObject.java +++ b/corba/src/share/classes/javax/rmi/PortableRemoteObject.java @@ -65,17 +65,14 @@ import com.sun.corba.se.impl.orbutil.GetPropertyAction; */ public class PortableRemoteObject { - private static javax.rmi.CORBA.PortableRemoteObjectDelegate proDelegate = null; + private static final javax.rmi.CORBA.PortableRemoteObjectDelegate proDelegate; private static final String PortableRemoteObjectClassKey = "javax.rmi.CORBA.PortableRemoteObjectClass"; - private static final String defaultPortableRemoteObjectImplName = - "com.sun.corba.se.impl.javax.rmi.PortableRemoteObject"; - static { proDelegate = (javax.rmi.CORBA.PortableRemoteObjectDelegate) - createDelegateIfSpecified(PortableRemoteObjectClassKey); + createDelegate(PortableRemoteObjectClassKey); } /** @@ -181,7 +178,7 @@ public class PortableRemoteObject { // are in different packages and the visibility needs to be package for // security reasons. If you know a better solution how to share this code // then remove it from here. - private static Object createDelegateIfSpecified(String classKey) { + private static Object createDelegate(String classKey) { String className = (String) AccessController.doPrivileged(new GetPropertyAction(classKey)); if (className == null) { @@ -191,7 +188,7 @@ public class PortableRemoteObject { } } if (className == null) { - className = defaultPortableRemoteObjectImplName; + return new com.sun.corba.se.impl.javax.rmi.PortableRemoteObject(); } try { diff --git a/corba/src/share/classes/org/omg/CORBA/ORB.java b/corba/src/share/classes/org/omg/CORBA/ORB.java index 42fe7bc0090..5b434097c65 100644 --- a/corba/src/share/classes/org/omg/CORBA/ORB.java +++ b/corba/src/share/classes/org/omg/CORBA/ORB.java @@ -173,15 +173,6 @@ abstract public class ORB { private static final String ORBClassKey = "org.omg.CORBA.ORBClass"; private static final String ORBSingletonClassKey = "org.omg.CORBA.ORBSingletonClass"; - // - // The last resort fallback ORB implementation classes in case - // no ORB implementation class is dynamically configured through - // properties or applet parameters. Change these values to - // vendor-specific class names. - // - private static final String defaultORB = "com.sun.corba.se.impl.orb.ORBImpl"; - private static final String defaultORBSingleton = "com.sun.corba.se.impl.orb.ORBSingleton"; - // // The global instance of the singleton ORB implementation which // acts as a factory for typecodes for generated Helper classes. @@ -294,10 +285,11 @@ abstract public class ORB { String className = getSystemProperty(ORBSingletonClassKey); if (className == null) className = getPropertyFromFile(ORBSingletonClassKey); - if (className == null) - className = defaultORBSingleton; - - singleton = create_impl(className); + if (className == null) { + singleton = new com.sun.corba.se.impl.orb.ORBSingleton(); + } else { + singleton = create_impl(className); + } } return singleton; } @@ -347,10 +339,12 @@ abstract public class ORB { className = getSystemProperty(ORBClassKey); if (className == null) className = getPropertyFromFile(ORBClassKey); - if (className == null) - className = defaultORB; + if (className == null) { + orb = new com.sun.corba.se.impl.orb.ORBImpl(); + } else { + orb = create_impl(className); + } - orb = create_impl(className); orb.set_parameters(args, props); return orb; } @@ -375,10 +369,12 @@ abstract public class ORB { className = getSystemProperty(ORBClassKey); if (className == null) className = getPropertyFromFile(ORBClassKey); - if (className == null) - className = defaultORB; + if (className == null) { + orb = new com.sun.corba.se.impl.orb.ORBImpl(); + } else { + orb = create_impl(className); + } - orb = create_impl(className); orb.set_parameters(app, props); return orb; } diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 75a05fd42c4..22734a967f6 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -387,3 +387,7 @@ f6962730bbde82f279a0ae3a1c14bc5e58096c6e jdk8-b111 4a845c7a463844cead9e1e1641d6bcfb8a77f1c7 hs25-b54 0ed9a90f45e1b392c671005f9ee22ce1acf02984 jdk8-b112 23b8db5ea31d3079f1326afde4cd5c67b1dac49c hs25-b55 +4589b398ab03aba6a5da8c06ff53603488d1b8f4 jdk8-b113 +82a9cdbf683e374a76f2009352de53e16bed5a91 hs25-b56 +7fd913010dbbf75260688fd2fa8964763fa49a09 jdk8-b114 +3b32d287da89a47a45d16f6d9ba5bd3cd9bf4b3e hs25-b57 diff --git a/hotspot/agent/src/os/bsd/ps_proc.c b/hotspot/agent/src/os/bsd/ps_proc.c index cf4a5d71d75..53cafe1f44e 100644 --- a/hotspot/agent/src/os/bsd/ps_proc.c +++ b/hotspot/agent/src/os/bsd/ps_proc.c @@ -131,7 +131,7 @@ static bool process_get_lwp_info(struct ps_prochandle *ph, lwpid_t lwp_id, void static bool ptrace_continue(pid_t pid, int signal) { // pass the signal to the process so we don't swallow it - if (ptrace(PTRACE_CONT, pid, NULL, signal) < 0) { + if (ptrace(PT_CONTINUE, pid, NULL, signal) < 0) { print_debug("ptrace(PTRACE_CONT, ..) failed for %d\n", pid); return false; } @@ -434,7 +434,6 @@ static ps_prochandle_ops process_ops = { // attach to the process. One and only one exposed stuff struct ps_prochandle* Pgrab(pid_t pid) { struct ps_prochandle* ph = NULL; - thread_info* thr = NULL; if ( (ph = (struct ps_prochandle*) calloc(1, sizeof(struct ps_prochandle))) == NULL) { print_debug("can't allocate memory for ps_prochandle\n"); diff --git a/hotspot/agent/src/os/linux/ps_core.c b/hotspot/agent/src/os/linux/ps_core.c index ab3866d5997..268fc2ad162 100644 --- a/hotspot/agent/src/os/linux/ps_core.c +++ b/hotspot/agent/src/os/linux/ps_core.c @@ -719,7 +719,7 @@ static bool read_lib_segments(struct ps_prochandle* ph, int lib_fd, ELF_EHDR* li ELF_PHDR* phbuf; ELF_PHDR* lib_php = NULL; - int page_size=sysconf(_SC_PAGE_SIZE); + int page_size = sysconf(_SC_PAGE_SIZE); if ((phbuf = read_program_header_table(lib_fd, lib_ehdr)) == NULL) { return false; @@ -736,26 +736,29 @@ static bool read_lib_segments(struct ps_prochandle* ph, int lib_fd, ELF_EHDR* li if (existing_map == NULL){ if (add_map_info(ph, lib_fd, lib_php->p_offset, - target_vaddr, lib_php->p_filesz) == NULL) { + target_vaddr, lib_php->p_memsz) == NULL) { goto err; } } else { + // Coredump stores value of p_memsz elf field + // rounded up to page boundary. + if ((existing_map->memsz != page_size) && (existing_map->fd != lib_fd) && - (existing_map->memsz != lib_php->p_filesz)){ + (ROUNDUP(existing_map->memsz, page_size) != ROUNDUP(lib_php->p_memsz, page_size))) { - print_debug("address conflict @ 0x%lx (size = %ld, flags = %d\n)", - target_vaddr, lib_php->p_filesz, lib_php->p_flags); + print_debug("address conflict @ 0x%lx (existing map size = %ld, size = %ld, flags = %d)\n", + target_vaddr, existing_map->memsz, lib_php->p_memsz, lib_php->p_flags); goto err; } /* replace PT_LOAD segment with library segment */ print_debug("overwrote with new address mapping (memsz %ld -> %ld)\n", - existing_map->memsz, lib_php->p_filesz); + existing_map->memsz, ROUNDUP(lib_php->p_memsz, page_size)); existing_map->fd = lib_fd; existing_map->offset = lib_php->p_offset; - existing_map->memsz = lib_php->p_filesz; + existing_map->memsz = ROUNDUP(lib_php->p_memsz, page_size); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java index 3d0a370cd66..585581fefe4 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstMethod.java @@ -51,6 +51,7 @@ public class ConstMethod extends VMObject { private static int HAS_GENERIC_SIGNATURE; private static int HAS_METHOD_ANNOTATIONS; private static int HAS_PARAMETER_ANNOTATIONS; + private static int HAS_METHOD_PARAMETERS; private static int HAS_DEFAULT_ANNOTATIONS; private static int HAS_TYPE_ANNOTATIONS; @@ -70,6 +71,7 @@ public class ConstMethod extends VMObject { HAS_GENERIC_SIGNATURE = db.lookupIntConstant("ConstMethod::_has_generic_signature").intValue(); HAS_METHOD_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_method_annotations").intValue(); HAS_PARAMETER_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_parameter_annotations").intValue(); + HAS_METHOD_PARAMETERS = db.lookupIntConstant("ConstMethod::_has_method_parameters").intValue(); HAS_DEFAULT_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_default_annotations").intValue(); HAS_TYPE_ANNOTATIONS = db.lookupIntConstant("ConstMethod::_has_type_annotations").intValue(); @@ -85,6 +87,9 @@ public class ConstMethod extends VMObject { // start of byte code bytecodeOffset = type.getSize(); + type = db.lookupType("MethodParametersElement"); + methodParametersElementSize = type.getSize(); + type = db.lookupType("CheckedExceptionElement"); checkedExceptionElementSize = type.getSize(); @@ -113,7 +118,7 @@ public class ConstMethod extends VMObject { // start of bytecode private static long bytecodeOffset; - + private static long methodParametersElementSize; private static long checkedExceptionElementSize; private static long localVariableTableElementSize; private static long exceptionTableElementSize; @@ -387,6 +392,10 @@ public class ConstMethod extends VMObject { return ret; } + private boolean hasMethodParameters() { + return (getFlags() & HAS_METHOD_PARAMETERS) != 0; + } + private boolean hasGenericSignature() { return (getFlags() & HAS_GENERIC_SIGNATURE) != 0; } @@ -442,11 +451,41 @@ public class ConstMethod extends VMObject { return offsetOfLastU2Element(); } - private long offsetOfCheckedExceptionsLength() { + private long offsetOfMethodParametersLength() { + if (Assert.ASSERTS_ENABLED) { + Assert.that(hasMethodParameters(), "should only be called if table is present"); + } return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : offsetOfLastU2Element(); } + private int getMethodParametersLength() { + if (hasMethodParameters()) + return (int) getAddress().getCIntegerAt(offsetOfMethodParametersLength(), 2, true); + else + return 0; + } + + // Offset of start of checked exceptions + private long offsetOfMethodParameters() { + long offset = offsetOfMethodParametersLength(); + long length = getMethodParametersLength(); + if (Assert.ASSERTS_ENABLED) { + Assert.that(length > 0, "should only be called if method parameter information is present"); + } + offset -= length * methodParametersElementSize; + return offset; + } + + private long offsetOfCheckedExceptionsLength() { + if (hasMethodParameters()) + return offsetOfMethodParameters() - sizeofShort; + else { + return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : + offsetOfLastU2Element(); + } + } + private int getCheckedExceptionsLength() { if (hasCheckedExceptions()) { return (int) getAddress().getCIntegerAt(offsetOfCheckedExceptionsLength(), 2, true); @@ -496,6 +535,8 @@ public class ConstMethod extends VMObject { return offsetOfExceptionTable() - sizeofShort; } else if (hasCheckedExceptions()) { return offsetOfCheckedExceptions() - sizeofShort; + } else if (hasMethodParameters()) { + return offsetOfMethodParameters() - sizeofShort; } else { return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : offsetOfLastU2Element(); @@ -526,6 +567,8 @@ public class ConstMethod extends VMObject { } if (hasCheckedExceptions()) { return offsetOfCheckedExceptions() - sizeofShort; + } else if (hasMethodParameters()) { + return offsetOfMethodParameters() - sizeofShort; } else { return hasGenericSignature() ? offsetOfLastU2Element() - sizeofShort : offsetOfLastU2Element(); diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java index eeda376b1d6..d2ea2db855d 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java @@ -51,8 +51,7 @@ public class ClassLoaderStats extends Tool { public static void main(String[] args) { ClassLoaderStats cls = new ClassLoaderStats(); - cls.start(args); - cls.stop(); + cls.execute(args); } private static class ClassData { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java index ed707b9ee8a..2a8ca2cfb7a 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java @@ -54,8 +54,7 @@ public class FinalizerInfo extends Tool { public static void main(String[] args) { FinalizerInfo finfo = new FinalizerInfo(); - finfo.start(args); - finfo.stop(); + finfo.execute(args); } public void run() { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java index c8db6d6b044..37fa4c83c26 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/FlagDumper.java @@ -54,7 +54,6 @@ public class FlagDumper extends Tool { public static void main(String[] args) { FlagDumper fd = new FlagDumper(); - fd.start(args); - fd.stop(); + fd.execute(args); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java index c5af0ed005d..e2da202acb9 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java @@ -80,8 +80,7 @@ public class HeapDumper extends Tool { } HeapDumper dumper = new HeapDumper(file); - dumper.start(args); - dumper.stop(); + dumper.execute(args); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java index daab682aaef..f87457c3c3e 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java @@ -46,8 +46,7 @@ public class HeapSummary extends Tool { public static void main(String[] args) { HeapSummary hs = new HeapSummary(); - hs.start(args); - hs.stop(); + hs.execute(args); } public void run() { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java index f2452420744..6f9cd0f41d2 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JInfo.java @@ -134,8 +134,7 @@ public class JInfo extends Tool { } JInfo jinfo = new JInfo(mode); - jinfo.start(args); - jinfo.stop(); + jinfo.execute(args); } private void printVMFlags() { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JMap.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JMap.java index f6f3c0741c0..847eac19468 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JMap.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JMap.java @@ -136,7 +136,9 @@ public class JMap extends Tool { mode = MODE_HEAP_GRAPH_GXL; } else { System.err.println("unknown heap format:" + format); - return; + + // Exit with error status + System.exit(1); } } else { copyArgs = false; @@ -153,8 +155,7 @@ public class JMap extends Tool { } JMap jmap = new JMap(mode); - jmap.start(args); - jmap.stop(); + jmap.execute(args); } public boolean writeHeapHprofBin(String fileName) { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java index 9301f1059fd..c2e5ed52f84 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JSnap.java @@ -64,7 +64,6 @@ public class JSnap extends Tool { public static void main(String[] args) { JSnap js = new JSnap(); - js.start(args); - js.stop(); + js.execute(args); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java index 7cbe8f4d945..52fb6654e70 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/JStack.java @@ -89,8 +89,7 @@ public class JStack extends Tool { } JStack jstack = new JStack(mixedMode, concurrentLocks); - jstack.start(args); - jstack.stop(); + jstack.execute(args); } private boolean mixedMode; diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java index 168202eec2c..6c6c555badf 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java @@ -61,7 +61,6 @@ public class ObjectHistogram extends Tool { public static void main(String[] args) { ObjectHistogram oh = new ObjectHistogram(); - oh.start(args); - oh.stop(); + oh.execute(args); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java index 2a234130991..e18aa76cfa6 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PMap.java @@ -69,7 +69,6 @@ public class PMap extends Tool { public static void main(String[] args) throws Exception { PMap t = new PMap(); - t.start(args); - t.stop(); + t.execute(args); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java index 7f10612b317..c4e7b5c7b74 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java @@ -182,8 +182,7 @@ public class PStack extends Tool { public static void main(String[] args) throws Exception { PStack t = new PStack(); - t.start(args); - t.stop(); + t.execute(args); } // -- Internals only below this point diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java index eb0cc88d116..bbb0b081b2d 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java @@ -137,8 +137,7 @@ public class StackTrace extends Tool { public static void main(String[] args) { StackTrace st = new StackTrace(); - st.start(args); - st.stop(); + st.execute(args); } private boolean verbose; diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java index d601fef4401..01465574006 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/SysPropsDumper.java @@ -58,7 +58,6 @@ public class SysPropsDumper extends Tool { public static void main(String[] args) { SysPropsDumper pd = new SysPropsDumper(); - pd.start(args); - pd.stop(); + pd.execute(args); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java index 3021801c9dd..19cfb349da8 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/Tool.java @@ -26,6 +26,7 @@ package sun.jvm.hotspot.tools; import java.io.PrintStream; import java.util.Hashtable; + import sun.jvm.hotspot.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.debugger.*; @@ -105,26 +106,44 @@ public abstract class Tool implements Runnable { public static void main(String[] args) { obj = new ; - obj.start(args); + obj.execute(args); } */ - protected void stop() { + protected void execute(String[] args) { + int returnStatus = 1; + + try { + returnStatus = start(args); + } finally { + stop(); + } + + // Exit with 0 or 1 + System.exit(returnStatus); + } + + public void stop() { if (agent != null) { agent.detach(); } } - protected void start(String[] args) { + private int start(String[] args) { + if ((args.length < 1) || (args.length > 2)) { usage(); - return; + return 1; } // Attempt to handle -h or -help or some invalid flag - if (args[0].startsWith("-")) { + if (args[0].startsWith("-h")) { usage(); + return 0; + } else if (args[0].startsWith("-")) { + usage(); + return 1; } PrintStream err = System.err; @@ -154,6 +173,7 @@ public abstract class Tool implements Runnable { default: usage(); + return 1; } agent = new HotSpotAgent(); @@ -191,15 +211,16 @@ public abstract class Tool implements Runnable { break; } if (e.getMessage() != null) { - err.print(e.getMessage()); + err.println(e.getMessage()); e.printStackTrace(); } err.println(); - return; + return 1; } err.println("Debugger attached successfully."); startInternal(); + return 0; } // When using an existing JVMDebugger. diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java index afd7f9865b5..98300c1d6c4 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassDump.java @@ -177,7 +177,6 @@ public class ClassDump extends Tool { public static void main(String[] args) { ClassDump cd = new ClassDump(); - cd.start(args); - cd.stop(); + cd.execute(args); } } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java index 09874af178e..db6dc339394 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/JSDB.java @@ -42,8 +42,7 @@ public class JSDB extends Tool { public static void main(String[] args) { JSDB jsdb = new JSDB(); - jsdb.start(args); - jsdb.stop(); + jsdb.execute(args); } public void run() { diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java index b3054b90bd0..67f5ed1e920 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java @@ -40,8 +40,7 @@ import sun.jvm.hotspot.utilities.soql.*; public class SOQL extends Tool { public static void main(String[] args) { SOQL soql = new SOQL(); - soql.start(args); - soql.stop(); + soql.execute(args); } public SOQL() { diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version index 51d77f8db50..69d9e8e9e59 100644 --- a/hotspot/make/hotspot_version +++ b/hotspot/make/hotspot_version @@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2013 HS_MAJOR_VER=25 HS_MINOR_VER=0 -HS_BUILD_NUMBER=55 +HS_BUILD_NUMBER=57 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 diff --git a/hotspot/make/jprt.properties b/hotspot/make/jprt.properties index f322e7024ae..9109ded6f98 100644 --- a/hotspot/make/jprt.properties +++ b/hotspot/make/jprt.properties @@ -24,12 +24,7 @@ # Properties for jprt -# All build result bundles are full jdks, so the 64bit testing does not -# need the 32bit sibling bundle installed. -# Note: If the hotspot/make/Makefile changed to only bundle the 64bit files -# when bundling 64bit, and stripped out the 64bit files from any 32bit -# bundles, then this setting would be need to be "true". - +# All build result bundles are full jdks. jprt.need.sibling.build=false # At submit time, the release supplied will be in jprt.submit.release @@ -52,21 +47,11 @@ jprt.sync.push=false # sparc etc. # Define the Solaris platforms we want for the various releases -jprt.my.solaris.sparc.jdk8=solaris_sparc_5.10 -jprt.my.solaris.sparc.jdk7=solaris_sparc_5.10 -jprt.my.solaris.sparc.jdk7u8=${jprt.my.solaris.sparc.jdk7} -jprt.my.solaris.sparc=${jprt.my.solaris.sparc.${jprt.tools.default.release}} - jprt.my.solaris.sparcv9.jdk8=solaris_sparcv9_5.10 jprt.my.solaris.sparcv9.jdk7=solaris_sparcv9_5.10 jprt.my.solaris.sparcv9.jdk7u8=${jprt.my.solaris.sparcv9.jdk7} jprt.my.solaris.sparcv9=${jprt.my.solaris.sparcv9.${jprt.tools.default.release}} -jprt.my.solaris.i586.jdk8=solaris_i586_5.10 -jprt.my.solaris.i586.jdk7=solaris_i586_5.10 -jprt.my.solaris.i586.jdk7u8=${jprt.my.solaris.i586.jdk7} -jprt.my.solaris.i586=${jprt.my.solaris.i586.${jprt.tools.default.release}} - jprt.my.solaris.x64.jdk8=solaris_x64_5.10 jprt.my.solaris.x64.jdk7=solaris_x64_5.10 jprt.my.solaris.x64.jdk7u8=${jprt.my.solaris.x64.jdk7} @@ -133,9 +118,7 @@ jprt.my.windows.x64=${jprt.my.windows.x64.${jprt.tools.default.release}} # Standard list of jprt build targets for this source tree jprt.build.targets.standard= \ - ${jprt.my.solaris.sparc}-{product|fastdebug}, \ ${jprt.my.solaris.sparcv9}-{product|fastdebug|optimized}, \ - ${jprt.my.solaris.i586}-{product|fastdebug}, \ ${jprt.my.solaris.x64}-{product|fastdebug}, \ ${jprt.my.linux.i586}-{product|fastdebug}, \ ${jprt.my.linux.x64}-{product|fastdebug|optimized}, \ @@ -145,7 +128,6 @@ jprt.build.targets.standard= \ ${jprt.my.linux.armvh}-{product|fastdebug} jprt.build.targets.open= \ - ${jprt.my.solaris.i586}-{productOpen}, \ ${jprt.my.solaris.x64}-{debugOpen}, \ ${jprt.my.linux.x64}-{productOpen} @@ -168,31 +150,6 @@ jprt.build.targets=${jprt.build.targets.${jprt.tools.default.release}} # Subset lists of test targets for this source tree -jprt.my.solaris.sparc.test.targets= \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jvm98, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-c2-jvm98_nontiered, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-scimark, \ - ${jprt.my.solaris.sparc}-product-{c1|c2}-runThese, \ - ${jprt.my.solaris.sparc}-fastdebug-c1-runThese_Xshare, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCBasher_SerialGC, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCBasher_ParallelGC, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCBasher_ParNewGC, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCBasher_CMS, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCBasher_G1, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCBasher_ParOldGC, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCOld_SerialGC, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCOld_ParallelGC, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCOld_ParNewGC, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCOld_CMS, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCOld_G1, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCOld_ParOldGC, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-c2-jbb_default_nontiered, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_SerialGC, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_ParallelGC, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_CMS, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_G1, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_ParOldGC - jprt.my.solaris.sparcv9.test.targets= \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jvm98, \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jvm98_nontiered, \ @@ -242,37 +199,6 @@ jprt.my.solaris.x64.test.targets= \ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GCOld_G1, \ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GCOld_ParOldGC -jprt.my.solaris.i586.test.targets= \ - ${jprt.my.solaris.i586}-{product|fastdebug}-{c1|c2}-jvm98, \ - ${jprt.my.solaris.i586}-{product|fastdebug}-c2-jvm98_nontiered, \ - ${jprt.my.solaris.i586}-{product|fastdebug}-{c1|c2}-scimark, \ - ${jprt.my.solaris.i586}-product-{c1|c2}-runThese_Xcomp, \ - ${jprt.my.solaris.i586}-fastdebug-c1-runThese_Xcomp, \ - ${jprt.my.solaris.i586}-fastdebug-c1-runThese_Xshare, \ - ${jprt.my.solaris.i586}-product-c1-GCBasher_SerialGC, \ - ${jprt.my.solaris.i586}-product-c1-GCBasher_ParallelGC, \ - ${jprt.my.solaris.i586}-product-c1-GCBasher_ParNewGC, \ - ${jprt.my.solaris.i586}-product-c1-GCBasher_CMS, \ - ${jprt.my.solaris.i586}-product-c1-GCBasher_G1, \ - ${jprt.my.solaris.i586}-product-c1-GCBasher_ParOldGC, \ - ${jprt.my.solaris.i586}-fastdebug-c2-GCBasher_SerialGC, \ - ${jprt.my.solaris.i586}-fastdebug-c2-GCBasher_ParallelGC, \ - ${jprt.my.solaris.i586}-fastdebug-c2-GCBasher_ParNewGC, \ - ${jprt.my.solaris.i586}-fastdebug-c2-GCBasher_CMS, \ - ${jprt.my.solaris.i586}-fastdebug-c2-GCBasher_G1, \ - ${jprt.my.solaris.i586}-fastdebug-c2-GCBasher_ParOldGC, \ - ${jprt.my.solaris.i586}-product-c1-GCOld_SerialGC, \ - ${jprt.my.solaris.i586}-product-c1-GCOld_ParallelGC, \ - ${jprt.my.solaris.i586}-product-c1-GCOld_ParNewGC, \ - ${jprt.my.solaris.i586}-product-c1-GCOld_CMS, \ - ${jprt.my.solaris.i586}-product-c1-GCOld_G1, \ - ${jprt.my.solaris.i586}-product-c1-GCOld_ParOldGC, \ - ${jprt.my.solaris.i586}-fastdebug-c2-jbb_default_nontiered, \ - ${jprt.my.solaris.i586}-fastdebug-c2-jbb_ParallelGC, \ - ${jprt.my.solaris.i586}-fastdebug-c2-jbb_CMS, \ - ${jprt.my.solaris.i586}-fastdebug-c2-jbb_G1, \ - ${jprt.my.solaris.i586}-fastdebug-c2-jbb_ParOldGC - jprt.my.linux.i586.test.targets = \ ${jprt.my.linux.i586}-{product|fastdebug}-{c1|c2}-jvm98, \ ${jprt.my.linux.i586}-{product|fastdebug}-c2-jvm98_nontiered, \ @@ -395,7 +321,6 @@ jprt.my.windows.x64.test.targets = \ # Some basic "smoke" tests for OpenJDK builds jprt.test.targets.open = \ ${jprt.my.solaris.x64}-{productOpen|fastdebugOpen}-c2-jvm98, \ - ${jprt.my.solaris.i586}-{productOpen|fastdebugOpen}-c2-jvm98, \ ${jprt.my.linux.x64}-{productOpen|fastdebugOpen}-c2-jvm98 # Testing for actual embedded builds is different to standard @@ -407,9 +332,7 @@ jprt.my.linux.i586.test.targets.embedded = \ jprt.test.targets.standard = \ ${jprt.my.linux.i586.test.targets.embedded}, \ - ${jprt.my.solaris.sparc.test.targets}, \ ${jprt.my.solaris.sparcv9.test.targets}, \ - ${jprt.my.solaris.i586.test.targets}, \ ${jprt.my.solaris.x64.test.targets}, \ ${jprt.my.linux.i586.test.targets}, \ ${jprt.my.linux.x64.test.targets}, \ @@ -420,15 +343,12 @@ jprt.test.targets.standard = \ jprt.test.targets.embedded= \ ${jprt.my.linux.i586.test.targets.embedded}, \ - ${jprt.my.solaris.sparc.test.targets}, \ ${jprt.my.solaris.sparcv9.test.targets}, \ - ${jprt.my.solaris.i586.test.targets}, \ ${jprt.my.solaris.x64.test.targets}, \ ${jprt.my.linux.x64.test.targets}, \ ${jprt.my.windows.i586.test.targets}, \ ${jprt.my.windows.x64.test.targets} - jprt.test.targets.jdk8=${jprt.test.targets.standard} jprt.test.targets.jdk7=${jprt.test.targets.standard} jprt.test.targets.jdk7u8=${jprt.test.targets.jdk7} @@ -439,15 +359,11 @@ jprt.test.targets=${jprt.test.targets.${jprt.tools.default.release}} #jprt.make.rule.test.targets=*-product-*-packtest jprt.make.rule.test.targets.standard.client = \ - ${jprt.my.solaris.sparc}-*-c1-clienttest, \ - ${jprt.my.solaris.i586}-*-c1-clienttest, \ ${jprt.my.linux.i586}-*-c1-clienttest, \ ${jprt.my.windows.i586}-*-c1-clienttest jprt.make.rule.test.targets.standard.server = \ - ${jprt.my.solaris.sparc}-*-c2-servertest, \ ${jprt.my.solaris.sparcv9}-*-c2-servertest, \ - ${jprt.my.solaris.i586}-*-c2-servertest, \ ${jprt.my.solaris.x64}-*-c2-servertest, \ ${jprt.my.linux.i586}-*-c2-servertest, \ ${jprt.my.linux.x64}-*-c2-servertest, \ @@ -456,9 +372,7 @@ jprt.make.rule.test.targets.standard.server = \ ${jprt.my.windows.x64}-*-c2-servertest jprt.make.rule.test.targets.standard.internalvmtests = \ - ${jprt.my.solaris.sparc}-fastdebug-c2-internalvmtests, \ ${jprt.my.solaris.sparcv9}-fastdebug-c2-internalvmtests, \ - ${jprt.my.solaris.i586}-fastdebug-c2-internalvmtests, \ ${jprt.my.solaris.x64}-fastdebug-c2-internalvmtests, \ ${jprt.my.linux.i586}-fastdebug-c2-internalvmtests, \ ${jprt.my.linux.x64}-fastdebug-c2-internalvmtests, \ @@ -467,16 +381,12 @@ jprt.make.rule.test.targets.standard.internalvmtests = \ ${jprt.my.windows.x64}-fastdebug-c2-internalvmtests jprt.make.rule.test.targets.standard.wbapi = \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-c2-wbapitest, \ ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.solaris.i586}-{product|fastdebug}-c2-wbapitest, \ ${jprt.my.solaris.x64}-{product|fastdebug}-c2-wbapitest, \ ${jprt.my.linux.i586}-{product|fastdebug}-c2-wbapitest, \ ${jprt.my.linux.x64}-{product|fastdebug}-c2-wbapitest, \ ${jprt.my.windows.i586}-{product|fastdebug}-c2-wbapitest, \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-wbapitest, \ - ${jprt.my.solaris.sparc}-{product|fastdebug}-c1-wbapitest, \ - ${jprt.my.solaris.i586}-{product|fastdebug}-c1-wbapitest, \ ${jprt.my.linux.i586}-{product|fastdebug}-c1-wbapitest, \ ${jprt.my.windows.i586}-{product|fastdebug}-c1-wbapitest diff --git a/hotspot/make/windows/makefiles/trace.make b/hotspot/make/windows/makefiles/trace.make index 02948c0a8d0..58fee24653c 100644 --- a/hotspot/make/windows/makefiles/trace.make +++ b/hotspot/make/windows/makefiles/trace.make @@ -40,8 +40,7 @@ TraceGeneratedNames = \ traceEventIds.hpp \ traceTypes.hpp - -!if "$(OPENJDK)" != "true" +!if EXISTS($(TraceAltSrcDir)) TraceGeneratedNames = $(TraceGeneratedNames) \ traceRequestables.hpp \ traceEventControl.hpp \ @@ -56,7 +55,7 @@ TraceGeneratedFiles = \ $(TraceOutDir)/traceEventIds.hpp \ $(TraceOutDir)/traceTypes.hpp -!if "$(OPENJDK)" != "true" +!if EXISTS($(TraceAltSrcDir)) TraceGeneratedFiles = $(TraceGeneratedFiles) \ $(TraceOutDir)/traceRequestables.hpp \ $(TraceOutDir)/traceEventControl.hpp \ @@ -68,7 +67,7 @@ XSLT = $(QUIETLY) $(REMOTE) $(RUN_JAVA) -classpath $(JvmtiOutDir) jvmtiGen XML_DEPS = $(TraceSrcDir)/trace.xml $(TraceSrcDir)/tracetypes.xml \ $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod -!if "$(OPENJDK)" != "true" +!if EXISTS($(TraceAltSrcDir)) XML_DEPS = $(XML_DEPS) $(TraceAltSrcDir)/traceevents.xml !endif @@ -87,7 +86,7 @@ $(TraceOutDir)/traceTypes.hpp: $(TraceSrcDir)/trace.xml $(TraceSrcDir)/traceType @echo Generating $@ @$(XSLT) -IN $(TraceSrcDir)/trace.xml -XSL $(TraceSrcDir)/traceTypes.xsl -OUT $(TraceOutDir)/traceTypes.hpp -!if "$(OPENJDK)" == "true" +!if !EXISTS($(TraceAltSrcDir)) $(TraceOutDir)/traceEventClasses.hpp: $(TraceSrcDir)/trace.xml $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS) @echo Generating OpenJDK $@ diff --git a/hotspot/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp index 97ec2239549..e6e7212ed4a 100644 --- a/hotspot/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_FrameMap_sparc.cpp @@ -53,6 +53,8 @@ LIR_Opr FrameMap::map_to_opr(BasicType type, VMRegPair* reg, bool outgoing) { opr = as_long_opr(reg); } else if (type == T_OBJECT || type == T_ARRAY) { opr = as_oop_opr(reg); + } else if (type == T_METADATA) { + opr = as_metadata_opr(reg); } else { opr = as_opr(reg); } diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp index 115302c9e1a..22ab05f7c9f 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @@ -2565,7 +2565,7 @@ void LIR_Assembler::type_profile_helper(Register mdo, int mdo_offset_bias, Address receiver_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)) - mdo_offset_bias); __ ld_ptr(receiver_addr, tmp1); - __ verify_oop(tmp1); + __ verify_klass_ptr(tmp1); __ cmp_and_brx_short(recv, tmp1, Assembler::notEqual, Assembler::pt, next_test); Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)) - mdo_offset_bias); diff --git a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp index 97c38cdebab..742cacc226b 100644 --- a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp @@ -404,7 +404,9 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { if (id == fast_new_instance_init_check_id) { // make sure the klass is initialized __ ldub(G5_klass, in_bytes(InstanceKlass::init_state_offset()), G3_t1); - __ cmp_and_br_short(G3_t1, InstanceKlass::fully_initialized, Assembler::notEqual, Assembler::pn, slow_path); + __ cmp(G3_t1, InstanceKlass::fully_initialized); + __ br(Assembler::notEqual, false, Assembler::pn, slow_path); + __ delayed()->nop(); } #ifdef ASSERT // assert object can be fast path allocated @@ -515,7 +517,9 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { // check that array length is small enough for fast path __ set(C1_MacroAssembler::max_array_allocation_length, G3_t1); - __ cmp_and_br_short(G4_length, G3_t1, Assembler::greaterUnsigned, Assembler::pn, slow_path); + __ cmp(G4_length, G3_t1); + __ br(Assembler::greaterUnsigned, false, Assembler::pn, slow_path); + __ delayed()->nop(); // if we got here then the TLAB allocation failed, so try // refilling the TLAB or allocating directly from eden. diff --git a/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp index 5750e5f587f..371b6aa7f71 100644 --- a/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp @@ -365,7 +365,7 @@ address CppInterpreterGenerator::generate_stack_to_native_abi_converter(BasicTyp return entry; } -address CppInterpreter::return_entry(TosState state, int length) { +address CppInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) { // make it look good in the debugger return CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation) + frame::pc_return_offset; } diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp index f4f45c0ae19..af142976b35 100644 --- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp @@ -3333,7 +3333,8 @@ void MacroAssembler::tlab_refill(Label& retry, Label& try_eden, Label& slow_case if (CMSIncrementalMode || !Universe::heap()->supports_inline_contig_alloc()) { // No allocation in the shared eden. - ba_short(slow_case); + ba(slow_case); + delayed()->nop(); } ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), top); @@ -3358,7 +3359,8 @@ void MacroAssembler::tlab_refill(Label& retry, Label& try_eden, Label& slow_case add(t2, 1, t2); stw(t2, G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset())); } - ba_short(try_eden); + ba(try_eden); + delayed()->nop(); bind(discard_tlab); if (TLABStats) { @@ -3420,7 +3422,8 @@ void MacroAssembler::tlab_refill(Label& retry, Label& try_eden, Label& slow_case sub(top, ThreadLocalAllocBuffer::alignment_reserve_in_bytes(), top); st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_end_offset())); verify_tlab(); - ba_short(retry); + ba(retry); + delayed()->nop(); } void MacroAssembler::incr_allocated_bytes(RegisterOrConstant size_in_bytes, @@ -4096,15 +4099,19 @@ void MacroAssembler::decode_heap_oop_not_null(Register src, Register dst) { void MacroAssembler::encode_klass_not_null(Register r) { assert (UseCompressedClassPointers, "must be compressed"); - assert(Universe::narrow_klass_base() != NULL, "narrow_klass_base should be initialized"); - assert(r != G6_heapbase, "bad register choice"); - set((intptr_t)Universe::narrow_klass_base(), G6_heapbase); - sub(r, G6_heapbase, r); - if (Universe::narrow_klass_shift() != 0) { - assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong"); - srlx(r, LogKlassAlignmentInBytes, r); + if (Universe::narrow_klass_base() != NULL) { + assert(r != G6_heapbase, "bad register choice"); + set((intptr_t)Universe::narrow_klass_base(), G6_heapbase); + sub(r, G6_heapbase, r); + if (Universe::narrow_klass_shift() != 0) { + assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong"); + srlx(r, LogKlassAlignmentInBytes, r); + } + reinit_heapbase(); + } else { + assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift() || Universe::narrow_klass_shift() == 0, "decode alg wrong"); + srlx(r, Universe::narrow_klass_shift(), r); } - reinit_heapbase(); } void MacroAssembler::encode_klass_not_null(Register src, Register dst) { @@ -4112,11 +4119,16 @@ void MacroAssembler::encode_klass_not_null(Register src, Register dst) { encode_klass_not_null(src); } else { assert (UseCompressedClassPointers, "must be compressed"); - assert(Universe::narrow_klass_base() != NULL, "narrow_klass_base should be initialized"); - set((intptr_t)Universe::narrow_klass_base(), dst); - sub(src, dst, dst); - if (Universe::narrow_klass_shift() != 0) { - srlx(dst, LogKlassAlignmentInBytes, dst); + if (Universe::narrow_klass_base() != NULL) { + set((intptr_t)Universe::narrow_klass_base(), dst); + sub(src, dst, dst); + if (Universe::narrow_klass_shift() != 0) { + srlx(dst, LogKlassAlignmentInBytes, dst); + } + } else { + // shift src into dst + assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift() || Universe::narrow_klass_shift() == 0, "decode alg wrong"); + srlx(src, Universe::narrow_klass_shift(), dst); } } } @@ -4126,14 +4138,16 @@ void MacroAssembler::encode_klass_not_null(Register src, Register dst) { // the instructions they generate change, then this method needs to be updated. int MacroAssembler::instr_size_for_decode_klass_not_null() { assert (UseCompressedClassPointers, "only for compressed klass ptrs"); - // set + add + set - int num_instrs = insts_for_internal_set((intptr_t)Universe::narrow_klass_base()) + 1 + - insts_for_internal_set((intptr_t)Universe::narrow_ptrs_base()); - if (Universe::narrow_klass_shift() == 0) { - return num_instrs * BytesPerInstWord; - } else { // sllx - return (num_instrs + 1) * BytesPerInstWord; + int num_instrs = 1; // shift src,dst or add + if (Universe::narrow_klass_base() != NULL) { + // set + add + set + num_instrs += insts_for_internal_set((intptr_t)Universe::narrow_klass_base()) + + insts_for_internal_set((intptr_t)Universe::narrow_ptrs_base()); + if (Universe::narrow_klass_shift() != 0) { + num_instrs += 1; // sllx + } } + return num_instrs * BytesPerInstWord; } // !!! If the instructions that get generated here change then function @@ -4142,13 +4156,17 @@ void MacroAssembler::decode_klass_not_null(Register r) { // Do not add assert code to this unless you change vtableStubs_sparc.cpp // pd_code_size_limit. assert (UseCompressedClassPointers, "must be compressed"); - assert(Universe::narrow_klass_base() != NULL, "narrow_klass_base should be initialized"); - assert(r != G6_heapbase, "bad register choice"); - set((intptr_t)Universe::narrow_klass_base(), G6_heapbase); - if (Universe::narrow_klass_shift() != 0) - sllx(r, LogKlassAlignmentInBytes, r); - add(r, G6_heapbase, r); - reinit_heapbase(); + if (Universe::narrow_klass_base() != NULL) { + assert(r != G6_heapbase, "bad register choice"); + set((intptr_t)Universe::narrow_klass_base(), G6_heapbase); + if (Universe::narrow_klass_shift() != 0) + sllx(r, LogKlassAlignmentInBytes, r); + add(r, G6_heapbase, r); + reinit_heapbase(); + } else { + assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift() || Universe::narrow_klass_shift() == 0, "decode alg wrong"); + sllx(r, Universe::narrow_klass_shift(), r); + } } void MacroAssembler::decode_klass_not_null(Register src, Register dst) { @@ -4158,16 +4176,21 @@ void MacroAssembler::decode_klass_not_null(Register src, Register dst) { // Do not add assert code to this unless you change vtableStubs_sparc.cpp // pd_code_size_limit. assert (UseCompressedClassPointers, "must be compressed"); - assert(Universe::narrow_klass_base() != NULL, "narrow_klass_base should be initialized"); - if (Universe::narrow_klass_shift() != 0) { - assert((src != G6_heapbase) && (dst != G6_heapbase), "bad register choice"); - set((intptr_t)Universe::narrow_klass_base(), G6_heapbase); - sllx(src, LogKlassAlignmentInBytes, dst); - add(dst, G6_heapbase, dst); - reinit_heapbase(); + if (Universe::narrow_klass_base() != NULL) { + if (Universe::narrow_klass_shift() != 0) { + assert((src != G6_heapbase) && (dst != G6_heapbase), "bad register choice"); + set((intptr_t)Universe::narrow_klass_base(), G6_heapbase); + sllx(src, LogKlassAlignmentInBytes, dst); + add(dst, G6_heapbase, dst); + reinit_heapbase(); + } else { + set((intptr_t)Universe::narrow_klass_base(), dst); + add(src, dst, dst); + } } else { - set((intptr_t)Universe::narrow_klass_base(), dst); - add(src, dst, dst); + // shift/mov src into dst. + assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift() || Universe::narrow_klass_shift() == 0, "decode alg wrong"); + sllx(src, Universe::narrow_klass_shift(), dst); } } } diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index 06235820bb8..eadb0a8b60f 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -1660,12 +1660,16 @@ void MachUEPNode::format( PhaseRegAlloc *ra_, outputStream *st ) const { if (UseCompressedClassPointers) { assert(Universe::heap() != NULL, "java heap should be initialized"); st->print_cr("\tLDUW [R_O0 + oopDesc::klass_offset_in_bytes],R_G5\t! Inline cache check - compressed klass"); - st->print_cr("\tSET Universe::narrow_klass_base,R_G6_heap_base"); - if (Universe::narrow_klass_shift() != 0) { - st->print_cr("\tSLL R_G5,3,R_G5"); + if (Universe::narrow_klass_base() != 0) { + st->print_cr("\tSET Universe::narrow_klass_base,R_G6_heap_base"); + if (Universe::narrow_klass_shift() != 0) { + st->print_cr("\tSLL R_G5,Universe::narrow_klass_shift,R_G5"); + } + st->print_cr("\tADD R_G5,R_G6_heap_base,R_G5"); + st->print_cr("\tSET Universe::narrow_ptrs_base,R_G6_heap_base"); + } else { + st->print_cr("\tSLL R_G5,Universe::narrow_klass_shift,R_G5"); } - st->print_cr("\tADD R_G5,R_G6_heap_base,R_G5"); - st->print_cr("\tSET Universe::narrow_ptrs_base,R_G6_heap_base"); } else { st->print_cr("\tLDX [R_O0 + oopDesc::klass_offset_in_bytes],R_G5\t! Inline cache check"); } @@ -2022,6 +2026,10 @@ const RegMask Matcher::mathExactI_result_proj_mask() { return G1_REGI_mask(); } +const RegMask Matcher::mathExactL_result_proj_mask() { + return G1_REGL_mask(); +} + const RegMask Matcher::mathExactI_flags_proj_mask() { return INT_FLAGS_mask(); } diff --git a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp index b6f8a5a5d1a..40847f8c2df 100644 --- a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp @@ -153,13 +153,9 @@ address TemplateInterpreterGenerator::generate_StackOverflowError_handler() { } -address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step) { - TosState incoming_state = state; - - Label cont; - address compiled_entry = __ pc(); - +address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step, size_t index_size) { address entry = __ pc(); + #if !defined(_LP64) && defined(COMPILER2) // All return values are where we want them, except for Longs. C2 returns // longs in G1 in the 32-bit build whereas the interpreter wants them in O0/O1. @@ -170,14 +166,12 @@ address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, // do this here. Unfortunately if we did a rethrow we'd see an machepilog node // first which would move g1 -> O0/O1 and destroy the exception we were throwing. - if (incoming_state == ltos) { + if (state == ltos) { __ srl (G1, 0, O1); __ srlx(G1, 32, O0); } #endif // !_LP64 && COMPILER2 - __ bind(cont); - // The callee returns with the stack possibly adjusted by adapter transition // We remove that possible adjustment here. // All interpreter local registers are untouched. Any result is passed back @@ -186,28 +180,17 @@ address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, __ mov(Llast_SP, SP); // Remove any adapter added stack space. - Label L_got_cache, L_giant_index; const Register cache = G3_scratch; - const Register size = G1_scratch; - if (EnableInvokeDynamic) { - __ ldub(Address(Lbcp, 0), G1_scratch); // Load current bytecode. - __ cmp_and_br_short(G1_scratch, Bytecodes::_invokedynamic, Assembler::equal, Assembler::pn, L_giant_index); - } - __ get_cache_and_index_at_bcp(cache, G1_scratch, 1); - __ bind(L_got_cache); - __ ld_ptr(cache, ConstantPoolCache::base_offset() + - ConstantPoolCacheEntry::flags_offset(), size); - __ and3(size, 0xFF, size); // argument size in words - __ sll(size, Interpreter::logStackElementSize, size); // each argument size in bytes - __ add(Lesp, size, Lesp); // pop arguments - __ dispatch_next(state, step); + const Register index = G1_scratch; + __ get_cache_and_index_at_bcp(cache, index, 1, index_size); - // out of the main line of code... - if (EnableInvokeDynamic) { - __ bind(L_giant_index); - __ get_cache_and_index_at_bcp(cache, G1_scratch, 1, sizeof(u4)); - __ ba_short(L_got_cache); - } + const Register flags = cache; + __ ld_ptr(cache, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset(), flags); + const Register parameter_size = flags; + __ and3(flags, ConstantPoolCacheEntry::parameter_size_mask, parameter_size); // argument size in words + __ sll(parameter_size, Interpreter::logStackElementSize, parameter_size); // each argument size in bytes + __ add(Lesp, parameter_size, Lesp); // pop arguments + __ dispatch_next(state, step); return entry; } diff --git a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp index c3e8b298d6e..92098113cca 100644 --- a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp @@ -2932,9 +2932,7 @@ void TemplateTable::prepare_invoke(int byte_no, ConstantPoolCacheEntry::verify_tos_state_shift(); // load return address { - const address table_addr = (is_invokeinterface || is_invokedynamic) ? - (address)Interpreter::return_5_addrs_by_index_table() : - (address)Interpreter::return_3_addrs_by_index_table(); + const address table_addr = (address) Interpreter::invoke_return_entry_table_for(code); AddressLiteral table(table_addr); __ set(table, temp); __ sll(ra, LogBytesPerWord, ra); @@ -2984,7 +2982,7 @@ void TemplateTable::invokevirtual(int byte_no) { __ verify_oop(O0_recv); // get return address - AddressLiteral table(Interpreter::return_3_addrs_by_index_table()); + AddressLiteral table(Interpreter::invoke_return_entry_table()); __ set(table, Rtemp); __ srl(Rret, ConstantPoolCacheEntry::tos_state_shift, Rret); // get return type // Make sure we don't need to mask Rret after the above shift @@ -3026,7 +3024,7 @@ void TemplateTable::invokevfinal_helper(Register Rscratch, Register Rret) { __ profile_final_call(O4); // get return address - AddressLiteral table(Interpreter::return_3_addrs_by_index_table()); + AddressLiteral table(Interpreter::invoke_return_entry_table()); __ set(table, Rtemp); __ srl(Rret, ConstantPoolCacheEntry::tos_state_shift, Rret); // get return type // Make sure we don't need to mask Rret after the above shift diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index 53f201b5033..49cc9ed65cf 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -1405,6 +1405,15 @@ void Assembler::imull(Register dst, Register src, int value) { } } +void Assembler::imull(Register dst, Address src) { + InstructionMark im(this); + prefix(src, dst); + emit_int8(0x0F); + emit_int8((unsigned char) 0xAF); + emit_operand(dst, src); +} + + void Assembler::incl(Address dst) { // Don't use it directly. Use MacroAssembler::increment() instead. InstructionMark im(this); @@ -5024,6 +5033,14 @@ void Assembler::imulq(Register dst, Register src, int value) { } } +void Assembler::imulq(Register dst, Address src) { + InstructionMark im(this); + prefixq(src, dst); + emit_int8(0x0F); + emit_int8((unsigned char) 0xAF); + emit_operand(dst, src); +} + void Assembler::incl(Register dst) { // Don't use it directly. Use MacroAssembler::incrementl() instead. // Use two-byte form (one-byte from is a REX prefix in 64-bit mode) diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index 31481b5808f..1ad66bd6a95 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -1162,9 +1162,13 @@ private: void imull(Register dst, Register src); void imull(Register dst, Register src, int value); + void imull(Register dst, Address src); void imulq(Register dst, Register src); void imulq(Register dst, Register src, int value); +#ifdef _LP64 + void imulq(Register dst, Address src); +#endif // jcc is the generic conditional branch generator to run- diff --git a/hotspot/src/cpu/x86/vm/bytecodeInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/bytecodeInterpreter_x86.cpp index 237c617ce3d..56129cc2d2e 100644 --- a/hotspot/src/cpu/x86/vm/bytecodeInterpreter_x86.cpp +++ b/hotspot/src/cpu/x86/vm/bytecodeInterpreter_x86.cpp @@ -40,11 +40,8 @@ #include "runtime/synchronizer.hpp" #include "runtime/vframeArray.hpp" #include "utilities/debug.hpp" -#ifdef TARGET_ARCH_MODEL_x86_32 -# include "interp_masm_x86_32.hpp" -#endif -#ifdef TARGET_ARCH_MODEL_x86_64 -# include "interp_masm_x86_64.hpp" +#ifdef TARGET_ARCH_x86 +# include "interp_masm_x86.hpp" #endif #ifdef CC_INTERP diff --git a/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp b/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp index bd3ad930b70..8ef1bea5d83 100644 --- a/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_FrameMap_x86.cpp @@ -52,6 +52,8 @@ LIR_Opr FrameMap::map_to_opr(BasicType type, VMRegPair* reg, bool) { #endif // _LP64 } else if (type == T_OBJECT || type == T_ARRAY) { opr = as_oop_opr(reg); + } else if (type == T_METADATA) { + opr = as_metadata_opr(reg); } else { opr = as_opr(reg); } diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp index 5ed890cfb4a..af13192330b 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @@ -432,15 +432,16 @@ int LIR_Assembler::emit_unwind_handler() { int offset = code_offset(); // Fetch the exception from TLS and clear out exception related thread state - __ get_thread(rsi); - __ movptr(rax, Address(rsi, JavaThread::exception_oop_offset())); - __ movptr(Address(rsi, JavaThread::exception_oop_offset()), (intptr_t)NULL_WORD); - __ movptr(Address(rsi, JavaThread::exception_pc_offset()), (intptr_t)NULL_WORD); + Register thread = NOT_LP64(rsi) LP64_ONLY(r15_thread); + NOT_LP64(__ get_thread(rsi)); + __ movptr(rax, Address(thread, JavaThread::exception_oop_offset())); + __ movptr(Address(thread, JavaThread::exception_oop_offset()), (intptr_t)NULL_WORD); + __ movptr(Address(thread, JavaThread::exception_pc_offset()), (intptr_t)NULL_WORD); __ bind(_unwind_handler_entry); __ verify_not_null_oop(rax); if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) { - __ mov(rsi, rax); // Preserve the exception + __ mov(rbx, rax); // Preserve the exception (rbx is always callee-saved) } // Preform needed unlocking @@ -448,19 +449,24 @@ int LIR_Assembler::emit_unwind_handler() { if (method()->is_synchronized()) { monitor_address(0, FrameMap::rax_opr); stub = new MonitorExitStub(FrameMap::rax_opr, true, 0); - __ unlock_object(rdi, rbx, rax, *stub->entry()); + __ unlock_object(rdi, rsi, rax, *stub->entry()); __ bind(*stub->continuation()); } if (compilation()->env()->dtrace_method_probes()) { +#ifdef _LP64 + __ mov(rdi, r15_thread); + __ mov_metadata(rsi, method()->constant_encoding()); +#else __ get_thread(rax); __ movptr(Address(rsp, 0), rax); __ mov_metadata(Address(rsp, sizeof(void*)), method()->constant_encoding()); +#endif __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit))); } if (method()->is_synchronized() || compilation()->env()->dtrace_method_probes()) { - __ mov(rax, rsi); // Restore the exception + __ mov(rax, rbx); // Restore the exception } // remove the activation and dispatch to the unwind handler @@ -1206,6 +1212,10 @@ void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_Patch LIR_Address* addr = src->as_address_ptr(); Address from_addr = as_Address(addr); + if (addr->base()->type() == T_OBJECT) { + __ verify_oop(addr->base()->as_pointer_register()); + } + switch (type) { case T_BOOLEAN: // fall through case T_BYTE: // fall through diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp index 308befddc77..4a30d597b3e 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @@ -1468,19 +1468,18 @@ void LIRGenerator::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) { addr = new LIR_Address(src.result(), offset, type); } - if (data != dst) { - __ move(data, dst); - data = dst; - } + // Because we want a 2-arg form of xchg and xadd + __ move(data, dst); + if (x->is_add()) { - __ xadd(LIR_OprFact::address(addr), data, dst, LIR_OprFact::illegalOpr); + __ xadd(LIR_OprFact::address(addr), dst, dst, LIR_OprFact::illegalOpr); } else { if (is_obj) { // Do the pre-write barrier, if any. pre_barrier(LIR_OprFact::address(addr), LIR_OprFact::illegalOpr /* pre_val */, true /* do_load */, false /* patch */, NULL); } - __ xchg(LIR_OprFact::address(addr), data, dst, LIR_OprFact::illegalOpr); + __ xchg(LIR_OprFact::address(addr), dst, dst, LIR_OprFact::illegalOpr); if (is_obj) { // Seems to be a precise address post_barrier(LIR_OprFact::address(addr), data); diff --git a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp index 1eef095b9a5..e669f5b6638 100644 --- a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp +++ b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp @@ -367,7 +367,7 @@ address CppInterpreterGenerator::generate_stack_to_native_abi_converter(BasicTyp return entry; } -address CppInterpreter::return_entry(TosState state, int length) { +address CppInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) { // make it look good in the debugger return CAST_FROM_FN_PTR(address, RecursiveInterpreterActivation); } diff --git a/hotspot/src/cpu/x86/vm/globals_x86.hpp b/hotspot/src/cpu/x86/vm/globals_x86.hpp index a727e077bd6..b194ffbcfbe 100644 --- a/hotspot/src/cpu/x86/vm/globals_x86.hpp +++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp @@ -79,7 +79,7 @@ define_pd_global(bool, UseMembar, false); // GC Ergo Flags define_pd_global(uintx, CMSYoungGenPerWorker, 64*M); // default max size of CMS young gen, per GC worker thread -define_pd_global(uintx, TypeProfileLevel, 11); +define_pd_global(uintx, TypeProfileLevel, 111); #define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct) \ \ diff --git a/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp new file mode 100644 index 00000000000..f47c0b1bb0c --- /dev/null +++ b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp @@ -0,0 +1,229 @@ +/* + * Copyright (c) 1997, 2013, 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. + * + */ + +#include "precompiled.hpp" +#include "interp_masm_x86.hpp" +#include "interpreter/interpreter.hpp" +#include "oops/methodData.hpp" + +#ifndef CC_INTERP +void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) { + Label update, next, none; + + verify_oop(obj); + + testptr(obj, obj); + jccb(Assembler::notZero, update); + orptr(mdo_addr, TypeEntries::null_seen); + jmpb(next); + + bind(update); + load_klass(obj, obj); + + xorptr(obj, mdo_addr); + testptr(obj, TypeEntries::type_klass_mask); + jccb(Assembler::zero, next); // klass seen before, nothing to + // do. The unknown bit may have been + // set already but no need to check. + + testptr(obj, TypeEntries::type_unknown); + jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore. + + cmpptr(mdo_addr, 0); + jccb(Assembler::equal, none); + cmpptr(mdo_addr, TypeEntries::null_seen); + jccb(Assembler::equal, none); + // There is a chance that the checks above (re-reading profiling + // data from memory) fail if another thread has just set the + // profiling to this obj's klass + xorptr(obj, mdo_addr); + testptr(obj, TypeEntries::type_klass_mask); + jccb(Assembler::zero, next); + + // different than before. Cannot keep accurate profile. + orptr(mdo_addr, TypeEntries::type_unknown); + jmpb(next); + + bind(none); + // first time here. Set profile type. + movptr(mdo_addr, obj); + + bind(next); +} + +void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) { + if (!ProfileInterpreter) { + return; + } + + if (MethodData::profile_arguments() || MethodData::profile_return()) { + Label profile_continue; + + test_method_data_pointer(mdp, profile_continue); + + int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size()); + + cmpb(Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start), is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag); + jcc(Assembler::notEqual, profile_continue); + + if (MethodData::profile_arguments()) { + Label done; + int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset()); + addptr(mdp, off_to_args); + + for (int i = 0; i < TypeProfileArgsLimit; i++) { + if (i > 0 || MethodData::profile_return()) { + // If return value type is profiled we may have no argument to profile + movptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); + subl(tmp, i*TypeStackSlotEntries::per_arg_count()); + cmpl(tmp, TypeStackSlotEntries::per_arg_count()); + jcc(Assembler::less, done); + } + movptr(tmp, Address(callee, Method::const_offset())); + load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset())); + // stack offset o (zero based) from the start of the argument + // list, for n arguments translates into offset n - o - 1 from + // the end of the argument list + subptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args)); + subl(tmp, 1); + Address arg_addr = argument_address(tmp); + movptr(tmp, arg_addr); + + Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args); + profile_obj_type(tmp, mdo_arg_addr); + + int to_add = in_bytes(TypeStackSlotEntries::per_arg_size()); + addptr(mdp, to_add); + off_to_args += to_add; + } + + if (MethodData::profile_return()) { + movptr(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); + subl(tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count()); + } + + bind(done); + + if (MethodData::profile_return()) { + // We're right after the type profile for the last + // argument. tmp is the number of cell left in the + // CallTypeData/VirtualCallTypeData to reach its end. Non null + // if there's a return to profile. + assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type"); + shll(tmp, exact_log2(DataLayout::cell_size)); + addptr(mdp, tmp); + } + movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp); + } else { + assert(MethodData::profile_return(), "either profile call args or call ret"); + update_mdp_by_constant(mdp, in_bytes(ReturnTypeEntry::size())); + } + + // mdp points right after the end of the + // CallTypeData/VirtualCallTypeData, right after the cells for the + // return value type if there's one + + bind(profile_continue); + } +} + +void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) { + assert_different_registers(mdp, ret, tmp, _bcp_register); + if (ProfileInterpreter && MethodData::profile_return()) { + Label profile_continue, done; + + test_method_data_pointer(mdp, profile_continue); + + if (MethodData::profile_return_jsr292_only()) { + // If we don't profile all invoke bytecodes we must make sure + // it's a bytecode we indeed profile. We can't go back to the + // begining of the ProfileData we intend to update to check its + // type because we're right after it and we don't known its + // length + Label do_profile; + cmpb(Address(_bcp_register, 0), Bytecodes::_invokedynamic); + jcc(Assembler::equal, do_profile); + cmpb(Address(_bcp_register, 0), Bytecodes::_invokehandle); + jcc(Assembler::equal, do_profile); + get_method(tmp); + cmpb(Address(tmp, Method::intrinsic_id_offset_in_bytes()), vmIntrinsics::_compiledLambdaForm); + jcc(Assembler::notEqual, profile_continue); + + bind(do_profile); + } + + Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size())); + mov(tmp, ret); + profile_obj_type(tmp, mdo_ret_addr); + + bind(profile_continue); + } +} + +void InterpreterMacroAssembler::profile_parameters_type(Register mdp, Register tmp1, Register tmp2) { + if (ProfileInterpreter && MethodData::profile_parameters()) { + Label profile_continue, done; + + test_method_data_pointer(mdp, profile_continue); + + // Load the offset of the area within the MDO used for + // parameters. If it's negative we're not profiling any parameters + movl(tmp1, Address(mdp, in_bytes(MethodData::parameters_type_data_di_offset()) - in_bytes(MethodData::data_offset()))); + testl(tmp1, tmp1); + jcc(Assembler::negative, profile_continue); + + // Compute a pointer to the area for parameters from the offset + // and move the pointer to the slot for the last + // parameters. Collect profiling from last parameter down. + // mdo start + parameters offset + array length - 1 + addptr(mdp, tmp1); + movptr(tmp1, Address(mdp, in_bytes(ArrayData::array_len_offset()))); + decrement(tmp1, TypeStackSlotEntries::per_arg_count()); + + Label loop; + bind(loop); + + int off_base = in_bytes(ParametersTypeData::stack_slot_offset(0)); + int type_base = in_bytes(ParametersTypeData::type_offset(0)); + Address::ScaleFactor per_arg_scale = Address::times(DataLayout::cell_size); + Address arg_off(mdp, tmp1, per_arg_scale, off_base); + Address arg_type(mdp, tmp1, per_arg_scale, type_base); + + // load offset on the stack from the slot for this parameter + movptr(tmp2, arg_off); + negptr(tmp2); + // read the parameter from the local area + movptr(tmp2, Address(_locals_register, tmp2, Interpreter::stackElementScale())); + + // profile the parameter + profile_obj_type(tmp2, arg_type); + + // go to next parameter + decrement(tmp1, TypeStackSlotEntries::per_arg_count()); + jcc(Assembler::positive, loop); + + bind(profile_continue); + } +} +#endif diff --git a/hotspot/src/cpu/x86/vm/interp_masm_x86.hpp b/hotspot/src/cpu/x86/vm/interp_masm_x86.hpp new file mode 100644 index 00000000000..2ac4d026654 --- /dev/null +++ b/hotspot/src/cpu/x86/vm/interp_masm_x86.hpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013, 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. + * + */ + +#ifndef CPU_X86_VM_INTERP_MASM_X86_HPP +#define CPU_X86_VM_INTERP_MASM_X86_HPP + +#include "asm/macroAssembler.hpp" +#include "asm/macroAssembler.inline.hpp" +#include "interpreter/invocationCounter.hpp" +#include "runtime/frame.hpp" + +// This file specializes the assember with interpreter-specific macros + + +class InterpreterMacroAssembler: public MacroAssembler { + +#ifdef TARGET_ARCH_MODEL_x86_32 +# include "interp_masm_x86_32.hpp" +#endif +#ifdef TARGET_ARCH_MODEL_x86_64 +# include "interp_masm_x86_64.hpp" +#endif + + private: + + Register _locals_register; // register that contains the pointer to the locals + Register _bcp_register; // register that contains the bcp + + public: +#ifndef CC_INTERP + void profile_obj_type(Register obj, const Address& mdo_addr); + void profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual); + void profile_return_type(Register mdp, Register ret, Register tmp); + void profile_parameters_type(Register mdp, Register tmp1, Register tmp2); +#endif /* !CC_INTERP */ + +}; + +#endif // CPU_X86_VM_INTERP_MASM_X86_HPP diff --git a/hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp b/hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp index 183defa8784..fcadd2ee9a3 100644 --- a/hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "interp_masm_x86_32.hpp" +#include "interp_masm_x86.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" #include "oops/arrayOop.hpp" @@ -1046,159 +1046,6 @@ void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) { } } -void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) { - Label update, next, none; - - verify_oop(obj); - - testptr(obj, obj); - jccb(Assembler::notZero, update); - orptr(mdo_addr, TypeEntries::null_seen); - jmpb(next); - - bind(update); - load_klass(obj, obj); - - xorptr(obj, mdo_addr); - testptr(obj, TypeEntries::type_klass_mask); - jccb(Assembler::zero, next); // klass seen before, nothing to - // do. The unknown bit may have been - // set already but no need to check. - - testptr(obj, TypeEntries::type_unknown); - jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore. - - cmpptr(mdo_addr, 0); - jccb(Assembler::equal, none); - cmpptr(mdo_addr, TypeEntries::null_seen); - jccb(Assembler::equal, none); - // There is a chance that the checks above (re-reading profiling - // data from memory) fail if another thread has just set the - // profiling to this obj's klass - xorptr(obj, mdo_addr); - testptr(obj, TypeEntries::type_klass_mask); - jccb(Assembler::zero, next); - - // different than before. Cannot keep accurate profile. - orptr(mdo_addr, TypeEntries::type_unknown); - jmpb(next); - - bind(none); - // first time here. Set profile type. - movptr(mdo_addr, obj); - - bind(next); -} - -void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) { - if (!ProfileInterpreter) { - return; - } - - if (MethodData::profile_arguments() || MethodData::profile_return()) { - Label profile_continue; - - test_method_data_pointer(mdp, profile_continue); - - int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size()); - - cmpb(Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start), is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag); - jcc(Assembler::notEqual, profile_continue); - - if (MethodData::profile_arguments()) { - Label done; - int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset()); - addptr(mdp, off_to_args); - - for (int i = 0; i < TypeProfileArgsLimit; i++) { - if (i > 0 || MethodData::profile_return()) { - // If return value type is profiled we may have no argument to profile - movl(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); - subl(tmp, i*TypeStackSlotEntries::per_arg_count()); - cmpl(tmp, TypeStackSlotEntries::per_arg_count()); - jcc(Assembler::less, done); - } - movptr(tmp, Address(callee, Method::const_offset())); - load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset())); - // stack offset o (zero based) from the start of the argument - // list, for n arguments translates into offset n - o - 1 from - // the end of the argument list - subl(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args)); - subl(tmp, 1); - Address arg_addr = argument_address(tmp); - movptr(tmp, arg_addr); - - Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args); - profile_obj_type(tmp, mdo_arg_addr); - - int to_add = in_bytes(TypeStackSlotEntries::per_arg_size()); - addptr(mdp, to_add); - off_to_args += to_add; - } - - if (MethodData::profile_return()) { - movl(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); - subl(tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count()); - } - - bind(done); - - if (MethodData::profile_return()) { - // We're right after the type profile for the last - // argument. tmp is the number of cell left in the - // CallTypeData/VirtualCallTypeData to reach its end. Non null - // if there's a return to profile. - assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type"); - shll(tmp, exact_log2(DataLayout::cell_size)); - addptr(mdp, tmp); - } - movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp); - } else { - assert(MethodData::profile_return(), "either profile call args or call ret"); - update_mdp_by_constant(mdp, in_bytes(ReturnTypeEntry::size())); - } - - // mdp points right after the end of the - // CallTypeData/VirtualCallTypeData, right after the cells for the - // return value type if there's one - - bind(profile_continue); - } -} - -void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) { - assert_different_registers(mdp, ret, tmp, rsi); - if (ProfileInterpreter && MethodData::profile_return()) { - Label profile_continue, done; - - test_method_data_pointer(mdp, profile_continue); - - if (MethodData::profile_return_jsr292_only()) { - // If we don't profile all invoke bytecodes we must make sure - // it's a bytecode we indeed profile. We can't go back to the - // begining of the ProfileData we intend to update to check its - // type because we're right after it and we don't known its - // length - Label do_profile; - cmpb(Address(rsi, 0), Bytecodes::_invokedynamic); - jcc(Assembler::equal, do_profile); - cmpb(Address(rsi, 0), Bytecodes::_invokehandle); - jcc(Assembler::equal, do_profile); - get_method(tmp); - cmpb(Address(tmp, Method::intrinsic_id_offset_in_bytes()), vmIntrinsics::_compiledLambdaForm); - jcc(Assembler::notEqual, profile_continue); - - bind(do_profile); - } - - Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size())); - mov(tmp, ret); - profile_obj_type(tmp, mdo_ret_addr); - - bind(profile_continue); - } -} - void InterpreterMacroAssembler::profile_call(Register mdp) { if (ProfileInterpreter) { Label profile_continue; diff --git a/hotspot/src/cpu/x86/vm/interp_masm_x86_32.hpp b/hotspot/src/cpu/x86/vm/interp_masm_x86_32.hpp index 91f0aa1bc41..19ff288bfee 100644 --- a/hotspot/src/cpu/x86/vm/interp_masm_x86_32.hpp +++ b/hotspot/src/cpu/x86/vm/interp_masm_x86_32.hpp @@ -22,18 +22,6 @@ * */ -#ifndef CPU_X86_VM_INTERP_MASM_X86_32_HPP -#define CPU_X86_VM_INTERP_MASM_X86_32_HPP - -#include "asm/macroAssembler.hpp" -#include "asm/macroAssembler.inline.hpp" -#include "interpreter/invocationCounter.hpp" -#include "runtime/frame.hpp" - -// This file specializes the assember with interpreter-specific macros - - -class InterpreterMacroAssembler: public MacroAssembler { #ifndef CC_INTERP protected: // Interpreter specific version of call_VM_base @@ -59,7 +47,7 @@ class InterpreterMacroAssembler: public MacroAssembler { #endif /* CC_INTERP */ public: - InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {} + InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code), _locals_register(rdi), _bcp_register(rsi) {} void load_earlyret_value(TosState state); @@ -215,9 +203,6 @@ class InterpreterMacroAssembler: public MacroAssembler { void profile_taken_branch(Register mdp, Register bumped_count); void profile_not_taken_branch(Register mdp); - void profile_obj_type(Register obj, const Address& mdo_addr); - void profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual); - void profile_return_type(Register mdp, Register ret, Register tmp); void profile_call(Register mdp); void profile_final_call(Register mdp); void profile_virtual_call(Register receiver, Register mdp, Register scratch2, @@ -236,7 +221,3 @@ class InterpreterMacroAssembler: public MacroAssembler { // support for jvmti void notify_method_entry(); void notify_method_exit(TosState state, NotifyMethodExitMode mode); - -}; - -#endif // CPU_X86_VM_INTERP_MASM_X86_32_HPP diff --git a/hotspot/src/cpu/x86/vm/interp_masm_x86_64.cpp b/hotspot/src/cpu/x86/vm/interp_masm_x86_64.cpp index 8495f0da130..7758d8fbcb5 100644 --- a/hotspot/src/cpu/x86/vm/interp_masm_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/interp_masm_x86_64.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "interp_masm_x86_64.hpp" +#include "interp_masm_x86.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" #include "oops/arrayOop.hpp" @@ -1067,160 +1067,6 @@ void InterpreterMacroAssembler::profile_not_taken_branch(Register mdp) { } } -void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& mdo_addr) { - Label update, next, none; - - verify_oop(obj); - - testptr(obj, obj); - jccb(Assembler::notZero, update); - orptr(mdo_addr, TypeEntries::null_seen); - jmpb(next); - - bind(update); - load_klass(obj, obj); - - xorptr(obj, mdo_addr); - testptr(obj, TypeEntries::type_klass_mask); - jccb(Assembler::zero, next); // klass seen before, nothing to - // do. The unknown bit may have been - // set already but no need to check. - - testptr(obj, TypeEntries::type_unknown); - jccb(Assembler::notZero, next); // already unknown. Nothing to do anymore. - - // There is a chance that by the time we do these checks (re-reading - // profiling data from memory) another thread has set the profling - // to this obj's klass and we set the profiling as unknow - // erroneously - cmpptr(mdo_addr, 0); - jccb(Assembler::equal, none); - cmpptr(mdo_addr, TypeEntries::null_seen); - jccb(Assembler::equal, none); - // There is a chance that the checks above (re-reading profiling - // data from memory) fail if another thread has just set the - // profiling to this obj's klass - xorptr(obj, mdo_addr); - testptr(obj, TypeEntries::type_klass_mask); - jccb(Assembler::zero, next); - - // different than before. Cannot keep accurate profile. - orptr(mdo_addr, TypeEntries::type_unknown); - jmpb(next); - - bind(none); - // first time here. Set profile type. - movptr(mdo_addr, obj); - - bind(next); -} - -void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual) { - if (!ProfileInterpreter) { - return; - } - - if (MethodData::profile_arguments() || MethodData::profile_return()) { - Label profile_continue; - - test_method_data_pointer(mdp, profile_continue); - - int off_to_start = is_virtual ? in_bytes(VirtualCallData::virtual_call_data_size()) : in_bytes(CounterData::counter_data_size()); - - cmpb(Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start), is_virtual ? DataLayout::virtual_call_type_data_tag : DataLayout::call_type_data_tag); - jcc(Assembler::notEqual, profile_continue); - - if (MethodData::profile_arguments()) { - Label done; - int off_to_args = in_bytes(TypeEntriesAtCall::args_data_offset()); - addptr(mdp, off_to_args); - - for (int i = 0; i < TypeProfileArgsLimit; i++) { - if (i > 0 || MethodData::profile_return()) { - // If return value type is profiled we may have no argument to profile - movq(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); - subl(tmp, i*TypeStackSlotEntries::per_arg_count()); - cmpl(tmp, TypeStackSlotEntries::per_arg_count()); - jcc(Assembler::less, done); - } - movptr(tmp, Address(callee, Method::const_offset())); - load_unsigned_short(tmp, Address(tmp, ConstMethod::size_of_parameters_offset())); - subq(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::stack_slot_offset(i))-off_to_args)); - subl(tmp, 1); - Address arg_addr = argument_address(tmp); - movptr(tmp, arg_addr); - - Address mdo_arg_addr(mdp, in_bytes(TypeEntriesAtCall::argument_type_offset(i))-off_to_args); - profile_obj_type(tmp, mdo_arg_addr); - - int to_add = in_bytes(TypeStackSlotEntries::per_arg_size()); - addptr(mdp, to_add); - off_to_args += to_add; - } - - if (MethodData::profile_return()) { - movq(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())-off_to_args)); - subl(tmp, TypeProfileArgsLimit*TypeStackSlotEntries::per_arg_count()); - } - - bind(done); - - if (MethodData::profile_return()) { - // We're right after the type profile for the last - // argument. tmp is the number of cell left in the - // CallTypeData/VirtualCallTypeData to reach its end. Non null - // if there's a return to profile. - assert(ReturnTypeEntry::static_cell_count() < TypeStackSlotEntries::per_arg_count(), "can't move past ret type"); - shll(tmp, exact_log2(DataLayout::cell_size)); - addptr(mdp, tmp); - } - movptr(Address(rbp, frame::interpreter_frame_mdx_offset * wordSize), mdp); - } else { - assert(MethodData::profile_return(), "either profile call args or call ret"); - update_mdp_by_constant(mdp, in_bytes(ReturnTypeEntry::size())); - } - - // mdp points right after the end of the - // CallTypeData/VirtualCallTypeData, right after the cells for the - // return value type if there's one - - bind(profile_continue); - } -} - -void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret, Register tmp) { - assert_different_registers(mdp, ret, tmp, r13); - if (ProfileInterpreter && MethodData::profile_return()) { - Label profile_continue, done; - - test_method_data_pointer(mdp, profile_continue); - - if (MethodData::profile_return_jsr292_only()) { - // If we don't profile all invoke bytecodes we must make sure - // it's a bytecode we indeed profile. We can't go back to the - // begining of the ProfileData we intend to update to check its - // type because we're right after it and we don't known its - // length - Label do_profile; - cmpb(Address(r13, 0), Bytecodes::_invokedynamic); - jcc(Assembler::equal, do_profile); - cmpb(Address(r13, 0), Bytecodes::_invokehandle); - jcc(Assembler::equal, do_profile); - get_method(tmp); - cmpb(Address(tmp, Method::intrinsic_id_offset_in_bytes()), vmIntrinsics::_compiledLambdaForm); - jcc(Assembler::notEqual, profile_continue); - - bind(do_profile); - } - - Address mdo_ret_addr(mdp, -in_bytes(ReturnTypeEntry::size())); - mov(tmp, ret); - profile_obj_type(tmp, mdo_ret_addr); - - bind(profile_continue); - } -} - void InterpreterMacroAssembler::profile_call(Register mdp) { if (ProfileInterpreter) { Label profile_continue; diff --git a/hotspot/src/cpu/x86/vm/interp_masm_x86_64.hpp b/hotspot/src/cpu/x86/vm/interp_masm_x86_64.hpp index fe7b76039f9..36bd779ef9b 100644 --- a/hotspot/src/cpu/x86/vm/interp_masm_x86_64.hpp +++ b/hotspot/src/cpu/x86/vm/interp_masm_x86_64.hpp @@ -22,18 +22,6 @@ * */ -#ifndef CPU_X86_VM_INTERP_MASM_X86_64_HPP -#define CPU_X86_VM_INTERP_MASM_X86_64_HPP - -#include "asm/macroAssembler.hpp" -#include "asm/macroAssembler.inline.hpp" -#include "interpreter/invocationCounter.hpp" -#include "runtime/frame.hpp" - -// This file specializes the assember with interpreter-specific macros - - -class InterpreterMacroAssembler: public MacroAssembler { #ifndef CC_INTERP protected: // Interpreter specific version of call_VM_base @@ -55,7 +43,7 @@ class InterpreterMacroAssembler: public MacroAssembler { #endif // CC_INTERP public: - InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code) {} + InterpreterMacroAssembler(CodeBuffer* code) : MacroAssembler(code), _locals_register(r14), _bcp_register(r13) {} void load_earlyret_value(TosState state); @@ -224,9 +212,6 @@ class InterpreterMacroAssembler: public MacroAssembler { void profile_taken_branch(Register mdp, Register bumped_count); void profile_not_taken_branch(Register mdp); - void profile_obj_type(Register obj, const Address& mdo_addr); - void profile_arguments_type(Register mdp, Register callee, Register tmp, bool is_virtual); - void profile_return_type(Register mdp, Register ret, Register tmp); void profile_call(Register mdp); void profile_final_call(Register mdp); void profile_virtual_call(Register receiver, Register mdp, @@ -253,6 +238,3 @@ class InterpreterMacroAssembler: public MacroAssembler { // support for jvmti/dtrace void notify_method_entry(); void notify_method_exit(TosState state, NotifyMethodExitMode mode); -}; - -#endif // CPU_X86_VM_INTERP_MASM_X86_64_HPP diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index c39c50082aa..cc4fe6869dc 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -5049,25 +5049,32 @@ void MacroAssembler::decode_heap_oop_not_null(Register dst, Register src) { } void MacroAssembler::encode_klass_not_null(Register r) { - assert(Universe::narrow_klass_base() != NULL, "Base should be initialized"); - // Use r12 as a scratch register in which to temporarily load the narrow_klass_base. - assert(r != r12_heapbase, "Encoding a klass in r12"); - mov64(r12_heapbase, (int64_t)Universe::narrow_klass_base()); - subq(r, r12_heapbase); + if (Universe::narrow_klass_base() != NULL) { + // Use r12 as a scratch register in which to temporarily load the narrow_klass_base. + assert(r != r12_heapbase, "Encoding a klass in r12"); + mov64(r12_heapbase, (int64_t)Universe::narrow_klass_base()); + subq(r, r12_heapbase); + } if (Universe::narrow_klass_shift() != 0) { assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong"); shrq(r, LogKlassAlignmentInBytes); } - reinit_heapbase(); + if (Universe::narrow_klass_base() != NULL) { + reinit_heapbase(); + } } void MacroAssembler::encode_klass_not_null(Register dst, Register src) { if (dst == src) { encode_klass_not_null(src); } else { - mov64(dst, (int64_t)Universe::narrow_klass_base()); - negq(dst); - addq(dst, src); + if (Universe::narrow_klass_base() != NULL) { + mov64(dst, (int64_t)Universe::narrow_klass_base()); + negq(dst); + addq(dst, src); + } else { + movptr(dst, src); + } if (Universe::narrow_klass_shift() != 0) { assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong"); shrq(dst, LogKlassAlignmentInBytes); @@ -5081,15 +5088,19 @@ void MacroAssembler::encode_klass_not_null(Register dst, Register src) { // generate change, then this method needs to be updated. int MacroAssembler::instr_size_for_decode_klass_not_null() { assert (UseCompressedClassPointers, "only for compressed klass ptrs"); - // mov64 + addq + shlq? + mov64 (for reinit_heapbase()). - return (Universe::narrow_klass_shift() == 0 ? 20 : 24); + if (Universe::narrow_klass_base() != NULL) { + // mov64 + addq + shlq? + mov64 (for reinit_heapbase()). + return (Universe::narrow_klass_shift() == 0 ? 20 : 24); + } else { + // longest load decode klass function, mov64, leaq + return 16; + } } // !!! If the instructions that get generated here change then function // instr_size_for_decode_klass_not_null() needs to get updated. void MacroAssembler::decode_klass_not_null(Register r) { // Note: it will change flags - assert(Universe::narrow_klass_base() != NULL, "Base should be initialized"); assert (UseCompressedClassPointers, "should only be used for compressed headers"); assert(r != r12_heapbase, "Decoding a klass in r12"); // Cannot assert, unverified entry point counts instructions (see .ad file) @@ -5100,14 +5111,15 @@ void MacroAssembler::decode_klass_not_null(Register r) { shlq(r, LogKlassAlignmentInBytes); } // Use r12 as a scratch register in which to temporarily load the narrow_klass_base. - mov64(r12_heapbase, (int64_t)Universe::narrow_klass_base()); - addq(r, r12_heapbase); - reinit_heapbase(); + if (Universe::narrow_klass_base() != NULL) { + mov64(r12_heapbase, (int64_t)Universe::narrow_klass_base()); + addq(r, r12_heapbase); + reinit_heapbase(); + } } void MacroAssembler::decode_klass_not_null(Register dst, Register src) { // Note: it will change flags - assert(Universe::narrow_klass_base() != NULL, "Base should be initialized"); assert (UseCompressedClassPointers, "should only be used for compressed headers"); if (dst == src) { decode_klass_not_null(dst); @@ -5115,7 +5127,6 @@ void MacroAssembler::decode_klass_not_null(Register dst, Register src) { // Cannot assert, unverified entry point counts instructions (see .ad file) // vtableStubs also counts instructions in pd_code_size_limit. // Also do not verify_oop as this is called by verify_oop. - mov64(dst, (int64_t)Universe::narrow_klass_base()); if (Universe::narrow_klass_shift() != 0) { assert(LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong"); diff --git a/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp b/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp index 7165872c239..f8a9407933b 100644 --- a/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp +++ b/hotspot/src/cpu/x86/vm/register_definitions_x86.cpp @@ -26,11 +26,8 @@ #include "asm/assembler.hpp" #include "asm/register.hpp" #include "register_x86.hpp" -#ifdef TARGET_ARCH_MODEL_x86_32 -# include "interp_masm_x86_32.hpp" -#endif -#ifdef TARGET_ARCH_MODEL_x86_64 -# include "interp_masm_x86_64.hpp" +#ifdef TARGET_ARCH_x86 +# include "interp_masm_x86.hpp" #endif REGISTER_DEFINITION(Register, noreg); diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86.hpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86.hpp index a632fbab313..ed2cef16e58 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86.hpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86.hpp @@ -34,9 +34,9 @@ // Run with +PrintInterpreter to get the VM to print out the size. // Max size with JVMTI #ifdef AMD64 - const static int InterpreterCodeSize = 208 * 1024; + const static int InterpreterCodeSize = 256 * 1024; #else - const static int InterpreterCodeSize = 176 * 1024; + const static int InterpreterCodeSize = 224 * 1024; #endif // AMD64 #endif // CPU_X86_VM_TEMPLATEINTERPRETER_X86_HPP diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp index 7d9af3e6404..c7fc0472677 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp @@ -150,13 +150,12 @@ address TemplateInterpreterGenerator::generate_continuation_for(TosState state) } -address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step) { - TosState incoming_state = state; +address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step, size_t index_size) { address entry = __ pc(); #ifdef COMPILER2 // The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases - if ((incoming_state == ftos && UseSSE < 1) || (incoming_state == dtos && UseSSE < 2)) { + if ((state == ftos && UseSSE < 1) || (state == dtos && UseSSE < 2)) { for (int i = 1; i < 8; i++) { __ ffree(i); } @@ -164,7 +163,7 @@ address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, __ empty_FPU_stack(); } #endif - if ((incoming_state == ftos && UseSSE < 1) || (incoming_state == dtos && UseSSE < 2)) { + if ((state == ftos && UseSSE < 1) || (state == dtos && UseSSE < 2)) { __ MacroAssembler::verify_FPU(1, "generate_return_entry_for compiled"); } else { __ MacroAssembler::verify_FPU(0, "generate_return_entry_for compiled"); @@ -172,12 +171,12 @@ address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, // In SSE mode, interpreter returns FP results in xmm0 but they need // to end up back on the FPU so it can operate on them. - if (incoming_state == ftos && UseSSE >= 1) { + if (state == ftos && UseSSE >= 1) { __ subptr(rsp, wordSize); __ movflt(Address(rsp, 0), xmm0); __ fld_s(Address(rsp, 0)); __ addptr(rsp, wordSize); - } else if (incoming_state == dtos && UseSSE >= 2) { + } else if (state == dtos && UseSSE >= 2) { __ subptr(rsp, 2*wordSize); __ movdbl(Address(rsp, 0), xmm0); __ fld_d(Address(rsp, 0)); @@ -194,32 +193,21 @@ address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, __ restore_bcp(); __ restore_locals(); - if (incoming_state == atos) { + if (state == atos) { Register mdp = rbx; Register tmp = rcx; __ profile_return_type(mdp, rax, tmp); } - Label L_got_cache, L_giant_index; - if (EnableInvokeDynamic) { - __ cmpb(Address(rsi, 0), Bytecodes::_invokedynamic); - __ jcc(Assembler::equal, L_giant_index); - } - __ get_cache_and_index_at_bcp(rbx, rcx, 1, sizeof(u2)); - __ bind(L_got_cache); - __ movl(rbx, Address(rbx, rcx, - Address::times_ptr, ConstantPoolCache::base_offset() + - ConstantPoolCacheEntry::flags_offset())); - __ andptr(rbx, 0xFF); - __ lea(rsp, Address(rsp, rbx, Interpreter::stackElementScale())); - __ dispatch_next(state, step); + const Register cache = rbx; + const Register index = rcx; + __ get_cache_and_index_at_bcp(cache, index, 1, index_size); - // out of the main line of code... - if (EnableInvokeDynamic) { - __ bind(L_giant_index); - __ get_cache_and_index_at_bcp(rbx, rcx, 1, sizeof(u4)); - __ jmp(L_got_cache); - } + const Register flags = cache; + __ movl(flags, Address(cache, index, Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset())); + __ andl(flags, ConstantPoolCacheEntry::parameter_size_mask); + __ lea(rsp, Address(rsp, flags, Interpreter::stackElementScale())); + __ dispatch_next(state, step); return entry; } @@ -1490,6 +1478,7 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); __ movbool(do_not_unlock_if_synchronized, true); + __ profile_parameters_type(rax, rcx, rdx); // increment invocation count & check for overflow Label invocation_counter_overflow; Label profile_method; diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp index d7e0d7742b0..ef1aa8409b9 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp @@ -166,7 +166,7 @@ address TemplateInterpreterGenerator::generate_continuation_for(TosState state) } -address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step) { +address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step, size_t index_size) { address entry = __ pc(); // Restore stack bottom in case i2c adjusted stack @@ -183,27 +183,15 @@ address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, __ profile_return_type(mdp, rax, tmp); } - Label L_got_cache, L_giant_index; - if (EnableInvokeDynamic) { - __ cmpb(Address(r13, 0), Bytecodes::_invokedynamic); - __ jcc(Assembler::equal, L_giant_index); - } - __ get_cache_and_index_at_bcp(rbx, rcx, 1, sizeof(u2)); - __ bind(L_got_cache); - __ movl(rbx, Address(rbx, rcx, - Address::times_ptr, - in_bytes(ConstantPoolCache::base_offset()) + - 3 * wordSize)); - __ andl(rbx, 0xFF); - __ lea(rsp, Address(rsp, rbx, Address::times_8)); - __ dispatch_next(state, step); + const Register cache = rbx; + const Register index = rcx; + __ get_cache_and_index_at_bcp(cache, index, 1, index_size); - // out of the main line of code... - if (EnableInvokeDynamic) { - __ bind(L_giant_index); - __ get_cache_and_index_at_bcp(rbx, rcx, 1, sizeof(u4)); - __ jmp(L_got_cache); - } + const Register flags = cache; + __ movl(flags, Address(cache, index, Address::times_ptr, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset())); + __ andl(flags, ConstantPoolCacheEntry::parameter_size_mask); + __ lea(rsp, Address(rsp, flags, Interpreter::stackElementScale())); + __ dispatch_next(state, step); return entry; } @@ -1497,6 +1485,7 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { in_bytes(JavaThread::do_not_unlock_if_synchronized_offset())); __ movbool(do_not_unlock_if_synchronized, true); + __ profile_parameters_type(rax, rcx, rdx); // increment invocation count & check for overflow Label invocation_counter_overflow; Label profile_method; diff --git a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp index 6e6033b02b6..3d07cb0ee32 100644 --- a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp @@ -2925,9 +2925,7 @@ void TemplateTable::prepare_invoke(int byte_no, ConstantPoolCacheEntry::verify_tos_state_shift(); // load return address { - const address table_addr = (is_invokeinterface || is_invokedynamic) ? - (address)Interpreter::return_5_addrs_by_index_table() : - (address)Interpreter::return_3_addrs_by_index_table(); + const address table_addr = (address) Interpreter::invoke_return_entry_table_for(code); ExternalAddress table(table_addr); __ movptr(flags, ArrayAddress(table, Address(noreg, flags, Address::times_ptr))); } diff --git a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp index 8c49726e5ff..1da6efa85e0 100644 --- a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp @@ -2980,9 +2980,7 @@ void TemplateTable::prepare_invoke(int byte_no, ConstantPoolCacheEntry::verify_tos_state_shift(); // load return address { - const address table_addr = (is_invokeinterface || is_invokedynamic) ? - (address)Interpreter::return_5_addrs_by_index_table() : - (address)Interpreter::return_3_addrs_by_index_table(); + const address table_addr = (address) Interpreter::invoke_return_entry_table_for(code); ExternalAddress table(table_addr); __ lea(rscratch1, table); __ movptr(flags, Address(rscratch1, flags, Address::times_ptr)); diff --git a/hotspot/src/cpu/x86/vm/vtableStubs_x86_32.cpp b/hotspot/src/cpu/x86/vm/vtableStubs_x86_32.cpp index 7c49d737fa5..3e7b4243510 100644 --- a/hotspot/src/cpu/x86/vm/vtableStubs_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/vtableStubs_x86_32.cpp @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" #include "code/vtableStubs.hpp" -#include "interp_masm_x86_32.hpp" +#include "interp_masm_x86.hpp" #include "memory/resourceArea.hpp" #include "oops/instanceKlass.hpp" #include "oops/klassVtable.hpp" diff --git a/hotspot/src/cpu/x86/vm/vtableStubs_x86_64.cpp b/hotspot/src/cpu/x86/vm/vtableStubs_x86_64.cpp index 911341736d8..4fc385f9737 100644 --- a/hotspot/src/cpu/x86/vm/vtableStubs_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/vtableStubs_x86_64.cpp @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "asm/macroAssembler.hpp" #include "code/vtableStubs.hpp" -#include "interp_masm_x86_64.hpp" +#include "interp_masm_x86.hpp" #include "memory/resourceArea.hpp" #include "oops/instanceKlass.hpp" #include "oops/klassVtable.hpp" diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index 8ef13d90bd2..2aa9e5f5793 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -1538,6 +1538,11 @@ const RegMask Matcher::mathExactI_result_proj_mask() { return EAX_REG_mask(); } +const RegMask Matcher::mathExactL_result_proj_mask() { + ShouldNotReachHere(); + return RegMask(); +} + const RegMask Matcher::mathExactI_flags_proj_mask() { return INT_FLAGS_mask(); } @@ -7519,7 +7524,7 @@ instruct cmovL_regUCF(cmpOpUCF cop, eFlagsRegUCF cr, eRegL dst, eRegL src) %{ //----------Arithmetic Instructions-------------------------------------------- //----------Addition Instructions---------------------------------------------- -instruct addExactI_rReg(eAXRegI dst, rRegI src, eFlagsReg cr) +instruct addExactI_eReg(eAXRegI dst, rRegI src, eFlagsReg cr) %{ match(AddExactI dst src); effect(DEF cr); @@ -7531,7 +7536,7 @@ instruct addExactI_rReg(eAXRegI dst, rRegI src, eFlagsReg cr) ins_pipe(ialu_reg_reg); %} -instruct addExactI_rReg_imm(eAXRegI dst, immI src, eFlagsReg cr) +instruct addExactI_eReg_imm(eAXRegI dst, immI src, eFlagsReg cr) %{ match(AddExactI dst src); effect(DEF cr); @@ -7543,6 +7548,20 @@ instruct addExactI_rReg_imm(eAXRegI dst, immI src, eFlagsReg cr) ins_pipe(ialu_reg_reg); %} +instruct addExactI_eReg_mem(eAXRegI dst, memory src, eFlagsReg cr) +%{ + match(AddExactI dst (LoadI src)); + effect(DEF cr); + + ins_cost(125); + format %{ "ADD $dst,$src\t# addExact int" %} + ins_encode %{ + __ addl($dst$$Register, $src$$Address); + %} + ins_pipe( ialu_reg_mem ); +%} + + // Integer Addition Instructions instruct addI_eReg(rRegI dst, rRegI src, eFlagsReg cr) %{ match(Set dst (AddI dst src)); @@ -7851,6 +7870,44 @@ instruct xchgP( memory mem, pRegP newval) %{ %} //----------Subtraction Instructions------------------------------------------- + +instruct subExactI_eReg(eAXRegI dst, rRegI src, eFlagsReg cr) +%{ + match(SubExactI dst src); + effect(DEF cr); + + format %{ "SUB $dst, $src\t# subExact int" %} + ins_encode %{ + __ subl($dst$$Register, $src$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct subExactI_eReg_imm(eAXRegI dst, immI src, eFlagsReg cr) +%{ + match(SubExactI dst src); + effect(DEF cr); + + format %{ "SUB $dst, $src\t# subExact int" %} + ins_encode %{ + __ subl($dst$$Register, $src$$constant); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct subExactI_eReg_mem(eAXRegI dst, memory src, eFlagsReg cr) +%{ + match(SubExactI dst (LoadI src)); + effect(DEF cr); + + ins_cost(125); + format %{ "SUB $dst,$src\t# subExact int" %} + ins_encode %{ + __ subl($dst$$Register, $src$$Address); + %} + ins_pipe( ialu_reg_mem ); +%} + // Integer Subtraction Instructions instruct subI_eReg(rRegI dst, rRegI src, eFlagsReg cr) %{ match(Set dst (SubI dst src)); @@ -7919,6 +7976,16 @@ instruct negI_eReg(rRegI dst, immI0 zero, eFlagsReg cr) %{ ins_pipe( ialu_reg ); %} +instruct negExactI_eReg(eAXRegI dst, eFlagsReg cr) %{ + match(NegExactI dst); + effect(DEF cr); + + format %{ "NEG $dst\t# negExact int"%} + ins_encode %{ + __ negl($dst$$Register); + %} + ins_pipe(ialu_reg); +%} //----------Multiplication/Division Instructions------------------------------- // Integer Multiplication Instructions @@ -8131,6 +8198,46 @@ instruct mulL_eReg_con(eADXRegL dst, immL_127 src, rRegI tmp, eFlagsReg cr) %{ ins_pipe( pipe_slow ); %} +instruct mulExactI_eReg(eAXRegI dst, rRegI src, eFlagsReg cr) +%{ + match(MulExactI dst src); + effect(DEF cr); + + ins_cost(300); + format %{ "IMUL $dst, $src\t# mulExact int" %} + ins_encode %{ + __ imull($dst$$Register, $src$$Register); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + +instruct mulExactI_eReg_imm(eAXRegI dst, rRegI src, immI imm, eFlagsReg cr) +%{ + match(MulExactI src imm); + effect(DEF cr); + + ins_cost(300); + format %{ "IMUL $dst, $src, $imm\t# mulExact int" %} + ins_encode %{ + __ imull($dst$$Register, $src$$Register, $imm$$constant); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + +instruct mulExactI_eReg_mem(eAXRegI dst, memory src, eFlagsReg cr) +%{ + match(MulExactI dst (LoadI src)); + effect(DEF cr); + + ins_cost(350); + format %{ "IMUL $dst, $src\t# mulExact int" %} + ins_encode %{ + __ imull($dst$$Register, $src$$Address); + %} + ins_pipe(ialu_reg_mem_alu0); +%} + + // Integer DIV with Register instruct divI_eReg(eAXRegI rax, eDXRegI rdx, eCXRegI div, eFlagsReg cr) %{ match(Set rax (DivI rax div)); diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad index 288f606cc15..182a7012ac8 100644 --- a/hotspot/src/cpu/x86/vm/x86_64.ad +++ b/hotspot/src/cpu/x86/vm/x86_64.ad @@ -1653,6 +1653,10 @@ const RegMask Matcher::mathExactI_result_proj_mask() { return INT_RAX_REG_mask(); } +const RegMask Matcher::mathExactL_result_proj_mask() { + return LONG_RAX_REG_mask(); +} + const RegMask Matcher::mathExactI_flags_proj_mask() { return INT_FLAGS_mask(); } @@ -6962,6 +6966,58 @@ instruct addExactI_rReg_imm(rax_RegI dst, immI src, rFlagsReg cr) ins_pipe(ialu_reg_reg); %} +instruct addExactI_rReg_mem(rax_RegI dst, memory src, rFlagsReg cr) +%{ + match(AddExactI dst (LoadI src)); + effect(DEF cr); + + ins_cost(125); // XXX + format %{ "addl $dst, $src\t# addExact int" %} + ins_encode %{ + __ addl($dst$$Register, $src$$Address); + %} + + ins_pipe(ialu_reg_mem); +%} + +instruct addExactL_rReg(rax_RegL dst, rRegL src, rFlagsReg cr) +%{ + match(AddExactL dst src); + effect(DEF cr); + + format %{ "addq $dst, $src\t# addExact long" %} + ins_encode %{ + __ addq($dst$$Register, $src$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct addExactL_rReg_imm(rax_RegL dst, immL32 src, rFlagsReg cr) +%{ + match(AddExactL dst src); + effect(DEF cr); + + format %{ "addq $dst, $src\t# addExact long" %} + ins_encode %{ + __ addq($dst$$Register, $src$$constant); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct addExactL_rReg_mem(rax_RegL dst, memory src, rFlagsReg cr) +%{ + match(AddExactL dst (LoadL src)); + effect(DEF cr); + + ins_cost(125); // XXX + format %{ "addq $dst, $src\t# addExact long" %} + ins_encode %{ + __ addq($dst$$Register, $src$$Address); + %} + + ins_pipe(ialu_reg_mem); +%} + instruct addI_rReg(rRegI dst, rRegI src, rFlagsReg cr) %{ match(Set dst (AddI dst src)); @@ -7574,6 +7630,80 @@ instruct subI_mem_imm(memory dst, immI src, rFlagsReg cr) ins_pipe(ialu_mem_imm); %} +instruct subExactI_rReg(rax_RegI dst, rRegI src, rFlagsReg cr) +%{ + match(SubExactI dst src); + effect(DEF cr); + + format %{ "subl $dst, $src\t# subExact int" %} + ins_encode %{ + __ subl($dst$$Register, $src$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct subExactI_rReg_imm(rax_RegI dst, immI src, rFlagsReg cr) +%{ + match(SubExactI dst src); + effect(DEF cr); + + format %{ "subl $dst, $src\t# subExact int" %} + ins_encode %{ + __ subl($dst$$Register, $src$$constant); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct subExactI_rReg_mem(rax_RegI dst, memory src, rFlagsReg cr) +%{ + match(SubExactI dst (LoadI src)); + effect(DEF cr); + + ins_cost(125); + format %{ "subl $dst, $src\t# subExact int" %} + ins_encode %{ + __ subl($dst$$Register, $src$$Address); + %} + ins_pipe(ialu_reg_mem); +%} + +instruct subExactL_rReg(rax_RegL dst, rRegL src, rFlagsReg cr) +%{ + match(SubExactL dst src); + effect(DEF cr); + + format %{ "subq $dst, $src\t# subExact long" %} + ins_encode %{ + __ subq($dst$$Register, $src$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct subExactL_rReg_imm(rax_RegL dst, immL32 src, rFlagsReg cr) +%{ + match(SubExactL dst (LoadL src)); + effect(DEF cr); + + format %{ "subq $dst, $src\t# subExact long" %} + ins_encode %{ + __ subq($dst$$Register, $src$$constant); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct subExactL_rReg_mem(rax_RegI dst, memory src, rFlagsReg cr) +%{ + match(SubExactI dst src); + effect(DEF cr); + + ins_cost(125); + format %{ "subq $dst, $src\t# subExact long" %} + ins_encode %{ + __ subq($dst$$Register, $src$$Address); + %} + ins_pipe(ialu_reg_mem); +%} + instruct subL_rReg(rRegL dst, rRegL src, rFlagsReg cr) %{ match(Set dst (SubL dst src)); @@ -7690,6 +7820,30 @@ instruct negL_mem(memory dst, immL0 zero, rFlagsReg cr) ins_pipe(ialu_reg); %} +instruct negExactI_rReg(rax_RegI dst, rFlagsReg cr) +%{ + match(NegExactI dst); + effect(KILL cr); + + format %{ "negl $dst\t# negExact int" %} + ins_encode %{ + __ negl($dst$$Register); + %} + ins_pipe(ialu_reg); +%} + +instruct negExactL_rReg(rax_RegL dst, rFlagsReg cr) +%{ + match(NegExactL dst); + effect(KILL cr); + + format %{ "negq $dst\t# negExact long" %} + ins_encode %{ + __ negq($dst$$Register); + %} + ins_pipe(ialu_reg); +%} + //----------Multiplication/Division Instructions------------------------------- // Integer Multiplication Instructions @@ -7807,6 +7961,86 @@ instruct mulHiL_rReg(rdx_RegL dst, no_rax_RegL src, rax_RegL rax, rFlagsReg cr) ins_pipe(ialu_reg_reg_alu0); %} + +instruct mulExactI_rReg(rax_RegI dst, rRegI src, rFlagsReg cr) +%{ + match(MulExactI dst src); + effect(DEF cr); + + ins_cost(300); + format %{ "imull $dst, $src\t# mulExact int" %} + ins_encode %{ + __ imull($dst$$Register, $src$$Register); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + + +instruct mulExactI_rReg_imm(rax_RegI dst, rRegI src, immI imm, rFlagsReg cr) +%{ + match(MulExactI src imm); + effect(DEF cr); + + ins_cost(300); + format %{ "imull $dst, $src, $imm\t# mulExact int" %} + ins_encode %{ + __ imull($dst$$Register, $src$$Register, $imm$$constant); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + +instruct mulExactI_rReg_mem(rax_RegI dst, memory src, rFlagsReg cr) +%{ + match(MulExactI dst (LoadI src)); + effect(DEF cr); + + ins_cost(350); + format %{ "imull $dst, $src\t# mulExact int" %} + ins_encode %{ + __ imull($dst$$Register, $src$$Address); + %} + ins_pipe(ialu_reg_mem_alu0); +%} + +instruct mulExactL_rReg(rax_RegL dst, rRegL src, rFlagsReg cr) +%{ + match(MulExactL dst src); + effect(DEF cr); + + ins_cost(300); + format %{ "imulq $dst, $src\t# mulExact long" %} + ins_encode %{ + __ imulq($dst$$Register, $src$$Register); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + +instruct mulExactL_rReg_imm(rax_RegL dst, rRegL src, immL32 imm, rFlagsReg cr) +%{ + match(MulExactL src imm); + effect(DEF cr); + + ins_cost(300); + format %{ "imulq $dst, $src, $imm\t# mulExact long" %} + ins_encode %{ + __ imulq($dst$$Register, $src$$Register, $imm$$constant); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + +instruct mulExactL_rReg_mem(rax_RegL dst, memory src, rFlagsReg cr) +%{ + match(MulExactL dst (LoadL src)); + effect(DEF cr); + + ins_cost(350); + format %{ "imulq $dst, $src\t# mulExact long" %} + ins_encode %{ + __ imulq($dst$$Register, $src$$Address); + %} + ins_pipe(ialu_reg_mem_alu0); +%} + instruct divI_rReg(rax_RegI rax, rdx_RegI rdx, no_rax_rdx_RegI div, rFlagsReg cr) %{ diff --git a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp index 42e88a7374b..27c9af71f17 100644 --- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp +++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp @@ -1006,7 +1006,7 @@ void BytecodeInterpreter::layout_interpreterState(interpreterState istate, istate->set_stack_limit(stack_base - method->max_stack() - 1); } -address CppInterpreter::return_entry(TosState state, int length) { +address CppInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) { ShouldNotCallThis(); return NULL; } diff --git a/hotspot/src/cpu/zero/vm/globals_zero.hpp b/hotspot/src/cpu/zero/vm/globals_zero.hpp index 71b566fceb0..9a304c7f3fb 100644 --- a/hotspot/src/cpu/zero/vm/globals_zero.hpp +++ b/hotspot/src/cpu/zero/vm/globals_zero.hpp @@ -57,6 +57,8 @@ define_pd_global(bool, UseMembar, true); // GC Ergo Flags define_pd_global(uintx, CMSYoungGenPerWorker, 16*M); // default max size of CMS young gen, per GC worker thread +define_pd_global(uintx, TypeProfileLevel, 0); + #define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct) #endif // CPU_ZERO_VM_GLOBALS_ZERO_HPP diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index f182b2af88d..1bea78444a8 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -945,17 +945,15 @@ extern "C" Thread* get_thread() { // Used by VMSelfDestructTimer and the MemProfiler. double os::elapsedTime() { - return (double)(os::elapsed_counter()) * 0.000001; + return ((double)os::elapsed_counter()) / os::elapsed_frequency(); } jlong os::elapsed_counter() { - timeval time; - int status = gettimeofday(&time, NULL); - return jlong(time.tv_sec) * 1000 * 1000 + jlong(time.tv_usec) - initial_time_count; + return javaTimeNanos() - initial_time_count; } jlong os::elapsed_frequency() { - return (1000 * 1000); + return NANOSECS_PER_SEC; // nanosecond resolution } bool os::supports_vtime() { return true; } @@ -3582,7 +3580,7 @@ void os::init(void) { Bsd::_main_thread = pthread_self(); Bsd::clock_init(); - initial_time_count = os::elapsed_counter(); + initial_time_count = javaTimeNanos(); #ifdef __APPLE__ // XXXDARWIN @@ -4746,6 +4744,10 @@ int os::fork_and_exec(char* cmd) { // as libawt.so, and renamed libawt_xawt.so // bool os::is_headless_jre() { +#ifdef __APPLE__ + // We no longer build headless-only on Mac OS X + return false; +#else struct stat statbuf; char buf[MAXPATHLEN]; char libmawtpath[MAXPATHLEN]; @@ -4777,6 +4779,7 @@ bool os::is_headless_jre() { if (::stat(libmawtpath, &statbuf) == 0) return false; return true; +#endif } // Get the default path to the core file diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 3aeb1b70484..1bb32901540 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -1333,17 +1333,15 @@ void os::Linux::capture_initial_stack(size_t max_size) { // Used by VMSelfDestructTimer and the MemProfiler. double os::elapsedTime() { - return (double)(os::elapsed_counter()) * 0.000001; + return ((double)os::elapsed_counter()) / os::elapsed_frequency(); // nanosecond resolution } jlong os::elapsed_counter() { - timeval time; - int status = gettimeofday(&time, NULL); - return jlong(time.tv_sec) * 1000 * 1000 + jlong(time.tv_usec) - initial_time_count; + return javaTimeNanos() - initial_time_count; } jlong os::elapsed_frequency() { - return (1000 * 1000); + return NANOSECS_PER_SEC; // nanosecond resolution } bool os::supports_vtime() { return true; } @@ -4750,7 +4748,7 @@ void os::init(void) { Linux::_main_thread = pthread_self(); Linux::clock_init(); - initial_time_count = os::elapsed_counter(); + initial_time_count = javaTimeNanos(); // pthread_condattr initialization for monotonic clock int status; diff --git a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp index ad3ebb2ead9..a1d7075af55 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp @@ -79,6 +79,15 @@ # include #endif +// needed by current_stack_region() workaround for Mavericks +#if defined(__APPLE__) +# include +# include +# include +# define DEFAULT_MAIN_THREAD_STACK_PAGES 2048 +# define OS_X_10_9_0_KERNEL_MAJOR_VERSION 13 +#endif + #ifdef AMD64 #define SPELL_REG_SP "rsp" #define SPELL_REG_FP "rbp" @@ -828,6 +837,21 @@ static void current_stack_region(address * bottom, size_t * size) { pthread_t self = pthread_self(); void *stacktop = pthread_get_stackaddr_np(self); *size = pthread_get_stacksize_np(self); + // workaround for OS X 10.9.0 (Mavericks) + // pthread_get_stacksize_np returns 128 pages even though the actual size is 2048 pages + if (pthread_main_np() == 1) { + if ((*size) < (DEFAULT_MAIN_THREAD_STACK_PAGES * (size_t)getpagesize())) { + char kern_osrelease[256]; + size_t kern_osrelease_size = sizeof(kern_osrelease); + int ret = sysctlbyname("kern.osrelease", kern_osrelease, &kern_osrelease_size, NULL, 0); + if (ret == 0) { + // get the major number, atoi will ignore the minor amd micro portions of the version string + if (atoi(kern_osrelease) >= OS_X_10_9_0_KERNEL_MAJOR_VERSION) { + *size = (DEFAULT_MAIN_THREAD_STACK_PAGES*getpagesize()); + } + } + } + } *bottom = (address) stacktop - *size; #elif defined(__OpenBSD__) stack_t ss; diff --git a/hotspot/src/share/vm/adlc/archDesc.cpp b/hotspot/src/share/vm/adlc/archDesc.cpp index 9447af252fc..fd60e25acb7 100644 --- a/hotspot/src/share/vm/adlc/archDesc.cpp +++ b/hotspot/src/share/vm/adlc/archDesc.cpp @@ -1193,6 +1193,13 @@ void ArchDesc::buildMustCloneMap(FILE *fp_hpp, FILE *fp_cpp) { || strcmp(idealName,"FastLock") == 0 || strcmp(idealName,"FastUnlock") == 0 || strcmp(idealName,"AddExactI") == 0 + || strcmp(idealName,"AddExactL") == 0 + || strcmp(idealName,"SubExactI") == 0 + || strcmp(idealName,"SubExactL") == 0 + || strcmp(idealName,"MulExactI") == 0 + || strcmp(idealName,"MulExactL") == 0 + || strcmp(idealName,"NegExactI") == 0 + || strcmp(idealName,"NegExactL") == 0 || strcmp(idealName,"FlagsProj") == 0 || strcmp(idealName,"Bool") == 0 || strcmp(idealName,"Binary") == 0 ) { diff --git a/hotspot/src/share/vm/adlc/formssel.cpp b/hotspot/src/share/vm/adlc/formssel.cpp index f3048a1e5df..cfa9f5b6222 100644 --- a/hotspot/src/share/vm/adlc/formssel.cpp +++ b/hotspot/src/share/vm/adlc/formssel.cpp @@ -536,12 +536,6 @@ bool InstructForm::rematerialize(FormDict &globals, RegisterForm *registers ) { if( data_type != Form::none ) rematerialize = true; - // Ugly: until a better fix is implemented, disable rematerialization for - // negD nodes because they are proved to be problematic. - if (is_ideal_negD()) { - return false; - } - // Constants if( _components.count() == 1 && _components[0]->is(Component::USE_DEF) ) rematerialize = true; diff --git a/hotspot/src/share/vm/c1/c1_Compilation.hpp b/hotspot/src/share/vm/c1/c1_Compilation.hpp index 7386dc414c8..679ff609a84 100644 --- a/hotspot/src/share/vm/c1/c1_Compilation.hpp +++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp @@ -238,7 +238,18 @@ class Compilation: public StackObj { return env()->comp_level() == CompLevel_full_profile && C1UpdateMethodData && C1ProfileCheckcasts; } - + bool profile_parameters() { + return env()->comp_level() == CompLevel_full_profile && + C1UpdateMethodData && MethodData::profile_parameters(); + } + bool profile_arguments() { + return env()->comp_level() == CompLevel_full_profile && + C1UpdateMethodData && MethodData::profile_arguments(); + } + bool profile_return() { + return env()->comp_level() == CompLevel_full_profile && + C1UpdateMethodData && MethodData::profile_return(); + } // will compilation make optimistic assumptions that might lead to // deoptimization and that the runtime will account for? bool is_optimistic() const { diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 23d800528b3..26bb8d0227e 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -1470,7 +1470,7 @@ void GraphBuilder::method_return(Value x) { set_state(state()->caller_state()->copy_for_parsing()); if (x != NULL) { state()->push(x->type(), x); - if (profile_calls() && MethodData::profile_return() && x->type()->is_object_kind()) { + if (profile_return() && x->type()->is_object_kind()) { ciMethod* caller = state()->scope()->method(); ciMethodData* md = caller->method_data_or_null(); ciProfileData* data = md->bci_to_data(invoke_bci); @@ -1672,15 +1672,23 @@ Dependencies* GraphBuilder::dependency_recorder() const { } // How many arguments do we want to profile? -Values* GraphBuilder::args_list_for_profiling(int& start, bool may_have_receiver) { +Values* GraphBuilder::args_list_for_profiling(ciMethod* target, int& start, bool may_have_receiver) { int n = 0; - assert(start == 0, "should be initialized"); - if (MethodData::profile_arguments()) { + bool has_receiver = may_have_receiver && Bytecodes::has_receiver(method()->java_code_at_bci(bci())); + start = has_receiver ? 1 : 0; + if (profile_arguments()) { ciProfileData* data = method()->method_data()->bci_to_data(bci()); if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) { n = data->is_CallTypeData() ? data->as_CallTypeData()->number_of_arguments() : data->as_VirtualCallTypeData()->number_of_arguments(); - bool has_receiver = may_have_receiver && Bytecodes::has_receiver(method()->java_code_at_bci(bci())); - start = has_receiver ? 1 : 0; + } + } + // If we are inlining then we need to collect arguments to profile parameters for the target + if (profile_parameters() && target != NULL) { + if (target->method_data() != NULL && target->method_data()->parameters_type_data() != NULL) { + // The receiver is profiled on method entry so it's included in + // the number of parameters but here we're only interested in + // actual arguments. + n = MAX2(n, target->method_data()->parameters_type_data()->number_of_parameters() - start); } } if (n > 0) { @@ -1690,9 +1698,9 @@ Values* GraphBuilder::args_list_for_profiling(int& start, bool may_have_receiver } // Collect arguments that we want to profile in a list -Values* GraphBuilder::collect_args_for_profiling(Values* args, bool may_have_receiver) { +Values* GraphBuilder::collect_args_for_profiling(Values* args, ciMethod* target, bool may_have_receiver) { int start = 0; - Values* obj_args = args_list_for_profiling(start, may_have_receiver); + Values* obj_args = args_list_for_profiling(target, start, may_have_receiver); if (obj_args == NULL) { return NULL; } @@ -1865,7 +1873,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) { // 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. - if (!holder->is_loaded() || decl_interface->nof_implementors() != 1) { + if (!holder->is_loaded() || decl_interface->nof_implementors() != 1 || decl_interface->has_default_methods()) { singleton = NULL; } } @@ -2006,7 +2014,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) { } else if (exact_target != NULL) { target_klass = exact_target->holder(); } - profile_call(target, recv, target_klass, collect_args_for_profiling(args, false), false); + profile_call(target, recv, target_klass, collect_args_for_profiling(args, NULL, false), false); } } @@ -2021,7 +2029,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) { push(result_type, result); } } - if (profile_calls() && MethodData::profile_return() && result_type->is_object_kind()) { + if (profile_return() && result_type->is_object_kind()) { profile_return_type(result, target); } } @@ -3561,7 +3569,7 @@ bool GraphBuilder::try_inline_intrinsics(ciMethod* callee) { recv = args->at(0); null_check(recv); } - profile_call(callee, recv, NULL, collect_args_for_profiling(args, true), true); + profile_call(callee, recv, NULL, collect_args_for_profiling(args, callee, true), true); } } } @@ -3572,7 +3580,7 @@ bool GraphBuilder::try_inline_intrinsics(ciMethod* callee) { Value value = append_split(result); if (result_type != voidType) push(result_type, value); - if (callee != method() && profile_calls() && MethodData::profile_return() && result_type->is_object_kind()) { + if (callee != method() && profile_return() && result_type->is_object_kind()) { profile_return_type(result, callee); } @@ -3760,6 +3768,7 @@ bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, Bytecode // now perform tests that are based on flag settings if (callee->force_inline()) { + if (inline_level() > MaxForceInlineLevel) INLINE_BAILOUT("MaxForceInlineLevel"); print_inlining(callee, "force inline by annotation"); } else if (callee->should_inline()) { print_inlining(callee, "force inline by CompileOracle"); @@ -3820,7 +3829,7 @@ bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, Bytecode if (profile_calls()) { int start = 0; - Values* obj_args = args_list_for_profiling(start, has_receiver); + Values* obj_args = args_list_for_profiling(callee, start, has_receiver); if (obj_args != NULL) { int s = obj_args->size(); // if called through method handle invoke, some arguments may have been popped diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp index 7945674fc4e..ce83cb73fe2 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp @@ -386,9 +386,12 @@ class GraphBuilder VALUE_OBJ_CLASS_SPEC { bool profile_calls() { return _compilation->profile_calls(); } bool profile_inlined_calls() { return _compilation->profile_inlined_calls(); } bool profile_checkcasts() { return _compilation->profile_checkcasts(); } + bool profile_parameters() { return _compilation->profile_parameters(); } + bool profile_arguments() { return _compilation->profile_arguments(); } + bool profile_return() { return _compilation->profile_return(); } - Values* args_list_for_profiling(int& start, bool may_have_receiver); - Values* collect_args_for_profiling(Values* args, bool may_have_receiver); + Values* args_list_for_profiling(ciMethod* target, int& start, bool may_have_receiver); + Values* collect_args_for_profiling(Values* args, ciMethod* target, bool may_have_receiver); public: NOT_PRODUCT(void print_stats();) diff --git a/hotspot/src/share/vm/c1/c1_LIR.cpp b/hotspot/src/share/vm/c1/c1_LIR.cpp index f40d9133306..2634f5f4105 100644 --- a/hotspot/src/share/vm/c1/c1_LIR.cpp +++ b/hotspot/src/share/vm/c1/c1_LIR.cpp @@ -183,10 +183,10 @@ char LIR_OprDesc::type_char(BasicType t) { case T_LONG: case T_OBJECT: case T_ADDRESS: - case T_METADATA: case T_VOID: return ::type2char(t); - + case T_METADATA: + return 'M'; case T_ILLEGAL: return '?'; diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index 40bccf8ef77..e3098911d88 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -1175,7 +1175,7 @@ void LIRGenerator::do_Return(Return* x) { if (compilation()->env()->dtrace_method_probes()) { BasicTypeList signature; signature.append(LP64_ONLY(T_LONG) NOT_LP64(T_INT)); // thread - signature.append(T_OBJECT); // Method* + signature.append(T_METADATA); // Method* LIR_OprList* args = new LIR_OprList(); args->append(getThreadPointer()); LIR_Opr meth = new_register(T_METADATA); @@ -1265,6 +1265,7 @@ void LIRGenerator::do_getClass(Intrinsic* x) { LIRItem rcvr(x->argument_at(0), this); rcvr.load_item(); + LIR_Opr temp = new_register(T_METADATA); LIR_Opr result = rlock_result(x); // need to perform the null check on the rcvr @@ -1272,8 +1273,11 @@ void LIRGenerator::do_getClass(Intrinsic* x) { if (x->needs_null_check()) { info = state_for(x); } - __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), result, info); - __ move_wide(new LIR_Address(result, in_bytes(Klass::java_mirror_offset()), T_OBJECT), result); + + // FIXME T_ADDRESS should actually be T_METADATA but it can't because the + // meaning of these two is mixed up (see JDK-8026837). + __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), temp, info); + __ move_wide(new LIR_Address(temp, in_bytes(Klass::java_mirror_offset()), T_OBJECT), result); } @@ -2643,6 +2647,39 @@ ciKlass* LIRGenerator::profile_arg_type(ciMethodData* md, int md_base_offset, in return result; } +// profile parameters on entry to the root of the compilation +void LIRGenerator::profile_parameters(Base* x) { + if (compilation()->profile_parameters()) { + CallingConvention* args = compilation()->frame_map()->incoming_arguments(); + ciMethodData* md = scope()->method()->method_data_or_null(); + assert(md != NULL, "Sanity"); + + if (md->parameters_type_data() != NULL) { + ciParametersTypeData* parameters_type_data = md->parameters_type_data(); + ciTypeStackSlotEntries* parameters = parameters_type_data->parameters(); + LIR_Opr mdp = LIR_OprFact::illegalOpr; + for (int java_index = 0, i = 0, j = 0; j < parameters_type_data->number_of_parameters(); i++) { + LIR_Opr src = args->at(i); + assert(!src->is_illegal(), "check"); + BasicType t = src->type(); + if (t == T_OBJECT || t == T_ARRAY) { + intptr_t profiled_k = parameters->type(j); + Local* local = x->state()->local_at(java_index)->as_Local(); + ciKlass* exact = profile_arg_type(md, md->byte_offset_of_slot(parameters_type_data, ParametersTypeData::type_offset(0)), + in_bytes(ParametersTypeData::type_offset(j)) - in_bytes(ParametersTypeData::type_offset(0)), + profiled_k, local, mdp, false, local->declared_type()->as_klass()); + // If the profile is known statically set it once for all and do not emit any code + if (exact != NULL) { + md->set_parameter_type(j, exact); + } + j++; + } + java_index += type2size[t]; + } + } + } +} + void LIRGenerator::do_Base(Base* x) { __ std_entry(LIR_OprFact::illegalOpr); // Emit moves from physical registers / stack slots to virtual registers @@ -2683,7 +2720,7 @@ void LIRGenerator::do_Base(Base* x) { if (compilation()->env()->dtrace_method_probes()) { BasicTypeList signature; signature.append(LP64_ONLY(T_LONG) NOT_LP64(T_INT)); // thread - signature.append(T_OBJECT); // Method* + signature.append(T_METADATA); // Method* LIR_OprList* args = new LIR_OprList(); args->append(getThreadPointer()); LIR_Opr meth = new_register(T_METADATA); @@ -2718,6 +2755,7 @@ void LIRGenerator::do_Base(Base* x) { // increment invocation counters if needed if (!method()->is_accessor()) { // Accessors do not have MDOs, so no counting. + profile_parameters(x); CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, false); increment_invocation_counter(info); } @@ -3077,11 +3115,12 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) { } void LIRGenerator::profile_arguments(ProfileCall* x) { - if (MethodData::profile_arguments()) { + if (compilation()->profile_arguments()) { int bci = x->bci_of_invoke(); ciMethodData* md = x->method()->method_data_or_null(); ciProfileData* data = md->bci_to_data(bci); - if (data->is_CallTypeData() || data->is_VirtualCallTypeData()) { + if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) || + (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) { ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset(); int base_offset = md->byte_offset_of_slot(data, extra); LIR_Opr mdp = LIR_OprFact::illegalOpr; @@ -3107,6 +3146,71 @@ void LIRGenerator::profile_arguments(ProfileCall* x) { md->set_argument_type(bci, i, exact); } } + } else { +#ifdef ASSERT + Bytecodes::Code code = x->method()->raw_code_at_bci(x->bci_of_invoke()); + int n = x->nb_profiled_args(); + assert(MethodData::profile_parameters() && x->inlined() && + ((code == Bytecodes::_invokedynamic && n <= 1) || (code == Bytecodes::_invokehandle && n <= 2)), + "only at JSR292 bytecodes"); +#endif + } + } +} + +// profile parameters on entry to an inlined method +void LIRGenerator::profile_parameters_at_call(ProfileCall* x) { + if (compilation()->profile_parameters() && x->inlined()) { + ciMethodData* md = x->callee()->method_data_or_null(); + if (md != NULL) { + ciParametersTypeData* parameters_type_data = md->parameters_type_data(); + if (parameters_type_data != NULL) { + ciTypeStackSlotEntries* parameters = parameters_type_data->parameters(); + LIR_Opr mdp = LIR_OprFact::illegalOpr; + bool has_receiver = !x->callee()->is_static(); + ciSignature* sig = x->callee()->signature(); + ciSignatureStream sig_stream(sig, has_receiver ? x->callee()->holder() : NULL); + int i = 0; // to iterate on the Instructions + Value arg = x->recv(); + bool not_null = false; + int bci = x->bci_of_invoke(); + Bytecodes::Code bc = x->method()->java_code_at_bci(bci); + // The first parameter is the receiver so that's what we start + // with if it exists. On exception if method handle call to + // virtual method has receiver in the args list + if (arg == NULL || !Bytecodes::has_receiver(bc)) { + i = 1; + arg = x->profiled_arg_at(0); + not_null = !x->arg_needs_null_check(0); + } + int k = 0; // to iterate on the profile data + for (;;) { + intptr_t profiled_k = parameters->type(k); + ciKlass* exact = profile_arg_type(md, md->byte_offset_of_slot(parameters_type_data, ParametersTypeData::type_offset(0)), + in_bytes(ParametersTypeData::type_offset(k)) - in_bytes(ParametersTypeData::type_offset(0)), + profiled_k, arg, mdp, not_null, sig_stream.next_klass()); + // If the profile is known statically set it once for all and do not emit any code + if (exact != NULL) { + md->set_parameter_type(k, exact); + } + k++; + if (k >= parameters_type_data->number_of_parameters()) { +#ifdef ASSERT + int extra = 0; + if (MethodData::profile_arguments() && TypeProfileParmsLimit != -1 && + x->nb_profiled_args() >= TypeProfileParmsLimit && + x->recv() != NULL && Bytecodes::has_receiver(bc)) { + extra += 1; + } + assert(i == x->nb_profiled_args() - extra || (TypeProfileParmsLimit != -1 && TypeProfileArgsLimit > TypeProfileParmsLimit), "unused parameters?"); +#endif + break; + } + arg = x->profiled_arg_at(i); + not_null = !x->arg_needs_null_check(i); + i++; + } + } } } } @@ -3122,6 +3226,11 @@ void LIRGenerator::do_ProfileCall(ProfileCall* x) { profile_arguments(x); } + // profile parameters on inlined method entry including receiver + if (x->recv() != NULL || x->nb_profiled_args() > 0) { + profile_parameters_at_call(x); + } + if (x->recv() != NULL) { LIRItem value(x->recv(), this); value.load_item(); @@ -3222,7 +3331,7 @@ void LIRGenerator::do_RuntimeCall(RuntimeCall* x) { BasicTypeList* signature = new BasicTypeList(x->number_of_arguments()); if (x->pass_thread()) { - signature->append(T_ADDRESS); + signature->append(LP64_ONLY(T_LONG) NOT_LP64(T_INT)); // thread args->append(getThreadPointer()); } diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp index 05399e59046..f0c640da919 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp @@ -436,6 +436,8 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { #endif ciKlass* profile_arg_type(ciMethodData* md, int md_first_offset, int md_offset, intptr_t profiled_k, Value arg, LIR_Opr& mdp, bool not_null, ciKlass* signature_k); void profile_arguments(ProfileCall* x); + void profile_parameters(Base* x); + void profile_parameters_at_call(ProfileCall* x); public: Compilation* compilation() const { return _compilation; } diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp index 65d4c60b670..b7c04dbe825 100644 --- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp +++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp @@ -75,9 +75,9 @@ // Map BasicType to spill size in 32-bit words, matching VMReg's notion of words #ifdef _LP64 -static int type2spill_size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 0, 1, -1}; +static int type2spill_size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 0, 2, 1, 2, 1, -1}; #else -static int type2spill_size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 0, 1, -1}; +static int type2spill_size[T_CONFLICT+1]={ -1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 0, 1, -1, 1, 1, -1}; #endif diff --git a/hotspot/src/share/vm/c1/c1_globals.hpp b/hotspot/src/share/vm/c1/c1_globals.hpp index 3dceebc9d5b..9cc51ede622 100644 --- a/hotspot/src/share/vm/c1/c1_globals.hpp +++ b/hotspot/src/share/vm/c1/c1_globals.hpp @@ -341,6 +341,8 @@ diagnostic(bool, C1PatchInvokeDynamic, true, \ "Patch invokedynamic appendix not known at compile time") \ \ + develop(intx, MaxForceInlineLevel, 100, \ + "maximum number of nested @ForceInline calls that are inlined") \ \ diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp index 9cdd475a352..7e61a849b0f 100644 --- a/hotspot/src/share/vm/ci/ciEnv.cpp +++ b/hotspot/src/share/vm/ci/ciEnv.cpp @@ -483,8 +483,7 @@ ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool, { // We have to lock the cpool to keep the oop from being resolved // while we are accessing it. - oop cplock = cpool->lock(); - ObjectLocker ol(cplock, THREAD, cplock != NULL); + MonitorLockerEx ml(cpool->lock()); constantTag tag = cpool->tag_at(index); if (tag.is_klass()) { // The klass has been inserted into the constant pool diff --git a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp index d40e460dcf3..f4389da46a6 100644 --- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp +++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp @@ -57,6 +57,7 @@ ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) : _init_state = ik->init_state(); _nonstatic_field_size = ik->nonstatic_field_size(); _has_nonstatic_fields = ik->has_nonstatic_fields(); + _has_default_methods = ik->has_default_methods(); _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields: _implementor = NULL; // we will fill these lazily diff --git a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp index fdd93ddc58c..34eb84ccfeb 100644 --- a/hotspot/src/share/vm/ci/ciInstanceKlass.hpp +++ b/hotspot/src/share/vm/ci/ciInstanceKlass.hpp @@ -52,6 +52,7 @@ private: bool _has_finalizer; bool _has_subklass; bool _has_nonstatic_fields; + bool _has_default_methods; ciFlags _flags; jint _nonstatic_field_size; @@ -171,6 +172,11 @@ public: } } + bool has_default_methods() { + assert(is_loaded(), "must be loaded"); + return _has_default_methods; + } + ciInstanceKlass* get_canonical_holder(int offset); ciField* get_field_by_offset(int field_offset, bool is_static); ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static); diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp index a5549702582..dd411642ad2 100644 --- a/hotspot/src/share/vm/ci/ciMethod.cpp +++ b/hotspot/src/share/vm/ci/ciMethod.cpp @@ -565,6 +565,116 @@ void ciCallProfile::add_receiver(ciKlass* receiver, int receiver_count) { if (_limit < MorphismLimit) _limit++; } + +void ciMethod::assert_virtual_call_type_ok(int bci) { + assert(java_code_at_bci(bci) == Bytecodes::_invokevirtual || + java_code_at_bci(bci) == Bytecodes::_invokeinterface, err_msg("unexpected bytecode %s", Bytecodes::name(java_code_at_bci(bci)))); +} + +void ciMethod::assert_call_type_ok(int bci) { + assert(java_code_at_bci(bci) == Bytecodes::_invokestatic || + java_code_at_bci(bci) == Bytecodes::_invokespecial || + java_code_at_bci(bci) == Bytecodes::_invokedynamic, err_msg("unexpected bytecode %s", Bytecodes::name(java_code_at_bci(bci)))); +} + +/** + * Check whether profiling provides a type for the argument i to the + * call at bci bci + * + * @param bci bci of the call + * @param i argument number + * @return profiled type + * + * If the profile reports that the argument may be null, return false + * at least for now. + */ +ciKlass* ciMethod::argument_profiled_type(int bci, int i) { + if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) { + ciProfileData* data = method_data()->bci_to_data(bci); + if (data != NULL) { + if (data->is_VirtualCallTypeData()) { + assert_virtual_call_type_ok(bci); + ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData(); + if (i >= call->number_of_arguments()) { + return NULL; + } + ciKlass* type = call->valid_argument_type(i); + if (type != NULL && !call->argument_maybe_null(i)) { + return type; + } + } else if (data->is_CallTypeData()) { + assert_call_type_ok(bci); + ciCallTypeData* call = (ciCallTypeData*)data->as_CallTypeData(); + if (i >= call->number_of_arguments()) { + return NULL; + } + ciKlass* type = call->valid_argument_type(i); + if (type != NULL && !call->argument_maybe_null(i)) { + return type; + } + } + } + } + return NULL; +} + +/** + * Check whether profiling provides a type for the return value from + * the call at bci bci + * + * @param bci bci of the call + * @return profiled type + * + * If the profile reports that the argument may be null, return false + * at least for now. + */ +ciKlass* ciMethod::return_profiled_type(int bci) { + if (MethodData::profile_return() && method_data() != NULL && method_data()->is_mature()) { + ciProfileData* data = method_data()->bci_to_data(bci); + if (data != NULL) { + if (data->is_VirtualCallTypeData()) { + assert_virtual_call_type_ok(bci); + ciVirtualCallTypeData* call = (ciVirtualCallTypeData*)data->as_VirtualCallTypeData(); + ciKlass* type = call->valid_return_type(); + if (type != NULL && !call->return_maybe_null()) { + return type; + } + } else if (data->is_CallTypeData()) { + assert_call_type_ok(bci); + ciCallTypeData* call = (ciCallTypeData*)data->as_CallTypeData(); + ciKlass* type = call->valid_return_type(); + if (type != NULL && !call->return_maybe_null()) { + return type; + } + } + } + } + return NULL; +} + +/** + * Check whether profiling provides a type for the parameter i + * + * @param i parameter number + * @return profiled type + * + * If the profile reports that the argument may be null, return false + * at least for now. + */ +ciKlass* ciMethod::parameter_profiled_type(int i) { + if (MethodData::profile_parameters() && method_data() != NULL && method_data()->is_mature()) { + ciParametersTypeData* parameters = method_data()->parameters_type_data(); + if (parameters != NULL && i < parameters->number_of_parameters()) { + ciKlass* type = parameters->valid_parameter_type(i); + if (type != NULL && !parameters->parameter_maybe_null(i)) { + return type; + } + } + } + return NULL; +} + + // ------------------------------------------------------------------ // ciMethod::find_monomorphic_target // diff --git a/hotspot/src/share/vm/ci/ciMethod.hpp b/hotspot/src/share/vm/ci/ciMethod.hpp index ecbbfefd4d6..604babb00dd 100644 --- a/hotspot/src/share/vm/ci/ciMethod.hpp +++ b/hotspot/src/share/vm/ci/ciMethod.hpp @@ -117,6 +117,10 @@ class ciMethod : public ciMetadata { *bcp = code; } + // Check bytecode and profile data collected are compatible + void assert_virtual_call_type_ok(int bci); + void assert_call_type_ok(int bci); + public: // Basic method information. ciFlags flags() const { check_is_loaded(); return _flags; } @@ -230,6 +234,11 @@ class ciMethod : public ciMetadata { ciCallProfile call_profile_at_bci(int bci); int interpreter_call_site_count(int bci); + // Does type profiling provide a useful type at this point? + ciKlass* argument_profiled_type(int bci, int i); + ciKlass* parameter_profiled_type(int i); + ciKlass* return_profiled_type(int bci); + ciField* get_field_at_bci( int bci, bool &will_link); ciMethod* get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature); diff --git a/hotspot/src/share/vm/ci/ciMethodData.cpp b/hotspot/src/share/vm/ci/ciMethodData.cpp index aae7d92c29a..e8b6ee6af5e 100644 --- a/hotspot/src/share/vm/ci/ciMethodData.cpp +++ b/hotspot/src/share/vm/ci/ciMethodData.cpp @@ -53,6 +53,7 @@ ciMethodData::ciMethodData(MethodData* md) : ciMetadata(md) { _hint_di = first_di(); // Initialize the escape information (to "don't know."); _eflags = _arg_local = _arg_stack = _arg_returned = 0; + _parameters = NULL; } // ------------------------------------------------------------------ @@ -74,6 +75,7 @@ ciMethodData::ciMethodData() : ciMetadata(NULL) { _hint_di = first_di(); // Initialize the escape information (to "don't know."); _eflags = _arg_local = _arg_stack = _arg_returned = 0; + _parameters = NULL; } void ciMethodData::load_data() { @@ -108,6 +110,12 @@ void ciMethodData::load_data() { ci_data = next_data(ci_data); data = mdo->next_data(data); } + if (mdo->parameters_type_data() != NULL) { + _parameters = data_layout_at(mdo->parameters_type_data_di()); + ciParametersTypeData* parameters = new ciParametersTypeData(_parameters); + parameters->translate_from(mdo->parameters_type_data()); + } + // Note: Extra data are all BitData, and do not need translation. _current_mileage = MethodData::mileage_of(mdo->method()); _invocation_counter = mdo->invocation_count(); @@ -182,6 +190,8 @@ ciProfileData* ciMethodData::data_at(int data_index) { return new ciCallTypeData(data_layout); case DataLayout::virtual_call_type_data_tag: return new ciVirtualCallTypeData(data_layout); + case DataLayout::parameters_type_data_tag: + return new ciParametersTypeData(data_layout); }; } @@ -318,6 +328,14 @@ void ciMethodData::set_argument_type(int bci, int i, ciKlass* k) { } } +void ciMethodData::set_parameter_type(int i, ciKlass* k) { + VM_ENTRY_MARK; + MethodData* mdo = get_MethodData(); + if (mdo != NULL) { + mdo->parameters_type_data()->set_type(i, k->get_Klass()); + } +} + void ciMethodData::set_return_type(int bci, ciKlass* k) { VM_ENTRY_MARK; MethodData* mdo = get_MethodData(); @@ -605,4 +623,9 @@ void ciVirtualCallTypeData::print_data_on(outputStream* st) const { ret()->print_data_on(st); } } + +void ciParametersTypeData::print_data_on(outputStream* st) const { + st->print_cr("Parametertypes"); + parameters()->print_data_on(st); +} #endif diff --git a/hotspot/src/share/vm/ci/ciMethodData.hpp b/hotspot/src/share/vm/ci/ciMethodData.hpp index b57ab6deeec..0602f85a125 100644 --- a/hotspot/src/share/vm/ci/ciMethodData.hpp +++ b/hotspot/src/share/vm/ci/ciMethodData.hpp @@ -43,6 +43,7 @@ class ciMultiBranchData; class ciArgInfoData; class ciCallTypeData; class ciVirtualCallTypeData; +class ciParametersTypeData; typedef ProfileData ciProfileData; @@ -99,6 +100,10 @@ public: return valid_ciklass(type(i)); } + bool maybe_null(int i) const { + return was_null_seen(type(i)); + } + #ifndef PRODUCT void print_data_on(outputStream* st) const; #endif @@ -112,6 +117,10 @@ public: return valid_ciklass(type()); } + bool maybe_null() const { + return was_null_seen(type()); + } + #ifndef PRODUCT void print_data_on(outputStream* st) const; #endif @@ -124,7 +133,7 @@ public: ciTypeStackSlotEntries* args() const { return (ciTypeStackSlotEntries*)CallTypeData::args(); } ciReturnTypeEntry* ret() const { return (ciReturnTypeEntry*)CallTypeData::ret(); } - void translate_type_data_from(const ProfileData* data) { + void translate_from(const ProfileData* data) { if (has_arguments()) { args()->translate_type_data_from(data->as_CallTypeData()->args()); } @@ -153,6 +162,14 @@ public: return ret()->valid_type(); } + bool argument_maybe_null(int i) const { + return args()->maybe_null(i); + } + + bool return_maybe_null() const { + return ret()->maybe_null(); + } + #ifndef PRODUCT void print_data_on(outputStream* st) const; #endif @@ -259,6 +276,14 @@ public: return ret()->valid_type(); } + bool argument_maybe_null(int i) const { + return args()->maybe_null(i); + } + + bool return_maybe_null() const { + return ret()->maybe_null(); + } + #ifndef PRODUCT void print_data_on(outputStream* st) const; #endif @@ -290,6 +315,29 @@ public: ciArgInfoData(DataLayout* layout) : ArgInfoData(layout) {}; }; +class ciParametersTypeData : public ParametersTypeData { +public: + ciParametersTypeData(DataLayout* layout) : ParametersTypeData(layout) {} + + virtual void translate_from(const ProfileData* data) { + parameters()->translate_type_data_from(data->as_ParametersTypeData()->parameters()); + } + + ciTypeStackSlotEntries* parameters() const { return (ciTypeStackSlotEntries*)ParametersTypeData::parameters(); } + + ciKlass* valid_parameter_type(int i) const { + return parameters()->valid_type(i); + } + + bool parameter_maybe_null(int i) const { + return parameters()->maybe_null(i); + } + +#ifndef PRODUCT + void print_data_on(outputStream* st) const; +#endif +}; + // ciMethodData // // This class represents a MethodData* in the HotSpot virtual @@ -335,6 +383,10 @@ private: // Coherent snapshot of original header. MethodData _orig; + // Dedicated area dedicated to parameters. Null if no parameter + // profiling for this method. + DataLayout* _parameters; + ciMethodData(MethodData* md); ciMethodData(); @@ -403,6 +455,7 @@ public: // If the compiler finds a profiled type that is known statically // for sure, set it in the MethodData void set_argument_type(int bci, int i, ciKlass* k); + void set_parameter_type(int i, ciKlass* k); void set_return_type(int bci, ciKlass* k); void load_data(); @@ -467,6 +520,10 @@ public: bool is_arg_returned(int i) const; uint arg_modified(int arg) const; + ciParametersTypeData* parameters_type_data() const { + return _parameters != NULL ? new ciParametersTypeData(_parameters) : NULL; + } + // Code generation helper ByteSize offset_of_slot(ciProfileData* data, ByteSize slot_offset_in_data); int byte_offset_of_slot(ciProfileData* data, ByteSize slot_offset_in_data) { return in_bytes(offset_of_slot(data, slot_offset_in_data)); } diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index 84c191e33bd..e3209ae1868 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -131,6 +131,17 @@ void ClassLoaderData::classes_do(void f(Klass * const)) { } } +void ClassLoaderData::loaded_classes_do(KlassClosure* klass_closure) { + // Lock to avoid classes being modified/added/removed during iteration + MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); + for (Klass* k = _klasses; k != NULL; k = k->next_link()) { + // Do not filter ArrayKlass oops here... + if (k->oop_is_array() || (k->oop_is_instance() && InstanceKlass::cast(k)->is_loaded())) { + klass_closure->do_klass(k); + } + } +} + void ClassLoaderData::classes_do(void f(InstanceKlass*)) { for (Klass* k = _klasses; k != NULL; k = k->next_link()) { if (k->oop_is_instance()) { @@ -600,6 +611,12 @@ void ClassLoaderDataGraph::classes_do(void f(Klass* const)) { } } +void ClassLoaderDataGraph::loaded_classes_do(KlassClosure* klass_closure) { + for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) { + cld->loaded_classes_do(klass_closure); + } +} + void ClassLoaderDataGraph::classes_unloading_do(void f(Klass* const)) { assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!"); for (ClassLoaderData* cld = _unloading; cld != NULL; cld = cld->next()) { diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index 6d5747483d4..cee114c75e0 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -78,6 +78,7 @@ class ClassLoaderDataGraph : public AllStatic { static void keep_alive_oops_do(OopClosure* blk, KlassClosure* klass_closure, bool must_claim); static void classes_do(KlassClosure* klass_closure); static void classes_do(void f(Klass* const)); + static void loaded_classes_do(KlassClosure* klass_closure); static void classes_unloading_do(void f(Klass* const)); static bool do_unloading(BoolObjectClosure* is_alive); @@ -186,6 +187,7 @@ class ClassLoaderData : public CHeapObj { bool keep_alive() const { return _keep_alive; } bool is_alive(BoolObjectClosure* is_alive_closure) const; void classes_do(void f(Klass*)); + void loaded_classes_do(KlassClosure* klass_closure); void classes_do(void f(InstanceKlass*)); // Deallocate free list during class unloading. diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index b6731c2e83a..b4dfe7475b9 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -2360,6 +2360,11 @@ methodHandle SystemDictionary::find_method_handle_invoker(Symbol* name, objArrayHandle appendix_box = oopFactory::new_objArray(SystemDictionary::Object_klass(), 1, CHECK_(empty)); assert(appendix_box->obj_at(0) == NULL, ""); + // This should not happen. JDK code should take care of that. + if (accessing_klass.is_null() || method_type.is_null()) { + THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad invokehandle", empty); + } + // call java.lang.invoke.MethodHandleNatives::linkMethod(... String, MethodType) -> MemberName JavaCallArguments args; args.push_oop(accessing_klass()->java_mirror()); @@ -2485,6 +2490,9 @@ Handle SystemDictionary::link_method_handle_constant(KlassHandle caller, Handle type; if (signature->utf8_length() > 0 && signature->byte_at(0) == '(') { type = find_method_handle_type(signature, caller, CHECK_(empty)); + } else if (caller.is_null()) { + // This should not happen. JDK code should take care of that. + THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad MH constant", empty); } else { ResourceMark rm(THREAD); SignatureStream ss(signature, false); @@ -2548,6 +2556,11 @@ methodHandle SystemDictionary::find_dynamic_call_site_invoker(KlassHandle caller Handle method_name = java_lang_String::create_from_symbol(name, CHECK_(empty)); Handle method_type = find_method_handle_type(type, caller, CHECK_(empty)); + // This should not happen. JDK code should take care of that. + if (caller.is_null() || method_type.is_null()) { + THROW_MSG_(vmSymbols::java_lang_InternalError(), "bad invokedynamic", empty); + } + objArrayHandle appendix_box = oopFactory::new_objArray(SystemDictionary::Object_klass(), 1, CHECK_(empty)); assert(appendix_box->obj_at(0) == NULL, ""); diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index 85735a732fa..c6436364533 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -173,8 +173,6 @@ class SymbolPropertyTable; /* It's okay if this turns out to be NULL in non-1.4 JDKs. */ \ do_klass(nio_Buffer_klass, java_nio_Buffer, Opt ) \ \ - do_klass(PostVMInitHook_klass, sun_misc_PostVMInitHook, Opt ) \ - \ /* Preload boxing klasses */ \ do_klass(Boolean_klass, java_lang_Boolean, Pre ) \ do_klass(Character_klass, java_lang_Character, Pre ) \ diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index fe966e89eeb..8ff789f81e5 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -624,6 +624,7 @@ do_class(java_lang_StrictMath, "java/lang/StrictMath") \ do_signature(double2_double_signature, "(DD)D") \ do_signature(int2_int_signature, "(II)I") \ + do_signature(long2_long_signature, "(JJ)J") \ \ /* here are the math names, all together: */ \ do_name(abs_name,"abs") do_name(sin_name,"sin") do_name(cos_name,"cos") \ @@ -632,8 +633,11 @@ do_name(exp_name,"exp") do_name(min_name,"min") do_name(max_name,"max") \ \ do_name(addExact_name,"addExact") \ - do_name(subtractExact_name,"subtractExact") \ + do_name(decrementExact_name,"decrementExact") \ + do_name(incrementExact_name,"incrementExact") \ do_name(multiplyExact_name,"multiplyExact") \ + do_name(negateExact_name,"negateExact") \ + do_name(subtractExact_name,"subtractExact") \ \ do_intrinsic(_dabs, java_lang_Math, abs_name, double_double_signature, F_S) \ do_intrinsic(_dsin, java_lang_Math, sin_name, double_double_signature, F_S) \ @@ -647,7 +651,18 @@ do_intrinsic(_dexp, java_lang_Math, exp_name, double_double_signature, F_S) \ do_intrinsic(_min, java_lang_Math, min_name, int2_int_signature, F_S) \ do_intrinsic(_max, java_lang_Math, max_name, int2_int_signature, F_S) \ - do_intrinsic(_addExact, java_lang_Math, addExact_name, int2_int_signature, F_S) \ + do_intrinsic(_addExactI, java_lang_Math, addExact_name, int2_int_signature, F_S) \ + do_intrinsic(_addExactL, java_lang_Math, addExact_name, long2_long_signature, F_S) \ + do_intrinsic(_decrementExactI, java_lang_Math, decrementExact_name, int_int_signature, F_S) \ + do_intrinsic(_decrementExactL, java_lang_Math, decrementExact_name, long2_long_signature, F_S) \ + do_intrinsic(_incrementExactI, java_lang_Math, incrementExact_name, int_int_signature, F_S) \ + do_intrinsic(_incrementExactL, java_lang_Math, incrementExact_name, long2_long_signature, F_S) \ + do_intrinsic(_multiplyExactI, java_lang_Math, multiplyExact_name, int2_int_signature, F_S) \ + do_intrinsic(_multiplyExactL, java_lang_Math, multiplyExact_name, long2_long_signature, F_S) \ + do_intrinsic(_negateExactI, java_lang_Math, negateExact_name, int_int_signature, F_S) \ + do_intrinsic(_negateExactL, java_lang_Math, negateExact_name, long_long_signature, F_S) \ + do_intrinsic(_subtractExactI, java_lang_Math, subtractExact_name, int2_int_signature, F_S) \ + do_intrinsic(_subtractExactL, java_lang_Math, subtractExact_name, long2_long_signature, F_S) \ \ do_intrinsic(_floatToRawIntBits, java_lang_Float, floatToRawIntBits_name, float_int_signature, F_S) \ do_name( floatToRawIntBits_name, "floatToRawIntBits") \ diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index cc860613a57..fb47df28267 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -780,6 +780,10 @@ CompilerCounters::CompilerCounters(const char* thread_name, int instance, TRAPS) void CompileBroker::compilation_init() { _last_method_compiled[0] = '\0'; + // No need to initialize compilation system if we do not use it. + if (!UseCompiler) { + return; + } #ifndef SHARK // Set the interface to the current compiler(s). int c1_count = CompilationPolicy::policy()->compiler_count(CompLevel_simple); @@ -1297,13 +1301,6 @@ nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci, method->jmethod_id(); } - // If the compiler is shut off due to code cache getting full - // fail out now so blocking compiles dont hang the java thread - if (!should_compile_new_jobs()) { - CompilationPolicy::policy()->delay_compilation(method()); - return NULL; - } - // do the compilation if (method->is_native()) { if (!PreferInterpreterNativeStubs || method->is_method_handle_intrinsic()) { @@ -1313,11 +1310,22 @@ nmethod* CompileBroker::compile_method(methodHandle method, int osr_bci, MutexLocker locker(MethodCompileQueue_lock, THREAD); compile_id = assign_compile_id(method, standard_entry_bci); } + // To properly handle the appendix argument for out-of-line calls we are using a small trampoline that + // pops off the appendix argument and jumps to the target (see gen_special_dispatch in SharedRuntime). + // + // Since normal compiled-to-compiled calls are not able to handle such a thing we MUST generate an adapter + // in this case. If we can't generate one and use it we can not execute the out-of-line method handle calls. (void) AdapterHandlerLibrary::create_native_wrapper(method, compile_id); } else { return NULL; } } else { + // If the compiler is shut off due to code cache getting full + // fail out now so blocking compiles dont hang the java thread + if (!should_compile_new_jobs()) { + CompilationPolicy::policy()->delay_compilation(method()); + return NULL; + } compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, THREAD); } diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp index 1f2c6cbdc2f..7823f77e643 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp @@ -55,7 +55,7 @@ private: // then _alloc_region is NULL and this object should not be used to // satisfy allocation requests (it was done this way to force the // correct use of init() and release()). - HeapRegion* _alloc_region; + HeapRegion* volatile _alloc_region; // It keeps track of the distinct number of regions that are used // for allocation in the active interval of this object, i.e., @@ -132,8 +132,9 @@ public: static void setup(G1CollectedHeap* g1h, HeapRegion* dummy_region); HeapRegion* get() const { + HeapRegion * hr = _alloc_region; // Make sure that the dummy region does not escape this class. - return (_alloc_region == _dummy_region) ? NULL : _alloc_region; + return (hr == _dummy_region) ? NULL : hr; } uint count() { return _count; } diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp index cbf9e8e7fd3..cdc13041a5d 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSetSummary.cpp @@ -187,19 +187,23 @@ public: size_t code_root_elems() const { return _code_root_elems; } void print_rs_mem_info_on(outputStream * out, size_t total) { - out->print_cr(" %8dK (%5.1f%%) by %zd %s regions", round_to_K(rs_mem_size()), rs_mem_size_percent_of(total), amount(), _name); + out->print_cr(" "SIZE_FORMAT_W(8)"K (%5.1f%%) by "SIZE_FORMAT" %s regions", + round_to_K(rs_mem_size()), rs_mem_size_percent_of(total), amount(), _name); } void print_cards_occupied_info_on(outputStream * out, size_t total) { - out->print_cr(" %8d (%5.1f%%) entries by %zd %s regions", cards_occupied(), cards_occupied_percent_of(total), amount(), _name); + out->print_cr(" "SIZE_FORMAT_W(8)" (%5.1f%%) entries by "SIZE_FORMAT" %s regions", + cards_occupied(), cards_occupied_percent_of(total), amount(), _name); } void print_code_root_mem_info_on(outputStream * out, size_t total) { - out->print_cr(" %8dK (%5.1f%%) by %zd %s regions", round_to_K(code_root_mem_size()), code_root_mem_size_percent_of(total), amount(), _name); + out->print_cr(" "SIZE_FORMAT_W(8)"K (%5.1f%%) by "SIZE_FORMAT" %s regions", + round_to_K(code_root_mem_size()), code_root_mem_size_percent_of(total), amount(), _name); } void print_code_root_elems_info_on(outputStream * out, size_t total) { - out->print_cr(" %8d (%5.1f%%) elements by %zd %s regions", code_root_elems(), code_root_elems_percent_of(total), amount(), _name); + out->print_cr(" "SIZE_FORMAT_W(8)" (%5.1f%%) elements by "SIZE_FORMAT" %s regions", + code_root_elems(), code_root_elems_percent_of(total), amount(), _name); } }; @@ -327,14 +331,14 @@ void G1RemSetSummary::print_on(outputStream* out) { out->print_cr("\n Recent concurrent refinement statistics"); out->print_cr(" Processed "SIZE_FORMAT" cards", num_concurrent_refined_cards()); - out->print_cr(" Of %d completed buffers:", num_processed_buf_total()); - out->print_cr(" %8d (%5.1f%%) by concurrent RS threads.", + out->print_cr(" Of "SIZE_FORMAT" completed buffers:", num_processed_buf_total()); + out->print_cr(" "SIZE_FORMAT_W(8)" (%5.1f%%) by concurrent RS threads.", num_processed_buf_total(), percent_of(num_processed_buf_rs_threads(), num_processed_buf_total())); - out->print_cr(" %8d (%5.1f%%) by mutator threads.", + out->print_cr(" "SIZE_FORMAT_W(8)" (%5.1f%%) by mutator threads.", num_processed_buf_mutator(), percent_of(num_processed_buf_mutator(), num_processed_buf_total())); - out->print_cr(" Did %d coarsenings.", num_coarsenings()); + out->print_cr(" Did "SIZE_FORMAT" coarsenings.", num_coarsenings()); out->print_cr(" Concurrent RS threads times (s)"); out->print(" "); for (uint i = 0; i < _num_vtimes; i++) { diff --git a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp index 77471ad3d5f..0ebfd1cdf13 100644 --- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp +++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp @@ -30,11 +30,8 @@ #include "runtime/thread.inline.hpp" #include "runtime/vmThread.hpp" #include "utilities/top.hpp" -#ifdef TARGET_ARCH_MODEL_x86_32 -# include "interp_masm_x86_32.hpp" -#endif -#ifdef TARGET_ARCH_MODEL_x86_64 -# include "interp_masm_x86_64.hpp" +#ifdef TARGET_ARCH_x86 +# include "interp_masm_x86.hpp" #endif #ifdef TARGET_ARCH_MODEL_sparc # include "interp_masm_sparc.hpp" @@ -161,8 +158,8 @@ class AbstractInterpreter: AllStatic { // Runtime support // length = invoke bytecode length (to advance to next bytecode) - static address deopt_entry (TosState state, int length) { ShouldNotReachHere(); return NULL; } - static address return_entry (TosState state, int length) { ShouldNotReachHere(); return NULL; } + static address deopt_entry(TosState state, int length) { ShouldNotReachHere(); return NULL; } + static address return_entry(TosState state, int length, Bytecodes::Code code) { ShouldNotReachHere(); return NULL; } static address rethrow_exception_entry() { return _rethrow_exception_entry; } diff --git a/hotspot/src/share/vm/interpreter/cppInterpreter.hpp b/hotspot/src/share/vm/interpreter/cppInterpreter.hpp index 4997a443257..71f78840b95 100644 --- a/hotspot/src/share/vm/interpreter/cppInterpreter.hpp +++ b/hotspot/src/share/vm/interpreter/cppInterpreter.hpp @@ -78,7 +78,7 @@ class CppInterpreter: public AbstractInterpreter { static address stack_result_to_stack(int index) { return _stack_to_stack[index]; } static address stack_result_to_native(int index) { return _stack_to_native_abi[index]; } - static address return_entry (TosState state, int length); + static address return_entry (TosState state, int length, Bytecodes::Code code); static address deopt_entry (TosState state, int length); #ifdef TARGET_ARCH_x86 diff --git a/hotspot/src/share/vm/interpreter/interpreter.cpp b/hotspot/src/share/vm/interpreter/interpreter.cpp index dfd8b5b145a..60246e9013d 100644 --- a/hotspot/src/share/vm/interpreter/interpreter.cpp +++ b/hotspot/src/share/vm/interpreter/interpreter.cpp @@ -329,15 +329,21 @@ void AbstractInterpreter::print_method_kind(MethodKind kind) { //------------------------------------------------------------------------------------------------------------------------ // Deoptimization support -// If deoptimization happens, this function returns the point of next bytecode to continue execution +/** + * If a deoptimization happens, this function returns the point of next bytecode to continue execution. + */ address AbstractInterpreter::deopt_continue_after_entry(Method* method, address bcp, int callee_parameters, bool is_top_frame) { assert(method->contains(bcp), "just checkin'"); - Bytecodes::Code code = Bytecodes::java_code_at(method, bcp); + + // Get the original and rewritten bytecode. + Bytecodes::Code code = Bytecodes::java_code_at(method, bcp); assert(!Interpreter::bytecode_should_reexecute(code), "should not reexecute"); - int bci = method->bci_from(bcp); - int length = -1; // initial value for debugging + + const int bci = method->bci_from(bcp); + // compute continuation length - length = Bytecodes::length_at(method, bcp); + const int length = Bytecodes::length_at(method, bcp); + // compute result type BasicType type = T_ILLEGAL; @@ -393,7 +399,7 @@ address AbstractInterpreter::deopt_continue_after_entry(Method* method, address return is_top_frame ? Interpreter::deopt_entry (as_TosState(type), length) - : Interpreter::return_entry(as_TosState(type), length); + : Interpreter::return_entry(as_TosState(type), length, code); } // If deoptimization happens, this function returns the point where the interpreter reexecutes diff --git a/hotspot/src/share/vm/interpreter/linkResolver.cpp b/hotspot/src/share/vm/interpreter/linkResolver.cpp index e0df09356f6..f88dd153394 100644 --- a/hotspot/src/share/vm/interpreter/linkResolver.cpp +++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp @@ -1,5 +1,4 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -265,7 +264,7 @@ void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle kl void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) { Method* result_oop = klass->uncached_lookup_method(name, signature); result = methodHandle(THREAD, result_oop); - while (!result.is_null() && result->is_static()) { + while (!result.is_null() && result->is_static() && result->method_holder()->super() != NULL) { klass = KlassHandle(THREAD, result->method_holder()->super()); result = methodHandle(THREAD, klass->uncached_lookup_method(name, signature)); } @@ -419,18 +418,28 @@ void LinkResolver::check_method_accessability(KlassHandle ref_klass, AccessFlags flags = sel_method->access_flags(); - // Special case: arrays always override "clone". JVMS 2.15. + // Special case #1: arrays always override "clone". JVMS 2.15. // If the resolved klass is an array class, and the declaring class // is java.lang.Object and the method is "clone", set the flags // to public. + // Special case #2: If the resolved klass is an interface, and + // the declaring class is java.lang.Object, and the method is + // "clone" or "finalize", set the flags to public. If the + // resolved interface does not contain "clone" or "finalize" + // methods, the method/interface method resolution looks to + // the interface's super class, java.lang.Object. With JDK 8 + // interface accessability check requirement, special casing + // this scenario is necessary to avoid an IAE. // - // We'll check for the method name first, as that's most likely - // to be false (so we'll short-circuit out of these tests). - if (sel_method->name() == vmSymbols::clone_name() && - sel_klass() == SystemDictionary::Object_klass() && - resolved_klass->oop_is_array()) { + // We'll check for each method name first and then java.lang.Object + // to best short-circuit out of these tests. + if (((sel_method->name() == vmSymbols::clone_name() && + (resolved_klass->oop_is_array() || resolved_klass->is_interface())) || + (sel_method->name() == vmSymbols::finalize_method_name() && + resolved_klass->is_interface())) && + sel_klass() == SystemDictionary::Object_klass()) { // We need to change "protected" to "public". - assert(flags.is_protected(), "clone not protected?"); + assert(flags.is_protected(), "clone or finalize not protected?"); jint new_flags = flags.as_int(); new_flags = new_flags & (~JVM_ACC_PROTECTED); new_flags = new_flags | JVM_ACC_PUBLIC; diff --git a/hotspot/src/share/vm/interpreter/templateInterpreter.cpp b/hotspot/src/share/vm/interpreter/templateInterpreter.cpp index 9f7ed4c7e97..e3e89e8eed9 100644 --- a/hotspot/src/share/vm/interpreter/templateInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/templateInterpreter.cpp @@ -184,8 +184,9 @@ EntryPoint TemplateInterpreter::_deopt_entry [TemplateInterpreter::number_of_deo EntryPoint TemplateInterpreter::_continuation_entry; EntryPoint TemplateInterpreter::_safept_entry; -address TemplateInterpreter::_return_3_addrs_by_index[TemplateInterpreter::number_of_return_addrs]; -address TemplateInterpreter::_return_5_addrs_by_index[TemplateInterpreter::number_of_return_addrs]; +address TemplateInterpreter::_invoke_return_entry[TemplateInterpreter::number_of_return_addrs]; +address TemplateInterpreter::_invokeinterface_return_entry[TemplateInterpreter::number_of_return_addrs]; +address TemplateInterpreter::_invokedynamic_return_entry[TemplateInterpreter::number_of_return_addrs]; DispatchTable TemplateInterpreter::_active_table; DispatchTable TemplateInterpreter::_normal_table; @@ -237,22 +238,37 @@ void TemplateInterpreterGenerator::generate_all() { #endif // !PRODUCT { CodeletMark cm(_masm, "return entry points"); + const int index_size = sizeof(u2); for (int i = 0; i < Interpreter::number_of_return_entries; i++) { Interpreter::_return_entry[i] = EntryPoint( - generate_return_entry_for(itos, i), - generate_return_entry_for(itos, i), - generate_return_entry_for(itos, i), - generate_return_entry_for(atos, i), - generate_return_entry_for(itos, i), - generate_return_entry_for(ltos, i), - generate_return_entry_for(ftos, i), - generate_return_entry_for(dtos, i), - generate_return_entry_for(vtos, i) + generate_return_entry_for(itos, i, index_size), + generate_return_entry_for(itos, i, index_size), + generate_return_entry_for(itos, i, index_size), + generate_return_entry_for(atos, i, index_size), + generate_return_entry_for(itos, i, index_size), + generate_return_entry_for(ltos, i, index_size), + generate_return_entry_for(ftos, i, index_size), + generate_return_entry_for(dtos, i, index_size), + generate_return_entry_for(vtos, i, index_size) ); } } + { CodeletMark cm(_masm, "invoke return entry points"); + const TosState states[] = {itos, itos, itos, itos, ltos, ftos, dtos, atos, vtos}; + const int invoke_length = Bytecodes::length_for(Bytecodes::_invokestatic); + const int invokeinterface_length = Bytecodes::length_for(Bytecodes::_invokeinterface); + const int invokedynamic_length = Bytecodes::length_for(Bytecodes::_invokedynamic); + + for (int i = 0; i < Interpreter::number_of_return_addrs; i++) { + TosState state = states[i]; + Interpreter::_invoke_return_entry[i] = generate_return_entry_for(state, invoke_length, sizeof(u2)); + Interpreter::_invokeinterface_return_entry[i] = generate_return_entry_for(state, invokeinterface_length, sizeof(u2)); + Interpreter::_invokedynamic_return_entry[i] = generate_return_entry_for(state, invokedynamic_length, sizeof(u4)); + } + } + { CodeletMark cm(_masm, "earlyret entry points"); Interpreter::_earlyret_entry = EntryPoint( @@ -298,13 +314,6 @@ void TemplateInterpreterGenerator::generate_all() { } } - for (int j = 0; j < number_of_states; j++) { - const TosState states[] = {btos, ctos, stos, itos, ltos, ftos, dtos, atos, vtos}; - int index = Interpreter::TosState_as_index(states[j]); - Interpreter::_return_3_addrs_by_index[index] = Interpreter::return_entry(states[j], 3); - Interpreter::_return_5_addrs_by_index[index] = Interpreter::return_entry(states[j], 5); - } - { CodeletMark cm(_masm, "continuation entry points"); Interpreter::_continuation_entry = EntryPoint( @@ -534,9 +543,46 @@ void TemplateInterpreterGenerator::generate_and_dispatch(Template* t, TosState t //------------------------------------------------------------------------------------------------------------------------ // Entry points -address TemplateInterpreter::return_entry(TosState state, int length) { +/** + * Returns the return entry table for the given invoke bytecode. + */ +address* TemplateInterpreter::invoke_return_entry_table_for(Bytecodes::Code code) { + switch (code) { + case Bytecodes::_invokestatic: + case Bytecodes::_invokespecial: + case Bytecodes::_invokevirtual: + case Bytecodes::_invokehandle: + return Interpreter::invoke_return_entry_table(); + case Bytecodes::_invokeinterface: + return Interpreter::invokeinterface_return_entry_table(); + case Bytecodes::_invokedynamic: + return Interpreter::invokedynamic_return_entry_table(); + default: + fatal(err_msg("invalid bytecode: %s", Bytecodes::name(code))); + return NULL; + } +} + +/** + * Returns the return entry address for the given top-of-stack state and bytecode. + */ +address TemplateInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) { guarantee(0 <= length && length < Interpreter::number_of_return_entries, "illegal length"); - return _return_entry[length].entry(state); + const int index = TosState_as_index(state); + switch (code) { + case Bytecodes::_invokestatic: + case Bytecodes::_invokespecial: + case Bytecodes::_invokevirtual: + case Bytecodes::_invokehandle: + return _invoke_return_entry[index]; + case Bytecodes::_invokeinterface: + return _invokeinterface_return_entry[index]; + case Bytecodes::_invokedynamic: + return _invokedynamic_return_entry[index]; + default: + assert(!Bytecodes::is_invoke(code), err_msg("invoke instructions should be handled separately: %s", Bytecodes::name(code))); + return _return_entry[length].entry(state); + } } diff --git a/hotspot/src/share/vm/interpreter/templateInterpreter.hpp b/hotspot/src/share/vm/interpreter/templateInterpreter.hpp index 43fe4bdb1c0..838e2e08473 100644 --- a/hotspot/src/share/vm/interpreter/templateInterpreter.hpp +++ b/hotspot/src/share/vm/interpreter/templateInterpreter.hpp @@ -120,8 +120,9 @@ class TemplateInterpreter: public AbstractInterpreter { static EntryPoint _continuation_entry; static EntryPoint _safept_entry; - static address _return_3_addrs_by_index[number_of_return_addrs]; // for invokevirtual return entries - static address _return_5_addrs_by_index[number_of_return_addrs]; // for invokeinterface return entries + static address _invoke_return_entry[number_of_return_addrs]; // for invokestatic, invokespecial, invokevirtual return entries + static address _invokeinterface_return_entry[number_of_return_addrs]; // for invokeinterface return entries + static address _invokedynamic_return_entry[number_of_return_addrs]; // for invokedynamic return entries static DispatchTable _active_table; // the active dispatch table (used by the interpreter for dispatch) static DispatchTable _normal_table; // the normal dispatch table (used to set the active table in normal mode) @@ -161,12 +162,15 @@ class TemplateInterpreter: public AbstractInterpreter { static address* normal_table() { return _normal_table.table_for(); } // Support for invokes - static address* return_3_addrs_by_index_table() { return _return_3_addrs_by_index; } - static address* return_5_addrs_by_index_table() { return _return_5_addrs_by_index; } - static int TosState_as_index(TosState state); // computes index into return_3_entry_by_index table + static address* invoke_return_entry_table() { return _invoke_return_entry; } + static address* invokeinterface_return_entry_table() { return _invokeinterface_return_entry; } + static address* invokedynamic_return_entry_table() { return _invokedynamic_return_entry; } + static int TosState_as_index(TosState state); - static address return_entry (TosState state, int length); - static address deopt_entry (TosState state, int length); + static address* invoke_return_entry_table_for(Bytecodes::Code code); + + static address deopt_entry(TosState state, int length); + static address return_entry(TosState state, int length, Bytecodes::Code code); // Safepoint support static void notice_safepoints(); // stops the thread when reaching a safepoint diff --git a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp index fb7bdc5b6c2..a80caa96409 100644 --- a/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp +++ b/hotspot/src/share/vm/interpreter/templateInterpreterGenerator.hpp @@ -53,7 +53,7 @@ class TemplateInterpreterGenerator: public AbstractInterpreterGenerator { address generate_ClassCastException_handler(); address generate_ArrayIndexOutOfBounds_handler(const char* name); address generate_continuation_for(TosState state); - address generate_return_entry_for(TosState state, int step); + address generate_return_entry_for(TosState state, int step, size_t index_size); address generate_earlyret_entry_for(TosState state); address generate_deopt_entry_for(TosState state, int step); address generate_safept_entry_for(TosState state, address runtime_entry); diff --git a/hotspot/src/share/vm/interpreter/templateTable.hpp b/hotspot/src/share/vm/interpreter/templateTable.hpp index 40d05f49b49..11c875ef32d 100644 --- a/hotspot/src/share/vm/interpreter/templateTable.hpp +++ b/hotspot/src/share/vm/interpreter/templateTable.hpp @@ -28,11 +28,8 @@ #include "interpreter/bytecodes.hpp" #include "memory/allocation.hpp" #include "runtime/frame.hpp" -#ifdef TARGET_ARCH_MODEL_x86_32 -# include "interp_masm_x86_32.hpp" -#endif -#ifdef TARGET_ARCH_MODEL_x86_64 -# include "interp_masm_x86_64.hpp" +#ifdef TARGET_ARCH_x86 +# include "interp_masm_x86.hpp" #endif #ifdef TARGET_ARCH_MODEL_sparc # include "interp_masm_sparc.hpp" diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp index 9b321de4c44..8df4e32c355 100644 --- a/hotspot/src/share/vm/memory/metaspace.cpp +++ b/hotspot/src/share/vm/memory/metaspace.cpp @@ -56,7 +56,7 @@ size_t const allocation_from_dictionary_limit = 4 * K; MetaWord* last_allocated = 0; -size_t Metaspace::_class_metaspace_size; +size_t Metaspace::_compressed_class_space_size; // Used in declarations in SpaceManager and ChunkManager enum ChunkIndex { @@ -75,8 +75,7 @@ enum ChunkSizes { // in words. ClassSmallChunk = 256, SmallChunk = 512, ClassMediumChunk = 4 * K, - MediumChunk = 8 * K, - HumongousChunkGranularity = 8 + MediumChunk = 8 * K }; static ChunkIndex next_chunk_index(ChunkIndex i) { @@ -92,6 +91,7 @@ typedef class FreeList ChunkList; // Manages the global free lists of chunks. class ChunkManager : public CHeapObj { + friend class TestVirtualSpaceNodeTest; // Free list of chunks of different sizes. // SpecializedChunk @@ -257,6 +257,8 @@ class VirtualSpaceNode : public CHeapObj { // VirtualSpace Metachunk* first_chunk() { return (Metachunk*) bottom(); } + // Committed but unused space in the virtual space + size_t free_words_in_vs() const; public: VirtualSpaceNode(size_t byte_size); @@ -301,7 +303,6 @@ class VirtualSpaceNode : public CHeapObj { // used and capacity in this single entry in the list size_t used_words_in_vs() const; size_t capacity_words_in_vs() const; - size_t free_words_in_vs() const; bool initialize(); @@ -319,6 +320,13 @@ class VirtualSpaceNode : public CHeapObj { // in the node from any freelist. void purge(ChunkManager* chunk_manager); + // If an allocation doesn't fit in the current node a new node is created. + // Allocate chunks out of the remaining committed space in this node + // to avoid wasting that memory. + // This always adds up because all the chunk sizes are multiples of + // the smallest chunk size. + void retire(ChunkManager* chunk_manager); + #ifdef ASSERT // Debug support void mangle(); @@ -461,6 +469,10 @@ class VirtualSpaceList : public CHeapObj { // and is typically followed by the allocation of a chunk. bool create_new_virtual_space(size_t vs_word_size); + // Chunk up the unused committed space in the current + // virtual space and add the chunks to the free list. + void retire_current_virtual_space(); + public: VirtualSpaceList(size_t word_size); VirtualSpaceList(ReservedSpace rs); @@ -624,10 +636,12 @@ class SpaceManager : public CHeapObj { bool is_class() { return _mdtype == Metaspace::ClassType; } // Accessors - size_t specialized_chunk_size() { return SpecializedChunk; } - size_t small_chunk_size() { return (size_t) is_class() ? ClassSmallChunk : SmallChunk; } - size_t medium_chunk_size() { return (size_t) is_class() ? ClassMediumChunk : MediumChunk; } - size_t medium_chunk_bunch() { return medium_chunk_size() * MediumChunkMultiple; } + size_t specialized_chunk_size() { return (size_t) is_class() ? ClassSpecializedChunk : SpecializedChunk; } + size_t small_chunk_size() { return (size_t) is_class() ? ClassSmallChunk : SmallChunk; } + size_t medium_chunk_size() { return (size_t) is_class() ? ClassMediumChunk : MediumChunk; } + size_t medium_chunk_bunch() { return medium_chunk_size() * MediumChunkMultiple; } + + size_t smallest_chunk_size() { return specialized_chunk_size(); } size_t allocated_blocks_words() const { return _allocated_blocks_words; } size_t allocated_blocks_bytes() const { return _allocated_blocks_words * BytesPerWord; } @@ -1056,6 +1070,35 @@ void VirtualSpaceList::purge(ChunkManager* chunk_manager) { #endif } +void VirtualSpaceList::retire_current_virtual_space() { + assert_lock_strong(SpaceManager::expand_lock()); + + VirtualSpaceNode* vsn = current_virtual_space(); + + ChunkManager* cm = is_class() ? Metaspace::chunk_manager_class() : + Metaspace::chunk_manager_metadata(); + + vsn->retire(cm); +} + +void VirtualSpaceNode::retire(ChunkManager* chunk_manager) { + for (int i = (int)MediumIndex; i >= (int)ZeroIndex; --i) { + ChunkIndex index = (ChunkIndex)i; + size_t chunk_size = chunk_manager->free_chunks(index)->size(); + + while (free_words_in_vs() >= chunk_size) { + DEBUG_ONLY(verify_container_count();) + Metachunk* chunk = get_chunk_vs(chunk_size); + assert(chunk != NULL, "allocation should have been successful"); + + chunk_manager->return_chunks(index, chunk); + chunk_manager->inc_free_chunks_total(chunk_size); + DEBUG_ONLY(verify_container_count();) + } + } + assert(free_words_in_vs() == 0, "should be empty now"); +} + VirtualSpaceList::VirtualSpaceList(size_t word_size) : _is_class(false), _virtual_space_list(NULL), @@ -1181,6 +1224,7 @@ bool VirtualSpaceList::expand_by(size_t min_words, size_t preferred_words) { if (vs_expanded) { return true; } + retire_current_virtual_space(); // Get another virtual space. size_t grow_vs_words = MAX2((size_t)VirtualSpaceSize, preferred_words); @@ -1902,12 +1946,12 @@ size_t SpaceManager::calc_chunk_size(size_t word_size) { chunk_word_size = medium_chunk_size(); } - // Might still need a humongous chunk. Enforce an - // eight word granularity to facilitate reuse (some - // wastage but better chance of reuse). + // Might still need a humongous chunk. Enforce + // humongous allocations sizes to be aligned up to + // the smallest chunk size. size_t if_humongous_sized_chunk = align_size_up(word_size + Metachunk::overhead(), - HumongousChunkGranularity); + smallest_chunk_size()); chunk_word_size = MAX2((size_t) chunk_word_size, if_humongous_sized_chunk); @@ -2151,10 +2195,10 @@ SpaceManager::~SpaceManager() { } assert(humongous_chunks->word_size() == (size_t) align_size_up(humongous_chunks->word_size(), - HumongousChunkGranularity), + smallest_chunk_size()), err_msg("Humongous chunk size is wrong: word size " SIZE_FORMAT " granularity %d", - humongous_chunks->word_size(), HumongousChunkGranularity)); + humongous_chunks->word_size(), smallest_chunk_size())); Metachunk* next_humongous_chunks = humongous_chunks->next(); humongous_chunks->container()->dec_container_count(); chunk_manager()->humongous_dictionary()->return_chunk(humongous_chunks); @@ -2799,6 +2843,8 @@ ChunkManager* Metaspace::_chunk_manager_class = NULL; #define VIRTUALSPACEMULTIPLIER 2 #ifdef _LP64 +static const uint64_t UnscaledClassSpaceMax = (uint64_t(max_juint) + 1); + void Metaspace::set_narrow_klass_base_and_shift(address metaspace_base, address cds_base) { // Figure out the narrow_klass_base and the narrow_klass_shift. The // narrow_klass_base is the lower of the metaspace base and the cds base @@ -2808,14 +2854,22 @@ void Metaspace::set_narrow_klass_base_and_shift(address metaspace_base, address address higher_address; if (UseSharedSpaces) { higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()), - (address)(metaspace_base + class_metaspace_size())); + (address)(metaspace_base + compressed_class_space_size())); lower_base = MIN2(metaspace_base, cds_base); } else { - higher_address = metaspace_base + class_metaspace_size(); + higher_address = metaspace_base + compressed_class_space_size(); lower_base = metaspace_base; + + uint64_t klass_encoding_max = UnscaledClassSpaceMax << LogKlassAlignmentInBytes; + // If compressed class space fits in lower 32G, we don't need a base. + if (higher_address <= (address)klass_encoding_max) { + lower_base = 0; // effectively lower base is zero. + } } + Universe::set_narrow_klass_base(lower_base); - if ((uint64_t)(higher_address - lower_base) < (uint64_t)max_juint) { + + if ((uint64_t)(higher_address - lower_base) < UnscaledClassSpaceMax) { Universe::set_narrow_klass_shift(0); } else { assert(!UseSharedSpaces, "Cannot shift with UseSharedSpaces"); @@ -2830,24 +2884,24 @@ bool Metaspace::can_use_cds_with_metaspace_addr(char* metaspace_base, address cd assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs"); address lower_base = MIN2((address)metaspace_base, cds_base); address higher_address = MAX2((address)(cds_base + FileMapInfo::shared_spaces_size()), - (address)(metaspace_base + class_metaspace_size())); - return ((uint64_t)(higher_address - lower_base) < (uint64_t)max_juint); + (address)(metaspace_base + compressed_class_space_size())); + return ((uint64_t)(higher_address - lower_base) < UnscaledClassSpaceMax); } // Try to allocate the metaspace at the requested addr. void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, address cds_base) { assert(using_class_space(), "called improperly"); assert(UseCompressedClassPointers, "Only use with CompressedKlassPtrs"); - assert(class_metaspace_size() < KlassEncodingMetaspaceMax, + assert(compressed_class_space_size() < KlassEncodingMetaspaceMax, "Metaspace size is too big"); - assert_is_ptr_aligned(requested_addr, _reserve_alignment); - assert_is_ptr_aligned(cds_base, _reserve_alignment); - assert_is_size_aligned(class_metaspace_size(), _reserve_alignment); + assert_is_ptr_aligned(requested_addr, _reserve_alignment); + assert_is_ptr_aligned(cds_base, _reserve_alignment); + assert_is_size_aligned(compressed_class_space_size(), _reserve_alignment); // Don't use large pages for the class space. bool large_pages = false; - ReservedSpace metaspace_rs = ReservedSpace(class_metaspace_size(), + ReservedSpace metaspace_rs = ReservedSpace(compressed_class_space_size(), _reserve_alignment, large_pages, requested_addr, 0); @@ -2862,7 +2916,7 @@ void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, a while (!metaspace_rs.is_reserved() && (addr + increment > addr) && can_use_cds_with_metaspace_addr(addr + increment, cds_base)) { addr = addr + increment; - metaspace_rs = ReservedSpace(class_metaspace_size(), + metaspace_rs = ReservedSpace(compressed_class_space_size(), _reserve_alignment, large_pages, addr, 0); } } @@ -2873,11 +2927,11 @@ void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, a // initialization has happened that depends on UseCompressedClassPointers. // So, UseCompressedClassPointers cannot be turned off at this point. if (!metaspace_rs.is_reserved()) { - metaspace_rs = ReservedSpace(class_metaspace_size(), + metaspace_rs = ReservedSpace(compressed_class_space_size(), _reserve_alignment, large_pages); if (!metaspace_rs.is_reserved()) { vm_exit_during_initialization(err_msg("Could not allocate metaspace: %d bytes", - class_metaspace_size())); + compressed_class_space_size())); } } } @@ -2899,8 +2953,8 @@ void Metaspace::allocate_metaspace_compressed_klass_ptrs(char* requested_addr, a if (PrintCompressedOopsMode || (PrintMiscellaneous && Verbose)) { gclog_or_tty->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: " SIZE_FORMAT, Universe::narrow_klass_base(), Universe::narrow_klass_shift()); - gclog_or_tty->print_cr("Metaspace Size: " SIZE_FORMAT " Address: " PTR_FORMAT " Req Addr: " PTR_FORMAT, - class_metaspace_size(), metaspace_rs.base(), requested_addr); + gclog_or_tty->print_cr("Compressed class space size: " SIZE_FORMAT " Address: " PTR_FORMAT " Req Addr: " PTR_FORMAT, + compressed_class_space_size(), metaspace_rs.base(), requested_addr); } } @@ -2966,7 +3020,7 @@ void Metaspace::ergo_initialize() { MaxMetaspaceExpansion = restricted_align_down(MaxMetaspaceExpansion, _commit_alignment); CompressedClassSpaceSize = restricted_align_down(CompressedClassSpaceSize, _reserve_alignment); - set_class_metaspace_size(CompressedClassSpaceSize); + set_compressed_class_space_size(CompressedClassSpaceSize); } void Metaspace::global_initialize() { @@ -2995,12 +3049,12 @@ void Metaspace::global_initialize() { } #ifdef _LP64 - if (cds_total + class_metaspace_size() > (uint64_t)max_juint) { + if (cds_total + compressed_class_space_size() > UnscaledClassSpaceMax) { vm_exit_during_initialization("Unable to dump shared archive.", err_msg("Size of archive (" SIZE_FORMAT ") + compressed class space (" SIZE_FORMAT ") == total (" SIZE_FORMAT ") is larger than compressed " - "klass limit: " SIZE_FORMAT, cds_total, class_metaspace_size(), - cds_total + class_metaspace_size(), (size_t)max_juint)); + "klass limit: " SIZE_FORMAT, cds_total, compressed_class_space_size(), + cds_total + compressed_class_space_size(), UnscaledClassSpaceMax)); } // Set the compressed klass pointer base so that decoding of these pointers works @@ -3048,7 +3102,8 @@ void Metaspace::global_initialize() { cds_end = (char *)align_ptr_up(cds_end, _reserve_alignment); allocate_metaspace_compressed_klass_ptrs(cds_end, cds_address); } else { - allocate_metaspace_compressed_klass_ptrs((char *)CompressedKlassPointersBase, 0); + char* base = (char*)align_ptr_up(Universe::heap()->reserved_region().end(), _reserve_alignment); + allocate_metaspace_compressed_klass_ptrs(base, 0); } } #endif @@ -3301,9 +3356,7 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, } if (result == NULL) { - report_metadata_oome(loader_data, word_size, mdtype, THREAD); - // Will not reach here. - return NULL; + report_metadata_oome(loader_data, word_size, mdtype, CHECK_NULL); } // Zero initialize. @@ -3312,6 +3365,11 @@ MetaWord* Metaspace::allocate(ClassLoaderData* loader_data, size_t word_size, return result; } +size_t Metaspace::class_chunk_size(size_t word_size) { + assert(using_class_space(), "Has to use class space"); + return class_vsm()->calc_chunk_size(word_size); +} + void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_size, MetadataType mdtype, TRAPS) { // If result is still null, we are out of memory. if (Verbose && TraceMetadataChunkAllocation) { @@ -3323,9 +3381,19 @@ void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_s MetaspaceAux::dump(gclog_or_tty); } + bool out_of_compressed_class_space = false; + if (is_class_space_allocation(mdtype)) { + Metaspace* metaspace = loader_data->metaspace_non_null(); + out_of_compressed_class_space = + MetaspaceAux::committed_bytes(Metaspace::ClassType) + + (metaspace->class_chunk_size(word_size) * BytesPerWord) > + CompressedClassSpaceSize; + } + // -XX:+HeapDumpOnOutOfMemoryError and -XX:OnOutOfMemoryError support - const char* space_string = is_class_space_allocation(mdtype) ? "Compressed class space" : - "Metadata space"; + const char* space_string = out_of_compressed_class_space ? + "Compressed class space" : "Metaspace"; + report_java_out_of_memory(space_string); if (JvmtiExport::should_post_resource_exhausted()) { @@ -3338,7 +3406,7 @@ void Metaspace::report_metadata_oome(ClassLoaderData* loader_data, size_t word_s vm_exit_during_initialization("OutOfMemoryError", space_string); } - if (is_class_space_allocation(mdtype)) { + if (out_of_compressed_class_space) { THROW_OOP(Universe::out_of_memory_error_class_metaspace()); } else { THROW_OOP(Universe::out_of_memory_error_metaspace()); @@ -3494,4 +3562,94 @@ void TestMetaspaceAux_test() { TestMetaspaceAuxTest::test(); } +class TestVirtualSpaceNodeTest { + static void chunk_up(size_t words_left, size_t& num_medium_chunks, + size_t& num_small_chunks, + size_t& num_specialized_chunks) { + num_medium_chunks = words_left / MediumChunk; + words_left = words_left % MediumChunk; + + num_small_chunks = words_left / SmallChunk; + words_left = words_left % SmallChunk; + // how many specialized chunks can we get? + num_specialized_chunks = words_left / SpecializedChunk; + assert(words_left % SpecializedChunk == 0, "should be nothing left"); + } + + public: + static void test() { + MutexLockerEx ml(SpaceManager::expand_lock(), Mutex::_no_safepoint_check_flag); + const size_t vsn_test_size_words = MediumChunk * 4; + const size_t vsn_test_size_bytes = vsn_test_size_words * BytesPerWord; + + // The chunk sizes must be multiples of eachother, or this will fail + STATIC_ASSERT(MediumChunk % SmallChunk == 0); + STATIC_ASSERT(SmallChunk % SpecializedChunk == 0); + + { // No committed memory in VSN + ChunkManager cm(SpecializedChunk, SmallChunk, MediumChunk); + VirtualSpaceNode vsn(vsn_test_size_bytes); + vsn.initialize(); + vsn.retire(&cm); + assert(cm.sum_free_chunks_count() == 0, "did not commit any memory in the VSN"); + } + + { // All of VSN is committed, half is used by chunks + ChunkManager cm(SpecializedChunk, SmallChunk, MediumChunk); + VirtualSpaceNode vsn(vsn_test_size_bytes); + vsn.initialize(); + vsn.expand_by(vsn_test_size_words, vsn_test_size_words); + vsn.get_chunk_vs(MediumChunk); + vsn.get_chunk_vs(MediumChunk); + vsn.retire(&cm); + assert(cm.sum_free_chunks_count() == 2, "should have been memory left for 2 medium chunks"); + assert(cm.sum_free_chunks() == 2*MediumChunk, "sizes should add up"); + } + + { // 4 pages of VSN is committed, some is used by chunks + ChunkManager cm(SpecializedChunk, SmallChunk, MediumChunk); + VirtualSpaceNode vsn(vsn_test_size_bytes); + const size_t page_chunks = 4 * (size_t)os::vm_page_size() / BytesPerWord; + assert(page_chunks < MediumChunk, "Test expects medium chunks to be at least 4*page_size"); + vsn.initialize(); + vsn.expand_by(page_chunks, page_chunks); + vsn.get_chunk_vs(SmallChunk); + vsn.get_chunk_vs(SpecializedChunk); + vsn.retire(&cm); + + // committed - used = words left to retire + const size_t words_left = page_chunks - SmallChunk - SpecializedChunk; + + size_t num_medium_chunks, num_small_chunks, num_spec_chunks; + chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks); + + assert(num_medium_chunks == 0, "should not get any medium chunks"); + assert(cm.sum_free_chunks_count() == (num_small_chunks + num_spec_chunks), "should be space for 3 chunks"); + assert(cm.sum_free_chunks() == words_left, "sizes should add up"); + } + + { // Half of VSN is committed, a humongous chunk is used + ChunkManager cm(SpecializedChunk, SmallChunk, MediumChunk); + VirtualSpaceNode vsn(vsn_test_size_bytes); + vsn.initialize(); + vsn.expand_by(MediumChunk * 2, MediumChunk * 2); + vsn.get_chunk_vs(MediumChunk + SpecializedChunk); // Humongous chunks will be aligned up to MediumChunk + SpecializedChunk + vsn.retire(&cm); + + const size_t words_left = MediumChunk * 2 - (MediumChunk + SpecializedChunk); + size_t num_medium_chunks, num_small_chunks, num_spec_chunks; + chunk_up(words_left, num_medium_chunks, num_small_chunks, num_spec_chunks); + + assert(num_medium_chunks == 0, "should not get any medium chunks"); + assert(cm.sum_free_chunks_count() == (num_small_chunks + num_spec_chunks), "should be space for 3 chunks"); + assert(cm.sum_free_chunks() == words_left, "sizes should add up"); + } + + } +}; + +void TestVirtualSpaceNode_test() { + TestVirtualSpaceNodeTest::test(); +} + #endif diff --git a/hotspot/src/share/vm/memory/metaspace.hpp b/hotspot/src/share/vm/memory/metaspace.hpp index 974a1aac62d..c22d2170761 100644 --- a/hotspot/src/share/vm/memory/metaspace.hpp +++ b/hotspot/src/share/vm/memory/metaspace.hpp @@ -115,13 +115,13 @@ class Metaspace : public CHeapObj { static size_t align_word_size_up(size_t); // Aligned size of the metaspace. - static size_t _class_metaspace_size; + static size_t _compressed_class_space_size; - static size_t class_metaspace_size() { - return _class_metaspace_size; + static size_t compressed_class_space_size() { + return _compressed_class_space_size; } - static void set_class_metaspace_size(size_t metaspace_size) { - _class_metaspace_size = metaspace_size; + static void set_compressed_class_space_size(size_t size) { + _compressed_class_space_size = size; } static size_t _first_chunk_word_size; @@ -192,6 +192,8 @@ class Metaspace : public CHeapObj { AllocRecord * _alloc_record_head; AllocRecord * _alloc_record_tail; + size_t class_chunk_size(size_t word_size); + public: Metaspace(Mutex* lock, MetaspaceType type); @@ -252,6 +254,7 @@ class Metaspace : public CHeapObj { static bool is_class_space_allocation(MetadataType mdType) { return mdType == ClassType && using_class_space(); } + }; class MetaspaceAux : AllStatic { diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 1f632ae478f..043962c6304 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -677,13 +677,13 @@ jint universe_init() { // HeapBased - Use compressed oops with heap base + encoding. // 4Gb -static const uint64_t NarrowOopHeapMax = (uint64_t(max_juint) + 1); +static const uint64_t UnscaledOopHeapMax = (uint64_t(max_juint) + 1); // 32Gb -// OopEncodingHeapMax == NarrowOopHeapMax << LogMinObjAlignmentInBytes; +// OopEncodingHeapMax == UnscaledOopHeapMax << LogMinObjAlignmentInBytes; char* Universe::preferred_heap_base(size_t heap_size, size_t alignment, NARROW_OOP_MODE mode) { assert(is_size_aligned((size_t)OopEncodingHeapMax, alignment), "Must be"); - assert(is_size_aligned((size_t)NarrowOopHeapMax, alignment), "Must be"); + assert(is_size_aligned((size_t)UnscaledOopHeapMax, alignment), "Must be"); assert(is_size_aligned(heap_size, alignment), "Must be"); uintx heap_base_min_address_aligned = align_size_up(HeapBaseMinAddress, alignment); @@ -702,20 +702,40 @@ char* Universe::preferred_heap_base(size_t heap_size, size_t alignment, NARROW_O // If the total size is small enough to allow UnscaledNarrowOop then // just use UnscaledNarrowOop. } else if ((total_size <= OopEncodingHeapMax) && (mode != HeapBasedNarrowOop)) { - if ((total_size <= NarrowOopHeapMax) && (mode == UnscaledNarrowOop) && + if ((total_size <= UnscaledOopHeapMax) && (mode == UnscaledNarrowOop) && (Universe::narrow_oop_shift() == 0)) { // Use 32-bits oops without encoding and // place heap's top on the 4Gb boundary - base = (NarrowOopHeapMax - heap_size); + base = (UnscaledOopHeapMax - heap_size); } else { // Can't reserve with NarrowOopShift == 0 Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); + if (mode == UnscaledNarrowOop || - mode == ZeroBasedNarrowOop && total_size <= NarrowOopHeapMax) { + mode == ZeroBasedNarrowOop && total_size <= UnscaledOopHeapMax) { + // Use zero based compressed oops with encoding and // place heap's top on the 32Gb boundary in case // total_size > 4Gb or failed to reserve below 4Gb. - base = (OopEncodingHeapMax - heap_size); + uint64_t heap_top = OopEncodingHeapMax; + + // For small heaps, save some space for compressed class pointer + // space so it can be decoded with no base. + if (UseCompressedClassPointers && !UseSharedSpaces && + OopEncodingHeapMax <= 32*G) { + + uint64_t class_space = align_size_up(CompressedClassSpaceSize, alignment); + assert(is_size_aligned((size_t)OopEncodingHeapMax-class_space, + alignment), "difference must be aligned too"); + uint64_t new_top = OopEncodingHeapMax-class_space; + + if (total_size <= new_top) { + heap_top = new_top; + } + } + + // Align base to the adjusted top of the heap + base = heap_top - heap_size; } } } else { @@ -737,7 +757,7 @@ char* Universe::preferred_heap_base(size_t heap_size, size_t alignment, NARROW_O // Set to a non-NULL value so the ReservedSpace ctor computes // the correct no-access prefix. // The final value will be set in initialize_heap() below. - Universe::set_narrow_oop_base((address)NarrowOopHeapMax); + Universe::set_narrow_oop_base((address)UnscaledOopHeapMax); #ifdef _WIN64 if (UseLargePages) { // Cannot allocate guard pages for implicit checks in indexed @@ -833,7 +853,7 @@ jint Universe::initialize_heap() { Universe::set_narrow_oop_use_implicit_null_checks(true); } #endif // _WIN64 - if((uint64_t)Universe::heap()->reserved_region().end() > NarrowOopHeapMax) { + if((uint64_t)Universe::heap()->reserved_region().end() > UnscaledOopHeapMax) { // Can't reserve heap below 4Gb. Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes); } else { @@ -1029,7 +1049,7 @@ bool universe_post_init() { Handle msg = java_lang_String::create_from_str("Java heap space", CHECK_false); java_lang_Throwable::set_message(Universe::_out_of_memory_error_java_heap, msg()); - msg = java_lang_String::create_from_str("Metadata space", CHECK_false); + msg = java_lang_String::create_from_str("Metaspace", CHECK_false); java_lang_Throwable::set_message(Universe::_out_of_memory_error_metaspace, msg()); msg = java_lang_String::create_from_str("Compressed class space", CHECK_false); java_lang_Throwable::set_message(Universe::_out_of_memory_error_class_metaspace, msg()); diff --git a/hotspot/src/share/vm/oops/constantPool.cpp b/hotspot/src/share/vm/oops/constantPool.cpp index 73cebb4258f..16b53a69929 100644 --- a/hotspot/src/share/vm/oops/constantPool.cpp +++ b/hotspot/src/share/vm/oops/constantPool.cpp @@ -40,7 +40,6 @@ #include "runtime/init.hpp" #include "runtime/javaCalls.hpp" #include "runtime/signature.hpp" -#include "runtime/synchronizer.hpp" #include "runtime/vframe.hpp" ConstantPool* ConstantPool::allocate(ClassLoaderData* loader_data, int length, TRAPS) { @@ -70,6 +69,7 @@ ConstantPool::ConstantPool(Array* tags) { // only set to non-zero if constant pool is merged by RedefineClasses set_version(0); + set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock")); // initialize tag array int length = tags->length(); @@ -95,6 +95,9 @@ void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) { void ConstantPool::release_C_heap_structures() { // walk constant pool and decrement symbol reference counts unreference_symbols(); + + delete _lock; + set_lock(NULL); } objArrayOop ConstantPool::resolved_references() const { @@ -151,6 +154,9 @@ void ConstantPool::restore_unshareable_info(TRAPS) { ClassLoaderData* loader_data = pool_holder()->class_loader_data(); set_resolved_references(loader_data->add_handle(refs_handle)); } + + // Also need to recreate the mutex. Make sure this matches the constructor + set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock")); } } @@ -161,23 +167,7 @@ void ConstantPool::remove_unshareable_info() { set_resolved_reference_length( resolved_references() != NULL ? resolved_references()->length() : 0); set_resolved_references(NULL); -} - -oop ConstantPool::lock() { - if (_pool_holder) { - // We re-use the _pool_holder's init_lock to reduce footprint. - // Notes on deadlocks: - // [1] This lock is a Java oop, so it can be recursively locked by - // the same thread without self-deadlocks. - // [2] Deadlock will happen if there is circular dependency between - // the of two Java classes. However, in this case, - // the deadlock would have happened long before we reach - // ConstantPool::lock(), so reusing init_lock does not - // increase the possibility of deadlock. - return _pool_holder->init_lock(); - } else { - return NULL; - } + set_lock(NULL); } int ConstantPool::cp_to_object_index(int cp_index) { @@ -211,9 +201,7 @@ Klass* ConstantPool::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS Symbol* name = NULL; Handle loader; - { - oop cplock = this_oop->lock(); - ObjectLocker ol(cplock , THREAD, cplock != NULL); + { MonitorLockerEx ml(this_oop->lock()); if (this_oop->tag_at(which).is_unresolved_klass()) { if (this_oop->tag_at(which).is_unresolved_klass_in_error()) { @@ -260,8 +248,7 @@ Klass* ConstantPool::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS bool throw_orig_error = false; { - oop cplock = this_oop->lock(); - ObjectLocker ol(cplock, THREAD, cplock != NULL); + MonitorLockerEx ml(this_oop->lock()); // some other thread has beaten us and has resolved the class. if (this_oop->tag_at(which).is_klass()) { @@ -329,8 +316,7 @@ Klass* ConstantPool::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS } return k(); } else { - oop cplock = this_oop->lock(); - ObjectLocker ol(cplock, THREAD, cplock != NULL); + MonitorLockerEx ml(this_oop->lock()); // Only updated constant pool - if it is resolved. do_resolve = this_oop->tag_at(which).is_unresolved_klass(); if (do_resolve) { @@ -600,8 +586,7 @@ void ConstantPool::save_and_throw_exception(constantPoolHandle this_oop, int whi int tag, TRAPS) { ResourceMark rm; Symbol* error = PENDING_EXCEPTION->klass()->name(); - oop cplock = this_oop->lock(); - ObjectLocker ol(cplock, THREAD, cplock != NULL); // lock cpool to change tag. + MonitorLockerEx ml(this_oop->lock()); // lock cpool to change tag. int error_tag = (tag == JVM_CONSTANT_MethodHandle) ? JVM_CONSTANT_MethodHandleInError : JVM_CONSTANT_MethodTypeInError; @@ -762,8 +747,7 @@ oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_oop, int inde if (cache_index >= 0) { // Cache the oop here also. Handle result_handle(THREAD, result_oop); - oop cplock = this_oop->lock(); - ObjectLocker ol(cplock, THREAD, cplock != NULL); // don't know if we really need this + MonitorLockerEx ml(this_oop->lock()); // don't know if we really need this oop result = this_oop->resolved_references()->obj_at(cache_index); // Benign race condition: resolved_references may already be filled in while we were trying to lock. // The important thing here is that all threads pick up the same result. diff --git a/hotspot/src/share/vm/oops/constantPool.hpp b/hotspot/src/share/vm/oops/constantPool.hpp index 47a51a835e2..497df53d778 100644 --- a/hotspot/src/share/vm/oops/constantPool.hpp +++ b/hotspot/src/share/vm/oops/constantPool.hpp @@ -111,6 +111,7 @@ class ConstantPool : public Metadata { int _version; } _saved; + Monitor* _lock; void set_tags(Array* tags) { _tags = tags; } void tag_at_put(int which, jbyte t) { tags()->at_put(which, t); } @@ -843,17 +844,8 @@ class ConstantPool : public Metadata { void set_resolved_reference_length(int length) { _saved._resolved_reference_length = length; } int resolved_reference_length() const { return _saved._resolved_reference_length; } - - // lock() may return null -- constant pool updates may happen before this lock is - // initialized, because the _pool_holder has not been fully initialized and - // has not been registered into the system dictionary. In this case, no other - // thread can be modifying this constantpool, so no synchronization is - // necessary. - // - // Use cplock() like this: - // oop cplock = cp->lock(); - // ObjectLocker ol(cplock , THREAD, cplock != NULL); - oop lock(); + void set_lock(Monitor* lock) { _lock = lock; } + Monitor* lock() { return _lock; } // Decrease ref counts of symbols that are in the constant pool // when the holder class is unloaded diff --git a/hotspot/src/share/vm/oops/cpCache.cpp b/hotspot/src/share/vm/oops/cpCache.cpp index eabd1e059b0..215cf7796f0 100644 --- a/hotspot/src/share/vm/oops/cpCache.cpp +++ b/hotspot/src/share/vm/oops/cpCache.cpp @@ -284,8 +284,7 @@ void ConstantPoolCacheEntry::set_method_handle_common(constantPoolHandle cpool, // the lock, so that when the losing writer returns, he can use the linked // cache entry. - oop cplock = cpool->lock(); - ObjectLocker ol(cplock, Thread::current(), cplock != NULL); + MonitorLockerEx ml(cpool->lock()); if (!is_f1_null()) { return; } diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 971039ab943..510102d4e35 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -498,13 +498,27 @@ objArrayOop InstanceKlass::signers() const { oop InstanceKlass::init_lock() const { // return the init lock from the mirror - return java_lang_Class::init_lock(java_mirror()); + oop lock = java_lang_Class::init_lock(java_mirror()); + assert((oop)lock != NULL || !is_not_initialized(), // initialized or in_error state + "only fully initialized state can have a null lock"); + return lock; +} + +// Set the initialization lock to null so the object can be GC'ed. Any racing +// threads to get this lock will see a null lock and will not lock. +// That's okay because they all check for initialized state after getting +// the lock and return. +void InstanceKlass::fence_and_clear_init_lock() { + // make sure previous stores are all done, notably the init_state. + OrderAccess::storestore(); + java_lang_Class::set_init_lock(java_mirror(), NULL); + assert(!is_not_initialized(), "class must be initialized now"); } void InstanceKlass::eager_initialize_impl(instanceKlassHandle this_oop) { EXCEPTION_MARK; oop init_lock = this_oop->init_lock(); - ObjectLocker ol(init_lock, THREAD); + ObjectLocker ol(init_lock, THREAD, init_lock != NULL); // abort if someone beat us to the initialization if (!this_oop->is_not_initialized()) return; // note: not equivalent to is_initialized() @@ -523,6 +537,7 @@ void InstanceKlass::eager_initialize_impl(instanceKlassHandle this_oop) { } else { // linking successfull, mark class as initialized this_oop->set_init_state (fully_initialized); + this_oop->fence_and_clear_init_lock(); // trace if (TraceClassInitialization) { ResourceMark rm(THREAD); @@ -649,7 +664,7 @@ bool InstanceKlass::link_class_impl( // verification & rewriting { oop init_lock = this_oop->init_lock(); - ObjectLocker ol(init_lock, THREAD); + ObjectLocker ol(init_lock, THREAD, init_lock != NULL); // rewritten will have been set if loader constraint error found // on an earlier link attempt // don't verify or rewrite if already rewritten @@ -772,7 +787,7 @@ void InstanceKlass::initialize_impl(instanceKlassHandle this_oop, TRAPS) { // Step 1 { oop init_lock = this_oop->init_lock(); - ObjectLocker ol(init_lock, THREAD); + ObjectLocker ol(init_lock, THREAD, init_lock != NULL); Thread *self = THREAD; // it's passed the current thread @@ -920,8 +935,9 @@ void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS) void InstanceKlass::set_initialization_state_and_notify_impl(instanceKlassHandle this_oop, ClassState state, TRAPS) { oop init_lock = this_oop->init_lock(); - ObjectLocker ol(init_lock, THREAD); + ObjectLocker ol(init_lock, THREAD, init_lock != NULL); this_oop->set_init_state(state); + this_oop->fence_and_clear_init_lock(); ol.notify_all(CHECK); } @@ -2377,15 +2393,38 @@ address InstanceKlass::static_field_addr(int offset) { const char* InstanceKlass::signature_name() const { + int hash_len = 0; + char hash_buf[40]; + + // If this is an anonymous class, append a hash to make the name unique + if (is_anonymous()) { + assert(EnableInvokeDynamic, "EnableInvokeDynamic was not set."); + intptr_t hash = (java_mirror() != NULL) ? java_mirror()->identity_hash() : 0; + sprintf(hash_buf, "/" UINTX_FORMAT, (uintx)hash); + hash_len = (int)strlen(hash_buf); + } + + // Get the internal name as a c string const char* src = (const char*) (name()->as_C_string()); const int src_length = (int)strlen(src); - char* dest = NEW_RESOURCE_ARRAY(char, src_length + 3); - int src_index = 0; + + char* dest = NEW_RESOURCE_ARRAY(char, src_length + hash_len + 3); + + // Add L as type indicator int dest_index = 0; dest[dest_index++] = 'L'; - while (src_index < src_length) { + + // Add the actual class name + for (int src_index = 0; src_index < src_length; ) { dest[dest_index++] = src[src_index++]; } + + // If we have a hash, append it + for (int hash_index = 0; hash_index < hash_len; ) { + dest[dest_index++] = hash_buf[hash_index++]; + } + + // Add the semicolon and the NULL dest[dest_index++] = ';'; dest[dest_index] = '\0'; return dest; diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 914cb1dc06a..283caa0a703 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -1023,6 +1023,7 @@ public: // It has to be an object not a Mutex because it's held through java calls. oop init_lock() const; private: + void fence_and_clear_init_lock(); // Static methods that are used to implement member methods where an exposed this pointer // is needed due to possible GCs diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index c0b4a97fca0..7c292c3ffe5 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -1515,7 +1515,10 @@ Bytecodes::Code Method::orig_bytecode_at(int bci) const { return bp->orig_bytecode(); } } - ShouldNotReachHere(); + { + ResourceMark rm; + fatal(err_msg("no original bytecode found in %s at bci %d", name_and_sig_as_C_string(), bci)); + } return Bytecodes::_shouldnotreachhere; } diff --git a/hotspot/src/share/vm/oops/methodData.cpp b/hotspot/src/share/vm/oops/methodData.cpp index e50107f29e3..2cff5ee2c79 100644 --- a/hotspot/src/share/vm/oops/methodData.cpp +++ b/hotspot/src/share/vm/oops/methodData.cpp @@ -41,7 +41,7 @@ // Some types of data layouts need a length field. bool DataLayout::needs_array_len(u1 tag) { - return (tag == multi_branch_data_tag) || (tag == arg_info_data_tag); + return (tag == multi_branch_data_tag) || (tag == arg_info_data_tag) || (tag == parameters_type_data_tag); } // Perform generic initialization of the data. More specific @@ -156,10 +156,13 @@ void JumpData::print_data_on(outputStream* st) const { } #endif // !PRODUCT -int TypeStackSlotEntries::compute_cell_count(Symbol* signature, int max) { +int TypeStackSlotEntries::compute_cell_count(Symbol* signature, bool include_receiver, int max) { + // Parameter profiling include the receiver + int args_count = include_receiver ? 1 : 0; ResourceMark rm; SignatureStream ss(signature); - int args_count = MIN2(ss.reference_parameter_count(), max); + args_count += ss.reference_parameter_count(); + args_count = MIN2(args_count, max); return args_count * per_arg_cell_count; } @@ -169,7 +172,7 @@ int TypeEntriesAtCall::compute_cell_count(BytecodeStream* stream) { Bytecode_invoke inv(stream->method(), stream->bci()); int args_cell = 0; if (arguments_profiling_enabled()) { - args_cell = TypeStackSlotEntries::compute_cell_count(inv.signature(), TypeProfileArgsLimit); + args_cell = TypeStackSlotEntries::compute_cell_count(inv.signature(), false, TypeProfileArgsLimit); } int ret_cell = 0; if (return_profiling_enabled() && (inv.result_type() == T_OBJECT || inv.result_type() == T_ARRAY)) { @@ -212,12 +215,19 @@ public: int off_at(int i) const { return _offsets.at(i); } }; -void TypeStackSlotEntries::post_initialize(Symbol* signature, bool has_receiver) { +void TypeStackSlotEntries::post_initialize(Symbol* signature, bool has_receiver, bool include_receiver) { ResourceMark rm; - ArgumentOffsetComputer aos(signature, _number_of_entries); + int start = 0; + // Parameter profiling include the receiver + if (include_receiver && has_receiver) { + set_stack_slot(0, 0); + set_type(0, type_none()); + start += 1; + } + ArgumentOffsetComputer aos(signature, _number_of_entries-start); aos.total(); - for (int i = 0; i < _number_of_entries; i++) { - set_stack_slot(i, aos.off_at(i) + (has_receiver ? 1 : 0)); + for (int i = start; i < _number_of_entries; i++) { + set_stack_slot(i, aos.off_at(i-start) + (has_receiver ? 1 : 0)); set_type(i, type_none()); } } @@ -234,7 +244,7 @@ void CallTypeData::post_initialize(BytecodeStream* stream, MethodData* mdo) { assert(count > 0, "room for args type but none found?"); check_number_of_arguments(count); #endif - _args.post_initialize(inv.signature(), inv.has_receiver()); + _args.post_initialize(inv.signature(), inv.has_receiver(), false); } if (has_return()) { @@ -255,7 +265,7 @@ void VirtualCallTypeData::post_initialize(BytecodeStream* stream, MethodData* md assert(count > 0, "room for args type but none found?"); check_number_of_arguments(count); #endif - _args.post_initialize(inv.signature(), inv.has_receiver()); + _args.post_initialize(inv.signature(), inv.has_receiver(), false); } if (has_return()) { @@ -579,6 +589,34 @@ void ArgInfoData::print_data_on(outputStream* st) const { } #endif + +int ParametersTypeData::compute_cell_count(Method* m) { + if (!MethodData::profile_parameters_for_method(m)) { + return 0; + } + int max = TypeProfileParmsLimit == -1 ? INT_MAX : TypeProfileParmsLimit; + int obj_args = TypeStackSlotEntries::compute_cell_count(m->signature(), !m->is_static(), max); + if (obj_args > 0) { + return obj_args + 1; // 1 cell for array len + } + return 0; +} + +void ParametersTypeData::post_initialize(BytecodeStream* stream, MethodData* mdo) { + _parameters.post_initialize(mdo->method()->signature(), !mdo->method()->is_static(), true); +} + +bool ParametersTypeData::profiling_enabled() { + return MethodData::profile_parameters(); +} + +#ifndef PRODUCT +void ParametersTypeData::print_data_on(outputStream* st) const { + st->print("parameter types"); + _parameters.print_data_on(st); +} +#endif + // ================================================================== // MethodData* // @@ -741,6 +779,12 @@ int MethodData::compute_allocation_size_in_bytes(methodHandle method) { int arg_size = method->size_of_parameters(); object_size += DataLayout::compute_size_in_bytes(arg_size+1); + // Reserve room for an area of the MDO dedicated to profiling of + // parameters + int args_cell = ParametersTypeData::compute_cell_count(method()); + if (args_cell > 0) { + object_size += DataLayout::compute_size_in_bytes(args_cell); + } return object_size; } @@ -915,6 +959,8 @@ ProfileData* DataLayout::data_in() { return new CallTypeData(this); case DataLayout::virtual_call_type_data_tag: return new VirtualCallTypeData(this); + case DataLayout::parameters_type_data_tag: + return new ParametersTypeData(this); }; } @@ -936,6 +982,9 @@ void MethodData::post_initialize(BytecodeStream* stream) { stream->next(); data->post_initialize(stream, this); } + if (_parameters_type_data_di != -1) { + parameters_type_data()->post_initialize(NULL, this); + } } // Initialize the MethodData* corresponding to a given method. @@ -975,7 +1024,23 @@ MethodData::MethodData(methodHandle method, int size, TRAPS) { int arg_size = method->size_of_parameters(); dp->initialize(DataLayout::arg_info_data_tag, 0, arg_size+1); - object_size += extra_size + DataLayout::compute_size_in_bytes(arg_size+1); + int arg_data_size = DataLayout::compute_size_in_bytes(arg_size+1); + object_size += extra_size + arg_data_size; + + int args_cell = ParametersTypeData::compute_cell_count(method()); + // If we are profiling parameters, we reserver an area near the end + // of the MDO after the slots for bytecodes (because there's no bci + // for method entry so they don't fit with the framework for the + // profiling of bytecodes). We store the offset within the MDO of + // this area (or -1 if no parameter is profiled) + if (args_cell > 0) { + object_size += DataLayout::compute_size_in_bytes(args_cell); + _parameters_type_data_di = data_size + extra_size + arg_data_size; + DataLayout *dp = data_layout_at(data_size + extra_size + arg_data_size); + dp->initialize(DataLayout::parameters_type_data_tag, 0, args_cell); + } else { + _parameters_type_data_di = -1; + } // Set an initial hint. Don't use set_hint_di() because // first_di() may be out of bounds if data_size is 0. @@ -1134,6 +1199,9 @@ void MethodData::print_value_on(outputStream* st) const { void MethodData::print_data_on(outputStream* st) const { ResourceMark rm; ProfileData* data = first_data(); + if (_parameters_type_data_di != -1) { + parameters_type_data()->print_data_on(st); + } for ( ; is_valid(data); data = next_data(data)) { st->print("%d", dp_to_di(data->dp())); st->fill_to(6); @@ -1222,7 +1290,7 @@ bool MethodData::profile_arguments_for_invoke(methodHandle m, int bci) { } int MethodData::profile_return_flag() { - return TypeProfileLevel / 10; + return (TypeProfileLevel % 100) / 10; } bool MethodData::profile_return() { @@ -1249,3 +1317,32 @@ bool MethodData::profile_return_for_invoke(methodHandle m, int bci) { assert(profile_return_jsr292_only(), "inconsistent"); return profile_jsr292(m, bci); } + +int MethodData::profile_parameters_flag() { + return TypeProfileLevel / 100; +} + +bool MethodData::profile_parameters() { + return profile_parameters_flag() > no_type_profile && profile_parameters_flag() <= type_profile_all; +} + +bool MethodData::profile_parameters_jsr292_only() { + return profile_parameters_flag() == type_profile_jsr292; +} + +bool MethodData::profile_all_parameters() { + return profile_parameters_flag() == type_profile_all; +} + +bool MethodData::profile_parameters_for_method(methodHandle m) { + if (!profile_parameters()) { + return false; + } + + if (profile_all_parameters()) { + return true; + } + + assert(profile_parameters_jsr292_only(), "inconsistent"); + return m->is_compiled_lambda_form(); +} diff --git a/hotspot/src/share/vm/oops/methodData.hpp b/hotspot/src/share/vm/oops/methodData.hpp index 1dc6272c66f..a007708bb31 100644 --- a/hotspot/src/share/vm/oops/methodData.hpp +++ b/hotspot/src/share/vm/oops/methodData.hpp @@ -119,7 +119,8 @@ public: multi_branch_data_tag, arg_info_data_tag, call_type_data_tag, - virtual_call_type_data_tag + virtual_call_type_data_tag, + parameters_type_data_tag }; enum { @@ -264,6 +265,7 @@ class BranchData; class ArrayData; class MultiBranchData; class ArgInfoData; +class ParametersTypeData; // ProfileData // @@ -397,6 +399,7 @@ public: virtual bool is_ArgInfoData() const { return false; } virtual bool is_CallTypeData() const { return false; } virtual bool is_VirtualCallTypeData()const { return false; } + virtual bool is_ParametersTypeData() const { return false; } BitData* as_BitData() const { @@ -447,6 +450,10 @@ public: assert(is_VirtualCallTypeData(), "wrong type"); return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : NULL; } + ParametersTypeData* as_ParametersTypeData() const { + assert(is_ParametersTypeData(), "wrong type"); + return is_ParametersTypeData() ? (ParametersTypeData*)this : NULL; + } // Subclass specific initialization @@ -767,9 +774,9 @@ public: TypeStackSlotEntries(int base_off, int nb_entries) : TypeEntries(base_off), _number_of_entries(nb_entries) {} - static int compute_cell_count(Symbol* signature, int max); + static int compute_cell_count(Symbol* signature, bool include_receiver, int max); - void post_initialize(Symbol* signature, bool has_receiver); + void post_initialize(Symbol* signature, bool has_receiver, bool include_receiver); // offset of cell for stack slot for entry i within this block of cells for a TypeStackSlotEntries static int stack_slot_local_offset(int i) { @@ -946,17 +953,6 @@ private: assert(number_of_arguments() == total, "should be set in DataLayout::initialize"); } -protected: - // An entry for a return value takes less space than an entry for an - // argument so if the number of cells exceeds the number of cells - // needed for an argument, this object contains type information for - // at least one argument. - bool has_arguments() const { - bool res = cell_count_no_header() >= TypeStackSlotEntries::per_arg_count(); - assert (!res || TypeEntriesAtCall::arguments_profiling_enabled(), "no profiling of arguments"); - return res; - } - public: CallTypeData(DataLayout* layout) : CounterData(layout), @@ -1017,6 +1013,16 @@ public: _ret.set_type(TypeEntries::with_status(k, current)); } + // An entry for a return value takes less space than an entry for an + // argument so if the number of cells exceeds the number of cells + // needed for an argument, this object contains type information for + // at least one argument. + bool has_arguments() const { + bool res = cell_count_no_header() >= TypeStackSlotEntries::per_arg_count(); + assert (!res || TypeEntriesAtCall::arguments_profiling_enabled(), "no profiling of arguments"); + return res; + } + // An entry for a return value takes less space than an entry for an // argument, so if the remainder of the number of cells divided by // the number of cells for an argument is not null, a return value @@ -1213,17 +1219,6 @@ private: assert(number_of_arguments() == total, "should be set in DataLayout::initialize"); } -protected: - // An entry for a return value takes less space than an entry for an - // argument so if the number of cells exceeds the number of cells - // needed for an argument, this object contains type information for - // at least one argument. - bool has_arguments() const { - bool res = cell_count_no_header() >= TypeStackSlotEntries::per_arg_count(); - assert (!res || TypeEntriesAtCall::arguments_profiling_enabled(), "no profiling of arguments"); - return res; - } - public: VirtualCallTypeData(DataLayout* layout) : VirtualCallData(layout), @@ -1294,6 +1289,16 @@ public: return res; } + // An entry for a return value takes less space than an entry for an + // argument so if the number of cells exceeds the number of cells + // needed for an argument, this object contains type information for + // at least one argument. + bool has_arguments() const { + bool res = cell_count_no_header() >= TypeStackSlotEntries::per_arg_count(); + assert (!res || TypeEntriesAtCall::arguments_profiling_enabled(), "no profiling of arguments"); + return res; + } + // Code generation support static ByteSize args_data_offset() { return cell_offset(VirtualCallData::static_cell_count()) + TypeEntriesAtCall::args_data_offset(); @@ -1662,6 +1667,75 @@ public: #endif }; +// ParametersTypeData +// +// A ParametersTypeData is used to access profiling information about +// types of parameters to a method +class ParametersTypeData : public ArrayData { + +private: + TypeStackSlotEntries _parameters; + + static int stack_slot_local_offset(int i) { + assert_profiling_enabled(); + return array_start_off_set + TypeStackSlotEntries::stack_slot_local_offset(i); + } + + static int type_local_offset(int i) { + assert_profiling_enabled(); + return array_start_off_set + TypeStackSlotEntries::type_local_offset(i); + } + + static bool profiling_enabled(); + static void assert_profiling_enabled() { + assert(profiling_enabled(), "method parameters profiling should be on"); + } + +public: + ParametersTypeData(DataLayout* layout) : ArrayData(layout), _parameters(1, number_of_parameters()) { + assert(layout->tag() == DataLayout::parameters_type_data_tag, "wrong type"); + // Some compilers (VC++) don't want this passed in member initialization list + _parameters.set_profile_data(this); + } + + static int compute_cell_count(Method* m); + + virtual bool is_ParametersTypeData() const { return true; } + + virtual void post_initialize(BytecodeStream* stream, MethodData* mdo); + + int number_of_parameters() const { + return array_len() / TypeStackSlotEntries::per_arg_count(); + } + + const TypeStackSlotEntries* parameters() const { return &_parameters; } + + uint stack_slot(int i) const { + return _parameters.stack_slot(i); + } + + void set_type(int i, Klass* k) { + intptr_t current = _parameters.type(i); + _parameters.set_type(i, TypeEntries::with_status((intptr_t)k, current)); + } + + virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) { + _parameters.clean_weak_klass_links(is_alive_closure); + } + +#ifndef PRODUCT + virtual void print_data_on(outputStream* st) const; +#endif + + static ByteSize stack_slot_offset(int i) { + return cell_offset(stack_slot_local_offset(i)); + } + + static ByteSize type_offset(int i) { + return cell_offset(type_local_offset(i)); + } +}; + // MethodData* // // A MethodData* holds information which has been collected about @@ -1773,6 +1847,10 @@ private: // Size of _data array in bytes. (Excludes header and extra_data fields.) int _data_size; + // data index for the area dedicated to parameters. -1 if no + // parameter profiling. + int _parameters_type_data_di; + // Beginning of the data entries intptr_t _data[1]; @@ -1842,6 +1920,9 @@ private: static int profile_return_flag(); static bool profile_all_return(); static bool profile_return_for_invoke(methodHandle m, int bci); + static int profile_parameters_flag(); + static bool profile_parameters_jsr292_only(); + static bool profile_all_parameters(); public: static int header_size() { @@ -2048,6 +2129,16 @@ public: } } + // Return pointer to area dedicated to parameters in MDO + ParametersTypeData* parameters_type_data() const { + return _parameters_type_data_di != -1 ? data_layout_at(_parameters_type_data_di)->data_in()->as_ParametersTypeData() : NULL; + } + + int parameters_type_data_di() const { + assert(_parameters_type_data_di != -1, "no args type data"); + return _parameters_type_data_di; + } + // Support for code generation static ByteSize data_offset() { return byte_offset_of(MethodData, _data[0]); @@ -2060,6 +2151,10 @@ public: return byte_offset_of(MethodData, _backedge_counter); } + static ByteSize parameters_type_data_di_offset() { + return byte_offset_of(MethodData, _parameters_type_data_di); + } + // Deallocation support - no pointer fields to deallocate void deallocate_contents(ClassLoaderData* loader_data) {} @@ -2083,8 +2178,10 @@ public: void verify_on(outputStream* st); void verify_data_on(outputStream* st); + static bool profile_parameters_for_method(methodHandle m); static bool profile_arguments(); static bool profile_return(); + static bool profile_parameters(); static bool profile_return_jsr292_only(); }; diff --git a/hotspot/src/share/vm/opto/c2_globals.hpp b/hotspot/src/share/vm/opto/c2_globals.hpp index c17f7758270..d1c4b2ca066 100644 --- a/hotspot/src/share/vm/opto/c2_globals.hpp +++ b/hotspot/src/share/vm/opto/c2_globals.hpp @@ -638,7 +638,13 @@ "Find best control for expensive operations") \ \ product(bool, UseMathExactIntrinsics, true, \ - "Enables intrinsification of various java.lang.Math funcitons") + "Enables intrinsification of various java.lang.Math functions") \ + \ + experimental(bool, ReplaceInParentMaps, false, \ + "Propagate type improvements in callers of inlinee if possible") \ + \ + experimental(bool, UseTypeSpeculation, false, \ + "Speculatively propagate types from profiles") C2_FLAGS(DECLARE_DEVELOPER_FLAG, DECLARE_PD_DEVELOPER_FLAG, DECLARE_PRODUCT_FLAG, DECLARE_PD_PRODUCT_FLAG, DECLARE_DIAGNOSTIC_FLAG, DECLARE_EXPERIMENTAL_FLAG, DECLARE_NOTPRODUCT_FLAG) diff --git a/hotspot/src/share/vm/opto/callGenerator.cpp b/hotspot/src/share/vm/opto/callGenerator.cpp index 470a36e5c9f..33a13c83190 100644 --- a/hotspot/src/share/vm/opto/callGenerator.cpp +++ b/hotspot/src/share/vm/opto/callGenerator.cpp @@ -63,12 +63,12 @@ public: } virtual bool is_parse() const { return true; } - virtual JVMState* generate(JVMState* jvms); + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); int is_osr() { return _is_osr; } }; -JVMState* ParseGenerator::generate(JVMState* jvms) { +JVMState* ParseGenerator::generate(JVMState* jvms, Parse* parent_parser) { Compile* C = Compile::current(); if (is_osr()) { @@ -80,7 +80,7 @@ JVMState* ParseGenerator::generate(JVMState* jvms) { return NULL; // bailing out of the compile; do not try to parse } - Parse parser(jvms, method(), _expected_uses); + Parse parser(jvms, method(), _expected_uses, parent_parser); // Grab signature for matching/allocation #ifdef ASSERT if (parser.tf() != (parser.depth() == 1 ? C->tf() : tf())) { @@ -119,12 +119,12 @@ class DirectCallGenerator : public CallGenerator { _separate_io_proj(separate_io_proj) { } - virtual JVMState* generate(JVMState* jvms); + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); CallStaticJavaNode* call_node() const { return _call_node; } }; -JVMState* DirectCallGenerator::generate(JVMState* jvms) { +JVMState* DirectCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { GraphKit kit(jvms); bool is_static = method()->is_static(); address target = is_static ? SharedRuntime::get_resolve_static_call_stub() @@ -171,10 +171,10 @@ public: vtable_index >= 0, "either invalid or usable"); } virtual bool is_virtual() const { return true; } - virtual JVMState* generate(JVMState* jvms); + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); }; -JVMState* VirtualCallGenerator::generate(JVMState* jvms) { +JVMState* VirtualCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { GraphKit kit(jvms); Node* receiver = kit.argument(0); @@ -276,7 +276,7 @@ class LateInlineCallGenerator : public DirectCallGenerator { // Convert the CallStaticJava into an inline virtual void do_late_inline(); - virtual JVMState* generate(JVMState* jvms) { + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) { Compile *C = Compile::current(); C->print_inlining_skip(this); @@ -290,7 +290,7 @@ class LateInlineCallGenerator : public DirectCallGenerator { // that the late inlining logic can distinguish between fall // through and exceptional uses of the memory and io projections // as is done for allocations and macro expansion. - return DirectCallGenerator::generate(jvms); + return DirectCallGenerator::generate(jvms, parent_parser); } virtual void print_inlining_late(const char* msg) { @@ -389,7 +389,7 @@ void LateInlineCallGenerator::do_late_inline() { } // Now perform the inling using the synthesized JVMState - JVMState* new_jvms = _inline_cg->generate(jvms); + JVMState* new_jvms = _inline_cg->generate(jvms, NULL); if (new_jvms == NULL) return; // no change if (C->failing()) return; @@ -429,8 +429,8 @@ class LateInlineMHCallGenerator : public LateInlineCallGenerator { virtual bool is_mh_late_inline() const { return true; } - virtual JVMState* generate(JVMState* jvms) { - JVMState* new_jvms = LateInlineCallGenerator::generate(jvms); + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) { + JVMState* new_jvms = LateInlineCallGenerator::generate(jvms, parent_parser); if (_input_not_const) { // inlining won't be possible so no need to enqueue right now. call_node()->set_generator(this); @@ -477,15 +477,17 @@ class LateInlineStringCallGenerator : public LateInlineCallGenerator { LateInlineStringCallGenerator(ciMethod* method, CallGenerator* inline_cg) : LateInlineCallGenerator(method, inline_cg) {} - virtual JVMState* generate(JVMState* jvms) { + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) { Compile *C = Compile::current(); C->print_inlining_skip(this); C->add_string_late_inline(this); - JVMState* new_jvms = DirectCallGenerator::generate(jvms); + JVMState* new_jvms = DirectCallGenerator::generate(jvms, parent_parser); return new_jvms; } + + virtual bool is_string_late_inline() const { return true; } }; CallGenerator* CallGenerator::for_string_late_inline(ciMethod* method, CallGenerator* inline_cg) { @@ -498,13 +500,13 @@ class LateInlineBoxingCallGenerator : public LateInlineCallGenerator { LateInlineBoxingCallGenerator(ciMethod* method, CallGenerator* inline_cg) : LateInlineCallGenerator(method, inline_cg) {} - virtual JVMState* generate(JVMState* jvms) { + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) { Compile *C = Compile::current(); C->print_inlining_skip(this); C->add_boxing_late_inline(this); - JVMState* new_jvms = DirectCallGenerator::generate(jvms); + JVMState* new_jvms = DirectCallGenerator::generate(jvms, parent_parser); return new_jvms; } }; @@ -540,7 +542,7 @@ public: virtual bool is_virtual() const { return _is_virtual; } virtual bool is_deferred() const { return true; } - virtual JVMState* generate(JVMState* jvms); + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); }; @@ -550,12 +552,12 @@ CallGenerator* CallGenerator::for_warm_call(WarmCallInfo* ci, return new WarmCallGenerator(ci, if_cold, if_hot); } -JVMState* WarmCallGenerator::generate(JVMState* jvms) { +JVMState* WarmCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { Compile* C = Compile::current(); if (C->log() != NULL) { C->log()->elem("warm_call bci='%d'", jvms->bci()); } - jvms = _if_cold->generate(jvms); + jvms = _if_cold->generate(jvms, parent_parser); if (jvms != NULL) { Node* m = jvms->map()->control(); if (m->is_CatchProj()) m = m->in(0); else m = C->top(); @@ -616,7 +618,7 @@ public: virtual bool is_inline() const { return _if_hit->is_inline(); } virtual bool is_deferred() const { return _if_hit->is_deferred(); } - virtual JVMState* generate(JVMState* jvms); + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); }; @@ -628,7 +630,7 @@ CallGenerator* CallGenerator::for_predicted_call(ciKlass* predicted_receiver, } -JVMState* PredictedCallGenerator::generate(JVMState* jvms) { +JVMState* PredictedCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { GraphKit kit(jvms); PhaseGVN& gvn = kit.gvn(); // We need an explicit receiver null_check before checking its type. @@ -656,7 +658,7 @@ JVMState* PredictedCallGenerator::generate(JVMState* jvms) { { PreserveJVMState pjvms(&kit); kit.set_control(slow_ctl); if (!kit.stopped()) { - slow_jvms = _if_missed->generate(kit.sync_jvms()); + slow_jvms = _if_missed->generate(kit.sync_jvms(), parent_parser); if (kit.failing()) return NULL; // might happen because of NodeCountInliningCutoff assert(slow_jvms != NULL, "must be"); @@ -677,12 +679,12 @@ JVMState* PredictedCallGenerator::generate(JVMState* jvms) { kit.replace_in_map(receiver, exact_receiver); // Make the hot call: - JVMState* new_jvms = _if_hit->generate(kit.sync_jvms()); + JVMState* new_jvms = _if_hit->generate(kit.sync_jvms(), parent_parser); if (new_jvms == NULL) { // Inline failed, so make a direct call. assert(_if_hit->is_inline(), "must have been a failed inline"); CallGenerator* cg = CallGenerator::for_direct_call(_if_hit->method()); - new_jvms = cg->generate(kit.sync_jvms()); + new_jvms = cg->generate(kit.sync_jvms(), parent_parser); } kit.add_exception_states_from(new_jvms); kit.set_jvms(new_jvms); @@ -773,7 +775,7 @@ CallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod* ciMethod* target = oop_ptr->const_oop()->as_method_handle()->get_vmtarget(); guarantee(!target->is_method_handle_intrinsic(), "should not happen"); // XXX remove const int vtable_index = Method::invalid_vtable_index; - CallGenerator* cg = C->call_generator(target, vtable_index, false, jvms, true, PROB_ALWAYS, true, true); + CallGenerator* cg = C->call_generator(target, vtable_index, false, jvms, true, PROB_ALWAYS, NULL, true, true); assert(!cg->is_late_inline() || cg->is_mh_late_inline(), "no late inline here"); if (cg != NULL && cg->is_inline()) return cg; @@ -829,6 +831,7 @@ CallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod* int vtable_index = Method::invalid_vtable_index; bool call_does_dispatch = false; + ciKlass* speculative_receiver_type = NULL; if (is_virtual_or_interface) { ciInstanceKlass* klass = target->holder(); Node* receiver_node = kit.argument(0); @@ -837,9 +840,12 @@ CallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod* target = C->optimize_virtual_call(caller, jvms->bci(), klass, target, receiver_type, is_virtual, call_does_dispatch, vtable_index); // out-parameters + // We lack profiling at this call but type speculation may + // provide us with a type + speculative_receiver_type = receiver_type->speculative_type(); } - CallGenerator* cg = C->call_generator(target, vtable_index, call_does_dispatch, jvms, true, PROB_ALWAYS, true, true); + CallGenerator* cg = C->call_generator(target, vtable_index, call_does_dispatch, jvms, true, PROB_ALWAYS, speculative_receiver_type, true, true); assert(!cg->is_late_inline() || cg->is_mh_late_inline(), "no late inline here"); if (cg != NULL && cg->is_inline()) return cg; @@ -874,7 +880,7 @@ public: virtual bool is_inlined() const { return true; } virtual bool is_intrinsic() const { return true; } - virtual JVMState* generate(JVMState* jvms); + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); }; @@ -884,7 +890,7 @@ CallGenerator* CallGenerator::for_predicted_intrinsic(CallGenerator* intrinsic, } -JVMState* PredictedIntrinsicGenerator::generate(JVMState* jvms) { +JVMState* PredictedIntrinsicGenerator::generate(JVMState* jvms, Parse* parent_parser) { GraphKit kit(jvms); PhaseGVN& gvn = kit.gvn(); @@ -904,7 +910,7 @@ JVMState* PredictedIntrinsicGenerator::generate(JVMState* jvms) { PreserveJVMState pjvms(&kit); kit.set_control(slow_ctl); if (!kit.stopped()) { - slow_jvms = _cg->generate(kit.sync_jvms()); + slow_jvms = _cg->generate(kit.sync_jvms(), parent_parser); if (kit.failing()) return NULL; // might happen because of NodeCountInliningCutoff assert(slow_jvms != NULL, "must be"); @@ -922,12 +928,12 @@ JVMState* PredictedIntrinsicGenerator::generate(JVMState* jvms) { } // Generate intrinsic code: - JVMState* new_jvms = _intrinsic->generate(kit.sync_jvms()); + JVMState* new_jvms = _intrinsic->generate(kit.sync_jvms(), parent_parser); if (new_jvms == NULL) { // Intrinsic failed, so use slow code or make a direct call. if (slow_map == NULL) { CallGenerator* cg = CallGenerator::for_direct_call(method()); - new_jvms = cg->generate(kit.sync_jvms()); + new_jvms = cg->generate(kit.sync_jvms(), parent_parser); } else { kit.set_jvms(slow_jvms); return kit.transfer_exceptions_into_jvms(); @@ -997,7 +1003,7 @@ public: virtual bool is_virtual() const { ShouldNotReachHere(); return false; } virtual bool is_trap() const { return true; } - virtual JVMState* generate(JVMState* jvms); + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); }; @@ -1009,7 +1015,7 @@ CallGenerator::for_uncommon_trap(ciMethod* m, } -JVMState* UncommonTrapCallGenerator::generate(JVMState* jvms) { +JVMState* UncommonTrapCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { GraphKit kit(jvms); // Take the trap with arguments pushed on the stack. (Cf. null_check_receiver). int nargs = method()->arg_size(); diff --git a/hotspot/src/share/vm/opto/callGenerator.hpp b/hotspot/src/share/vm/opto/callGenerator.hpp index 956f227c32f..d03555fefdb 100644 --- a/hotspot/src/share/vm/opto/callGenerator.hpp +++ b/hotspot/src/share/vm/opto/callGenerator.hpp @@ -31,6 +31,8 @@ #include "opto/type.hpp" #include "runtime/deoptimization.hpp" +class Parse; + //---------------------------CallGenerator------------------------------------- // The subclasses of this class handle generation of ideal nodes for // call sites and method entry points. @@ -72,6 +74,7 @@ class CallGenerator : public ResourceObj { virtual bool is_late_inline() const { return false; } // same but for method handle calls virtual bool is_mh_late_inline() const { return false; } + virtual bool is_string_late_inline() const{ return false; } // for method handle calls: have we tried inlinining the call already? virtual bool already_attempted() const { ShouldNotReachHere(); return false; } @@ -108,7 +111,7 @@ class CallGenerator : public ResourceObj { // // If the result is NULL, it means that this CallGenerator was unable // to handle the given call, and another CallGenerator should be consulted. - virtual JVMState* generate(JVMState* jvms) = 0; + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) = 0; // How to generate a call site that is inlined: static CallGenerator* for_inline(ciMethod* m, float expected_uses = -1); diff --git a/hotspot/src/share/vm/opto/classes.hpp b/hotspot/src/share/vm/opto/classes.hpp index 3217c4fb492..002d2db636d 100644 --- a/hotspot/src/share/vm/opto/classes.hpp +++ b/hotspot/src/share/vm/opto/classes.hpp @@ -30,6 +30,7 @@ macro(AbsF) macro(AbsI) macro(AddD) macro(AddExactI) +macro(AddExactL) macro(AddF) macro(AddI) macro(AddL) @@ -170,6 +171,8 @@ macro(LoopLimit) macro(Mach) macro(MachProj) macro(MathExact) +macro(MathExactI) +macro(MathExactL) macro(MaxI) macro(MemBarAcquire) macro(MemBarAcquireLock) @@ -189,12 +192,16 @@ macro(MoveF2I) macro(MoveL2D) macro(MoveD2L) macro(MulD) +macro(MulExactI) +macro(MulExactL) macro(MulF) macro(MulHiL) macro(MulI) macro(MulL) macro(Multi) macro(NegD) +macro(NegExactI) +macro(NegExactL) macro(NegF) macro(NeverBranch) macro(Opaque1) @@ -244,6 +251,8 @@ macro(StrComp) macro(StrEquals) macro(StrIndexOf) macro(SubD) +macro(SubExactI) +macro(SubExactL) macro(SubF) macro(SubI) macro(SubL) diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index 19c6a97b24c..a896532f5d3 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -655,7 +655,8 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr _inlining_progress(false), _inlining_incrementally(false), _print_inlining_list(NULL), - _print_inlining_idx(0) { + _print_inlining_idx(0), + _preserve_jvm_state(0) { C = this; CompileWrapper cw(this); @@ -763,7 +764,7 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr return; } JVMState* jvms = build_start_state(start(), tf()); - if ((jvms = cg->generate(jvms)) == NULL) { + if ((jvms = cg->generate(jvms, NULL)) == NULL) { record_method_not_compilable("method parse failed"); return; } @@ -940,7 +941,8 @@ Compile::Compile( ciEnv* ci_env, _inlining_progress(false), _inlining_incrementally(false), _print_inlining_list(NULL), - _print_inlining_idx(0) { + _print_inlining_idx(0), + _preserve_jvm_state(0) { C = this; #ifndef PRODUCT @@ -1358,7 +1360,7 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const { // During the 2nd round of IterGVN, NotNull castings are removed. // Make sure the Bottom and NotNull variants alias the same. // Also, make sure exact and non-exact variants alias the same. - if( ptr == TypePtr::NotNull || ta->klass_is_exact() ) { + if (ptr == TypePtr::NotNull || ta->klass_is_exact() || ta->speculative() != NULL) { tj = ta = TypeAryPtr::make(TypePtr::BotPTR,ta->ary(),ta->klass(),false,offset); } } @@ -1383,6 +1385,9 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const { // Also, make sure exact and non-exact variants alias the same. tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset); } + if (to->speculative() != NULL) { + tj = to = TypeInstPtr::make(to->ptr(),to->klass(),to->klass_is_exact(),to->const_oop(),to->offset(), to->instance_id()); + } // Canonicalize the holder of this field if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) { // First handle header references such as a LoadKlassNode, even if the @@ -2011,6 +2016,12 @@ void Compile::Optimize() { if (failing()) return; } + // Remove the speculative part of types and clean up the graph from + // the extra CastPP nodes whose only purpose is to carry them. Do + // that early so that optimizations are not disrupted by the extra + // CastPP nodes. + remove_speculative_types(igvn); + // No more new expensive nodes will be added to the list from here // so keep only the actual candidates for optimizations. cleanup_expensive_nodes(igvn); @@ -3004,10 +3015,15 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { if (result != NULL) { for (DUIterator_Fast jmax, j = result->fast_outs(jmax); j < jmax; j++) { Node* out = result->fast_out(j); - if (out->in(0) == NULL) { - out->set_req(0, non_throwing); - } else if (out->in(0) == ctrl) { - out->set_req(0, non_throwing); + // Phi nodes shouldn't be moved. They would only match below if they + // had the same control as the MathExactNode. The only time that + // would happen is if the Phi is also an input to the MathExact + if (!out->is_Phi()) { + if (out->in(0) == NULL) { + out->set_req(0, non_throwing); + } else if (out->in(0) == ctrl) { + out->set_req(0, non_throwing); + } } } } @@ -3792,6 +3808,45 @@ void Compile::add_expensive_node(Node * n) { } } +/** + * Remove the speculative part of types and clean up the graph + */ +void Compile::remove_speculative_types(PhaseIterGVN &igvn) { + if (UseTypeSpeculation) { + Unique_Node_List worklist; + worklist.push(root()); + int modified = 0; + // Go over all type nodes that carry a speculative type, drop the + // speculative part of the type and enqueue the node for an igvn + // which may optimize it out. + for (uint next = 0; next < worklist.size(); ++next) { + Node *n = worklist.at(next); + if (n->is_Type() && n->as_Type()->type()->isa_oopptr() != NULL && + n->as_Type()->type()->is_oopptr()->speculative() != NULL) { + TypeNode* tn = n->as_Type(); + const TypeOopPtr* t = tn->type()->is_oopptr(); + bool in_hash = igvn.hash_delete(n); + assert(in_hash, "node should be in igvn hash table"); + tn->set_type(t->remove_speculative()); + igvn.hash_insert(n); + igvn._worklist.push(n); // give it a chance to go away + modified++; + } + uint max = n->len(); + for( uint i = 0; i < max; ++i ) { + Node *m = n->in(i); + if (not_a_node(m)) continue; + worklist.push(m); + } + } + // Drop the speculative part of all types in the igvn's type table + igvn.remove_speculative_types(); + if (modified > 0) { + igvn.optimize(); + } + } +} + // Auxiliary method to support randomized stressing/fuzzing. // // This method can be called the arbitrary number of times, with current count diff --git a/hotspot/src/share/vm/opto/compile.hpp b/hotspot/src/share/vm/opto/compile.hpp index 631372efabc..5eb340df651 100644 --- a/hotspot/src/share/vm/opto/compile.hpp +++ b/hotspot/src/share/vm/opto/compile.hpp @@ -424,6 +424,11 @@ class Compile : public Phase { static int cmp_expensive_nodes(Node** n1, Node** n2); // Expensive nodes list already sorted? bool expensive_nodes_sorted() const; + // Remove the speculative part of types and clean up the graph + void remove_speculative_types(PhaseIterGVN &igvn); + + // Are we within a PreserveJVMState block? + int _preserve_jvm_state; public: @@ -820,7 +825,9 @@ class Compile : public Phase { // Decide how to build a call. // The profile factor is a discount to apply to this site's interp. profile. - CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch, JVMState* jvms, bool allow_inline, float profile_factor, bool allow_intrinsics = true, bool delayed_forbidden = false); + CallGenerator* call_generator(ciMethod* call_method, int vtable_index, bool call_does_dispatch, + JVMState* jvms, bool allow_inline, float profile_factor, ciKlass* speculative_receiver_type = NULL, + bool allow_intrinsics = true, bool delayed_forbidden = false); bool should_delay_inlining(ciMethod* call_method, JVMState* jvms) { return should_delay_string_inlining(call_method, jvms) || should_delay_boxing_inlining(call_method, jvms); @@ -1156,6 +1163,21 @@ class Compile : public Phase { // Auxiliary method for randomized fuzzing/stressing static bool randomized_select(int count); + + // enter a PreserveJVMState block + void inc_preserve_jvm_state() { + _preserve_jvm_state++; + } + + // exit a PreserveJVMState block + void dec_preserve_jvm_state() { + _preserve_jvm_state--; + assert(_preserve_jvm_state >= 0, "_preserve_jvm_state shouldn't be negative"); + } + + bool has_preserve_jvm_state() const { + return _preserve_jvm_state > 0; + } }; #endif // SHARE_VM_OPTO_COMPILE_HPP diff --git a/hotspot/src/share/vm/opto/doCall.cpp b/hotspot/src/share/vm/opto/doCall.cpp index 9558d604068..6768968bebd 100644 --- a/hotspot/src/share/vm/opto/doCall.cpp +++ b/hotspot/src/share/vm/opto/doCall.cpp @@ -63,7 +63,8 @@ void trace_type_profile(Compile* C, ciMethod *method, int depth, int bci, ciMeth CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool call_does_dispatch, JVMState* jvms, bool allow_inline, - float prof_factor, bool allow_intrinsics, bool delayed_forbidden) { + float prof_factor, ciKlass* speculative_receiver_type, + bool allow_intrinsics, bool delayed_forbidden) { ciMethod* caller = jvms->method(); int bci = jvms->bci(); Bytecodes::Code bytecode = caller->java_code_at_bci(bci); @@ -117,7 +118,7 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool if (cg->is_predicted()) { // Code without intrinsic but, hopefully, inlined. CallGenerator* inline_cg = this->call_generator(callee, - vtable_index, call_does_dispatch, jvms, allow_inline, prof_factor, false); + vtable_index, call_does_dispatch, jvms, allow_inline, prof_factor, speculative_receiver_type, false); if (inline_cg != NULL) { cg = CallGenerator::for_predicted_intrinsic(cg, inline_cg); } @@ -212,8 +213,24 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool // The major receiver's count >= TypeProfileMajorReceiverPercent of site_count. bool have_major_receiver = (100.*profile.receiver_prob(0) >= (float)TypeProfileMajorReceiverPercent); ciMethod* receiver_method = NULL; - if (have_major_receiver || profile.morphism() == 1 || - (profile.morphism() == 2 && UseBimorphicInlining)) { + + int morphism = profile.morphism(); + if (speculative_receiver_type != NULL) { + // We have a speculative type, we should be able to resolve + // the call. We do that before looking at the profiling at + // this invoke because it may lead to bimorphic inlining which + // a speculative type should help us avoid. + receiver_method = callee->resolve_invoke(jvms->method()->holder(), + speculative_receiver_type); + if (receiver_method == NULL) { + speculative_receiver_type = NULL; + } else { + morphism = 1; + } + } + if (receiver_method == NULL && + (have_major_receiver || morphism == 1 || + (morphism == 2 && UseBimorphicInlining))) { // receiver_method = profile.method(); // Profiles do not suggest methods now. Look it up in the major receiver. receiver_method = callee->resolve_invoke(jvms->method()->holder(), @@ -227,7 +244,7 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool // Look up second receiver. CallGenerator* next_hit_cg = NULL; ciMethod* next_receiver_method = NULL; - if (profile.morphism() == 2 && UseBimorphicInlining) { + if (morphism == 2 && UseBimorphicInlining) { next_receiver_method = callee->resolve_invoke(jvms->method()->holder(), profile.receiver(1)); if (next_receiver_method != NULL) { @@ -242,11 +259,10 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool } } CallGenerator* miss_cg; - Deoptimization::DeoptReason reason = (profile.morphism() == 2) ? + Deoptimization::DeoptReason reason = morphism == 2 ? Deoptimization::Reason_bimorphic : Deoptimization::Reason_class_check; - if (( profile.morphism() == 1 || - (profile.morphism() == 2 && next_hit_cg != NULL) ) && + if ((morphism == 1 || (morphism == 2 && next_hit_cg != NULL)) && !too_many_traps(jvms->method(), jvms->bci(), reason) ) { // Generate uncommon trap for class check failure path @@ -260,6 +276,7 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool } if (miss_cg != NULL) { if (next_hit_cg != NULL) { + assert(speculative_receiver_type == NULL, "shouldn't end up here if we used speculation"); trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), next_receiver_method, profile.receiver(1), site_count, profile.receiver_count(1)); // We don't need to record dependency on a receiver here and below. // Whenever we inline, the dependency is added by Parse::Parse(). @@ -267,7 +284,9 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool } if (miss_cg != NULL) { trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), receiver_method, profile.receiver(0), site_count, receiver_count); - CallGenerator* cg = CallGenerator::for_predicted_call(profile.receiver(0), miss_cg, hit_cg, profile.receiver_prob(0)); + ciKlass* k = speculative_receiver_type != NULL ? speculative_receiver_type : profile.receiver(0); + float hit_prob = speculative_receiver_type != NULL ? 1.0 : profile.receiver_prob(0); + CallGenerator* cg = CallGenerator::for_predicted_call(k, miss_cg, hit_cg, hit_prob); if (cg != NULL) return cg; } } @@ -446,13 +465,16 @@ void Parse::do_call() { int vtable_index = Method::invalid_vtable_index; bool call_does_dispatch = false; + // Speculative type of the receiver if any + ciKlass* speculative_receiver_type = NULL; if (is_virtual_or_interface) { - Node* receiver_node = stack(sp() - nargs); + Node* receiver_node = stack(sp() - nargs); const TypeOopPtr* receiver_type = _gvn.type(receiver_node)->isa_oopptr(); // call_does_dispatch and vtable_index are out-parameters. They might be changed. callee = C->optimize_virtual_call(method(), bci(), klass, orig_callee, receiver_type, is_virtual, call_does_dispatch, vtable_index); // out-parameters + speculative_receiver_type = receiver_type != NULL ? receiver_type->speculative_type() : NULL; } // Note: It's OK to try to inline a virtual call. @@ -468,7 +490,7 @@ void Parse::do_call() { // Decide call tactic. // This call checks with CHA, the interpreter profile, intrinsics table, etc. // It decides whether inlining is desirable or not. - CallGenerator* cg = C->call_generator(callee, vtable_index, call_does_dispatch, jvms, try_inline, prof_factor()); + CallGenerator* cg = C->call_generator(callee, vtable_index, call_does_dispatch, jvms, try_inline, prof_factor(), speculative_receiver_type); // NOTE: Don't use orig_callee and callee after this point! Use cg->method() instead. orig_callee = callee = NULL; @@ -477,6 +499,10 @@ void Parse::do_call() { // Round double arguments before call round_double_arguments(cg->method()); + // Feed profiling data for arguments to the type system so it can + // propagate it as speculative types + record_profiled_arguments_for_speculation(cg->method(), bc()); + #ifndef PRODUCT // bump global counters for calls count_compiled_calls(/*at_method_entry*/ false, cg->is_inline()); @@ -491,11 +517,18 @@ void Parse::do_call() { // save across call, for a subsequent cast_not_null. Node* receiver = has_receiver ? argument(0) : NULL; + // The extra CheckCastPP for speculative types mess with PhaseStringOpts + if (receiver != NULL && !call_does_dispatch && !cg->is_string_late_inline()) { + // Feed profiling data for a single receiver to the type system so + // it can propagate it as a speculative type + receiver = record_profiled_receiver_for_speculation(receiver); + } + // Bump method data counters (We profile *before* the call is made // because exceptions don't return to the call site.) profile_call(receiver); - JVMState* new_jvms = cg->generate(jvms); + JVMState* new_jvms = cg->generate(jvms, this); if (new_jvms == NULL) { // When inlining attempt fails (e.g., too many arguments), // it may contaminate the current compile state, making it @@ -508,8 +541,8 @@ void Parse::do_call() { // the call site, perhaps because it did not match a pattern the // intrinsic was expecting to optimize. Should always be possible to // get a normal java call that may inline in that case - cg = C->call_generator(cg->method(), vtable_index, call_does_dispatch, jvms, try_inline, prof_factor(), /* allow_intrinsics= */ false); - if ((new_jvms = cg->generate(jvms)) == NULL) { + cg = C->call_generator(cg->method(), vtable_index, call_does_dispatch, jvms, try_inline, prof_factor(), speculative_receiver_type, /* allow_intrinsics= */ false); + if ((new_jvms = cg->generate(jvms, this)) == NULL) { guarantee(failing(), "call failed to generate: calls should work"); return; } @@ -607,6 +640,16 @@ void Parse::do_call() { null_assert(peek()); set_bci(iter().cur_bci()); // put it back } + BasicType ct = ctype->basic_type(); + if (ct == T_OBJECT || ct == T_ARRAY) { + ciKlass* better_type = method()->return_profiled_type(bci()); + if (UseTypeSpeculation && better_type != NULL) { + // If profiling reports a single type for the return value, + // feed it to the type system so it can propagate it as a + // speculative type + record_profile_for_speculation(stack(sp()-1), better_type); + } + } } // Restart record of parsing work after possible inlining of call diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index 7377053a7ab..8c5e05c3ac7 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -639,6 +639,7 @@ PreserveJVMState::PreserveJVMState(GraphKit* kit, bool clone_map) { _map = kit->map(); // preserve the map _sp = kit->sp(); kit->set_map(clone_map ? kit->clone_map() : NULL); + Compile::current()->inc_preserve_jvm_state(); #ifdef ASSERT _bci = kit->bci(); Parse* parser = kit->is_Parse(); @@ -656,6 +657,7 @@ PreserveJVMState::~PreserveJVMState() { #endif kit->set_map(_map); kit->set_sp(_sp); + Compile::current()->dec_preserve_jvm_state(); } @@ -1373,17 +1375,70 @@ Node* GraphKit::cast_not_null(Node* obj, bool do_replace_in_map) { //--------------------------replace_in_map------------------------------------- void GraphKit::replace_in_map(Node* old, Node* neww) { - this->map()->replace_edge(old, neww); + if (old == neww) { + return; + } + + map()->replace_edge(old, neww); // Note: This operation potentially replaces any edge // on the map. This includes locals, stack, and monitors // of the current (innermost) JVM state. - // We can consider replacing in caller maps. - // The idea would be that an inlined function's null checks - // can be shared with the entire inlining tree. - // The expense of doing this is that the PreserveJVMState class - // would have to preserve caller states too, with a deep copy. + if (!ReplaceInParentMaps) { + return; + } + + // PreserveJVMState doesn't do a deep copy so we can't modify + // parents + if (Compile::current()->has_preserve_jvm_state()) { + return; + } + + Parse* parser = is_Parse(); + bool progress = true; + Node* ctrl = map()->in(0); + // Follow the chain of parsers and see whether the update can be + // done in the map of callers. We can do the replace for a caller if + // the current control post dominates the control of a caller. + while (parser != NULL && parser->caller() != NULL && progress) { + progress = false; + Node* parent_map = parser->caller()->map(); + assert(parser->exits().map()->jvms()->depth() == parser->caller()->depth(), "map mismatch"); + + Node* parent_ctrl = parent_map->in(0); + + while (parent_ctrl->is_Region()) { + Node* n = parent_ctrl->as_Region()->is_copy(); + if (n == NULL) { + break; + } + parent_ctrl = n; + } + + for (;;) { + if (ctrl == parent_ctrl) { + // update the map of the exits which is the one that will be + // used when compilation resume after inlining + parser->exits().map()->replace_edge(old, neww); + progress = true; + break; + } + if (ctrl->is_Proj() && ctrl->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none)) { + ctrl = ctrl->in(0)->in(0); + } else if (ctrl->is_Region()) { + Node* n = ctrl->as_Region()->is_copy(); + if (n == NULL) { + break; + } + ctrl = n; + } else { + break; + } + } + + parser = parser->parent_parser(); + } } @@ -2043,6 +2098,104 @@ void GraphKit::round_double_arguments(ciMethod* dest_method) { } } +/** + * Record profiling data exact_kls for Node n with the type system so + * that it can propagate it (speculation) + * + * @param n node that the type applies to + * @param exact_kls type from profiling + * + * @return node with improved type + */ +Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls) { + const TypeOopPtr* current_type = _gvn.type(n)->isa_oopptr(); + assert(UseTypeSpeculation, "type speculation must be on"); + if (exact_kls != NULL && + // nothing to improve if type is already exact + (current_type == NULL || + (!current_type->klass_is_exact() && + (current_type->speculative() == NULL || + !current_type->speculative()->klass_is_exact())))) { + const TypeKlassPtr* tklass = TypeKlassPtr::make(exact_kls); + const TypeOopPtr* xtype = tklass->as_instance_type(); + assert(xtype->klass_is_exact(), "Should be exact"); + + // Build a type with a speculative type (what we think we know + // about the type but will need a guard when we use it) + const TypeOopPtr* spec_type = TypeOopPtr::make(TypePtr::BotPTR, Type::OffsetBot, TypeOopPtr::InstanceBot, xtype); + // We're changing the type, we need a new cast node to carry the + // new type. The new type depends on the control: what profiling + // tells us is only valid from here as far as we can tell. + Node* cast = new(C) CastPPNode(n, spec_type); + cast->init_req(0, control()); + cast = _gvn.transform(cast); + replace_in_map(n, cast); + n = cast; + } + return n; +} + +/** + * Record profiling data from receiver profiling at an invoke with the + * type system so that it can propagate it (speculation) + * + * @param n receiver node + * + * @return node with improved type + */ +Node* GraphKit::record_profiled_receiver_for_speculation(Node* n) { + if (!UseTypeSpeculation) { + return n; + } + ciKlass* exact_kls = profile_has_unique_klass(); + return record_profile_for_speculation(n, exact_kls); +} + +/** + * Record profiling data from argument profiling at an invoke with the + * type system so that it can propagate it (speculation) + * + * @param dest_method target method for the call + * @param bc what invoke bytecode is this? + */ +void GraphKit::record_profiled_arguments_for_speculation(ciMethod* dest_method, Bytecodes::Code bc) { + if (!UseTypeSpeculation) { + return; + } + const TypeFunc* tf = TypeFunc::make(dest_method); + int nargs = tf->_domain->_cnt - TypeFunc::Parms; + int skip = Bytecodes::has_receiver(bc) ? 1 : 0; + for (int j = skip, i = 0; j < nargs && i < TypeProfileArgsLimit; j++) { + const Type *targ = tf->_domain->field_at(j + TypeFunc::Parms); + if (targ->basic_type() == T_OBJECT || targ->basic_type() == T_ARRAY) { + ciKlass* better_type = method()->argument_profiled_type(bci(), i); + if (better_type != NULL) { + record_profile_for_speculation(argument(j), better_type); + } + i++; + } + } +} + +/** + * Record profiling data from parameter profiling at an invoke with + * the type system so that it can propagate it (speculation) + */ +void GraphKit::record_profiled_parameters_for_speculation() { + if (!UseTypeSpeculation) { + return; + } + for (int i = 0, j = 0; i < method()->arg_size() ; i++) { + if (_gvn.type(local(i))->isa_oopptr()) { + ciKlass* better_type = method()->parameter_profiled_type(j); + if (better_type != NULL) { + record_profile_for_speculation(local(i), better_type); + } + j++; + } + } +} + void GraphKit::round_double_result(ciMethod* dest_method) { // A non-strict method may return a double value which has an extended // exponent, but this must not be visible in a caller which is 'strict' @@ -2580,10 +2733,10 @@ bool GraphKit::seems_never_null(Node* obj, ciProfileData* data) { // If the profile has seen exactly one type, narrow to exactly that type. // Subsequent type checks will always fold up. Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj, - ciProfileData* data, - ciKlass* require_klass) { + ciKlass* require_klass, + ciKlass* spec_klass, + bool safe_for_replace) { if (!UseTypeProfile || !TypeProfileCasts) return NULL; - if (data == NULL) return NULL; // Make sure we haven't already deoptimized from this tactic. if (too_many_traps(Deoptimization::Reason_class_check)) @@ -2591,15 +2744,15 @@ Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj, // (No, this isn't a call, but it's enough like a virtual call // to use the same ciMethod accessor to get the profile info...) - ciCallProfile profile = method()->call_profile_at_bci(bci()); - if (profile.count() >= 0 && // no cast failures here - profile.has_receiver(0) && - profile.morphism() == 1) { - ciKlass* exact_kls = profile.receiver(0); + // If we have a speculative type use it instead of profiling (which + // may not help us) + ciKlass* exact_kls = spec_klass == NULL ? profile_has_unique_klass() : spec_klass; + if (exact_kls != NULL) {// no cast failures here if (require_klass == NULL || static_subtype_check(require_klass, exact_kls) == SSC_always_true) { - // If we narrow the type to match what the type profile sees, - // we can then remove the rest of the cast. + // If we narrow the type to match what the type profile sees or + // the speculative type, we can then remove the rest of the + // cast. // This is a win, even if the exact_kls is very specific, // because downstream operations, such as method calls, // will often benefit from the sharper type. @@ -2611,7 +2764,9 @@ Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj, uncommon_trap(Deoptimization::Reason_class_check, Deoptimization::Action_maybe_recompile); } - replace_in_map(not_null_obj, exact_obj); + if (safe_for_replace) { + replace_in_map(not_null_obj, exact_obj); + } return exact_obj; } // assert(ssc == SSC_always_true)... except maybe the profile lied to us. @@ -2620,11 +2775,59 @@ Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj, return NULL; } +/** + * Cast obj to type and emit guard unless we had too many traps here + * already + * + * @param obj node being casted + * @param type type to cast the node to + * @param not_null true if we know node cannot be null + */ +Node* GraphKit::maybe_cast_profiled_obj(Node* obj, + ciKlass* type, + bool not_null) { + // type == NULL if profiling tells us this object is always null + if (type != NULL) { + if (!too_many_traps(Deoptimization::Reason_null_check) && + !too_many_traps(Deoptimization::Reason_class_check)) { + Node* not_null_obj = NULL; + // not_null is true if we know the object is not null and + // there's no need for a null check + if (!not_null) { + Node* null_ctl = top(); + not_null_obj = null_check_oop(obj, &null_ctl, true, true); + assert(null_ctl->is_top(), "no null control here"); + } else { + not_null_obj = obj; + } + + Node* exact_obj = not_null_obj; + ciKlass* exact_kls = type; + Node* slow_ctl = type_check_receiver(exact_obj, exact_kls, 1.0, + &exact_obj); + { + PreserveJVMState pjvms(this); + set_control(slow_ctl); + uncommon_trap(Deoptimization::Reason_class_check, + Deoptimization::Action_maybe_recompile); + } + replace_in_map(not_null_obj, exact_obj); + obj = exact_obj; + } + } else { + if (!too_many_traps(Deoptimization::Reason_null_assert)) { + Node* exact_obj = null_assert(obj); + replace_in_map(obj, exact_obj); + obj = exact_obj; + } + } + return obj; +} //-------------------------------gen_instanceof-------------------------------- // Generate an instance-of idiom. Used by both the instance-of bytecode // and the reflective instance-of call. -Node* GraphKit::gen_instanceof(Node* obj, Node* superklass) { +Node* GraphKit::gen_instanceof(Node* obj, Node* superklass, bool safe_for_replace) { kill_dead_locals(); // Benefit all the uncommon traps assert( !stopped(), "dead parse path should be checked in callers" ); assert(!TypePtr::NULL_PTR->higher_equal(_gvn.type(superklass)->is_klassptr()), @@ -2637,10 +2840,8 @@ Node* GraphKit::gen_instanceof(Node* obj, Node* superklass) { C->set_has_split_ifs(true); // Has chance for split-if optimization ciProfileData* data = NULL; - bool safe_for_replace = false; if (java_bc() == Bytecodes::_instanceof) { // Only for the bytecode data = method()->method_data()->bci_to_data(bci()); - safe_for_replace = true; } bool never_see_null = (ProfileDynamicTypes // aggressive use of profile && seems_never_null(obj, data)); @@ -2664,14 +2865,37 @@ Node* GraphKit::gen_instanceof(Node* obj, Node* superklass) { phi ->del_req(_null_path); } - if (ProfileDynamicTypes && data != NULL) { - Node* cast_obj = maybe_cast_profiled_receiver(not_null_obj, data, NULL); - if (stopped()) { // Profile disagrees with this path. - set_control(null_ctl); // Null is the only remaining possibility. - return intcon(0); + // Do we know the type check always succeed? + bool known_statically = false; + if (_gvn.type(superklass)->singleton()) { + ciKlass* superk = _gvn.type(superklass)->is_klassptr()->klass(); + ciKlass* subk = _gvn.type(obj)->is_oopptr()->klass(); + if (subk != NULL && subk->is_loaded()) { + int static_res = static_subtype_check(superk, subk); + known_statically = (static_res == SSC_always_true || static_res == SSC_always_false); + } + } + + if (known_statically && UseTypeSpeculation) { + // If we know the type check always succeed then we don't use the + // profiling data at this bytecode. Don't lose it, feed it to the + // type system as a speculative type. + not_null_obj = record_profiled_receiver_for_speculation(not_null_obj); + } else { + const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr(); + // We may not have profiling here or it may not help us. If we + // have a speculative type use it to perform an exact cast. + ciKlass* spec_obj_type = obj_type->speculative_type(); + if (spec_obj_type != NULL || (ProfileDynamicTypes && data != NULL)) { + Node* cast_obj = maybe_cast_profiled_receiver(not_null_obj, NULL, spec_obj_type, safe_for_replace); + if (stopped()) { // Profile disagrees with this path. + set_control(null_ctl); // Null is the only remaining possibility. + return intcon(0); + } + if (cast_obj != NULL) { + not_null_obj = cast_obj; + } } - if (cast_obj != NULL) - not_null_obj = cast_obj; } // Load the object's klass @@ -2718,7 +2942,10 @@ Node* GraphKit::gen_checkcast(Node *obj, Node* superklass, if (objtp != NULL && objtp->klass() != NULL) { switch (static_subtype_check(tk->klass(), objtp->klass())) { case SSC_always_true: - return obj; + // If we know the type check always succeed then we don't use + // the profiling data at this bytecode. Don't lose it, feed it + // to the type system as a speculative type. + return record_profiled_receiver_for_speculation(obj); case SSC_always_false: // It needs a null check because a null will *pass* the cast check. // A non-null value will always produce an exception. @@ -2767,12 +2994,17 @@ Node* GraphKit::gen_checkcast(Node *obj, Node* superklass, } Node* cast_obj = NULL; - if (data != NULL && - // Counter has never been decremented (due to cast failure). - // ...This is a reasonable thing to expect. It is true of - // all casts inserted by javac to implement generic types. - data->as_CounterData()->count() >= 0) { - cast_obj = maybe_cast_profiled_receiver(not_null_obj, data, tk->klass()); + const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr(); + // We may not have profiling here or it may not help us. If we have + // a speculative type use it to perform an exact cast. + ciKlass* spec_obj_type = obj_type->speculative_type(); + if (spec_obj_type != NULL || + (data != NULL && + // Counter has never been decremented (due to cast failure). + // ...This is a reasonable thing to expect. It is true of + // all casts inserted by javac to implement generic types. + data->as_CounterData()->count() >= 0)) { + cast_obj = maybe_cast_profiled_receiver(not_null_obj, tk->klass(), spec_obj_type, safe_for_replace); if (cast_obj != NULL) { if (failure_control != NULL) // failure is now impossible (*failure_control) = top(); diff --git a/hotspot/src/share/vm/opto/graphKit.hpp b/hotspot/src/share/vm/opto/graphKit.hpp index f9c068d7c40..75e01784e4c 100644 --- a/hotspot/src/share/vm/opto/graphKit.hpp +++ b/hotspot/src/share/vm/opto/graphKit.hpp @@ -386,10 +386,33 @@ class GraphKit : public Phase { // Check the null_seen bit. bool seems_never_null(Node* obj, ciProfileData* data); + // Check for unique class for receiver at call + ciKlass* profile_has_unique_klass() { + ciCallProfile profile = method()->call_profile_at_bci(bci()); + if (profile.count() >= 0 && // no cast failures here + profile.has_receiver(0) && + profile.morphism() == 1) { + return profile.receiver(0); + } + return NULL; + } + + // record type from profiling with the type system + Node* record_profile_for_speculation(Node* n, ciKlass* exact_kls); + Node* record_profiled_receiver_for_speculation(Node* n); + void record_profiled_arguments_for_speculation(ciMethod* dest_method, Bytecodes::Code bc); + void record_profiled_parameters_for_speculation(); + // Use the type profile to narrow an object type. Node* maybe_cast_profiled_receiver(Node* not_null_obj, - ciProfileData* data, - ciKlass* require_klass); + ciKlass* require_klass, + ciKlass* spec, + bool safe_for_replace); + + // Cast obj to type and emit guard unless we had too many traps here already + Node* maybe_cast_profiled_obj(Node* obj, + ciKlass* type, + bool not_null = false); // Cast obj to not-null on this path Node* cast_not_null(Node* obj, bool do_replace_in_map = true); @@ -775,7 +798,7 @@ class GraphKit : public Phase { // Generate an instance-of idiom. Used by both the instance-of bytecode // and the reflective instance-of call. - Node* gen_instanceof( Node *subobj, Node* superkls ); + Node* gen_instanceof(Node *subobj, Node* superkls, bool safe_for_replace = false); // Generate a check-cast idiom. Used by both the check-cast bytecode // and the array-store bytecode diff --git a/hotspot/src/share/vm/opto/ifnode.cpp b/hotspot/src/share/vm/opto/ifnode.cpp index ee54c4fc40d..029a9f64adc 100644 --- a/hotspot/src/share/vm/opto/ifnode.cpp +++ b/hotspot/src/share/vm/opto/ifnode.cpp @@ -1019,7 +1019,7 @@ void IfNode::dominated_by( Node *prev_dom, PhaseIterGVN *igvn ) { // be skipped. For example, range check predicate has two checks // for lower and upper bounds. ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj(); - if (PhaseIdealLoop::is_uncommon_trap_proj(unc_proj, Deoptimization::Reason_predicate)) + if (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate)) prev_dom = idom; // Now walk the current IfNode's projections. diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 45b8f333799..df6c29f5766 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -63,7 +63,7 @@ class LibraryIntrinsic : public InlineCallGenerator { virtual bool is_virtual() const { return _is_virtual; } virtual bool is_predicted() const { return _is_predicted; } virtual bool does_virtual_dispatch() const { return _does_virtual_dispatch; } - virtual JVMState* generate(JVMState* jvms); + virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); virtual Node* generate_predicate(JVMState* jvms); vmIntrinsics::ID intrinsic_id() const { return _intrinsic_id; } }; @@ -203,8 +203,15 @@ class LibraryCallKit : public GraphKit { bool inline_math_native(vmIntrinsics::ID id); bool inline_trig(vmIntrinsics::ID id); bool inline_math(vmIntrinsics::ID id); - bool inline_math_mathExact(Node* math); - bool inline_math_addExact(); + void inline_math_mathExact(Node* math); + bool inline_math_addExactI(bool is_increment); + bool inline_math_addExactL(bool is_increment); + bool inline_math_multiplyExactI(); + bool inline_math_multiplyExactL(); + bool inline_math_negateExactI(); + bool inline_math_negateExactL(); + bool inline_math_subtractExactI(bool is_decrement); + bool inline_math_subtractExactL(bool is_decrement); bool inline_exp(); bool inline_pow(); void finish_pow_exp(Node* result, Node* x, Node* y, const TypeFunc* call_type, address funcAddr, const char* funcName); @@ -507,13 +514,33 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { if (!UseCRC32Intrinsics) return NULL; break; - case vmIntrinsics::_addExact: - if (!Matcher::match_rule_supported(Op_AddExactI)) { - return NULL; - } - if (!UseMathExactIntrinsics) { - return NULL; - } + case vmIntrinsics::_incrementExactI: + case vmIntrinsics::_addExactI: + if (!Matcher::match_rule_supported(Op_AddExactI) || !UseMathExactIntrinsics) return NULL; + break; + case vmIntrinsics::_incrementExactL: + case vmIntrinsics::_addExactL: + if (!Matcher::match_rule_supported(Op_AddExactL) || !UseMathExactIntrinsics) return NULL; + break; + case vmIntrinsics::_decrementExactI: + case vmIntrinsics::_subtractExactI: + if (!Matcher::match_rule_supported(Op_SubExactI) || !UseMathExactIntrinsics) return NULL; + break; + case vmIntrinsics::_decrementExactL: + case vmIntrinsics::_subtractExactL: + if (!Matcher::match_rule_supported(Op_SubExactL) || !UseMathExactIntrinsics) return NULL; + break; + case vmIntrinsics::_negateExactI: + if (!Matcher::match_rule_supported(Op_NegExactI) || !UseMathExactIntrinsics) return NULL; + break; + case vmIntrinsics::_negateExactL: + if (!Matcher::match_rule_supported(Op_NegExactL) || !UseMathExactIntrinsics) return NULL; + break; + case vmIntrinsics::_multiplyExactI: + if (!Matcher::match_rule_supported(Op_MulExactI) || !UseMathExactIntrinsics) return NULL; + break; + case vmIntrinsics::_multiplyExactL: + if (!Matcher::match_rule_supported(Op_MulExactL) || !UseMathExactIntrinsics) return NULL; break; default: @@ -556,7 +583,7 @@ void Compile::register_library_intrinsics() { // Nothing to do here. } -JVMState* LibraryIntrinsic::generate(JVMState* jvms) { +JVMState* LibraryIntrinsic::generate(JVMState* jvms, Parse* parent_parser) { LibraryCallKit kit(jvms, this); Compile* C = kit.C; int nodes = C->unique(); @@ -686,7 +713,18 @@ bool LibraryCallKit::try_to_inline() { case vmIntrinsics::_min: case vmIntrinsics::_max: return inline_min_max(intrinsic_id()); - case vmIntrinsics::_addExact: return inline_math_addExact(); + case vmIntrinsics::_addExactI: return inline_math_addExactI(false /* add */); + case vmIntrinsics::_addExactL: return inline_math_addExactL(false /* add */); + case vmIntrinsics::_decrementExactI: return inline_math_subtractExactI(true /* decrement */); + case vmIntrinsics::_decrementExactL: return inline_math_subtractExactL(true /* decrement */); + case vmIntrinsics::_incrementExactI: return inline_math_addExactI(true /* increment */); + case vmIntrinsics::_incrementExactL: return inline_math_addExactL(true /* increment */); + case vmIntrinsics::_multiplyExactI: return inline_math_multiplyExactI(); + case vmIntrinsics::_multiplyExactL: return inline_math_multiplyExactL(); + case vmIntrinsics::_negateExactI: return inline_math_negateExactI(); + case vmIntrinsics::_negateExactL: return inline_math_negateExactL(); + case vmIntrinsics::_subtractExactI: return inline_math_subtractExactI(false /* subtract */); + case vmIntrinsics::_subtractExactL: return inline_math_subtractExactL(false /* subtract */); case vmIntrinsics::_arraycopy: return inline_arraycopy(); @@ -1931,7 +1969,14 @@ bool LibraryCallKit::inline_min_max(vmIntrinsics::ID id) { return true; } -bool LibraryCallKit::inline_math_mathExact(Node* math) { +void LibraryCallKit::inline_math_mathExact(Node* math) { + // If we didn't get the expected opcode it means we have optimized + // the node to something else and don't need the exception edge. + if (!math->is_MathExact()) { + set_result(math); + return; + } + Node* result = _gvn.transform( new(C) ProjNode(math, MathExactNode::result_proj_node)); Node* flags = _gvn.transform( new(C) FlagsProjNode(math, MathExactNode::flags_proj_node)); @@ -1954,19 +1999,106 @@ bool LibraryCallKit::inline_math_mathExact(Node* math) { set_control(fast_path); set_result(result); +} + +bool LibraryCallKit::inline_math_addExactI(bool is_increment) { + Node* arg1 = argument(0); + Node* arg2 = NULL; + + if (is_increment) { + arg2 = intcon(1); + } else { + arg2 = argument(1); + } + + Node* add = _gvn.transform( new(C) AddExactINode(NULL, arg1, arg2) ); + inline_math_mathExact(add); return true; } -bool LibraryCallKit::inline_math_addExact() { +bool LibraryCallKit::inline_math_addExactL(bool is_increment) { + Node* arg1 = argument(0); // type long + // argument(1) == TOP + Node* arg2 = NULL; + + if (is_increment) { + arg2 = longcon(1); + } else { + arg2 = argument(2); // type long + // argument(3) == TOP + } + + Node* add = _gvn.transform(new(C) AddExactLNode(NULL, arg1, arg2)); + inline_math_mathExact(add); + return true; +} + +bool LibraryCallKit::inline_math_subtractExactI(bool is_decrement) { + Node* arg1 = argument(0); + Node* arg2 = NULL; + + if (is_decrement) { + arg2 = intcon(1); + } else { + arg2 = argument(1); + } + + Node* sub = _gvn.transform(new(C) SubExactINode(NULL, arg1, arg2)); + inline_math_mathExact(sub); + return true; +} + +bool LibraryCallKit::inline_math_subtractExactL(bool is_decrement) { + Node* arg1 = argument(0); // type long + // argument(1) == TOP + Node* arg2 = NULL; + + if (is_decrement) { + arg2 = longcon(1); + } else { + arg2 = argument(2); // type long + // argument(3) == TOP + } + + Node* sub = _gvn.transform(new(C) SubExactLNode(NULL, arg1, arg2)); + inline_math_mathExact(sub); + return true; +} + +bool LibraryCallKit::inline_math_negateExactI() { + Node* arg1 = argument(0); + + Node* neg = _gvn.transform(new(C) NegExactINode(NULL, arg1)); + inline_math_mathExact(neg); + return true; +} + +bool LibraryCallKit::inline_math_negateExactL() { + Node* arg1 = argument(0); + // argument(1) == TOP + + Node* neg = _gvn.transform(new(C) NegExactLNode(NULL, arg1)); + inline_math_mathExact(neg); + return true; +} + +bool LibraryCallKit::inline_math_multiplyExactI() { Node* arg1 = argument(0); Node* arg2 = argument(1); - Node* add = _gvn.transform( new(C) AddExactINode(NULL, arg1, arg2) ); - if (add->Opcode() == Op_AddExactI) { - return inline_math_mathExact(add); - } else { - set_result(add); - } + Node* mul = _gvn.transform(new(C) MulExactINode(NULL, arg1, arg2)); + inline_math_mathExact(mul); + return true; +} + +bool LibraryCallKit::inline_math_multiplyExactL() { + Node* arg1 = argument(0); + // argument(1) == TOP + Node* arg2 = argument(2); + // argument(3) == TOP + + Node* mul = _gvn.transform(new(C) MulExactLNode(NULL, arg1, arg2)); + inline_math_mathExact(mul); return true; } @@ -3353,6 +3485,7 @@ bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { // If kls is null, we have a primitive mirror. phi->init_req(_prim_path, prim_return_value); if (stopped()) { set_result(region, phi); return true; } + bool safe_for_replace = (region->in(_prim_path) == top()); Node* p; // handy temp Node* null_ctl; @@ -3363,7 +3496,7 @@ bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { switch (id) { case vmIntrinsics::_isInstance: // nothing is an instance of a primitive type - query_value = gen_instanceof(obj, kls); + query_value = gen_instanceof(obj, kls, safe_for_replace); break; case vmIntrinsics::_getModifiers: @@ -4553,8 +4686,62 @@ bool LibraryCallKit::inline_arraycopy() { const Type* dest_type = dest->Value(&_gvn); const TypeAryPtr* top_src = src_type->isa_aryptr(); const TypeAryPtr* top_dest = dest_type->isa_aryptr(); - if (top_src == NULL || top_src->klass() == NULL || - top_dest == NULL || top_dest->klass() == NULL) { + + // Do we have the type of src? + bool has_src = (top_src != NULL && top_src->klass() != NULL); + // Do we have the type of dest? + bool has_dest = (top_dest != NULL && top_dest->klass() != NULL); + // Is the type for src from speculation? + bool src_spec = false; + // Is the type for dest from speculation? + bool dest_spec = false; + + if (!has_src || !has_dest) { + // We don't have sufficient type information, let's see if + // speculative types can help. We need to have types for both src + // and dest so that it pays off. + + // Do we already have or could we have type information for src + bool could_have_src = has_src; + // Do we already have or could we have type information for dest + bool could_have_dest = has_dest; + + ciKlass* src_k = NULL; + if (!has_src) { + src_k = src_type->speculative_type(); + if (src_k != NULL && src_k->is_array_klass()) { + could_have_src = true; + } + } + + ciKlass* dest_k = NULL; + if (!has_dest) { + dest_k = dest_type->speculative_type(); + if (dest_k != NULL && dest_k->is_array_klass()) { + could_have_dest = true; + } + } + + if (could_have_src && could_have_dest) { + // This is going to pay off so emit the required guards + if (!has_src) { + src = maybe_cast_profiled_obj(src, src_k); + src_type = _gvn.type(src); + top_src = src_type->isa_aryptr(); + has_src = (top_src != NULL && top_src->klass() != NULL); + src_spec = true; + } + if (!has_dest) { + dest = maybe_cast_profiled_obj(dest, dest_k); + dest_type = _gvn.type(dest); + top_dest = dest_type->isa_aryptr(); + has_dest = (top_dest != NULL && top_dest->klass() != NULL); + dest_spec = true; + } + } + } + + if (!has_src || !has_dest) { // Conservatively insert a memory barrier on all memory slices. // Do not let writes into the source float below the arraycopy. insert_mem_bar(Op_MemBarCPUOrder); @@ -4589,6 +4776,40 @@ bool LibraryCallKit::inline_arraycopy() { return true; } + if (src_elem == T_OBJECT) { + // If both arrays are object arrays then having the exact types + // for both will remove the need for a subtype check at runtime + // before the call and may make it possible to pick a faster copy + // routine (without a subtype check on every element) + // Do we have the exact type of src? + bool could_have_src = src_spec; + // Do we have the exact type of dest? + bool could_have_dest = dest_spec; + ciKlass* src_k = top_src->klass(); + ciKlass* dest_k = top_dest->klass(); + if (!src_spec) { + src_k = src_type->speculative_type(); + if (src_k != NULL && src_k->is_array_klass()) { + could_have_src = true; + } + } + if (!dest_spec) { + dest_k = dest_type->speculative_type(); + if (dest_k != NULL && dest_k->is_array_klass()) { + could_have_dest = true; + } + } + if (could_have_src && could_have_dest) { + // If we can have both exact types, emit the missing guards + if (could_have_src && !src_spec) { + src = maybe_cast_profiled_obj(src, src_k); + } + if (could_have_dest && !dest_spec) { + dest = maybe_cast_profiled_obj(dest, dest_k); + } + } + } + //--------------------------------------------------------------------------- // We will make a fast path for this call to arraycopy. diff --git a/hotspot/src/share/vm/opto/loopPredicate.cpp b/hotspot/src/share/vm/opto/loopPredicate.cpp index f29d9daab55..411226acffa 100644 --- a/hotspot/src/share/vm/opto/loopPredicate.cpp +++ b/hotspot/src/share/vm/opto/loopPredicate.cpp @@ -41,63 +41,6 @@ * checks (such as null checks). */ -//-------------------------------is_uncommon_trap_proj---------------------------- -// Return true if proj is the form of "proj->[region->..]call_uct" -bool PhaseIdealLoop::is_uncommon_trap_proj(ProjNode* proj, Deoptimization::DeoptReason reason) { - int path_limit = 10; - assert(proj, "invalid argument"); - Node* out = proj; - for (int ct = 0; ct < path_limit; ct++) { - out = out->unique_ctrl_out(); - if (out == NULL) - return false; - if (out->is_CallStaticJava()) { - int req = out->as_CallStaticJava()->uncommon_trap_request(); - if (req != 0) { - Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req); - if (trap_reason == reason || reason == Deoptimization::Reason_none) { - return true; - } - } - return false; // don't do further after call - } - if (out->Opcode() != Op_Region) - return false; - } - return false; -} - -//-------------------------------is_uncommon_trap_if_pattern------------------------- -// Return true for "if(test)-> proj -> ... -// | -// V -// other_proj->[region->..]call_uct" -// -// "must_reason_predicate" means the uct reason must be Reason_predicate -bool PhaseIdealLoop::is_uncommon_trap_if_pattern(ProjNode *proj, Deoptimization::DeoptReason reason) { - Node *in0 = proj->in(0); - if (!in0->is_If()) return false; - // Variation of a dead If node. - if (in0->outcnt() < 2) return false; - IfNode* iff = in0->as_If(); - - // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate - if (reason != Deoptimization::Reason_none) { - if (iff->in(1)->Opcode() != Op_Conv2B || - iff->in(1)->in(1)->Opcode() != Op_Opaque1) { - return false; - } - } - - ProjNode* other_proj = iff->proj_out(1-proj->_con)->as_Proj(); - if (is_uncommon_trap_proj(other_proj, reason)) { - assert(reason == Deoptimization::Reason_none || - Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list"); - return true; - } - return false; -} - //-------------------------------register_control------------------------- void PhaseIdealLoop::register_control(Node* n, IdealLoopTree *loop, Node* pred) { assert(n->is_CFG(), "must be control node"); @@ -147,7 +90,7 @@ void PhaseIdealLoop::register_control(Node* n, IdealLoopTree *loop, Node* pred) // This code is also used to clone predicates to clonned loops. ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry, Deoptimization::DeoptReason reason) { - assert(is_uncommon_trap_if_pattern(cont_proj, reason), "must be a uct if pattern!"); + assert(cont_proj->is_uncommon_trap_if_pattern(reason), "must be a uct if pattern!"); IfNode* iff = cont_proj->in(0)->as_If(); ProjNode *uncommon_proj = iff->proj_out(1 - cont_proj->_con); @@ -235,7 +178,7 @@ ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj, Node* ProjNode* PhaseIterGVN::create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry, Deoptimization::DeoptReason reason) { assert(new_entry != 0, "only used for clone predicate"); - assert(PhaseIdealLoop::is_uncommon_trap_if_pattern(cont_proj, reason), "must be a uct if pattern!"); + assert(cont_proj->is_uncommon_trap_if_pattern(reason), "must be a uct if pattern!"); IfNode* iff = cont_proj->in(0)->as_If(); ProjNode *uncommon_proj = iff->proj_out(1 - cont_proj->_con); @@ -422,7 +365,7 @@ Node* PhaseIdealLoop::skip_loop_predicates(Node* entry) { ProjNode* PhaseIdealLoop::find_predicate_insertion_point(Node* start_c, Deoptimization::DeoptReason reason) { if (start_c == NULL || !start_c->is_Proj()) return NULL; - if (is_uncommon_trap_if_pattern(start_c->as_Proj(), reason)) { + if (start_c->as_Proj()->is_uncommon_trap_if_pattern(reason)) { return start_c->as_Proj(); } return NULL; @@ -773,7 +716,7 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) { ProjNode* proj = if_proj_list.pop()->as_Proj(); IfNode* iff = proj->in(0)->as_If(); - if (!is_uncommon_trap_if_pattern(proj, Deoptimization::Reason_none)) { + if (!proj->is_uncommon_trap_if_pattern(Deoptimization::Reason_none)) { if (loop->is_loop_exit(iff)) { // stop processing the remaining projs in the list because the execution of them // depends on the condition of "iff" (iff->in(1)). diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp index 41c0a9d416d..55a533bc38a 100644 --- a/hotspot/src/share/vm/opto/loopTransform.cpp +++ b/hotspot/src/share/vm/opto/loopTransform.cpp @@ -713,6 +713,10 @@ bool IdealLoopTree::policy_unroll( PhaseIdealLoop *phase ) const { case Op_ModL: body_size += 30; break; case Op_DivL: body_size += 30; break; case Op_MulL: body_size += 10; break; + case Op_FlagsProj: + // Can't handle unrolling of loops containing + // nodes that generate a FlagsProj at the moment + return false; case Op_StrComp: case Op_StrEquals: case Op_StrIndexOf: diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp index ab05d186ba4..719a1fb34f1 100644 --- a/hotspot/src/share/vm/opto/loopnode.cpp +++ b/hotspot/src/share/vm/opto/loopnode.cpp @@ -167,7 +167,7 @@ Node *PhaseIdealLoop::get_early_ctrl_for_expensive(Node *n, Node* earliest) { // expensive nodes will notice the loop and skip over it to try to // move the node further up. if (ctl->is_CountedLoop() && ctl->in(1) != NULL && ctl->in(1)->in(0) != NULL && ctl->in(1)->in(0)->is_If()) { - if (!is_uncommon_trap_if_pattern(ctl->in(1)->as_Proj(), Deoptimization::Reason_none)) { + if (!ctl->in(1)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none)) { break; } next = idom(ctl->in(1)->in(0)); @@ -181,7 +181,7 @@ Node *PhaseIdealLoop::get_early_ctrl_for_expensive(Node *n, Node* earliest) { } else if (parent_ctl->is_CountedLoopEnd() && parent_ctl->as_CountedLoopEnd()->loopnode() != NULL) { next = parent_ctl->as_CountedLoopEnd()->loopnode()->init_control(); } else if (parent_ctl->is_If()) { - if (!is_uncommon_trap_if_pattern(ctl->as_Proj(), Deoptimization::Reason_none)) { + if (!ctl->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none)) { break; } assert(idom(ctl) == parent_ctl, "strange"); diff --git a/hotspot/src/share/vm/opto/loopnode.hpp b/hotspot/src/share/vm/opto/loopnode.hpp index df3eb4c0520..6d4933893bb 100644 --- a/hotspot/src/share/vm/opto/loopnode.hpp +++ b/hotspot/src/share/vm/opto/loopnode.hpp @@ -876,13 +876,6 @@ public: // Return true if exp is a scaled induction var plus (or minus) constant bool is_scaled_iv_plus_offset(Node* exp, Node* iv, int* p_scale, Node** p_offset, int depth = 0); - // Return true if proj is for "proj->[region->..]call_uct" - static bool is_uncommon_trap_proj(ProjNode* proj, Deoptimization::DeoptReason reason); - // Return true for "if(test)-> proj -> ... - // | - // V - // other_proj->[region->..]call_uct" - static bool is_uncommon_trap_if_pattern(ProjNode* proj, Deoptimization::DeoptReason reason); // Create a new if above the uncommon_trap_if_pattern for the predicate to be promoted ProjNode* create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry, Deoptimization::DeoptReason reason); diff --git a/hotspot/src/share/vm/opto/loopopts.cpp b/hotspot/src/share/vm/opto/loopopts.cpp index 9ee7ec7db9a..6529d1919ab 100644 --- a/hotspot/src/share/vm/opto/loopopts.cpp +++ b/hotspot/src/share/vm/opto/loopopts.cpp @@ -238,7 +238,7 @@ void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff, bool flip, bool exc ProjNode* dp_proj = dp->as_Proj(); ProjNode* unc_proj = iff->as_If()->proj_out(1 - dp_proj->_con)->as_Proj(); if (exclude_loop_predicate && - is_uncommon_trap_proj(unc_proj, Deoptimization::Reason_predicate)) + unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate)) return; // Let IGVN transformation change control dependence. IdealLoopTree *old_loop = get_loop(dp); diff --git a/hotspot/src/share/vm/opto/matcher.hpp b/hotspot/src/share/vm/opto/matcher.hpp index 23ad64d2b83..1131d09f1d5 100644 --- a/hotspot/src/share/vm/opto/matcher.hpp +++ b/hotspot/src/share/vm/opto/matcher.hpp @@ -338,6 +338,7 @@ public: static RegMask modL_proj_mask(); static const RegMask mathExactI_result_proj_mask(); + static const RegMask mathExactL_result_proj_mask(); static const RegMask mathExactI_flags_proj_mask(); // Use hardware DIV instruction when it is faster than diff --git a/hotspot/src/share/vm/opto/mathexactnode.cpp b/hotspot/src/share/vm/opto/mathexactnode.cpp index 7e68daf8ca5..bb930b37d52 100644 --- a/hotspot/src/share/vm/opto/mathexactnode.cpp +++ b/hotspot/src/share/vm/opto/mathexactnode.cpp @@ -31,10 +31,17 @@ #include "opto/mathexactnode.hpp" #include "opto/subnode.hpp" -MathExactNode::MathExactNode(Node* ctrl, Node* n1, Node* n2) : MultiNode(3) { +MathExactNode::MathExactNode(Node* ctrl, Node* in1) : MultiNode(2) { + init_class_id(Class_MathExact); init_req(0, ctrl); - init_req(1, n1); - init_req(2, n2); + init_req(1, in1); +} + +MathExactNode::MathExactNode(Node* ctrl, Node* in1, Node* in2) : MultiNode(3) { + init_class_id(Class_MathExact); + init_req(0, ctrl); + init_req(1, in1); + init_req(2, in2); } BoolNode* MathExactNode::bool_node() const { @@ -64,23 +71,10 @@ Node* MathExactNode::non_throwing_branch() const { return ifnode->proj_out(1); } -Node* AddExactINode::match(const ProjNode* proj, const Matcher* m) { - uint ideal_reg = proj->ideal_reg(); - RegMask rm; - if (proj->_con == result_proj_node) { - rm = m->mathExactI_result_proj_mask(); - } else { - assert(proj->_con == flags_proj_node, "must be result or flags"); - assert(ideal_reg == Op_RegFlags, "sanity"); - rm = m->mathExactI_flags_proj_mask(); - } - return new (m->C) MachProjNode(this, proj->_con, rm, ideal_reg); -} - // If the MathExactNode won't overflow we have to replace the // FlagsProjNode and ProjNode that is generated by the MathExactNode -Node* MathExactNode::no_overflow(PhaseGVN *phase, Node* new_result) { - PhaseIterGVN *igvn = phase->is_IterGVN(); +Node* MathExactNode::no_overflow(PhaseGVN* phase, Node* new_result) { + PhaseIterGVN* igvn = phase->is_IterGVN(); if (igvn) { ProjNode* result = result_node(); ProjNode* flags = flags_node(); @@ -110,9 +104,35 @@ Node* MathExactNode::no_overflow(PhaseGVN *phase, Node* new_result) { return new_result; } -Node *AddExactINode::Ideal(PhaseGVN *phase, bool can_reshape) { - Node *arg1 = in(1); - Node *arg2 = in(2); +Node* MathExactINode::match(const ProjNode* proj, const Matcher* m) { + uint ideal_reg = proj->ideal_reg(); + RegMask rm; + if (proj->_con == result_proj_node) { + rm = m->mathExactI_result_proj_mask(); + } else { + assert(proj->_con == flags_proj_node, "must be result or flags"); + assert(ideal_reg == Op_RegFlags, "sanity"); + rm = m->mathExactI_flags_proj_mask(); + } + return new (m->C) MachProjNode(this, proj->_con, rm, ideal_reg); +} + +Node* MathExactLNode::match(const ProjNode* proj, const Matcher* m) { + uint ideal_reg = proj->ideal_reg(); + RegMask rm; + if (proj->_con == result_proj_node) { + rm = m->mathExactL_result_proj_mask(); + } else { + assert(proj->_con == flags_proj_node, "must be result or flags"); + assert(ideal_reg == Op_RegFlags, "sanity"); + rm = m->mathExactI_flags_proj_mask(); + } + return new (m->C) MachProjNode(this, proj->_con, rm, ideal_reg); +} + +Node* AddExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { + Node* arg1 = in(1); + Node* arg2 = in(2); const Type* type1 = phase->type(arg1); const Type* type2 = phase->type(arg2); @@ -130,12 +150,7 @@ Node *AddExactINode::Ideal(PhaseGVN *phase, bool can_reshape) { return NULL; } - if (type1 == TypeInt::ZERO) { // (Add 0 x) == x - Node* add_result = new (phase->C) AddINode(arg1, arg2); - return no_overflow(phase, add_result); - } - - if (type2 == TypeInt::ZERO) { // (Add x 0) == x + if (type1 == TypeInt::ZERO || type2 == TypeInt::ZERO) { // (Add 0 x) == x Node* add_result = new (phase->C) AddINode(arg1, arg2); return no_overflow(phase, add_result); } @@ -169,3 +184,247 @@ Node *AddExactINode::Ideal(PhaseGVN *phase, bool can_reshape) { return NULL; } +Node* AddExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { + Node* arg1 = in(1); + Node* arg2 = in(2); + + const Type* type1 = phase->type(arg1); + const Type* type2 = phase->type(arg2); + + if (type1 != Type::TOP && type1->singleton() && + type2 != Type::TOP && type2->singleton()) { + jlong val1 = arg1->get_long(); + jlong val2 = arg2->get_long(); + jlong result = val1 + val2; + // Hacker's Delight 2-12 Overflow if both arguments have the opposite sign of the result + if ( (((val1 ^ result) & (val2 ^ result)) >= 0)) { + Node* con_result = ConLNode::make(phase->C, result); + return no_overflow(phase, con_result); + } + return NULL; + } + + if (type1 == TypeLong::ZERO || type2 == TypeLong::ZERO) { // (Add 0 x) == x + Node* add_result = new (phase->C) AddLNode(arg1, arg2); + return no_overflow(phase, add_result); + } + + if (type2->singleton()) { + return NULL; // no change - keep constant on the right + } + + if (type1->singleton()) { + // Make it x + Constant - move constant to the right + swap_edges(1, 2); + return this; + } + + if (arg2->is_Load()) { + return NULL; // no change - keep load on the right + } + + if (arg1->is_Load()) { + // Make it x + Load - move load to the right + swap_edges(1, 2); + return this; + } + + if (arg1->_idx > arg2->_idx) { + // Sort the edges + swap_edges(1, 2); + return this; + } + + return NULL; +} + +Node* SubExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { + Node* arg1 = in(1); + Node* arg2 = in(2); + + const Type* type1 = phase->type(arg1); + const Type* type2 = phase->type(arg2); + + if (type1 != Type::TOP && type1->singleton() && + type2 != Type::TOP && type2->singleton()) { + jint val1 = arg1->get_int(); + jint val2 = arg2->get_int(); + jint result = val1 - val2; + + // Hacker's Delight 2-12 Overflow iff the arguments have different signs and + // the sign of the result is different than the sign of arg1 + if (((val1 ^ val2) & (val1 ^ result)) >= 0) { + Node* con_result = ConINode::make(phase->C, result); + return no_overflow(phase, con_result); + } + return NULL; + } + + if (type1 == TypeInt::ZERO || type2 == TypeInt::ZERO) { + // Sub with zero is the same as add with zero + Node* add_result = new (phase->C) AddINode(arg1, arg2); + return no_overflow(phase, add_result); + } + + return NULL; +} + +Node* SubExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { + Node* arg1 = in(1); + Node* arg2 = in(2); + + const Type* type1 = phase->type(arg1); + const Type* type2 = phase->type(arg2); + + if (type1 != Type::TOP && type1->singleton() && + type2 != Type::TOP && type2->singleton()) { + jlong val1 = arg1->get_long(); + jlong val2 = arg2->get_long(); + jlong result = val1 - val2; + + // Hacker's Delight 2-12 Overflow iff the arguments have different signs and + // the sign of the result is different than the sign of arg1 + if (((val1 ^ val2) & (val1 ^ result)) >= 0) { + Node* con_result = ConLNode::make(phase->C, result); + return no_overflow(phase, con_result); + } + return NULL; + } + + if (type1 == TypeLong::ZERO || type2 == TypeLong::ZERO) { + // Sub with zero is the same as add with zero + Node* add_result = new (phase->C) AddLNode(arg1, arg2); + return no_overflow(phase, add_result); + } + + return NULL; +} + +Node* NegExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { + Node *arg = in(1); + + const Type* type = phase->type(arg); + if (type != Type::TOP && type->singleton()) { + jint value = arg->get_int(); + if (value != min_jint) { + Node* neg_result = ConINode::make(phase->C, -value); + return no_overflow(phase, neg_result); + } + } + return NULL; +} + +Node* NegExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { + Node *arg = in(1); + + const Type* type = phase->type(arg); + if (type != Type::TOP && type->singleton()) { + jlong value = arg->get_long(); + if (value != min_jlong) { + Node* neg_result = ConLNode::make(phase->C, -value); + return no_overflow(phase, neg_result); + } + } + return NULL; +} + +Node* MulExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { + Node* arg1 = in(1); + Node* arg2 = in(2); + + const Type* type1 = phase->type(arg1); + const Type* type2 = phase->type(arg2); + + if (type1 != Type::TOP && type1->singleton() && + type2 != Type::TOP && type2->singleton()) { + jint val1 = arg1->get_int(); + jint val2 = arg2->get_int(); + jlong result = (jlong) val1 * (jlong) val2; + if ((jint) result == result) { + // no overflow + Node* mul_result = ConINode::make(phase->C, result); + return no_overflow(phase, mul_result); + } + } + + if (type1 == TypeInt::ZERO || type2 == TypeInt::ZERO) { + return no_overflow(phase, ConINode::make(phase->C, 0)); + } + + if (type1 == TypeInt::ONE) { + Node* mul_result = new (phase->C) AddINode(arg2, phase->intcon(0)); + return no_overflow(phase, mul_result); + } + if (type2 == TypeInt::ONE) { + Node* mul_result = new (phase->C) AddINode(arg1, phase->intcon(0)); + return no_overflow(phase, mul_result); + } + + if (type1 == TypeInt::MINUS_1) { + return new (phase->C) NegExactINode(NULL, arg2); + } + + if (type2 == TypeInt::MINUS_1) { + return new (phase->C) NegExactINode(NULL, arg1); + } + + return NULL; +} + +Node* MulExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { + Node* arg1 = in(1); + Node* arg2 = in(2); + + const Type* type1 = phase->type(arg1); + const Type* type2 = phase->type(arg2); + + if (type1 != Type::TOP && type1->singleton() && + type2 != Type::TOP && type2->singleton()) { + jlong val1 = arg1->get_long(); + jlong val2 = arg2->get_long(); + + jlong result = val1 * val2; + jlong ax = (val1 < 0 ? -val1 : val1); + jlong ay = (val2 < 0 ? -val2 : val2); + + bool overflow = false; + if ((ax | ay) & CONST64(0xFFFFFFFF00000000)) { + // potential overflow if any bit in upper 32 bits are set + if ((val1 == min_jlong && val2 == -1) || (val2 == min_jlong && val1 == -1)) { + // -1 * Long.MIN_VALUE will overflow + overflow = true; + } else if (val2 != 0 && (result / val2 != val1)) { + overflow = true; + } + } + + if (!overflow) { + Node* mul_result = ConLNode::make(phase->C, result); + return no_overflow(phase, mul_result); + } + } + + if (type1 == TypeLong::ZERO || type2 == TypeLong::ZERO) { + return no_overflow(phase, ConLNode::make(phase->C, 0)); + } + + if (type1 == TypeLong::ONE) { + Node* mul_result = new (phase->C) AddLNode(arg2, phase->longcon(0)); + return no_overflow(phase, mul_result); + } + if (type2 == TypeLong::ONE) { + Node* mul_result = new (phase->C) AddLNode(arg1, phase->longcon(0)); + return no_overflow(phase, mul_result); + } + + if (type1 == TypeLong::MINUS_1) { + return new (phase->C) NegExactLNode(NULL, arg2); + } + + if (type2 == TypeLong::MINUS_1) { + return new (phase->C) NegExactLNode(NULL, arg1); + } + + return NULL; +} + diff --git a/hotspot/src/share/vm/opto/mathexactnode.hpp b/hotspot/src/share/vm/opto/mathexactnode.hpp index b58482a1092..59983e10bcd 100644 --- a/hotspot/src/share/vm/opto/mathexactnode.hpp +++ b/hotspot/src/share/vm/opto/mathexactnode.hpp @@ -39,6 +39,7 @@ class PhaseTransform; class MathExactNode : public MultiNode { public: + MathExactNode(Node* ctrl, Node* in1); MathExactNode(Node* ctrl, Node* in1, Node* in2); enum { result_proj_node = 0, @@ -62,15 +63,80 @@ protected: Node* no_overflow(PhaseGVN *phase, Node* new_result); }; -class AddExactINode : public MathExactNode { -public: - AddExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactNode(ctrl, in1, in2) {} +class MathExactINode : public MathExactNode { + public: + MathExactINode(Node* ctrl, Node* in1) : MathExactNode(ctrl, in1) {} + MathExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactNode(ctrl, in1, in2) {} virtual int Opcode() const; - virtual const Type* bottom_type() const { return TypeTuple::INT_CC_PAIR; } virtual Node* match(const ProjNode* proj, const Matcher* m); + virtual const Type* bottom_type() const { return TypeTuple::INT_CC_PAIR; } +}; + +class MathExactLNode : public MathExactNode { +public: + MathExactLNode(Node* ctrl, Node* in1) : MathExactNode(ctrl, in1) {} + MathExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactNode(ctrl, in1, in2) {} + virtual int Opcode() const; + virtual Node* match(const ProjNode* proj, const Matcher* m); + virtual const Type* bottom_type() const { return TypeTuple::LONG_CC_PAIR; } +}; + +class AddExactINode : public MathExactINode { +public: + AddExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {} + virtual int Opcode() const; virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); }; +class AddExactLNode : public MathExactLNode { +public: + AddExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {} + virtual int Opcode() const; + virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); +}; + +class SubExactINode : public MathExactINode { +public: + SubExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {} + virtual int Opcode() const; + virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); +}; + +class SubExactLNode : public MathExactLNode { +public: + SubExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {} + virtual int Opcode() const; + virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); +}; + +class NegExactINode : public MathExactINode { +public: + NegExactINode(Node* ctrl, Node* in1) : MathExactINode(ctrl, in1) {} + virtual int Opcode() const; + virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); +}; + +class NegExactLNode : public MathExactLNode { +public: + NegExactLNode(Node* ctrl, Node* in1) : MathExactLNode(ctrl, in1) {} + virtual int Opcode() const; + virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); +}; + +class MulExactINode : public MathExactINode { +public: + MulExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {} + virtual int Opcode() const; + virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); +}; + +class MulExactLNode : public MathExactLNode { +public: + MulExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {} + virtual int Opcode() const; + virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); +}; + class FlagsProjNode : public ProjNode { public: FlagsProjNode(Node* src, uint con) : ProjNode(src, con) { diff --git a/hotspot/src/share/vm/opto/multnode.cpp b/hotspot/src/share/vm/opto/multnode.cpp index 286f0461b20..bb3357abcf0 100644 --- a/hotspot/src/share/vm/opto/multnode.cpp +++ b/hotspot/src/share/vm/opto/multnode.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "opto/callnode.hpp" +#include "opto/cfgnode.hpp" #include "opto/matcher.hpp" #include "opto/mathexactnode.hpp" #include "opto/multnode.hpp" @@ -150,3 +151,59 @@ const RegMask &ProjNode::out_RegMask() const { uint ProjNode::ideal_reg() const { return bottom_type()->ideal_reg(); } + +//-------------------------------is_uncommon_trap_proj---------------------------- +// Return true if proj is the form of "proj->[region->..]call_uct" +bool ProjNode::is_uncommon_trap_proj(Deoptimization::DeoptReason reason) { + int path_limit = 10; + Node* out = this; + for (int ct = 0; ct < path_limit; ct++) { + out = out->unique_ctrl_out(); + if (out == NULL) + return false; + if (out->is_CallStaticJava()) { + int req = out->as_CallStaticJava()->uncommon_trap_request(); + if (req != 0) { + Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req); + if (trap_reason == reason || reason == Deoptimization::Reason_none) { + return true; + } + } + return false; // don't do further after call + } + if (out->Opcode() != Op_Region) + return false; + } + return false; +} + +//-------------------------------is_uncommon_trap_if_pattern------------------------- +// Return true for "if(test)-> proj -> ... +// | +// V +// other_proj->[region->..]call_uct" +// +// "must_reason_predicate" means the uct reason must be Reason_predicate +bool ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) { + Node *in0 = in(0); + if (!in0->is_If()) return false; + // Variation of a dead If node. + if (in0->outcnt() < 2) return false; + IfNode* iff = in0->as_If(); + + // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate + if (reason != Deoptimization::Reason_none) { + if (iff->in(1)->Opcode() != Op_Conv2B || + iff->in(1)->in(1)->Opcode() != Op_Opaque1) { + return false; + } + } + + ProjNode* other_proj = iff->proj_out(1-_con)->as_Proj(); + if (other_proj->is_uncommon_trap_proj(reason)) { + assert(reason == Deoptimization::Reason_none || + Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list"); + return true; + } + return false; +} diff --git a/hotspot/src/share/vm/opto/multnode.hpp b/hotspot/src/share/vm/opto/multnode.hpp index 242e58f4850..e3866c8b9a1 100644 --- a/hotspot/src/share/vm/opto/multnode.hpp +++ b/hotspot/src/share/vm/opto/multnode.hpp @@ -88,6 +88,14 @@ public: #ifndef PRODUCT virtual void dump_spec(outputStream *st) const; #endif + + // Return true if proj is for "proj->[region->..]call_uct" + bool is_uncommon_trap_proj(Deoptimization::DeoptReason reason); + // Return true for "if(test)-> proj -> ... + // | + // V + // other_proj->[region->..]call_uct" + bool is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason); }; #endif // SHARE_VM_OPTO_MULTNODE_HPP diff --git a/hotspot/src/share/vm/opto/node.hpp b/hotspot/src/share/vm/opto/node.hpp index 0e58abc8518..924db1b37f9 100644 --- a/hotspot/src/share/vm/opto/node.hpp +++ b/hotspot/src/share/vm/opto/node.hpp @@ -100,6 +100,7 @@ class MachSafePointNode; class MachSpillCopyNode; class MachTempNode; class Matcher; +class MathExactNode; class MemBarNode; class MemBarStoreStoreNode; class MemNode; @@ -568,6 +569,7 @@ public: DEFINE_CLASS_ID(MemBar, Multi, 3) DEFINE_CLASS_ID(Initialize, MemBar, 0) DEFINE_CLASS_ID(MemBarStoreStore, MemBar, 1) + DEFINE_CLASS_ID(MathExact, Multi, 4) DEFINE_CLASS_ID(Mach, Node, 1) DEFINE_CLASS_ID(MachReturn, Mach, 0) @@ -757,6 +759,7 @@ public: DEFINE_CLASS_QUERY(MachSafePoint) DEFINE_CLASS_QUERY(MachSpillCopy) DEFINE_CLASS_QUERY(MachTemp) + DEFINE_CLASS_QUERY(MathExact) DEFINE_CLASS_QUERY(Mem) DEFINE_CLASS_QUERY(MemBar) DEFINE_CLASS_QUERY(MemBarStoreStore) diff --git a/hotspot/src/share/vm/opto/parse.hpp b/hotspot/src/share/vm/opto/parse.hpp index f88ecf12dad..f60e6a540ea 100644 --- a/hotspot/src/share/vm/opto/parse.hpp +++ b/hotspot/src/share/vm/opto/parse.hpp @@ -349,13 +349,15 @@ class Parse : public GraphKit { int _est_switch_depth; // Debugging SwitchRanges. #endif + // parser for the caller of the method of this object + Parse* const _parent; + public: // Constructor - Parse(JVMState* caller, ciMethod* parse_method, float expected_uses); + Parse(JVMState* caller, ciMethod* parse_method, float expected_uses, Parse* parent); virtual Parse* is_Parse() const { return (Parse*)this; } - public: // Accessors. JVMState* caller() const { return _caller; } float expected_uses() const { return _expected_uses; } @@ -407,6 +409,8 @@ class Parse : public GraphKit { return block()->successor_for_bci(bci); } + Parse* parent_parser() const { return _parent; } + private: // Create a JVMS & map for the initial state of this method. SafePointNode* create_entry_map(); @@ -603,6 +607,9 @@ class Parse : public GraphKit { // Assumes that there is no applicable local handler. void throw_to_exit(SafePointNode* ex_map); + // Use speculative type to optimize CmpP node + Node* optimize_cmp_with_klass(Node* c); + public: #ifndef PRODUCT // Handle PrintOpto, etc. diff --git a/hotspot/src/share/vm/opto/parse1.cpp b/hotspot/src/share/vm/opto/parse1.cpp index 10d98b92f08..808f64d2d9a 100644 --- a/hotspot/src/share/vm/opto/parse1.cpp +++ b/hotspot/src/share/vm/opto/parse1.cpp @@ -381,8 +381,8 @@ void Parse::load_interpreter_state(Node* osr_buf) { //------------------------------Parse------------------------------------------ // Main parser constructor. -Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses) - : _exits(caller) +Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses, Parse* parent) + : _exits(caller), _parent(parent) { // Init some variables _caller = caller; @@ -1102,6 +1102,10 @@ void Parse::do_method_entry() { _synch_lock = shared_lock(lock_obj); } + // Feed profiling data for parameters to the type system so it can + // propagate it as speculative types + record_profiled_parameters_for_speculation(); + if (depth() == 1) { increment_and_test_invocation_counter(Tier2CompileThreshold); } diff --git a/hotspot/src/share/vm/opto/parse2.cpp b/hotspot/src/share/vm/opto/parse2.cpp index a910c3ee879..74119ef9f51 100644 --- a/hotspot/src/share/vm/opto/parse2.cpp +++ b/hotspot/src/share/vm/opto/parse2.cpp @@ -1366,6 +1366,56 @@ void Parse::sharpen_type_after_if(BoolTest::mask btest, } } +/** + * Use speculative type to optimize CmpP node: if comparison is + * against the low level class, cast the object to the speculative + * type if any. CmpP should then go away. + * + * @param c expected CmpP node + * @return result of CmpP on object casted to speculative type + * + */ +Node* Parse::optimize_cmp_with_klass(Node* c) { + // If this is transformed by the _gvn to a comparison with the low + // level klass then we may be able to use speculation + if (c->Opcode() == Op_CmpP && + (c->in(1)->Opcode() == Op_LoadKlass || c->in(1)->Opcode() == Op_DecodeNKlass) && + c->in(2)->is_Con()) { + Node* load_klass = NULL; + Node* decode = NULL; + if (c->in(1)->Opcode() == Op_DecodeNKlass) { + decode = c->in(1); + load_klass = c->in(1)->in(1); + } else { + load_klass = c->in(1); + } + if (load_klass->in(2)->is_AddP()) { + Node* addp = load_klass->in(2); + Node* obj = addp->in(AddPNode::Address); + const TypeOopPtr* obj_type = _gvn.type(obj)->is_oopptr(); + if (obj_type->speculative_type() != NULL) { + ciKlass* k = obj_type->speculative_type(); + inc_sp(2); + obj = maybe_cast_profiled_obj(obj, k); + dec_sp(2); + // Make the CmpP use the casted obj + addp = basic_plus_adr(obj, addp->in(AddPNode::Offset)); + load_klass = load_klass->clone(); + load_klass->set_req(2, addp); + load_klass = _gvn.transform(load_klass); + if (decode != NULL) { + decode = decode->clone(); + decode->set_req(1, load_klass); + load_klass = _gvn.transform(decode); + } + c = c->clone(); + c->set_req(1, load_klass); + c = _gvn.transform(c); + } + } + } + return c; +} //------------------------------do_one_bytecode-------------------------------- // Parse this bytecode, and alter the Parsers JVM->Node mapping @@ -2239,6 +2289,7 @@ void Parse::do_one_bytecode() { a = pop(); b = pop(); c = _gvn.transform( new (C) CmpPNode(b, a) ); + c = optimize_cmp_with_klass(c); do_if(btest, c); break; diff --git a/hotspot/src/share/vm/opto/parseHelper.cpp b/hotspot/src/share/vm/opto/parseHelper.cpp index 2ab580b5ce5..43d58e79546 100644 --- a/hotspot/src/share/vm/opto/parseHelper.cpp +++ b/hotspot/src/share/vm/opto/parseHelper.cpp @@ -128,7 +128,7 @@ void Parse::do_instanceof() { } // Push the bool result back on stack - Node* res = gen_instanceof(peek(), makecon(TypeKlassPtr::make(klass))); + Node* res = gen_instanceof(peek(), makecon(TypeKlassPtr::make(klass)), true); // Pop from stack AFTER gen_instanceof because it can uncommon trap. pop(); diff --git a/hotspot/src/share/vm/opto/phaseX.cpp b/hotspot/src/share/vm/opto/phaseX.cpp index 71c8d8afcd8..15b9b778883 100644 --- a/hotspot/src/share/vm/opto/phaseX.cpp +++ b/hotspot/src/share/vm/opto/phaseX.cpp @@ -1385,6 +1385,20 @@ void PhaseIterGVN::add_users_to_worklist( Node *n ) { } } +/** + * Remove the speculative part of all types that we know of + */ +void PhaseIterGVN::remove_speculative_types() { + assert(UseTypeSpeculation, "speculation is off"); + for (uint i = 0; i < _types.Size(); i++) { + const Type* t = _types.fast_lookup(i); + if (t != NULL && t->isa_oopptr()) { + const TypeOopPtr* to = t->is_oopptr(); + _types.map(i, to->remove_speculative()); + } + } +} + //============================================================================= #ifndef PRODUCT uint PhaseCCP::_total_invokes = 0; diff --git a/hotspot/src/share/vm/opto/phaseX.hpp b/hotspot/src/share/vm/opto/phaseX.hpp index 60b1f82fa78..7f39e538154 100644 --- a/hotspot/src/share/vm/opto/phaseX.hpp +++ b/hotspot/src/share/vm/opto/phaseX.hpp @@ -500,6 +500,8 @@ public: ProjNode* create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry, Deoptimization::DeoptReason reason); + void remove_speculative_types(); + #ifndef PRODUCT protected: // Sub-quadratic implementation of VerifyIterativeGVN. diff --git a/hotspot/src/share/vm/opto/postaloc.cpp b/hotspot/src/share/vm/opto/postaloc.cpp index 76de2ed16a1..2ad809d1a58 100644 --- a/hotspot/src/share/vm/opto/postaloc.cpp +++ b/hotspot/src/share/vm/opto/postaloc.cpp @@ -97,7 +97,8 @@ int PhaseChaitin::yank( Node *old, Block *current_block, Node_List *value, Node_ static bool expected_yanked_node(Node *old, Node *orig_old) { // This code is expected only next original nodes: // - load from constant table node which may have next data input nodes: - // MachConstantBase, Phi, MachTemp, MachSpillCopy + // MachConstantBase, MachTemp, MachSpillCopy + // - Phi nodes that are considered Junk // - load constant node which may have next data input nodes: // MachTemp, MachSpillCopy // - MachSpillCopy @@ -112,7 +113,9 @@ static bool expected_yanked_node(Node *old, Node *orig_old) { return (old == orig_old); } else if (old->is_MachTemp()) { return orig_old->is_Con(); - } else if (old->is_Phi() || old->is_MachConstantBase()) { + } else if (old->is_Phi()) { // Junk phi's + return true; + } else if (old->is_MachConstantBase()) { return (orig_old->is_Con() && orig_old->is_MachConstant()); } return false; @@ -522,11 +525,9 @@ void PhaseChaitin::post_allocate_copy_removal() { u = u ? NodeSentinel : x; // Capture unique input, or NodeSentinel for 2nd input } if (u != NodeSentinel) { // Junk Phi. Remove - block->remove_node(j--); - phi_dex--; - _cfg.unmap_node_from_block(phi); phi->replace_by(u); - phi->disconnect_inputs(NULL, C); + j -= yank_if_dead(phi, block, &value, ®nd); + phi_dex--; continue; } // Note that if value[pidx] exists, then we merged no new values here diff --git a/hotspot/src/share/vm/opto/reg_split.cpp b/hotspot/src/share/vm/opto/reg_split.cpp index f58a380edd7..842048f46f5 100644 --- a/hotspot/src/share/vm/opto/reg_split.cpp +++ b/hotspot/src/share/vm/opto/reg_split.cpp @@ -51,15 +51,6 @@ static const char out_of_nodes[] = "out of nodes during split"; -static bool contains_no_live_range_input(const Node* def) { - for (uint i = 1; i < def->req(); ++i) { - if (def->in(i) != NULL && def->in_RegMask(i).is_NotEmpty()) { - return false; - } - } - return true; -} - //------------------------------get_spillcopy_wide----------------------------- // Get a SpillCopy node with wide-enough masks. Use the 'wide-mask', the // wide ideal-register spill-mask if possible. If the 'wide-mask' does @@ -326,12 +317,11 @@ Node *PhaseChaitin::split_Rematerialize( Node *def, Block *b, uint insidx, uint if( def->req() > 1 ) { for( uint i = 1; i < def->req(); i++ ) { Node *in = def->in(i); - // Check for single-def (LRG cannot redefined) uint lidx = _lrg_map.live_range_id(in); - if (lidx >= _lrg_map.max_lrg_id()) { - continue; // Value is a recent spill-copy - } - if (lrgs(lidx).is_singledef()) { + // We do not need this for live ranges that are only defined once. + // However, this is not true for spill copies that are added in this + // Split() pass, since they might get coalesced later on in this pass. + if (lidx < _lrg_map.max_lrg_id() && lrgs(lidx).is_singledef()) { continue; } @@ -375,7 +365,6 @@ Node *PhaseChaitin::split_Rematerialize( Node *def, Block *b, uint insidx, uint } if (lidx < _lrg_map.max_lrg_id() && lrgs(lidx).reg() >= LRG::SPILL_REG) { - assert(Reachblock != NULL, "Reachblock must be non-NULL"); Node *rdef = Reachblock[lrg2reach[lidx]]; if (rdef) { spill->set_req(i, rdef); @@ -486,7 +475,6 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { uint bidx, pidx, slidx, insidx, inpidx, twoidx; uint non_phi = 1, spill_cnt = 0; - Node **Reachblock; Node *n1, *n2, *n3; Node_List *defs,*phis; bool *UPblock; @@ -569,7 +557,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { b = _cfg.get_block(bidx); // Reaches & UP arrays for this block - Reachblock = Reaches[b->_pre_order]; + Node** Reachblock = Reaches[b->_pre_order]; UPblock = UP[b->_pre_order]; // Reset counter of start of non-Phi nodes in block non_phi = 1; @@ -1325,9 +1313,10 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { pidx = pred->_pre_order; // Grab reaching def Node *def = Reaches[pidx][slidx]; + Node** Reachblock = Reaches[pidx]; assert( def, "must have reaching def" ); // If input up/down sense and reg-pressure DISagree - if (def->rematerialize() && contains_no_live_range_input(def)) { + if (def->rematerialize()) { // Place the rematerialized node above any MSCs created during // phi node splitting. end_idx points at the insertion point // so look at the node before it. @@ -1337,8 +1326,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { _lrg_map.find(pred->get_node(insert - 1)) >= lrgs_before_phi_split) { insert--; } - // since the def cannot contain any live range input, we can pass in NULL as Reachlock parameter - def = split_Rematerialize(def, pred, insert, maxlrg, splits, slidx, lrg2reach, NULL, false); + def = split_Rematerialize(def, pred, insert, maxlrg, splits, slidx, lrg2reach, Reachblock, false); if (!def) { return 0; // Bail out } diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp index 18f2b9d3181..3f628195f78 100644 --- a/hotspot/src/share/vm/opto/type.cpp +++ b/hotspot/src/share/vm/opto/type.cpp @@ -358,7 +358,7 @@ void Type::Initialize_shared(Compile* current) { false, 0, oopDesc::mark_offset_in_bytes()); TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), false, 0, oopDesc::klass_offset_in_bytes()); - TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot); + TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot, NULL); TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot); @@ -435,6 +435,11 @@ void Type::Initialize_shared(Compile* current) { intccpair[1] = TypeInt::CC; TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair); + const Type **longccpair = TypeTuple::fields(2); + longccpair[0] = TypeLong::LONG; + longccpair[1] = TypeInt::CC; + TypeTuple::LONG_CC_PAIR = TypeTuple::make(2, longccpair); + _const_basic_type[T_NARROWOOP] = TypeNarrowOop::BOTTOM; _const_basic_type[T_NARROWKLASS] = Type::BOTTOM; _const_basic_type[T_BOOLEAN] = TypeInt::BOOL; @@ -577,7 +582,7 @@ bool Type::is_nan() const { //----------------------interface_vs_oop--------------------------------------- #ifdef ASSERT -bool Type::interface_vs_oop(const Type *t) const { +bool Type::interface_vs_oop_helper(const Type *t) const { bool result = false; const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop @@ -595,6 +600,29 @@ bool Type::interface_vs_oop(const Type *t) const { return result; } + +bool Type::interface_vs_oop(const Type *t) const { + if (interface_vs_oop_helper(t)) { + return true; + } + // Now check the speculative parts as well + const TypeOopPtr* this_spec = isa_oopptr() != NULL ? isa_oopptr()->speculative() : NULL; + const TypeOopPtr* t_spec = t->isa_oopptr() != NULL ? t->isa_oopptr()->speculative() : NULL; + if (this_spec != NULL && t_spec != NULL) { + if (this_spec->interface_vs_oop_helper(t_spec)) { + return true; + } + return false; + } + if (this_spec != NULL && this_spec->interface_vs_oop_helper(t)) { + return true; + } + if (t_spec != NULL && interface_vs_oop_helper(t_spec)) { + return true; + } + return false; +} + #endif //------------------------------meet------------------------------------------- @@ -1652,6 +1680,7 @@ const TypeTuple *TypeTuple::START_I2C; const TypeTuple *TypeTuple::INT_PAIR; const TypeTuple *TypeTuple::LONG_PAIR; const TypeTuple *TypeTuple::INT_CC_PAIR; +const TypeTuple *TypeTuple::LONG_CC_PAIR; //------------------------------make------------------------------------------- @@ -2407,14 +2436,15 @@ void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const { const TypeOopPtr *TypeOopPtr::BOTTOM; //------------------------------TypeOopPtr------------------------------------- -TypeOopPtr::TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ) +TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative) : TypePtr(t, ptr, offset), _const_oop(o), _klass(k), _klass_is_exact(xk), _is_ptr_to_narrowoop(false), _is_ptr_to_narrowklass(false), _is_ptr_to_boxed_value(false), - _instance_id(instance_id) { + _instance_id(instance_id), + _speculative(speculative) { if (Compile::current()->eliminate_boxing() && (t == InstPtr) && (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); @@ -2481,12 +2511,12 @@ TypeOopPtr::TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int //------------------------------make------------------------------------------- const TypeOopPtr *TypeOopPtr::make(PTR ptr, - int offset, int instance_id) { + int offset, int instance_id, const TypeOopPtr* speculative) { assert(ptr != Constant, "no constant generic pointers"); ciKlass* k = Compile::current()->env()->Object_klass(); bool xk = false; ciObject* o = NULL; - return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id))->hashcons(); + return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative))->hashcons(); } @@ -2494,7 +2524,7 @@ const TypeOopPtr *TypeOopPtr::make(PTR ptr, const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); if( ptr == _ptr ) return this; - return make(ptr, _offset, _instance_id); + return make(ptr, _offset, _instance_id, _speculative); } //-----------------------------cast_to_instance_id---------------------------- @@ -2524,10 +2554,31 @@ const TypeKlassPtr* TypeOopPtr::as_klass_type() const { return TypeKlassPtr::make(xk? Constant: NotNull, k, 0); } +const Type *TypeOopPtr::xmeet(const Type *t) const { + const Type* res = xmeet_helper(t); + if (res->isa_oopptr() == NULL) { + return res; + } + + if (res->isa_oopptr() != NULL) { + // type->speculative() == NULL means that speculation is no better + // than type, i.e. type->speculative() == type. So there are 2 + // ways to represent the fact that we have no useful speculative + // data and we should use a single one to be able to test for + // equality between types. Check whether type->speculative() == + // type and set speculative to NULL if it is the case. + const TypeOopPtr* res_oopptr = res->is_oopptr(); + if (res_oopptr->remove_speculative() == res_oopptr->speculative()) { + return res_oopptr->remove_speculative(); + } + } + + return res; +} //------------------------------meet------------------------------------------- // Compute the MEET of two types. It returns a new Type object. -const Type *TypeOopPtr::xmeet( const Type *t ) const { +const Type *TypeOopPtr::xmeet_helper(const Type *t) const { // Perform a fast test for common case; meeting the same types together. if( this == t ) return this; // Meeting same type-rep? @@ -2569,7 +2620,8 @@ const Type *TypeOopPtr::xmeet( const Type *t ) const { case TopPTR: case AnyNull: { int instance_id = meet_instance_id(InstanceTop); - return make(ptr, offset, instance_id); + const TypeOopPtr* speculative = _speculative; + return make(ptr, offset, instance_id, speculative); } case BotPTR: case NotNull: @@ -2581,7 +2633,8 @@ const Type *TypeOopPtr::xmeet( const Type *t ) const { case OopPtr: { // Meeting to other OopPtrs const TypeOopPtr *tp = t->is_oopptr(); int instance_id = meet_instance_id(tp->instance_id()); - return make( meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id ); + const TypeOopPtr* speculative = meet_speculative(tp); + return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative); } case InstPtr: // For these, flip the call around to cut down @@ -2598,7 +2651,7 @@ const Type *TypeOopPtr::xmeet( const Type *t ) const { const Type *TypeOopPtr::xdual() const { assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); assert(const_oop() == NULL, "no constants here"); - return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() ); + return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); } //--------------------------make_from_klass_common----------------------------- @@ -2689,7 +2742,7 @@ const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, } else if (!o->should_be_constant()) { return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); } - const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, is_autobox_cache); + const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, is_autobox_cache); return arr; } else if (klass->is_type_array_klass()) { // Element is an typeArray @@ -2734,13 +2787,11 @@ intptr_t TypeOopPtr::get_con() const { //-----------------------------filter------------------------------------------ // Do not allow interface-vs.-noninterface joins to collapse to top. -const Type *TypeOopPtr::filter( const Type *kills ) const { +const Type *TypeOopPtr::filter(const Type *kills) const { const Type* ft = join(kills); const TypeInstPtr* ftip = ft->isa_instptr(); const TypeInstPtr* ktip = kills->isa_instptr(); - const TypeKlassPtr* ftkp = ft->isa_klassptr(); - const TypeKlassPtr* ktkp = kills->isa_klassptr(); if (ft->empty()) { // Check for evil case of 'this' being a class and 'kills' expecting an @@ -2754,8 +2805,6 @@ const Type *TypeOopPtr::filter( const Type *kills ) const { // uplift the type. if (!empty() && ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface()) return kills; // Uplift to interface - if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface()) - return kills; // Uplift to interface return Type::TOP; // Canonical empty value } @@ -2772,14 +2821,6 @@ const Type *TypeOopPtr::filter( const Type *kills ) const { assert(!ftip->klass_is_exact(), "interface could not be exact"); return ktip->cast_to_ptr_type(ftip->ptr()); } - // Interface klass type could be exact in opposite to interface type, - // return it here instead of incorrect Constant ptr J/L/Object (6894807). - if (ftkp != NULL && ktkp != NULL && - ftkp->is_loaded() && ftkp->klass()->is_interface() && - !ftkp->klass_is_exact() && // Keep exact interface klass - ktkp->is_loaded() && !ktkp->klass()->is_interface()) { - return ktkp->cast_to_ptr_type(ftkp->ptr()); - } return ft; } @@ -2789,7 +2830,8 @@ const Type *TypeOopPtr::filter( const Type *kills ) const { bool TypeOopPtr::eq( const Type *t ) const { const TypeOopPtr *a = (const TypeOopPtr*)t; if (_klass_is_exact != a->_klass_is_exact || - _instance_id != a->_instance_id) return false; + _instance_id != a->_instance_id || + !eq_speculative(a)) return false; ciObject* one = const_oop(); ciObject* two = a->const_oop(); if (one == NULL || two == NULL) { @@ -2806,6 +2848,7 @@ int TypeOopPtr::hash(void) const { (const_oop() ? const_oop()->hash() : 0) + _klass_is_exact + _instance_id + + hash_speculative() + TypePtr::hash(); } @@ -2825,6 +2868,19 @@ void TypeOopPtr::dump2( Dict &d, uint depth, outputStream *st ) const { st->print(",iid=top"); else if (_instance_id != InstanceBot) st->print(",iid=%d",_instance_id); + + dump_speculative(st); +} + +/** + *dump the speculative part of the type + */ +void TypeOopPtr::dump_speculative(outputStream *st) const { + if (_speculative != NULL) { + st->print(" (speculative="); + _speculative->dump_on(st); + st->print(")"); + } } #endif @@ -2838,8 +2894,15 @@ bool TypeOopPtr::singleton(void) const { } //------------------------------add_offset------------------------------------- -const TypePtr *TypeOopPtr::add_offset( intptr_t offset ) const { - return make( _ptr, xadd_offset(offset), _instance_id); +const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const { + return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); +} + +/** + * Return same type without a speculative part + */ +const TypeOopPtr* TypeOopPtr::remove_speculative() const { + return make(_ptr, _offset, _instance_id, NULL); } //------------------------------meet_instance_id-------------------------------- @@ -2859,6 +2922,89 @@ int TypeOopPtr::dual_instance_id( ) const { return _instance_id; // Map everything else into self } +/** + * meet of the speculative parts of 2 types + * + * @param other type to meet with + */ +const TypeOopPtr* TypeOopPtr::meet_speculative(const TypeOopPtr* other) const { + bool this_has_spec = (_speculative != NULL); + bool other_has_spec = (other->speculative() != NULL); + + if (!this_has_spec && !other_has_spec) { + return NULL; + } + + // If we are at a point where control flow meets and one branch has + // a speculative type and the other has not, we meet the speculative + // type of one branch with the actual type of the other. If the + // actual type is exact and the speculative is as well, then the + // result is a speculative type which is exact and we can continue + // speculation further. + const TypeOopPtr* this_spec = _speculative; + const TypeOopPtr* other_spec = other->speculative(); + + if (!this_has_spec) { + this_spec = this; + } + + if (!other_has_spec) { + other_spec = other; + } + + return this_spec->meet(other_spec)->is_oopptr(); +} + +/** + * dual of the speculative part of the type + */ +const TypeOopPtr* TypeOopPtr::dual_speculative() const { + if (_speculative == NULL) { + return NULL; + } + return _speculative->dual()->is_oopptr(); +} + +/** + * add offset to the speculative part of the type + * + * @param offset offset to add + */ +const TypeOopPtr* TypeOopPtr::add_offset_speculative(intptr_t offset) const { + if (_speculative == NULL) { + return NULL; + } + return _speculative->add_offset(offset)->is_oopptr(); +} + +/** + * Are the speculative parts of 2 types equal? + * + * @param other type to compare this one to + */ +bool TypeOopPtr::eq_speculative(const TypeOopPtr* other) const { + if (_speculative == NULL || other->speculative() == NULL) { + return _speculative == other->speculative(); + } + + if (_speculative->base() != other->speculative()->base()) { + return false; + } + + return _speculative->eq(other->speculative()); +} + +/** + * Hash of the speculative part of the type + */ +int TypeOopPtr::hash_speculative() const { + if (_speculative == NULL) { + return 0; + } + + return _speculative->hash(); +} + //============================================================================= // Convenience common pre-built types. @@ -2869,8 +3015,8 @@ const TypeInstPtr *TypeInstPtr::MARK; const TypeInstPtr *TypeInstPtr::KLASS; //------------------------------TypeInstPtr------------------------------------- -TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id) - : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id), _name(k->name()) { +TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative) + : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative), _name(k->name()) { assert(k != NULL && (k->is_loaded() || o == NULL), "cannot have constants with non-loaded klass"); @@ -2882,7 +3028,8 @@ const TypeInstPtr *TypeInstPtr::make(PTR ptr, bool xk, ciObject* o, int offset, - int instance_id) { + int instance_id, + const TypeOopPtr* speculative) { assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance"); // Either const_oop() is NULL or else ptr is Constant assert( (!o && ptr != Constant) || (o && ptr == Constant), @@ -2903,7 +3050,7 @@ const TypeInstPtr *TypeInstPtr::make(PTR ptr, // Now hash this baby TypeInstPtr *result = - (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id))->hashcons(); + (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative))->hashcons(); return result; } @@ -2936,7 +3083,7 @@ const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const { if( ptr == _ptr ) return this; // Reconstruct _sig info here since not a problem with later lazy // construction, _sig will show up on demand. - return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id); + return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative); } @@ -2948,13 +3095,13 @@ const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { ciInstanceKlass* ik = _klass->as_instance_klass(); if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk if( ik->is_interface() ) return this; // cannot set xk - return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id); + return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative); } //-----------------------------cast_to_instance_id---------------------------- const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { if( instance_id == _instance_id ) return this; - return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id); + return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative); } //------------------------------xmeet_unloaded--------------------------------- @@ -2964,6 +3111,7 @@ const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { int off = meet_offset(tinst->offset()); PTR ptr = meet_ptr(tinst->ptr()); int instance_id = meet_instance_id(tinst->instance_id()); + const TypeOopPtr* speculative = meet_speculative(tinst); const TypeInstPtr *loaded = is_loaded() ? this : tinst; const TypeInstPtr *unloaded = is_loaded() ? tinst : this; @@ -2984,7 +3132,7 @@ const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { assert(loaded->ptr() != TypePtr::Null, "insanity check"); // if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } - else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make( ptr, unloaded->klass(), false, NULL, off, instance_id ); } + else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative); } else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } @@ -3006,7 +3154,7 @@ const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { //------------------------------meet------------------------------------------- // Compute the MEET of two types. It returns a new Type object. -const Type *TypeInstPtr::xmeet( const Type *t ) const { +const Type *TypeInstPtr::xmeet_helper(const Type *t) const { // Perform a fast test for common case; meeting the same types together. if( this == t ) return this; // Meeting same type-rep? @@ -3040,16 +3188,20 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { int offset = meet_offset(tp->offset()); PTR ptr = meet_ptr(tp->ptr()); int instance_id = meet_instance_id(tp->instance_id()); + const TypeOopPtr* speculative = meet_speculative(tp); switch (ptr) { case TopPTR: case AnyNull: // Fall 'down' to dual of object klass - if (klass()->equals(ciEnv::current()->Object_klass())) { - return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id); + // For instances when a subclass meets a superclass we fall + // below the centerline when the superclass is exact. We need to + // do the same here. + if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { + return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); } else { // cannot subclass, so the meet has to fall badly below the centerline ptr = NotNull; instance_id = InstanceBot; - return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id); + return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); } case Constant: case NotNull: @@ -3058,10 +3210,13 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull ) // If 'this' (InstPtr) is above the centerline and it is Object class // then we can subclass in the Java class hierarchy. - if (klass()->equals(ciEnv::current()->Object_klass())) { + // For instances when a subclass meets a superclass we fall + // below the centerline when the superclass is exact. We need + // to do the same here. + if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { // that is, tp's array type is a subtype of my klass return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), - tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id); + tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); } } // The other case cannot happen, since I cannot be a subtype of an array. @@ -3069,7 +3224,7 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { if( ptr == Constant ) ptr = NotNull; instance_id = InstanceBot; - return make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id ); + return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); default: typerr(t); } } @@ -3083,13 +3238,15 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { case TopPTR: case AnyNull: { int instance_id = meet_instance_id(InstanceTop); + const TypeOopPtr* speculative = meet_speculative(tp); return make(ptr, klass(), klass_is_exact(), - (ptr == Constant ? const_oop() : NULL), offset, instance_id); + (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); } case NotNull: case BotPTR: { int instance_id = meet_instance_id(tp->instance_id()); - return TypeOopPtr::make(ptr, offset, instance_id); + const TypeOopPtr* speculative = meet_speculative(tp); + return TypeOopPtr::make(ptr, offset, instance_id, speculative); } default: typerr(t); } @@ -3102,17 +3259,18 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { PTR ptr = meet_ptr(tp->ptr()); switch (tp->ptr()) { case Null: - if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset ); + if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset); // else fall through to AnyNull case TopPTR: case AnyNull: { int instance_id = meet_instance_id(InstanceTop); - return make( ptr, klass(), klass_is_exact(), - (ptr == Constant ? const_oop() : NULL), offset, instance_id); + const TypeOopPtr* speculative = _speculative; + return make(ptr, klass(), klass_is_exact(), + (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); } case NotNull: case BotPTR: - return TypePtr::make( AnyPtr, ptr, offset ); + return TypePtr::make(AnyPtr, ptr, offset); default: typerr(t); } } @@ -3139,13 +3297,14 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { int off = meet_offset( tinst->offset() ); PTR ptr = meet_ptr( tinst->ptr() ); int instance_id = meet_instance_id(tinst->instance_id()); + const TypeOopPtr* speculative = meet_speculative(tinst); // Check for easy case; klasses are equal (and perhaps not loaded!) // If we have constants, then we created oops so classes are loaded // and we can handle the constants further down. This case handles // both-not-loaded or both-loaded classes if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) { - return make( ptr, klass(), klass_is_exact(), NULL, off, instance_id ); + return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative); } // Classes require inspection in the Java klass hierarchy. Must be loaded. @@ -3167,7 +3326,8 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { } // Handle mixing oops and interfaces first. - if( this_klass->is_interface() && !tinst_klass->is_interface() ) { + if( this_klass->is_interface() && !(tinst_klass->is_interface() || + tinst_klass == ciEnv::current()->Object_klass())) { ciKlass *tmp = tinst_klass; // Swap interface around tinst_klass = this_klass; this_klass = tmp; @@ -3208,7 +3368,7 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { // Find out which constant. o = (this_klass == klass()) ? const_oop() : tinst->const_oop(); } - return make( ptr, k, xk, o, off, instance_id ); + return make(ptr, k, xk, o, off, instance_id, speculative); } // Either oop vs oop or interface vs interface or interface vs Object @@ -3285,7 +3445,7 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { else ptr = NotNull; } - return make( ptr, this_klass, this_xk, o, off, instance_id ); + return make(ptr, this_klass, this_xk, o, off, instance_id, speculative); } // Else classes are not equal // Since klasses are different, we require a LCA in the Java @@ -3296,7 +3456,7 @@ const Type *TypeInstPtr::xmeet( const Type *t ) const { // Now we find the LCA of Java classes ciKlass* k = this_klass->least_common_ancestor(tinst_klass); - return make( ptr, k, false, NULL, off, instance_id ); + return make(ptr, k, false, NULL, off, instance_id, speculative); } // End of case InstPtr } // End of switch @@ -3320,7 +3480,7 @@ ciType* TypeInstPtr::java_mirror_type() const { // Dual: do NOT dual on klasses. This means I do NOT understand the Java // inheritance mechanism. const Type *TypeInstPtr::xdual() const { - return new TypeInstPtr( dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() ); + return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); } //------------------------------eq--------------------------------------------- @@ -3376,12 +3536,18 @@ void TypeInstPtr::dump2( Dict &d, uint depth, outputStream *st ) const { st->print(",iid=top"); else if (_instance_id != InstanceBot) st->print(",iid=%d",_instance_id); + + dump_speculative(st); } #endif //------------------------------add_offset------------------------------------- -const TypePtr *TypeInstPtr::add_offset( intptr_t offset ) const { - return make( _ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id ); +const TypePtr *TypeInstPtr::add_offset(intptr_t offset) const { + return make(_ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id, add_offset_speculative(offset)); +} + +const TypeOopPtr *TypeInstPtr::remove_speculative() const { + return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL); } //============================================================================= @@ -3398,30 +3564,30 @@ const TypeAryPtr *TypeAryPtr::FLOATS; const TypeAryPtr *TypeAryPtr::DOUBLES; //------------------------------make------------------------------------------- -const TypeAryPtr *TypeAryPtr::make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) { +const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative) { assert(!(k == NULL && ary->_elem->isa_int()), "integral arrays must be pre-equipped with a class"); if (!xk) xk = ary->ary_must_be_exact(); assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); if (!UseExactTypes) xk = (ptr == Constant); - return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false))->hashcons(); + return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative))->hashcons(); } //------------------------------make------------------------------------------- -const TypeAryPtr *TypeAryPtr::make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, bool is_autobox_cache) { +const TypeAryPtr *TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, bool is_autobox_cache) { assert(!(k == NULL && ary->_elem->isa_int()), "integral arrays must be pre-equipped with a class"); assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); if (!UseExactTypes) xk = (ptr == Constant); - return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache))->hashcons(); + return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative))->hashcons(); } //------------------------------cast_to_ptr_type------------------------------- const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { if( ptr == _ptr ) return this; - return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id); + return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); } @@ -3430,13 +3596,13 @@ const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { if( klass_is_exact == _klass_is_exact ) return this; if (!UseExactTypes) return this; if (_ary->ary_must_be_exact()) return this; // cannot clear xk - return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id); + return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative); } //-----------------------------cast_to_instance_id---------------------------- const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { if( instance_id == _instance_id ) return this; - return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id); + return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative); } //-----------------------------narrow_size_type------------------------------- @@ -3499,7 +3665,7 @@ const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { new_size = narrow_size_type(new_size); if (new_size == size()) return this; const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable()); - return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id); + return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); } @@ -3548,7 +3714,7 @@ int TypeAryPtr::hash(void) const { //------------------------------meet------------------------------------------- // Compute the MEET of two types. It returns a new Type object. -const Type *TypeAryPtr::xmeet( const Type *t ) const { +const Type *TypeAryPtr::xmeet_helper(const Type *t) const { // Perform a fast test for common case; meeting the same types together. if( this == t ) return this; // Meeting same type-rep? // Current "this->_base" is Pointer @@ -3582,13 +3748,15 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { case TopPTR: case AnyNull: { int instance_id = meet_instance_id(InstanceTop); + const TypeOopPtr* speculative = meet_speculative(tp); return make(ptr, (ptr == Constant ? const_oop() : NULL), - _ary, _klass, _klass_is_exact, offset, instance_id); + _ary, _klass, _klass_is_exact, offset, instance_id, speculative); } case BotPTR: case NotNull: { int instance_id = meet_instance_id(tp->instance_id()); - return TypeOopPtr::make(ptr, offset, instance_id); + const TypeOopPtr* speculative = meet_speculative(tp); + return TypeOopPtr::make(ptr, offset, instance_id, speculative); } default: ShouldNotReachHere(); } @@ -3610,8 +3778,9 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { // else fall through to AnyNull case AnyNull: { int instance_id = meet_instance_id(InstanceTop); - return make( ptr, (ptr == Constant ? const_oop() : NULL), - _ary, _klass, _klass_is_exact, offset, instance_id); + const TypeOopPtr* speculative = _speculative; + return make(ptr, (ptr == Constant ? const_oop() : NULL), + _ary, _klass, _klass_is_exact, offset, instance_id, speculative); } default: ShouldNotReachHere(); } @@ -3627,6 +3796,7 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { const TypeAry *tary = _ary->meet(tap->_ary)->is_ary(); PTR ptr = meet_ptr(tap->ptr()); int instance_id = meet_instance_id(tap->instance_id()); + const TypeOopPtr* speculative = meet_speculative(tap); ciKlass* lazy_klass = NULL; if (tary->_elem->isa_int()) { // Integral array element types have irrelevant lattice relations. @@ -3654,7 +3824,7 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { // 'this' is exact and super or unrelated: (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); - return make( NotNull, NULL, tary, lazy_klass, false, off, InstanceBot ); + return make(NotNull, NULL, tary, lazy_klass, false, off, InstanceBot); } bool xk = false; @@ -3662,8 +3832,12 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { case AnyNull: case TopPTR: // Compute new klass on demand, do not use tap->_klass - xk = (tap->_klass_is_exact | this->_klass_is_exact); - return make( ptr, const_oop(), tary, lazy_klass, xk, off, instance_id ); + if (below_centerline(this->_ptr)) { + xk = this->_klass_is_exact; + } else { + xk = (tap->_klass_is_exact | this->_klass_is_exact); + } + return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative); case Constant: { ciObject* o = const_oop(); if( _ptr == Constant ) { @@ -3675,25 +3849,23 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { } else { xk = true; } - } else if( above_centerline(_ptr) ) { + } else if(above_centerline(_ptr)) { o = tap->const_oop(); xk = true; } else { // Only precise for identical arrays xk = this->_klass_is_exact && (klass() == tap->klass()); } - return TypeAryPtr::make( ptr, o, tary, lazy_klass, xk, off, instance_id ); + return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative); } case NotNull: case BotPTR: // Compute new klass on demand, do not use tap->_klass if (above_centerline(this->_ptr)) xk = tap->_klass_is_exact; - else if (above_centerline(tap->_ptr)) - xk = this->_klass_is_exact; else xk = (tap->_klass_is_exact & this->_klass_is_exact) && (klass() == tap->klass()); // Only precise for identical arrays - return TypeAryPtr::make( ptr, NULL, tary, lazy_klass, xk, off, instance_id ); + return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative); default: ShouldNotReachHere(); } } @@ -3704,16 +3876,20 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { int offset = meet_offset(tp->offset()); PTR ptr = meet_ptr(tp->ptr()); int instance_id = meet_instance_id(tp->instance_id()); + const TypeOopPtr* speculative = meet_speculative(tp); switch (ptr) { case TopPTR: case AnyNull: // Fall 'down' to dual of object klass - if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) { - return TypeAryPtr::make( ptr, _ary, _klass, _klass_is_exact, offset, instance_id ); + // For instances when a subclass meets a superclass we fall + // below the centerline when the superclass is exact. We need to + // do the same here. + if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { + return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative); } else { // cannot subclass, so the meet has to fall badly below the centerline ptr = NotNull; instance_id = InstanceBot; - return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id); + return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); } case Constant: case NotNull: @@ -3722,10 +3898,13 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { if (above_centerline(tp->ptr())) { // If 'tp' is above the centerline and it is Object class // then we can subclass in the Java class hierarchy. - if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) { + // For instances when a subclass meets a superclass we fall + // below the centerline when the superclass is exact. We need + // to do the same here. + if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { // that is, my array type is a subtype of 'tp' klass - return make( ptr, (ptr == Constant ? const_oop() : NULL), - _ary, _klass, _klass_is_exact, offset, instance_id ); + return make(ptr, (ptr == Constant ? const_oop() : NULL), + _ary, _klass, _klass_is_exact, offset, instance_id, speculative); } } // The other case cannot happen, since t cannot be a subtype of an array. @@ -3733,7 +3912,7 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { if( ptr == Constant ) ptr = NotNull; instance_id = InstanceBot; - return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id); + return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); default: typerr(t); } } @@ -3744,7 +3923,7 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const { //------------------------------xdual------------------------------------------ // Dual: compute field-by-field dual const Type *TypeAryPtr::xdual() const { - return new TypeAryPtr( dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache() ); + return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative()); } //----------------------interface_vs_oop--------------------------------------- @@ -3796,6 +3975,8 @@ void TypeAryPtr::dump2( Dict &d, uint depth, outputStream *st ) const { st->print(",iid=top"); else if (_instance_id != InstanceBot) st->print(",iid=%d",_instance_id); + + dump_speculative(st); } #endif @@ -3805,10 +3986,13 @@ bool TypeAryPtr::empty(void) const { } //------------------------------add_offset------------------------------------- -const TypePtr *TypeAryPtr::add_offset( intptr_t offset ) const { - return make( _ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id ); +const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const { + return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); } +const TypeOopPtr *TypeAryPtr::remove_speculative() const { + return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, _offset, _instance_id, NULL); +} //============================================================================= @@ -4189,6 +4373,33 @@ bool TypeKlassPtr::singleton(void) const { return (_offset == 0) && !below_centerline(_ptr); } +// Do not allow interface-vs.-noninterface joins to collapse to top. +const Type *TypeKlassPtr::filter(const Type *kills) const { + // logic here mirrors the one from TypeOopPtr::filter. See comments + // there. + const Type* ft = join(kills); + const TypeKlassPtr* ftkp = ft->isa_klassptr(); + const TypeKlassPtr* ktkp = kills->isa_klassptr(); + + if (ft->empty()) { + if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface()) + return kills; // Uplift to interface + + return Type::TOP; // Canonical empty value + } + + // Interface klass type could be exact in opposite to interface type, + // return it here instead of incorrect Constant ptr J/L/Object (6894807). + if (ftkp != NULL && ktkp != NULL && + ftkp->is_loaded() && ftkp->klass()->is_interface() && + !ftkp->klass_is_exact() && // Keep exact interface klass + ktkp->is_loaded() && !ktkp->klass()->is_interface()) { + return ktkp->cast_to_ptr_type(ftkp->ptr()); + } + + return ft; +} + //----------------------compute_klass------------------------------------------ // Compute the defining klass for this class ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const { diff --git a/hotspot/src/share/vm/opto/type.hpp b/hotspot/src/share/vm/opto/type.hpp index 2d7637bb5c7..9810edfe724 100644 --- a/hotspot/src/share/vm/opto/type.hpp +++ b/hotspot/src/share/vm/opto/type.hpp @@ -63,7 +63,7 @@ class TypeRawPtr; class TypeOopPtr; class TypeInstPtr; class TypeAryPtr; -class TypeKlassPtr; +class TypeKlassPtr; class TypeMetadataPtr; //------------------------------Type------------------------------------------- @@ -159,6 +159,11 @@ private: // Table for efficient dualing of base types static const TYPES dual_type[lastype]; +#ifdef ASSERT + // One type is interface, the other is oop + virtual bool interface_vs_oop_helper(const Type *t) const; +#endif + protected: // Each class of type is also identified by its base. const TYPES _base; // Enum of Types type @@ -376,6 +381,9 @@ public: bool require_constant = false, bool is_autobox_cache = false); + // Speculative type. See TypeInstPtr + virtual ciKlass* speculative_type() const { return NULL; } + private: // support arrays static const BasicType _basic_type[]; @@ -585,6 +593,7 @@ public: static const TypeTuple *INT_PAIR; static const TypeTuple *LONG_PAIR; static const TypeTuple *INT_CC_PAIR; + static const TypeTuple *LONG_CC_PAIR; #ifndef PRODUCT virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping #endif @@ -784,7 +793,7 @@ public: // Some kind of oop (Java pointer), either klass or instance or array. class TypeOopPtr : public TypePtr { protected: - TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ); + TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative); public: virtual bool eq( const Type *t ) const; virtual int hash() const; // Type specific hashing @@ -810,11 +819,27 @@ protected: // This is the the node index of the allocation node creating this instance. int _instance_id; + // Extra type information profiling gave us. We propagate it the + // same way the rest of the type info is propagated. If we want to + // use it, then we have to emit a guard: this part of the type is + // not something we know but something we speculate about the type. + const TypeOopPtr* _speculative; + static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact); int dual_instance_id() const; int meet_instance_id(int uid) const; + // utility methods to work on the speculative part of the type + const TypeOopPtr* dual_speculative() const; + const TypeOopPtr* meet_speculative(const TypeOopPtr* other) const; + bool eq_speculative(const TypeOopPtr* other) const; + int hash_speculative() const; + const TypeOopPtr* add_offset_speculative(intptr_t offset) const; +#ifndef PRODUCT + void dump_speculative(outputStream *st) const; +#endif + public: // Creates a type given a klass. Correctly handles multi-dimensional arrays // Respects UseUniqueSubclasses. @@ -841,7 +866,7 @@ public: bool not_null_elements = false); // Make a generic (unclassed) pointer to an oop. - static const TypeOopPtr* make(PTR ptr, int offset, int instance_id); + static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative); ciObject* const_oop() const { return _const_oop; } virtual ciKlass* klass() const { return _klass; } @@ -855,6 +880,7 @@ public: bool is_known_instance() const { return _instance_id > 0; } int instance_id() const { return _instance_id; } bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; } + const TypeOopPtr* speculative() const { return _speculative; } virtual intptr_t get_con() const; @@ -868,9 +894,13 @@ public: const TypeKlassPtr* as_klass_type() const; virtual const TypePtr *add_offset( intptr_t offset ) const; + // Return same type without a speculative part + virtual const TypeOopPtr* remove_speculative() const; - virtual const Type *xmeet( const Type *t ) const; + virtual const Type *xmeet(const Type *t) const; virtual const Type *xdual() const; // Compute dual right now. + // the core of the computation of the meet for TypeOopPtr and for its subclasses + virtual const Type *xmeet_helper(const Type *t) const; // Do not allow interface-vs.-noninterface joins to collapse to top. virtual const Type *filter( const Type *kills ) const; @@ -880,13 +910,24 @@ public: #ifndef PRODUCT virtual void dump2( Dict &d, uint depth, outputStream *st ) const; #endif + + // Return the speculative type if any + ciKlass* speculative_type() const { + if (_speculative != NULL) { + const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr(); + if (speculative->klass_is_exact()) { + return speculative->klass(); + } + } + return NULL; + } }; //------------------------------TypeInstPtr------------------------------------ // Class of Java object pointers, pointing either to non-array Java instances // or to a Klass* (including array klasses). class TypeInstPtr : public TypeOopPtr { - TypeInstPtr( PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ); + TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative); virtual bool eq( const Type *t ) const; virtual int hash() const; // Type specific hashing @@ -899,30 +940,30 @@ class TypeInstPtr : public TypeOopPtr { // Make a pointer to a constant oop. static const TypeInstPtr *make(ciObject* o) { - return make(TypePtr::Constant, o->klass(), true, o, 0); + return make(TypePtr::Constant, o->klass(), true, o, 0, InstanceBot); } // Make a pointer to a constant oop with offset. static const TypeInstPtr *make(ciObject* o, int offset) { - return make(TypePtr::Constant, o->klass(), true, o, offset); + return make(TypePtr::Constant, o->klass(), true, o, offset, InstanceBot); } // Make a pointer to some value of type klass. static const TypeInstPtr *make(PTR ptr, ciKlass* klass) { - return make(ptr, klass, false, NULL, 0); + return make(ptr, klass, false, NULL, 0, InstanceBot); } // Make a pointer to some non-polymorphic value of exactly type klass. static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) { - return make(ptr, klass, true, NULL, 0); + return make(ptr, klass, true, NULL, 0, InstanceBot); } // Make a pointer to some value of type klass with offset. static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) { - return make(ptr, klass, false, NULL, offset); + return make(ptr, klass, false, NULL, offset, InstanceBot); } // Make a pointer to an oop. - static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot ); + static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL); /** Create constant type for a constant boxed value */ const Type* get_const_boxed_value() const; @@ -939,8 +980,11 @@ class TypeInstPtr : public TypeOopPtr { virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; virtual const TypePtr *add_offset( intptr_t offset ) const; + // Return same type without a speculative part + virtual const TypeOopPtr* remove_speculative() const; - virtual const Type *xmeet( const Type *t ) const; + // the core of the computation of the meet of 2 types + virtual const Type *xmeet_helper(const Type *t) const; virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; virtual const Type *xdual() const; // Compute dual right now. @@ -959,8 +1003,8 @@ class TypeInstPtr : public TypeOopPtr { // Class of Java array pointers class TypeAryPtr : public TypeOopPtr { TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, - int offset, int instance_id, bool is_autobox_cache ) - : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id), + int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative) + : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative), _ary(ary), _is_autobox_cache(is_autobox_cache) { @@ -998,9 +1042,9 @@ public: bool is_autobox_cache() const { return _is_autobox_cache; } - static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot); + static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL); // Constant pointer to array - static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, bool is_autobox_cache = false); + static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, bool is_autobox_cache = false); // Return a 'ptr' version of this type virtual const Type *cast_to_ptr_type(PTR ptr) const; @@ -1014,8 +1058,11 @@ public: virtual bool empty(void) const; // TRUE if type is vacuous virtual const TypePtr *add_offset( intptr_t offset ) const; + // Return same type without a speculative part + virtual const TypeOopPtr* remove_speculative() const; - virtual const Type *xmeet( const Type *t ) const; + // the core of the computation of the meet of 2 types + virtual const Type *xmeet_helper(const Type *t) const; virtual const Type *xdual() const; // Compute dual right now. const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const; @@ -1155,6 +1202,9 @@ public: virtual intptr_t get_con() const; + // Do not allow interface-vs.-noninterface joins to collapse to top. + virtual const Type *filter( const Type *kills ) const; + // Convenience common pre-built types. static const TypeKlassPtr* OBJECT; // Not-null object klass or below static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index b5c271897e4..ab24446baf1 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -5060,6 +5060,7 @@ void TestReserveMemorySpecial_test(); void TestVirtualSpace_test(); void TestMetaspaceAux_test(); void TestMetachunk_test(); +void TestVirtualSpaceNode_test(); #if INCLUDE_ALL_GCS void TestG1BiasedArray_test(); #endif @@ -5072,6 +5073,7 @@ void execute_internal_vm_tests() { run_unit_test(TestVirtualSpace_test()); run_unit_test(TestMetaspaceAux_test()); run_unit_test(TestMetachunk_test()); + run_unit_test(TestVirtualSpaceNode_test()); run_unit_test(GlobalDefinitions::test_globals()); run_unit_test(GCTimerAllTest::all()); run_unit_test(arrayOopDesc::test_max_array_length()); diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp index f24c80f4339..318fe4e0b7e 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp @@ -259,8 +259,7 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) { // bytes to the InstanceKlass here because they have not been // validated and we're not at a safepoint. constantPoolHandle constants(current_thread, ikh->constants()); - oop cplock = constants->lock(); - ObjectLocker ol(cplock, current_thread, cplock != NULL); // lock constant pool while we query it + MonitorLockerEx ml(constants->lock()); // lock constant pool while we query it JvmtiClassFileReconstituter reconstituter(ikh); if (reconstituter.get_error() != JVMTI_ERROR_NONE) { @@ -2418,8 +2417,7 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con instanceKlassHandle ikh(thread, k_oop); constantPoolHandle constants(thread, ikh->constants()); - oop cplock = constants->lock(); - ObjectLocker ol(cplock, thread, cplock != NULL); // lock constant pool while we query it + MonitorLockerEx ml(constants->lock()); // lock constant pool while we query it JvmtiConstantPoolReconstituter reconstituter(ikh); if (reconstituter.get_error() != JVMTI_ERROR_NONE) { diff --git a/hotspot/src/share/vm/prims/jvmtiGetLoadedClasses.cpp b/hotspot/src/share/vm/prims/jvmtiGetLoadedClasses.cpp index 51cfb384ac9..f58a5a3d532 100644 --- a/hotspot/src/share/vm/prims/jvmtiGetLoadedClasses.cpp +++ b/hotspot/src/share/vm/prims/jvmtiGetLoadedClasses.cpp @@ -29,8 +29,43 @@ #include "runtime/thread.hpp" +// The closure for GetLoadedClasses +class LoadedClassesClosure : public KlassClosure { +private: + Stack _classStack; + JvmtiEnv* _env; -// The closure for GetLoadedClasses and GetClassLoaderClasses +public: + LoadedClassesClosure(JvmtiEnv* env) { + _env = env; + } + + void do_klass(Klass* k) { + // Collect all jclasses + _classStack.push((jclass) _env->jni_reference(k->java_mirror())); + } + + int extract(jclass* result_list) { + // The size of the Stack will be 0 after extract, so get it here + int count = (int)_classStack.size(); + int i = count; + + // Pop all jclasses, fill backwards + while (!_classStack.is_empty()) { + result_list[--i] = _classStack.pop(); + } + + // Return the number of elements written + return count; + } + + // Return current size of the Stack + int get_count() { + return (int)_classStack.size(); + } +}; + +// The closure for GetClassLoaderClasses class JvmtiGetLoadedClassesClosure : public StackObj { // Since the SystemDictionary::classes_do callback // doesn't pass a closureData pointer, @@ -165,19 +200,6 @@ class JvmtiGetLoadedClassesClosure : public StackObj { } } - // Finally, the static methods that are the callbacks - static void increment(Klass* k) { - JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); - if (that->get_initiatingLoader() == NULL) { - for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) { - that->set_count(that->get_count() + 1); - } - } else if (k != NULL) { - // if initiating loader not null, just include the instance with 1 dimension - that->set_count(that->get_count() + 1); - } - } - static void increment_with_loader(Klass* k, ClassLoaderData* loader_data) { JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); oop class_loader = loader_data->class_loader(); @@ -196,24 +218,6 @@ class JvmtiGetLoadedClassesClosure : public StackObj { } } - static void add(Klass* k) { - JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); - if (that->available()) { - if (that->get_initiatingLoader() == NULL) { - for (Klass* l = k; l != NULL; l = l->array_klass_or_null()) { - oop mirror = l->java_mirror(); - that->set_element(that->get_index(), mirror); - that->set_index(that->get_index() + 1); - } - } else if (k != NULL) { - // if initiating loader not null, just include the instance with 1 dimension - oop mirror = k->java_mirror(); - that->set_element(that->get_index(), mirror); - that->set_index(that->get_index() + 1); - } - } - } - static void add_with_loader(Klass* k, ClassLoaderData* loader_data) { JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); if (that->available()) { @@ -255,39 +259,30 @@ class JvmtiGetLoadedClassesClosure : public StackObj { jvmtiError JvmtiGetLoadedClasses::getLoadedClasses(JvmtiEnv *env, jint* classCountPtr, jclass** classesPtr) { - // Since SystemDictionary::classes_do only takes a function pointer - // and doesn't call back with a closure data pointer, - // we can only pass static methods. - JvmtiGetLoadedClassesClosure closure; + LoadedClassesClosure closure(env); { // To get a consistent list of classes we need MultiArray_lock to ensure - // array classes aren't created, and SystemDictionary_lock to ensure that - // classes aren't added to the system dictionary, + // array classes aren't created. MutexLocker ma(MultiArray_lock); - MutexLocker sd(SystemDictionary_lock); - // First, count the classes - SystemDictionary::classes_do(&JvmtiGetLoadedClassesClosure::increment); - Universe::basic_type_classes_do(&JvmtiGetLoadedClassesClosure::increment); - // Next, fill in the classes - closure.allocate(); - SystemDictionary::classes_do(&JvmtiGetLoadedClassesClosure::add); - Universe::basic_type_classes_do(&JvmtiGetLoadedClassesClosure::add); - // Drop the SystemDictionary_lock, so the results could be wrong from here, - // but we still have a snapshot. + // Iterate through all classes in ClassLoaderDataGraph + // and collect them using the LoadedClassesClosure + ClassLoaderDataGraph::loaded_classes_do(&closure); } - // Post results + + // Return results by extracting the collected contents into a list + // allocated via JvmtiEnv jclass* result_list; - jvmtiError err = env->Allocate(closure.get_count() * sizeof(jclass), - (unsigned char**)&result_list); - if (err != JVMTI_ERROR_NONE) { - return err; + jvmtiError error = env->Allocate(closure.get_count() * sizeof(jclass), + (unsigned char**)&result_list); + + if (error == JVMTI_ERROR_NONE) { + int count = closure.extract(result_list); + *classCountPtr = count; + *classesPtr = result_list; } - closure.extract(env, result_list); - *classCountPtr = closure.get_count(); - *classesPtr = result_list; - return JVMTI_ERROR_NONE; + return error; } jvmtiError diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.cpp b/hotspot/src/share/vm/prims/jvmtiImpl.cpp index 0fcd1ba94ed..5d560f56a2d 100644 --- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp +++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp @@ -225,18 +225,20 @@ JvmtiBreakpoint::JvmtiBreakpoint() { _method = NULL; _bci = 0; _class_loader = NULL; -#ifdef CHECK_UNHANDLED_OOPS - // This one is always allocated with new, but check it just in case. - Thread *thread = Thread::current(); - if (thread->is_in_stack((address)&_method)) { - thread->allow_unhandled_oop((oop*)&_method); - } -#endif // CHECK_UNHANDLED_OOPS } JvmtiBreakpoint::JvmtiBreakpoint(Method* m_method, jlocation location) { _method = m_method; _class_loader = _method->method_holder()->class_loader_data()->class_loader(); +#ifdef CHECK_UNHANDLED_OOPS + // _class_loader can't be wrapped in a Handle, because JvmtiBreakpoint:s are + // eventually allocated on the heap. + // + // The code handling JvmtiBreakpoint:s allocated on the stack can't be + // interrupted by a GC until _class_loader is reachable by the GC via the + // oops_do method. + Thread::current()->allow_unhandled_oop(&_class_loader); +#endif // CHECK_UNHANDLED_OOPS assert(_method != NULL, "_method != NULL"); _bci = (int) location; assert(_bci >= 0, "_bci >= 0"); diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp index 7faaebbac16..94b5537a6a5 100644 --- a/hotspot/src/share/vm/prims/methodHandles.cpp +++ b/hotspot/src/share/vm/prims/methodHandles.cpp @@ -1194,9 +1194,7 @@ JVM_ENTRY(jobject, MHN_getMemberVMInfo(JNIEnv *env, jobject igcls, jobject mname } else if (vmtarget->is_klass()) { x = ((Klass*) vmtarget)->java_mirror(); } else if (vmtarget->is_method()) { - Handle mname2 = MethodHandles::new_MemberName(CHECK_NULL); - CallInfo info((Method*)vmtarget); - x = MethodHandles::init_method_MemberName(mname2, info); + x = mname(); } result->obj_at_put(1, x); return JNIHandles::make_local(env, result()); diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index d1217b0ba93..8060dae0377 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1957,12 +1957,6 @@ bool Arguments::check_gc_consistency() { "please refer to the release notes for the combinations " "allowed\n"); status = false; - } else if (ReservedCodeCacheSize > 2*G) { - // Code cache size larger than MAXINT is not supported. - jio_fprintf(defaultStream::error_stream(), - "Invalid ReservedCodeCacheSize=%dM. Must be at most %uM.\n", ReservedCodeCacheSize/M, - (2*G)/M); - status = false; } return status; } @@ -1994,6 +1988,15 @@ void Arguments::check_deprecated_gc_flags() { warning("DefaultMaxRAMFraction is deprecated and will likely be removed in a future release. " "Use MaxRAMFraction instead."); } + if (FLAG_IS_CMDLINE(UseCMSCompactAtFullCollection)) { + warning("UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release."); + } + if (FLAG_IS_CMDLINE(CMSFullGCsBeforeCompaction)) { + warning("CMSFullGCsBeforeCompaction is deprecated and will likely be removed in a future release."); + } + if (FLAG_IS_CMDLINE(UseCMSCollectionPassing)) { + warning("UseCMSCollectionPassing is deprecated and will likely be removed in a future release."); + } } // Check stack pages settings @@ -3721,6 +3724,18 @@ jint Arguments::apply_ergo() { // incremental inlining: bump MaxNodeLimit FLAG_SET_DEFAULT(MaxNodeLimit, (intx)75000); } + if (!UseTypeSpeculation && FLAG_IS_DEFAULT(TypeProfileLevel)) { + // nothing to use the profiling, turn if off + FLAG_SET_DEFAULT(TypeProfileLevel, 0); + } + if (UseTypeSpeculation && FLAG_IS_DEFAULT(ReplaceInParentMaps)) { + // Doing the replace in parent maps helps speculation + FLAG_SET_DEFAULT(ReplaceInParentMaps, true); + } +#ifndef X86 + // Only on x86 for now + FLAG_SET_DEFAULT(TypeProfileLevel, 0); +#endif #endif if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) { diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 9e821652943..2fe5420be39 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -2671,13 +2671,18 @@ class CommandLineFlags { "Enable aggressive optimizations - see arguments.cpp") \ \ product_pd(uintx, TypeProfileLevel, \ - "=XY, with Y, Type profiling of arguments at call" \ - " X, Type profiling of return value at call" \ - "X and Y in 0->off ; 1->js292 only; 2->all methods") \ + "=XYZ, with Z: Type profiling of arguments at call; " \ + "Y: Type profiling of return value at call; " \ + "X: Type profiling of parameters to methods; " \ + "X, Y and Z in 0=off ; 1=jsr292 only; 2=all methods") \ \ product(intx, TypeProfileArgsLimit, 2, \ "max number of call arguments to consider for type profiling") \ \ + product(intx, TypeProfileParmsLimit, 2, \ + "max number of incoming parameters to consider for type profiling"\ + ", -1 for all") \ + \ /* statistics */ \ develop(bool, CountCompiledCalls, false, \ "Count method invocations") \ diff --git a/hotspot/src/share/vm/runtime/handles.cpp b/hotspot/src/share/vm/runtime/handles.cpp index 1b4e9faecf9..ca73f86ba7f 100644 --- a/hotspot/src/share/vm/runtime/handles.cpp +++ b/hotspot/src/share/vm/runtime/handles.cpp @@ -45,7 +45,7 @@ oop* HandleArea::allocate_handle(oop obj) { assert(_handle_mark_nesting > 1, "memory leak: allocating handle outside HandleMark"); assert(_no_handle_mark_nesting == 0, "allocating handle inside NoHandleMark"); - assert(obj->is_oop(), "sanity check"); + assert(obj->is_oop(), err_msg("not an oop: " INTPTR_FORMAT, (intptr_t*) obj)); return real_allocate_handle(obj); } diff --git a/hotspot/src/share/vm/runtime/java.cpp b/hotspot/src/share/vm/runtime/java.cpp index e33e935fb6f..a356157e4f9 100644 --- a/hotspot/src/share/vm/runtime/java.cpp +++ b/hotspot/src/share/vm/runtime/java.cpp @@ -193,6 +193,11 @@ void print_method_profiling_data() { m->print_invocation_count(); tty->print_cr(" mdo size: %d bytes", m->method_data()->size_in_bytes()); tty->cr(); + // Dump data on parameters if any + if (m->method_data() != NULL && m->method_data()->parameters_type_data() != NULL) { + tty->fill_to(2); + m->method_data()->parameters_type_data()->print_data_on(tty); + } m->print_codes(); total_size += m->method_data()->size_in_bytes(); } diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index f645be31d80..9f31c25b7c6 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -1097,7 +1097,7 @@ static const char* get_java_runtime_version(TRAPS) { // General purpose hook into Java code, run once when the VM is initialized. // The Java library method itself may be changed independently from the VM. static void call_postVMInitHook(TRAPS) { - Klass* k = SystemDictionary::PostVMInitHook_klass(); + Klass* k = SystemDictionary::resolve_or_null(vmSymbols::sun_misc_PostVMInitHook(), THREAD); instanceKlassHandle klass (THREAD, k); if (klass.not_null()) { JavaValue result(T_VOID); diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index ba70ec1933a..0897c25183b 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -1464,6 +1464,7 @@ typedef BinaryTreeDictionary MetablockTreeDictionary; declare_toplevel_type(CheckedExceptionElement) \ declare_toplevel_type(LocalVariableTableElement) \ declare_toplevel_type(ExceptionTableElement) \ + declare_toplevel_type(MethodParametersElement) \ \ declare_toplevel_type(ClassLoaderData) \ declare_toplevel_type(ClassLoaderDataGraph) \ @@ -1938,7 +1939,13 @@ typedef BinaryTreeDictionary MetablockTreeDictionary; declare_c2_type(CmpDNode, CmpNode) \ declare_c2_type(CmpD3Node, CmpDNode) \ declare_c2_type(MathExactNode, MultiNode) \ - declare_c2_type(AddExactINode, MathExactNode) \ + declare_c2_type(MathExactINode, MathExactNode) \ + declare_c2_type(AddExactINode, MathExactINode) \ + declare_c2_type(AddExactLNode, MathExactLNode) \ + declare_c2_type(SubExactINode, MathExactINode) \ + declare_c2_type(SubExactLNode, MathExactLNode) \ + declare_c2_type(NegExactINode, MathExactINode) \ + declare_c2_type(MulExactINode, MathExactINode) \ declare_c2_type(FlagsProjNode, ProjNode) \ declare_c2_type(BoolNode, Node) \ declare_c2_type(AbsNode, Node) \ @@ -2336,6 +2343,7 @@ typedef BinaryTreeDictionary MetablockTreeDictionary; declare_constant(ConstMethod::_has_localvariable_table) \ declare_constant(ConstMethod::_has_exception_table) \ declare_constant(ConstMethod::_has_generic_signature) \ + declare_constant(ConstMethod::_has_method_parameters) \ declare_constant(ConstMethod::_has_method_annotations) \ declare_constant(ConstMethod::_has_parameter_annotations) \ declare_constant(ConstMethod::_has_default_annotations) \ diff --git a/hotspot/src/share/vm/services/diagnosticCommand.cpp b/hotspot/src/share/vm/services/diagnosticCommand.cpp index 162010e425e..71b552801aa 100644 --- a/hotspot/src/share/vm/services/diagnosticCommand.cpp +++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp @@ -505,7 +505,11 @@ JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated _jdp_pause ("jdp.pause", - "set com.sun.management.jdp.pause", "INT", false) + "set com.sun.management.jdp.pause", "INT", false), + + _jdp_name + ("jdp.name", + "set com.sun.management.jdp.name", "STRING", false) { _dcmdparser.add_dcmd_option(&_config_file); @@ -527,6 +531,7 @@ JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated _dcmdparser.add_dcmd_option(&_jdp_source_addr); _dcmdparser.add_dcmd_option(&_jdp_ttl); _dcmdparser.add_dcmd_option(&_jdp_pause); + _dcmdparser.add_dcmd_option(&_jdp_name); } @@ -596,6 +601,7 @@ void JMXStartRemoteDCmd::execute(DCmdSource source, TRAPS) { PUT_OPTION(_jdp_source_addr); PUT_OPTION(_jdp_ttl); PUT_OPTION(_jdp_pause); + PUT_OPTION(_jdp_name); #undef PUT_OPTION diff --git a/hotspot/src/share/vm/services/diagnosticCommand.hpp b/hotspot/src/share/vm/services/diagnosticCommand.hpp index 9c7216177bf..5485b119dec 100644 --- a/hotspot/src/share/vm/services/diagnosticCommand.hpp +++ b/hotspot/src/share/vm/services/diagnosticCommand.hpp @@ -302,6 +302,7 @@ class JMXStartRemoteDCmd : public DCmdWithParser { DCmdArgument _jdp_source_addr; DCmdArgument _jdp_ttl; DCmdArgument _jdp_pause; + DCmdArgument _jdp_name; public: JMXStartRemoteDCmd(outputStream *output, bool heap_allocated); diff --git a/hotspot/src/share/vm/services/jmm.h b/hotspot/src/share/vm/services/jmm.h index 9f46499b4e8..e0a748a41d5 100644 --- a/hotspot/src/share/vm/services/jmm.h +++ b/hotspot/src/share/vm/services/jmm.h @@ -78,6 +78,7 @@ typedef enum { JMM_COMPILE_TOTAL_TIME_MS = 8, /* Total accumulated time spent in compilation */ JMM_GC_TIME_MS = 9, /* Total accumulated time spent in collection */ JMM_GC_COUNT = 10, /* Total number of collections */ + JMM_JVM_UPTIME_MS = 11, /* The JVM uptime in milliseconds */ JMM_INTERNAL_ATTRIBUTE_INDEX = 100, JMM_CLASS_LOADED_BYTES = 101, /* Number of bytes loaded instance classes */ diff --git a/hotspot/src/share/vm/services/management.cpp b/hotspot/src/share/vm/services/management.cpp index 9c87989601b..9585960daa2 100644 --- a/hotspot/src/share/vm/services/management.cpp +++ b/hotspot/src/share/vm/services/management.cpp @@ -1032,6 +1032,9 @@ static jlong get_long_attribute(jmmLongAttribute att) { case JMM_JVM_INIT_DONE_TIME_MS: return Management::vm_init_done_time(); + case JMM_JVM_UPTIME_MS: + return Management::ticks_to_ms(os::elapsed_counter()); + case JMM_COMPILE_TOTAL_TIME_MS: return Management::ticks_to_ms(CompileBroker::total_compilation_ticks()); diff --git a/hotspot/src/share/vm/trace/traceEventClasses.xsl b/hotspot/src/share/vm/trace/traceEventClasses.xsl index 70ac9c03759..d9d2cf276ed 100644 --- a/hotspot/src/share/vm/trace/traceEventClasses.xsl +++ b/hotspot/src/share/vm/trace/traceEventClasses.xsl @@ -23,8 +23,8 @@ --> - + diff --git a/hotspot/src/share/vm/trace/traceEventIds.xsl b/hotspot/src/share/vm/trace/traceEventIds.xsl index 737377cadd7..6a7e95474c0 100644 --- a/hotspot/src/share/vm/trace/traceEventIds.xsl +++ b/hotspot/src/share/vm/trace/traceEventIds.xsl @@ -23,8 +23,8 @@ --> - + diff --git a/hotspot/src/share/vm/trace/traceTypes.xsl b/hotspot/src/share/vm/trace/traceTypes.xsl index b06b604cedd..278720d1c1a 100644 --- a/hotspot/src/share/vm/trace/traceTypes.xsl +++ b/hotspot/src/share/vm/trace/traceTypes.xsl @@ -23,8 +23,8 @@ --> - + diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp index 06a32dc9037..7806cdc0811 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp @@ -368,8 +368,6 @@ const int KlassAlignment = KlassAlignmentInBytes / HeapWordSize; // Klass encoding metaspace max size const uint64_t KlassEncodingMetaspaceMax = (uint64_t(max_juint) + 1) << LogKlassAlignmentInBytes; -const jlong CompressedKlassPointersBase = NOT_LP64(0) LP64_ONLY(CONST64(0x800000000)); // 32*G - // Machine dependent stuff #ifdef TARGET_ARCH_x86 diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups index 6787bd8f2c4..18fb1d9a157 100644 --- a/hotspot/test/TEST.groups +++ b/hotspot/test/TEST.groups @@ -64,6 +64,7 @@ needs_jdk = \ gc/TestG1ZeroPGCTJcmdThreadPrint.java \ gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java \ gc/metaspace/TestMetaspacePerfCounters.java \ + gc/metaspace/TestPerfCountersAndMemoryPools.java \ runtime/6819213/TestBootNativeLibraryPath.java \ runtime/6925573/SortMethodsTest.java \ runtime/7107135/Test7107135.sh \ @@ -101,7 +102,9 @@ jre = \ needs_jre = \ compiler/6852078/Test6852078.java \ compiler/7047069/Test7047069.java \ - runtime/6294277/SourceDebugExtension.java + runtime/6294277/SourceDebugExtension.java \ + runtime/ClassFile/JsrRewriting.java \ + runtime/ClassFile/OomWhileParsingRepeatedJsr.java # Compact 3 adds further tests to compact2 # diff --git a/hotspot/test/compiler/inlining/InlineDefaultMethod.java b/hotspot/test/compiler/inlining/InlineDefaultMethod.java new file mode 100644 index 00000000000..609eaf217d5 --- /dev/null +++ b/hotspot/test/compiler/inlining/InlineDefaultMethod.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026735 + * @summary CHA in C1 should make correct decisions about default methods + * @run main/othervm -Xcomp -XX:CompileOnly=InlineDefaultMethod::test -XX:TieredStopAtLevel=1 InlineDefaultMethod + */ + + +interface InterfaceWithDefaultMethod0 { + default public int defaultMethod() { + return 1; + } +} + +interface InterfaceWithDefaultMethod1 extends InterfaceWithDefaultMethod0 { } + +abstract class Subtype implements InterfaceWithDefaultMethod1 { } + +class Decoy extends Subtype { + public int defaultMethod() { + return 2; + } +} + +class Instance extends Subtype { } + +public class InlineDefaultMethod { + public static int test(InterfaceWithDefaultMethod1 x) { + return x.defaultMethod(); + } + public static void main(String[] args) { + InterfaceWithDefaultMethod1 a = new Decoy(); + InterfaceWithDefaultMethod1 b = new Instance(); + if (test(a) != 2 || + test(b) != 1) { + System.err.println("FAILED"); + System.exit(97); + } + System.err.println("PASSED"); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/CondTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactICondTest.java similarity index 93% rename from hotspot/test/compiler/intrinsics/mathexact/CondTest.java rename to hotspot/test/compiler/intrinsics/mathexact/AddExactICondTest.java index a6507cf052f..8862160d8b4 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/CondTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactICondTest.java @@ -25,14 +25,12 @@ * @test * @bug 8024924 * @summary Test non constant addExact - * @compile CondTest.java Verify.java - * @run main CondTest + * @compile AddExactICondTest.java + * @run main AddExactICondTest * */ -import java.lang.ArithmeticException; - -public class CondTest { +public class AddExactICondTest { public static int result = 0; public static void main(String[] args) { diff --git a/hotspot/test/compiler/intrinsics/mathexact/ConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java similarity index 69% rename from hotspot/test/compiler/intrinsics/mathexact/ConstantTest.java rename to hotspot/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java index b7bf93f66ec..77000a1d958 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/ConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java @@ -25,23 +25,13 @@ * @test * @bug 8024924 * @summary Test constant addExact - * @compile ConstantTest.java Verify.java - * @run main ConstantTest + * @compile AddExactIConstantTest.java Verify.java + * @run main AddExactIConstantTest * */ -import java.lang.ArithmeticException; - -public class ConstantTest { +public class AddExactIConstantTest { public static void main(String[] args) { - for (int i = 0; i < 50000; ++i) { - Verify.verify(5, 7); - Verify.verify(Integer.MAX_VALUE, 1); - Verify.verify(Integer.MIN_VALUE, -1); - Verify.verify(Integer.MAX_VALUE, -1); - Verify.verify(Integer.MIN_VALUE, 1); - Verify.verify(Integer.MAX_VALUE / 2, Integer.MAX_VALUE / 2); - Verify.verify(Integer.MAX_VALUE / 2, (Integer.MAX_VALUE / 2) + 3); - } + Verify.ConstantTest.verify(new Verify.AddExactI()); } } diff --git a/hotspot/test/compiler/intrinsics/mathexact/NonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactILoadTest.java similarity index 70% rename from hotspot/test/compiler/intrinsics/mathexact/NonConstantTest.java rename to hotspot/test/compiler/intrinsics/mathexact/AddExactILoadTest.java index 78c9f9d99e2..2d96bb8b8a6 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/NonConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactILoadTest.java @@ -25,24 +25,14 @@ * @test * @bug 8024924 * @summary Test non constant addExact - * @compile NonConstantTest.java Verify.java - * @run main NonConstantTest + * @compile AddExactILoadTest.java Verify.java + * @run main AddExactILoadTest * */ -import java.lang.ArithmeticException; - -public class NonConstantTest { - public static java.util.Random rnd = new java.util.Random(); - +public class AddExactILoadTest { public static void main(String[] args) { - for (int i = 0; i < 50000; ++i) { - int rnd1 = rnd.nextInt(), rnd2 = rnd.nextInt(); - Verify.verify(rnd1, rnd2); - Verify.verify(rnd1, rnd2 + 1); - Verify.verify(rnd1 + 1, rnd2); - Verify.verify(rnd1 - 1, rnd2); - Verify.verify(rnd1, rnd2 - 1); - } + Verify.LoadTest.init(); + Verify.LoadTest.verify(new Verify.AddExactI()); } } diff --git a/hotspot/test/compiler/intrinsics/mathexact/LoopDependentTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java similarity index 68% rename from hotspot/test/compiler/intrinsics/mathexact/LoopDependentTest.java rename to hotspot/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java index 17f58921f28..99aae0d7b21 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/LoopDependentTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java @@ -25,24 +25,13 @@ * @test * @bug 8024924 * @summary Test non constant addExact - * @compile LoopDependentTest.java Verify.java - * @run main LoopDependentTest + * @compile AddExactILoopDependentTest.java Verify.java + * @run main AddExactILoopDependentTest * */ -import java.lang.ArithmeticException; - -public class LoopDependentTest { - public static java.util.Random rnd = new java.util.Random(); - +public class AddExactILoopDependentTest { public static void main(String[] args) { - int rnd1 = rnd.nextInt(), rnd2 = rnd.nextInt(); - for (int i = 0; i < 50000; ++i) { - Verify.verify(rnd1 + i, rnd2 + i); - Verify.verify(rnd1 + i, rnd2 + (i & 0xff)); - Verify.verify(rnd1 - i, rnd2 - (i & 0xff)); - Verify.verify(rnd1 + i + 1, rnd2 + i + 2); - Verify.verify(rnd1 + i * 2, rnd2 + i); - } + Verify.LoopDependentTest.verify(new Verify.AddExactI()); } } diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java new file mode 100644 index 00000000000..b3a24758569 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8024924 + * @summary Test non constant addExact + * @compile AddExactINonConstantTest.java Verify.java + * @run main AddExactINonConstantTest + * + */ + +public class AddExactINonConstantTest { + public static void main(String[] args) { + Verify.NonConstantTest.verify(new Verify.AddExactI()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java new file mode 100644 index 00000000000..d111b66ce82 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8025657 + * @summary Test repeating addExact + * @compile AddExactIRepeatTest.java Verify.java + * @run main AddExactIRepeatTest + * + */ + +public class AddExactIRepeatTest { + public static void main(String[] args) { + runTest(new Verify.AddExactI()); + } + + public static int nonExact(int x, int y, Verify.BinaryMethod method) { + int result = method.unchecked(x, y); + result += method.unchecked(x, y); + result += method.unchecked(x, y); + result += method.unchecked(x, y); + return result; + } + + public static void runTest(Verify.BinaryMethod method) { + java.util.Random rnd = new java.util.Random(); + for (int i = 0; i < 50000; ++i) { + int x = Integer.MAX_VALUE - 10; + int y = Integer.MAX_VALUE - 10 + rnd.nextInt(5); + + int c = rnd.nextInt() / 2; + int d = rnd.nextInt() / 2; + + int a = catchingExact(x, y, method); + + if (a != 36) { + throw new RuntimeException("a != 36 : " + a); + } + + int b = nonExact(c, d, method); + int n = exact(c, d, method); + + + if (n != b) { + throw new RuntimeException("n != b : " + n + " != " + b); + } + } + } + + public static int exact(int x, int y, Verify.BinaryMethod method) { + int result = 0; + result += method.checkMethod(x, y); + result += method.checkMethod(x, y); + result += method.checkMethod(x, y); + result += method.checkMethod(x, y); + return result; + } + + public static int catchingExact(int x, int y, Verify.BinaryMethod method) { + int result = 0; + try { + result += 5; + result = method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 1; + } + try { + result += 6; + + result += method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 2; + } + try { + result += 7; + result += method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 3; + } + try { + result += 8; + result += method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 4; + } + return result; + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java new file mode 100644 index 00000000000..dc751406192 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test constant addExact + * @compile AddExactLConstantTest.java Verify.java + * @run main AddExactLConstantTest + * + */ + +public class AddExactLConstantTest { + public static void main(String[] args) { + Verify.ConstantLongTest.verify(new Verify.AddExactL()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java new file mode 100644 index 00000000000..efd5fd7c92b --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test non constant addExact + * @compile AddExactLNonConstantTest.java Verify.java + * @run main AddExactLNonConstantTest + * + */ + +public class AddExactLNonConstantTest { + public static void main(String[] args) { + Verify.NonConstantLongTest.verify(new Verify.AddExactL()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/DecExactITest.java b/hotspot/test/compiler/intrinsics/mathexact/DecExactITest.java new file mode 100644 index 00000000000..7e6e1ca3bde --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/DecExactITest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test decrementExact + * @compile DecExactITest.java Verify.java + * @run main DecExactITest + * + */ + +public class DecExactITest { + public static int[] values = {1, 1, 1, 1}; + public static int[] minvalues = {Integer.MIN_VALUE, Integer.MIN_VALUE}; + + public static void main(String[] args) { + runTest(new Verify.DecExactI()); + } + + public static void runTest(Verify.UnaryMethod method) { + for (int i = 0; i < 20000; ++i) { + Verify.verifyUnary(Integer.MIN_VALUE, method); + Verify.verifyUnary(minvalues[0], method); + Verify.verifyUnary(Integer.MIN_VALUE - values[2], method); + Verify.verifyUnary(0, method); + Verify.verifyUnary(values[2], method); + Verify.verifyUnary(Integer.MAX_VALUE, method); + Verify.verifyUnary(Integer.MIN_VALUE - values[0] + values[3], method); + Verify.verifyUnary(Integer.MIN_VALUE + 1 - values[0], method); + } + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/DecExactLTest.java b/hotspot/test/compiler/intrinsics/mathexact/DecExactLTest.java new file mode 100644 index 00000000000..7dca00b963e --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/DecExactLTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test decrementExact + * @compile DecExactITest.java Verify.java + * @run main DecExactITest + * + */ + +public class DecExactLTest { + public static long[] values = {1, 1, 1, 1}; + public static long[] minvalues = {Long.MIN_VALUE, Long.MIN_VALUE}; + + public static void main(String[] args) { + runTest(new Verify.DecExactL()); + } + + public static void runTest(Verify.UnaryLongMethod method) { + for (int i = 0; i < 20000; ++i) { + Verify.verifyUnary(Long.MIN_VALUE, method); + Verify.verifyUnary(minvalues[0], method); + Verify.verifyUnary(Long.MIN_VALUE - values[2], method); + Verify.verifyUnary(0, method); + Verify.verifyUnary(values[2], method); + Verify.verifyUnary(Long.MAX_VALUE, method); + Verify.verifyUnary(Long.MIN_VALUE - values[0] + values[3], method); + Verify.verifyUnary(Long.MIN_VALUE + 1 - values[0], method); + } + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/IncExactITest.java b/hotspot/test/compiler/intrinsics/mathexact/IncExactITest.java new file mode 100644 index 00000000000..9f7ddbd3211 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/IncExactITest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test incrementExact + * @compile IncExactITest.java Verify.java + * @run main IncExactITest + * + */ + + +public class IncExactITest { + public static int[] values = {1, 1, 1, 1}; + public static void main(String[] args) { + runTest(new Verify.IncExactI()); + } + + public static void runTest(Verify.UnaryMethod method) { + for (int i = 0; i < 20000; ++i) { + Verify.verifyUnary(Integer.MIN_VALUE, method); + Verify.verifyUnary(Integer.MAX_VALUE - 1, method); + Verify.verifyUnary(0, method); + Verify.verifyUnary(values[1], method); + Verify.verifyUnary(Integer.MAX_VALUE, method); + Verify.verifyUnary(Integer.MAX_VALUE - values[0] + values[3], method); + Verify.verifyUnary(Integer.MAX_VALUE - 1 + values[0], method); + } + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/LoadTest.java b/hotspot/test/compiler/intrinsics/mathexact/IncExactLTest.java similarity index 56% rename from hotspot/test/compiler/intrinsics/mathexact/LoadTest.java rename to hotspot/test/compiler/intrinsics/mathexact/IncExactLTest.java index c04180ba634..755d81908ce 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/LoadTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/IncExactLTest.java @@ -23,33 +23,28 @@ /* * @test - * @bug 8024924 - * @summary Test non constant addExact - * @compile LoadTest.java Verify.java - * @run main LoadTest + * @bug 8026844 + * @summary Test incrementExact + * @compile IncExactLTest.java Verify.java + * @run main IncExactLTest * */ -import java.lang.ArithmeticException; - -public class LoadTest { - public static java.util.Random rnd = new java.util.Random(); - public static int[] values = new int[256]; - - public static void main(String[] args) { - for (int i = 0; i < values.length; ++i) { - values[i] = rnd.nextInt(); +public class IncExactLTest { + public static long[] values = {1, 1, 1, 1}; + public static void main(String[] args) { + runTest(new Verify.IncExactL()); } - for (int i = 0; i < 50000; ++i) { - Verify.verify(values[i & 255], values[i & 255] - i); - Verify.verify(values[i & 255] + i, values[i & 255] - i); - Verify.verify(values[i & 255], values[i & 255]); - if ((i & 1) == 1 && i > 5) { - Verify.verify(values[i & 255] + i, values[i & 255] - i); - } else { - Verify.verify(values[i & 255] - i, values[i & 255] + i); - } + public static void runTest(Verify.UnaryLongMethod method) { + for (int i = 0; i < 20000; ++i) { + Verify.verifyUnary(Long.MIN_VALUE, method); + Verify.verifyUnary(Long.MAX_VALUE - 1, method); + Verify.verifyUnary(0, method); + Verify.verifyUnary(values[1], method); + Verify.verifyUnary(Long.MAX_VALUE, method); + Verify.verifyUnary(Long.MAX_VALUE - values[0] + values[3], method); + Verify.verifyUnary(Long.MAX_VALUE - 1 + values[0], method); + } } - } } diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactICondTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactICondTest.java new file mode 100644 index 00000000000..5f3e1e64568 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactICondTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test multiplyExact as condition + * @compile MulExactICondTest.java + * @run main MulExactICondTest + * + */ + +public class MulExactICondTest { + public static int result = 0; + + public static void main(String[] args) { + for (int i = 0; i < 50000; ++i) { + runTest(); + } + } + + public static void runTest() { + int i = 7; + while (java.lang.Math.multiplyExact(i, result) < 89361) { + if ((java.lang.Math.multiplyExact(i, i) & 1) == 1) { + i += 3; + } else if ((i & 5) == 4) { + i += 7; + } else if ((i & 0xf) == 6) { + i += 2; + } else { + i += 1; + } + result += 2; + } + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java new file mode 100644 index 00000000000..120bef5e9b9 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test constant multiplyExact + * @compile MulExactIConstantTest.java Verify.java + * @run main MulExactIConstantTest + * + */ + +public class MulExactIConstantTest { + public static void main(String[] args) { + Verify.ConstantTest.verify(new Verify.MulExactI()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactILoadTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactILoadTest.java new file mode 100644 index 00000000000..36aa3d46230 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactILoadTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test multiplyExact + * @compile MulExactILoadTest.java Verify.java + * @run main MulExactILoadTest + * + */ + +public class MulExactILoadTest { + public static void main(String[] args) { + Verify.LoadTest.init(); + Verify.LoadTest.verify(new Verify.MulExactI()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java new file mode 100644 index 00000000000..5ba4ad3cfc3 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test loop dependent multiplyExact + * @compile MulExactILoopDependentTest.java Verify.java + * @run main MulExactILoopDependentTest + * + */ +public class MulExactILoopDependentTest { + public static void main(String[] args) { + Verify.LoopDependentTest.verify(new Verify.MulExactI()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java new file mode 100644 index 00000000000..e108059885b --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test non constant multiplyExact + * @compile MulExactINonConstantTest.java Verify.java + * @run main MulExactINonConstantTest + * + */ + +public class MulExactINonConstantTest { + public static void main(String[] args) { + Verify.NonConstantTest.verify(new Verify.MulExactI()); + Verify.LoadTest.verify(new Verify.MulExactI()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java new file mode 100644 index 00000000000..dd14ce21ed6 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test repeating multiplyExact + * @compile MulExactIRepeatTest.java Verify.java + * @run main MulExactIRepeatTest + * + */ + +public class MulExactIRepeatTest { + public static void main(String[] args) { + runTest(new Verify.MulExactI()); + } + + public static int nonExact(int x, int y, Verify.BinaryMethod method) { + int result = method.unchecked(x, y); + result += method.unchecked(x, y); + result += method.unchecked(x, y); + result += method.unchecked(x, y); + return result; + } + + public static void runTest(Verify.BinaryMethod method) { + java.util.Random rnd = new java.util.Random(); + for (int i = 0; i < 50000; ++i) { + int x = Integer.MAX_VALUE - 10; + int y = Integer.MAX_VALUE - 10 + rnd.nextInt(5); + + int c = rnd.nextInt() / 10; + int d = rnd.nextInt(9); + + int a = catchingExact(x, y, method); + + if (a != 36) { + throw new RuntimeException("a != 36 : " + a); + } + + int b = nonExact(c, d, method); + int n = exact(c, d, method); + + + if (n != b) { + throw new RuntimeException("n != b : " + n + " != " + b); + } + } + } + + public static int exact(int x, int y, Verify.BinaryMethod method) { + int result = 0; + result += method.checkMethod(x, y); + result += method.checkMethod(x, y); + result += method.checkMethod(x, y); + result += method.checkMethod(x, y); + return result; + } + + public static int catchingExact(int x, int y, Verify.BinaryMethod method) { + int result = 0; + try { + result += 5; + result = method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 1; + } + try { + result += 6; + + result += method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 2; + } + try { + result += 7; + result += method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 3; + } + try { + result += 8; + result += method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 4; + } + return result; + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java new file mode 100644 index 00000000000..c687cc276f2 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test constant mulExact + * @compile MulExactLConstantTest.java Verify.java + * @run main MulExactLConstantTest + * + */ + +public class MulExactLConstantTest { + public static void main(String[] args) { + Verify.ConstantLongTest.verify(new Verify.MulExactL()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java new file mode 100644 index 00000000000..f9d82ed0876 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test non constant mulExact + * @compile MulExactLNonConstantTest.java Verify.java + * @run main MulExactLNonConstantTest + * + */ + +public class MulExactLNonConstantTest { + public static void main(String[] args) { + Verify.NonConstantLongTest.verify(new Verify.MulExactL()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java new file mode 100644 index 00000000000..ba49d778762 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test constant negExact + * @compile NegExactIConstantTest.java Verify.java + * @run main NegExactIConstantTest + * + */ + +public class NegExactIConstantTest { + public static void main(String[] args) { + Verify.ConstantTest.verify(new Verify.UnaryToBinary(new Verify.NegExactI())); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactILoadTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactILoadTest.java new file mode 100644 index 00000000000..371f3aedb6c --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactILoadTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test negExact + * @compile NegExactILoadTest.java Verify.java + * @run main NegExactILoadTest + * + */ + +public class NegExactILoadTest { + public static void main(String[] args) { + Verify.LoadTest.init(); + Verify.LoadTest.verify(new Verify.UnaryToBinary(new Verify.NegExactI())); + } + +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java new file mode 100644 index 00000000000..882f80b91a1 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test negExact loop dependent + * @compile NegExactILoopDependentTest.java Verify.java + * @run main NegExactILoopDependentTest + * + */ +public class NegExactILoopDependentTest { + public static void main(String[] args) { + Verify.LoopDependentTest.verify(new Verify.UnaryToBinary(new Verify.NegExactI())); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java new file mode 100644 index 00000000000..6f044f0d969 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test non constant negExact + * @compile NegExactINonConstantTest.java Verify.java + * @run main NegExactINonConstantTest + * + */ + +public class NegExactINonConstantTest { + public static void main(String[] args) { + Verify.NonConstantTest.verify(new Verify.UnaryToBinary(new Verify.NegExactI())); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java new file mode 100644 index 00000000000..382cd5c5f9e --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test constant negExact + * @compile NegExactLConstantTest.java Verify.java + * @run main NegExactLConstantTest + * + */ + +public class NegExactLConstantTest { + public static void main(String[] args) { + Verify.ConstantLongTest.verify(new Verify.UnaryToBinaryLong(new Verify.NegExactL())); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java new file mode 100644 index 00000000000..0bcad8b2b78 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test constant negExact + * @compile NegExactLNonConstantTest.java Verify.java + * @run main NegExactLNonConstantTest + * + */ + +public class NegExactLNonConstantTest { + public static void main(String[] args) { + Verify.NonConstantLongTest.verify(new Verify.UnaryToBinaryLong(new Verify.NegExactL())); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/NestedMathExactTest.java b/hotspot/test/compiler/intrinsics/mathexact/NestedMathExactTest.java new file mode 100644 index 00000000000..211dc8baff1 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/NestedMathExactTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8027444 + * @summary Test nested loops + * @compile NestedMathExactTest.java + * @run main NestedMathExactTest + * + */ + +public class NestedMathExactTest { + public static final int LIMIT = 100; + public static int[] result = new int[LIMIT]; + public static int value = 17; + + public static void main(String[] args) { + for (int i = 0; i < 100; ++i) { + result[i] = runTest(); + } + } + + public static int runTest() { + int sum = 0; + for (int j = 0; j < 100000; j = Math.addExact(j, 1)) { + sum = 1; + for (int i = 0; i < 5; ++i) { + sum *= value; + } + } + return sum; + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/RepeatTest.java b/hotspot/test/compiler/intrinsics/mathexact/RepeatTest.java deleted file mode 100644 index aaf63de1d0a..00000000000 --- a/hotspot/test/compiler/intrinsics/mathexact/RepeatTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2013, 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. - */ - -/* - * @test - * @bug 8025657 - * @summary Test repeating addExact - * @compile RepeatTest.java - * @run main RepeatTest - * - */ - -import java.lang.ArithmeticException; - -public class RepeatTest { - public static void main(String[] args) { - java.util.Random rnd = new java.util.Random(); - for (int i = 0; i < 50000; ++i) { - int x = Integer.MAX_VALUE - 10; - int y = Integer.MAX_VALUE - 10 + rnd.nextInt(5); //rnd.nextInt() / 2; - - int c = rnd.nextInt() / 2; - int d = rnd.nextInt() / 2; - - int a = addExact(x, y); - - if (a != 36) { - throw new RuntimeException("a != 0 : " + a); - } - - int b = nonExact(c, d); - int n = addExact2(c, d); - - - if (n != b) { - throw new RuntimeException("n != b : " + n + " != " + b); - } - } - } - - public static int addExact2(int x, int y) { - int result = 0; - result += java.lang.Math.addExact(x, y); - result += java.lang.Math.addExact(x, y); - result += java.lang.Math.addExact(x, y); - result += java.lang.Math.addExact(x, y); - return result; - } - - public static int addExact(int x, int y) { - int result = 0; - try { - result += 5; - result = java.lang.Math.addExact(x, y); - } catch (ArithmeticException e) { - result += 1; - } - try { - result += 6; - - result += java.lang.Math.addExact(x, y); - } catch (ArithmeticException e) { - result += 2; - } - try { - result += 7; - result += java.lang.Math.addExact(x, y); - } catch (ArithmeticException e) { - result += 3; - } - try { - result += 8; - result += java.lang.Math.addExact(x, y); - } catch (ArithmeticException e) { - result += 4; - } - return result; - } - - public static int nonExact(int x, int y) { - int result = x + y; - result += x + y; - result += x + y; - result += x + y; - return result; - } -} diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactICondTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactICondTest.java new file mode 100644 index 00000000000..f539bdc7cbe --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactICondTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test subtractExact as condition + * @compile SubExactICondTest.java Verify.java + * @run main SubExactICondTest + * + */ + +public class SubExactICondTest { + public static int result = 0; + + public static void main(String[] args) { + for (int i = 0; i < 50000; ++i) { + runTest(); + } + } + + public static void runTest() { + int i = 7; + while (java.lang.Math.subtractExact(i, result) > -31361) { + if ((java.lang.Math.subtractExact(i, i) & 1) == 1) { + i -= 3; + } else if ((i & 5) == 4) { + i -= 7; + } else if ((i & 0xf) == 6) { + i -= 2; + } else { + i -= 1; + } + result += 2; + } + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java new file mode 100644 index 00000000000..b450bd90b11 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test constant subtractExact + * @compile SubExactIConstantTest.java Verify.java + * @run main SubExactIConstantTest + * + */ + +public class SubExactIConstantTest { + public static void main(String[] args) { + Verify.ConstantTest.verify(new Verify.SubExactI()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactILoadTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactILoadTest.java new file mode 100644 index 00000000000..af2ed018258 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactILoadTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test non constant subtractExact + * @compile SubExactILoadTest.java Verify.java + * @run main SubExactILoadTest + * + */ + +public class SubExactILoadTest { + public static void main(String[] args) { + Verify.LoadTest.init(); + Verify.LoadTest.verify(new Verify.SubExactI()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java new file mode 100644 index 00000000000..67ebcbca321 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test non constant subtractExact + * @compile SubExactILoopDependentTest.java Verify.java + * @run main SubExactILoopDependentTest + * + */ + +public class SubExactILoopDependentTest { + public static void main(String[] args) { + Verify.LoopDependentTest.verify(new Verify.SubExactI()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java new file mode 100644 index 00000000000..b8153810892 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test non constant subtractExact + * @compile SubExactINonConstantTest.java Verify.java + * @run main SubExactINonConstantTest + * + */ + +public class SubExactINonConstantTest { + public static void main(String[] args) { + Verify.NonConstantTest.verify(new Verify.SubExactI()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java new file mode 100644 index 00000000000..3c57f6f3f76 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @summary Test repeating subtractExact + * @compile SubExactIRepeatTest.java Verify.java + * @run main SubExactIRepeatTest + * + */ + +import java.lang.ArithmeticException; + +public class SubExactIRepeatTest { + public static void main(String[] args) { + runTest(new Verify.SubExactI()); + } + + public static int nonExact(int x, int y, Verify.BinaryMethod method) { + int result = method.unchecked(x, y); + result += method.unchecked(x, y); + result += method.unchecked(x, y); + result += method.unchecked(x, y); + return result; + } + + public static void runTest(Verify.BinaryMethod method) { + java.util.Random rnd = new java.util.Random(); + for (int i = 0; i < 50000; ++i) { + int x = Integer.MIN_VALUE + 10; + int y = Integer.MAX_VALUE - 10 + rnd.nextInt(5); + + int c = rnd.nextInt() / 2; + int d = rnd.nextInt() / 2; + + int a = catchingExact(x, y, method); + + if (a != 36) { + throw new RuntimeException("a != 36 : " + a); + } + + int b = nonExact(c, d, method); + int n = exact(c, d, method); + + + if (n != b) { + throw new RuntimeException("n != b : " + n + " != " + b); + } + } + } + + public static int exact(int x, int y, Verify.BinaryMethod method) { + int result = 0; + result += method.checkMethod(x, y); + result += method.checkMethod(x, y); + result += method.checkMethod(x, y); + result += method.checkMethod(x, y); + return result; + } + + public static int catchingExact(int x, int y, Verify.BinaryMethod method) { + int result = 0; + try { + result += 5; + result = method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 1; + } + try { + result += 6; + + result += method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 2; + } + try { + result += 7; + result += method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 3; + } + try { + result += 8; + result += method.checkMethod(x, y); + } catch (ArithmeticException e) { + result += 4; + } + return result; + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java new file mode 100644 index 00000000000..ec554d7662b --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @bug 8027353 + * @summary Test constant subtractExact + * @compile SubExactLConstantTest.java Verify.java + * @run main SubExactLConstantTest + * + */ + +public class SubExactLConstantTest { + public static void main(String[] args) { + Verify.ConstantLongTest.verify(new Verify.SubExactL()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java new file mode 100644 index 00000000000..86ecf20f366 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026844 + * @bug 8027353 + * @summary Test non constant subtractExact + * @compile SubExactLNonConstantTest.java Verify.java + * @run main SubExactLNonConstantTest + * + */ + +public class SubExactLNonConstantTest { + public static void main(String[] args) { + Verify.NonConstantLongTest.verify(new Verify.SubExactL()); + } +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/Verify.java b/hotspot/test/compiler/intrinsics/mathexact/Verify.java index de5a4cc44ef..a4d728bfd6b 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/Verify.java +++ b/hotspot/test/compiler/intrinsics/mathexact/Verify.java @@ -22,47 +22,641 @@ */ public class Verify { - public static String throwWord(boolean threw) { - return (threw ? "threw" : "didn't throw"); - } - - public static void verify(int a, int b) { - boolean exception1 = false, exception2 = false; - int result1 = 0, result2 = 0; - try { - result1 = testIntrinsic(a, b); - } catch (ArithmeticException e) { - exception1 = true; - } - try { - result2 = testNonIntrinsic(a, b); - } catch (ArithmeticException e) { - exception2 = true; + public static String throwWord(boolean threw) { + return (threw ? "threw" : "didn't throw"); } - if (exception1 != exception2) { - throw new RuntimeException("Intrinsic version " + throwWord(exception1) + " exception, NonIntrinsic version " + throwWord(exception2) + " for: " + a + " + " + b); + public static void verifyResult(UnaryMethod method, int result1, int result2, boolean exception1, boolean exception2, int value) { + if (exception1 != exception2) { + throw new RuntimeException("Intrinsic version [" + method.name() + "]" + throwWord(exception1) + " exception, NonIntrinsic version" + throwWord(exception2) + " for: " + value); + } + if (result1 != result2) { + throw new RuntimeException("Intrinsic version [" + method.name() + "] returned: " + result1 + " while NonIntrinsic version returned: " + result2); + } } - if (result1 != result2) { - throw new RuntimeException("Intrinsic version returned: " + a + " while NonIntrinsic version returned: " + b); + + public static void verifyResult(UnaryLongMethod method, long result1, long result2, boolean exception1, boolean exception2, long value) { + if (exception1 != exception2) { + throw new RuntimeException("Intrinsic version [" + method.name() + "]" + throwWord(exception1) + " exception, NonIntrinsic version" + throwWord(exception2) + " for: " + value); + } + if (result1 != result2) { + throw new RuntimeException("Intrinsic version [" + method.name() + "] returned: " + result1 + " while NonIntrinsic version returned: " + result2); + } } - } - public static int testIntrinsic(int a, int b) { - return java.lang.Math.addExact(a, b); - } - - public static int testNonIntrinsic(int a, int b) { - return safeAddExact(a, b); - } - - // Copied java.lang.Math.addExact to avoid intrinsification - public static int safeAddExact(int x, int y) { - int r = x + y; - // HD 2-12 Overflow iff both arguments have the opposite sign of the result - if (((x ^ r) & (y ^ r)) < 0) { - throw new ArithmeticException("integer overflow"); + private static void verifyResult(BinaryMethod method, int result1, int result2, boolean exception1, boolean exception2, int a, int b) { + if (exception1 != exception2) { + throw new RuntimeException("Intrinsic version [" + method.name() + "]" + throwWord(exception1) + " exception, NonIntrinsic version " + throwWord(exception2) + " for: " + a + " + " + b); + } + if (result1 != result2) { + throw new RuntimeException("Intrinsic version [" + method.name() + "] returned: " + result1 + " while NonIntrinsic version returned: " + result2); + } } - return r; - } + + private static void verifyResult(BinaryLongMethod method, long result1, long result2, boolean exception1, boolean exception2, long a, long b) { + if (exception1 != exception2) { + throw new RuntimeException("Intrinsic version [" + method.name() + "]" + throwWord(exception1) + " exception, NonIntrinsic version " + throwWord(exception2) + " for: " + a + " + " + b); + } + if (result1 != result2) { + throw new RuntimeException("Intrinsic version [" + method.name() + "] returned: " + result1 + " while NonIntrinsic version returned: " + result2); + } + } + + + public static void verifyUnary(int a, UnaryMethod method) { + boolean exception1 = false, exception2 = false; + int result1 = 0, result2 = 0; + try { + result1 = method.checkMethod(a); + } catch (ArithmeticException e) { + exception1 = true; + } + try { + result2 = method.safeMethod(a); + } catch (ArithmeticException e) { + exception2 = true; + } + + verifyResult(method, result1, result2, exception1, exception2, a); + } + + public static void verifyUnary(long a, UnaryLongMethod method) { + boolean exception1 = false, exception2 = false; + long result1 = 0, result2 = 0; + try { + result1 = method.checkMethod(a); + } catch (ArithmeticException e) { + exception1 = true; + } + try { + result2 = method.safeMethod(a); + } catch (ArithmeticException e) { + exception2 = true; + } + + verifyResult(method, result1, result2, exception1, exception2, a); + } + + + public static void verifyBinary(int a, int b, BinaryMethod method) { + boolean exception1 = false, exception2 = false; + int result1 = 0, result2 = 0; + try { + result1 = method.checkMethod(a, b); + } catch (ArithmeticException e) { + exception1 = true; + } + try { + result2 = method.safeMethod(a, b); + } catch (ArithmeticException e) { + exception2 = true; + } + + verifyResult(method, result1, result2, exception1, exception2, a, b); + } + + public static void verifyBinary(long a, long b, BinaryLongMethod method) { + boolean exception1 = false, exception2 = false; + long result1 = 0, result2 = 0; + try { + result1 = method.checkMethod(a, b); + } catch (ArithmeticException e) { + exception1 = true; + } + try { + result2 = method.safeMethod(a, b); + } catch (ArithmeticException e) { + exception2 = true; + } + + verifyResult(method, result1, result2, exception1, exception2, a, b); + } + + + public static class LoadTest { + public static java.util.Random rnd = new java.util.Random(); + public static int[] values = new int[256]; + + public static void init() { + for (int i = 0; i < values.length; ++i) { + values[i] = rnd.nextInt(); + } + } + + public static void verify(BinaryMethod method) { + for (int i = 0; i < 50000; ++i) { + Verify.verifyBinary(values[i & 255], values[i & 255] - i, method); + Verify.verifyBinary(values[i & 255] + i, values[i & 255] - i, method); + Verify.verifyBinary(values[i & 255], values[i & 255], method); + if ((i & 1) == 1 && i > 5) { + Verify.verifyBinary(values[i & 255] + i, values[i & 255] - i, method); + } else { + Verify.verifyBinary(values[i & 255] - i, values[i & 255] + i, method); + } + Verify.verifyBinary(values[i & 255], values[(i + 1) & 255], method); + } + } + } + + public static class NonConstantTest { + public static java.util.Random rnd = new java.util.Random(); + + public static void verify(BinaryMethod method) { + for (int i = 0; i < 50000; ++i) { + int rnd1 = rnd.nextInt(), rnd2 = rnd.nextInt(); + Verify.verifyBinary(rnd1, rnd2, method); + Verify.verifyBinary(rnd1, rnd2 + 1, method); + Verify.verifyBinary(rnd1 + 1, rnd2, method); + Verify.verifyBinary(rnd1 - 1, rnd2, method); + Verify.verifyBinary(rnd1, rnd2 - 1, method); + } + } + } + + public static class NonConstantLongTest { + public static long[] values = { Long.MIN_VALUE, Long.MAX_VALUE, 0, Long.MAX_VALUE - 1831 }; + public static java.util.Random rnd = new java.util.Random(); + + public static void verify(BinaryLongMethod method) { + for (int i = 0; i < 50000; ++i) { + long rnd1 = rnd.nextLong(), rnd2 = rnd.nextLong(); + Verify.verifyBinary(rnd1, rnd2, method); + Verify.verifyBinary(rnd1, rnd2 + 1, method); + Verify.verifyBinary(rnd1 + 1, rnd2, method); + Verify.verifyBinary(rnd1 - 1, rnd2, method); + Verify.verifyBinary(rnd1, rnd2 - 1, method); + Verify.verifyBinary(rnd1 + Long.MAX_VALUE - rnd2, rnd2 + 1, method); + Verify.verifyBinary(values[0], values[2], method); + Verify.verifyBinary(values[1], values[2], method); + Verify.verifyBinary(values[3], 74L, method); + } + } + } + + public static class LoopDependentTest { + public static java.util.Random rnd = new java.util.Random(); + + public static void verify(BinaryMethod method) { + int rnd1 = rnd.nextInt(), rnd2 = rnd.nextInt(); + runTest(rnd1, rnd2, method); + } + + private static void runTest(int rnd1, int rnd2, BinaryMethod method) { + for (int i = 0; i < 50000; ++i) { + Verify.verifyBinary(rnd1 + i, rnd2 + i, method); + Verify.verifyBinary(rnd1 + i, rnd2 + (i & 0xff), method); + Verify.verifyBinary(rnd1 - i, rnd2 - (i & 0xff), method); + Verify.verifyBinary(rnd1 + i + 1, rnd2 + i + 2, method); + Verify.verifyBinary(rnd1 + i * 2, rnd2 + i, method); + } + } + } + + public static class ConstantTest { + public static void verify(BinaryMethod method) { + for (int i = 0; i < 50000; ++i) { + Verify.verifyBinary(5, 7, method); + Verify.verifyBinary(Integer.MAX_VALUE, 1, method); + Verify.verifyBinary(Integer.MIN_VALUE, -1, method); + Verify.verifyBinary(Integer.MAX_VALUE, -1, method); + Verify.verifyBinary(Integer.MIN_VALUE, 1, method); + Verify.verifyBinary(Integer.MAX_VALUE / 2, Integer.MAX_VALUE / 2, method); + Verify.verifyBinary(Integer.MAX_VALUE / 2, (Integer.MAX_VALUE / 2) + 3, method); + Verify.verifyBinary(Integer.MAX_VALUE, Integer.MIN_VALUE, method); + } + } + } + + public static class ConstantLongTest { + public static void verify(BinaryLongMethod method) { + for (int i = 0; i < 50000; ++i) { + Verify.verifyBinary(5, 7, method); + Verify.verifyBinary(Long.MAX_VALUE, 1, method); + Verify.verifyBinary(Long.MIN_VALUE, -1, method); + Verify.verifyBinary(Long.MAX_VALUE, -1, method); + Verify.verifyBinary(Long.MIN_VALUE, 1, method); + Verify.verifyBinary(Long.MAX_VALUE / 2, Long.MAX_VALUE / 2, method); + Verify.verifyBinary(Long.MAX_VALUE / 2, (Long.MAX_VALUE / 2) + 3, method); + Verify.verifyBinary(Long.MAX_VALUE, Long.MIN_VALUE, method); + } + } + } + + public static interface BinaryMethod { + int safeMethod(int a, int b); + int checkMethod(int a, int b); + int unchecked(int a, int b); + String name(); + } + + public static interface UnaryMethod { + int safeMethod(int value); + int checkMethod(int value); + int unchecked(int value); + String name(); + } + + public static interface BinaryLongMethod { + long safeMethod(long a, long b); + long checkMethod(long a, long b); + long unchecked(long a, long b); + String name(); + } + + public static interface UnaryLongMethod { + long safeMethod(long value); + long checkMethod(long value); + long unchecked(long value); + String name(); + } + + public static class UnaryToBinary implements BinaryMethod { + private final UnaryMethod method; + public UnaryToBinary(UnaryMethod method) { + this.method = method; + } + + @Override + public int safeMethod(int a, int b) { + return method.safeMethod(a); + } + + @Override + public int checkMethod(int a, int b) { + return method.checkMethod(a); + } + + @Override + public int unchecked(int a, int b) { + return method.unchecked(a); + + } + + @Override + public String name() { + return method.name(); + } + } + + public static class UnaryToBinaryLong implements BinaryLongMethod { + private final UnaryLongMethod method; + public UnaryToBinaryLong(UnaryLongMethod method) { + this.method = method; + } + + @Override + public long safeMethod(long a, long b) { + return method.safeMethod(a); + } + + @Override + public long checkMethod(long a, long b) { + return method.checkMethod(a); + } + + @Override + public long unchecked(long a, long b) { + return method.unchecked(a); + + } + + @Override + public String name() { + return method.name(); + } + } + + + public static class AddExactI implements BinaryMethod { + @Override + public int safeMethod(int x, int y) { + int r = x + y; + // HD 2-12 Overflow iff both arguments have the opposite sign of the result + if (((x ^ r) & (y ^ r)) < 0) { + throw new ArithmeticException("integer overflow"); + } + return r; + + } + + @Override + public int checkMethod(int a, int b) { + return Math.addExact(a, b); + } + + @Override + public String name() { + return "addExact"; + } + + @Override + public int unchecked(int a, int b) { + return a + b; + } + } + + public static class AddExactL implements BinaryLongMethod { + @Override + public long safeMethod(long x, long y) { + long r = x + y; + // HD 2-12 Overflow iff both arguments have the opposite sign of the result + if (((x ^ r) & (y ^ r)) < 0) { + throw new ArithmeticException("integer overflow"); + } + return r; + + } + + @Override + public long checkMethod(long a, long b) { + return Math.addExact(a, b); + } + + @Override + public String name() { + return "addExactLong"; + } + + @Override + public long unchecked(long a, long b) { + return a + b; + } + } + + public static class MulExactI implements BinaryMethod { + @Override + public int safeMethod(int x, int y) { + long r = (long)x * (long)y; + if ((int)r != r) { + throw new ArithmeticException("integer overflow"); + } + return (int)r; + + } + + @Override + public int checkMethod(int a, int b) { + return Math.multiplyExact(a, b); + } + + @Override + public int unchecked(int a, int b) { + return a * b; + } + + @Override + public String name() { + return "multiplyExact"; + } + } + + public static class MulExactL implements BinaryLongMethod { + @Override + public long safeMethod(long x, long y) { + long r = x * y; + long ax = Math.abs(x); + long ay = Math.abs(y); + if (((ax | ay) >>> 31 != 0)) { + // Some bits greater than 2^31 that might cause overflow + // Check the result using the divide operator + // and check for the special case of Long.MIN_VALUE * -1 + if (((y != 0) && (r / y != x)) || + (x == Long.MIN_VALUE && y == -1)) { + throw new ArithmeticException("long overflow"); + } + } + return r; + } + + @Override + public long checkMethod(long a, long b) { + return Math.multiplyExact(a, b); + } + + @Override + public long unchecked(long a, long b) { + return a * b; + } + + @Override + public String name() { + return "multiplyExact"; + } + } + + public static class NegExactL implements UnaryLongMethod { + @Override + public long safeMethod(long a) { + if (a == Long.MIN_VALUE) { + throw new ArithmeticException("long overflow"); + } + + return -a; + + } + + @Override + public long checkMethod(long value) { + return Math.negateExact(value); + } + + @Override + public long unchecked(long value) { + return -value; + } + + @Override + public String name() { + return "negateExactLong"; + } + } + + public static class NegExactI implements UnaryMethod { + @Override + public int safeMethod(int a) { + if (a == Integer.MIN_VALUE) { + throw new ArithmeticException("integer overflow"); + } + + return -a; + + } + + @Override + public int checkMethod(int value) { + return Math.negateExact(value); + } + + @Override + public int unchecked(int value) { + return -value; + } + + @Override + public String name() { + return "negateExact"; + } + } + + public static class SubExactI implements BinaryMethod { + @Override + public int safeMethod(int x, int y) { + int r = x - y; + // HD 2-12 Overflow iff the arguments have different signs and + // the sign of the result is different than the sign of x + if (((x ^ y) & (x ^ r)) < 0) { + throw new ArithmeticException("integer overflow"); + } + return r; + } + + @Override + public int checkMethod(int a, int b) { + return Math.subtractExact(a, b); + } + + @Override + public int unchecked(int a, int b) { + return a - b; + } + + @Override + public String name() { + return "subtractExact"; + } + } + + public static class SubExactL implements BinaryLongMethod { + @Override + public long safeMethod(long x, long y) { + long r = x - y; + // HD 2-12 Overflow iff the arguments have different signs and + // the sign of the result is different than the sign of x + if (((x ^ y) & (x ^ r)) < 0) { + throw new ArithmeticException("integer overflow"); + } + return r; + } + + @Override + public long checkMethod(long a, long b) { + return Math.subtractExact(a, b); + } + + @Override + public long unchecked(long a, long b) { + return a - b; + } + + @Override + public String name() { + return "subtractExactLong"; + } + } + + static class IncExactL implements UnaryLongMethod { + @Override + public long safeMethod(long a) { + if (a == Long.MAX_VALUE) { + throw new ArithmeticException("long overflow"); + } + + return a + 1L; + + } + + @Override + public long checkMethod(long value) { + return Math.incrementExact(value); + } + + @Override + public long unchecked(long value) { + return value + 1; + } + + @Override + public String name() { + return "incrementExactLong"; + } + } + + static class IncExactI implements UnaryMethod { + @Override + public int safeMethod(int a) { + if (a == Integer.MAX_VALUE) { + throw new ArithmeticException("integer overflow"); + } + + return a + 1; + } + + @Override + public int checkMethod(int value) { + return Math.incrementExact(value); + } + + @Override + public int unchecked(int value) { + return value + 1; + } + + @Override + public String name() { + return "incrementExact"; + } + } + + static class DecExactL implements UnaryLongMethod { + @Override + public long safeMethod(long a) { + if (a == Long.MIN_VALUE) { + throw new ArithmeticException("long overflow"); + } + + return a - 1L; + } + + @Override + public long checkMethod(long value) { + return Math.decrementExact(value); + } + + @Override + public long unchecked(long value) { + return value - 1; + } + + @Override + public String name() { + return "decExactLong"; + } + } + + static class DecExactI implements UnaryMethod { + @Override + public int safeMethod(int a) { + if (a == Integer.MIN_VALUE) { + throw new ArithmeticException("integer overflow"); + } + + return a - 1; + } + + @Override + public int checkMethod(int value) { + return Math.decrementExact(value); + } + + @Override + public int unchecked(int value) { + return value - 1; + } + + @Override + public String name() { + return "decrementExact"; + } + } + } diff --git a/hotspot/test/compiler/print/PrintInlining.java b/hotspot/test/compiler/print/PrintInlining.java index 877d25e8c38..6aa90333561 100644 --- a/hotspot/test/compiler/print/PrintInlining.java +++ b/hotspot/test/compiler/print/PrintInlining.java @@ -25,7 +25,7 @@ * @test * @bug 8022585 * @summary VM crashes when ran with -XX:+PrintInlining - * @run main/othervm -Xcomp -XX:+PrintInlining PrintInlining + * @run main/othervm -Xcomp -XX:+UnlockDiagnosticVMOptions -XX:+PrintInlining PrintInlining * */ diff --git a/hotspot/test/compiler/startup/StartupOutput.java b/hotspot/test/compiler/startup/StartupOutput.java new file mode 100644 index 00000000000..f677853d51c --- /dev/null +++ b/hotspot/test/compiler/startup/StartupOutput.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026949 + * @summary Test ensures correct VM output during startup + * @library ../../testlibrary + * + */ +import com.oracle.java.testlibrary.*; + +public class StartupOutput { + public static void main(String[] args) throws Exception { + ProcessBuilder pb; + OutputAnalyzer out; + + pb = ProcessTools.createJavaProcessBuilder("-Xint", "-XX:+DisplayVMOutputToStdout", "-version"); + out = new OutputAnalyzer(pb.start()); + out.shouldNotContain("no space to run compilers"); + + out.shouldHaveExitValue(0); + } +} diff --git a/hotspot/test/compiler/tiered/CompLevelsTest.java b/hotspot/test/compiler/tiered/CompLevelsTest.java new file mode 100644 index 00000000000..5c61ba173d7 --- /dev/null +++ b/hotspot/test/compiler/tiered/CompLevelsTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2013, 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. + */ + +/** + * Abstract class for testing of used compilation levels correctness. + * + * @author igor.ignatyev@oracle.com + */ +public abstract class CompLevelsTest extends CompilerWhiteBoxTest { + protected CompLevelsTest(TestCase testCase) { + super(testCase); + // to prevent inlining of #method + WHITE_BOX.testSetDontInlineMethod(method, true); + } + + /** + * Checks that level is available. + * @param compLevel level to check + */ + protected void testAvailableLevel(int compLevel, int bci) { + if (IS_VERBOSE) { + System.out.printf("testAvailableLevel(level = %d, bci = %d)%n", + compLevel, bci); + } + WHITE_BOX.enqueueMethodForCompilation(method, compLevel, bci); + checkCompiled(); + checkLevel(compLevel, getCompLevel()); + deoptimize(); + } + + /** + * Checks that level is unavailable. + * @param compLevel level to check + */ + protected void testUnavailableLevel(int compLevel, int bci) { + if (IS_VERBOSE) { + System.out.printf("testUnavailableLevel(level = %d, bci = %d)%n", + compLevel, bci); + } + WHITE_BOX.enqueueMethodForCompilation(method, compLevel, bci); + checkNotCompiled(); + } + + /** + * Checks validity of compilation level. + * @param expected expected level + * @param actual actually level + */ + protected void checkLevel(int expected, int actual) { + if (expected != actual) { + throw new RuntimeException("expected[" + expected + "] != actual[" + + actual + "]"); + } + } +} diff --git a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java new file mode 100644 index 00000000000..28fd24d30bd --- /dev/null +++ b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.function.IntPredicate; + +/** + * @test NonTieredLevelsTest + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build NonTieredLevelsTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:-TieredCompilation + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:CompileCommand=compileonly,TestCase$Helper::* + * NonTieredLevelsTest + * @summary Verify that only one level can be used + * @author igor.ignatyev@oracle.com + */ +public class NonTieredLevelsTest extends CompLevelsTest { + private static final int AVAILABLE_COMP_LEVEL; + private static final IntPredicate IS_AVAILABLE_COMPLEVEL; + static { + String vmName = System.getProperty("java.vm.name"); + if (vmName.endsWith(" Server VM")) { + AVAILABLE_COMP_LEVEL = COMP_LEVEL_FULL_OPTIMIZATION; + IS_AVAILABLE_COMPLEVEL = x -> x == COMP_LEVEL_FULL_OPTIMIZATION; + } else if (vmName.endsWith(" Client VM") + || vmName.endsWith(" Minimal VM")) { + AVAILABLE_COMP_LEVEL = COMP_LEVEL_SIMPLE; + IS_AVAILABLE_COMPLEVEL = x -> x >= COMP_LEVEL_SIMPLE + && x <= COMP_LEVEL_FULL_PROFILE; + } else { + throw new RuntimeException("Unknown VM: " + vmName); + } + + } + public static void main(String[] args) throws Exception { + if (TIERED_COMPILATION) { + System.err.println("Test isn't applicable w/ enabled " + + "TieredCompilation. Skip test."); + return; + } + for (TestCase test : TestCase.values()) { + new NonTieredLevelsTest(test).runTest(); + } + } + + private NonTieredLevelsTest(TestCase testCase) { + super(testCase); + // to prevent inlining of #method + WHITE_BOX.testSetDontInlineMethod(method, true); + } + + @Override + protected void test() throws Exception { + checkNotCompiled(); + compile(); + checkCompiled(); + + int compLevel = getCompLevel(); + checkLevel(AVAILABLE_COMP_LEVEL, compLevel); + int bci = WHITE_BOX.getMethodEntryBci(method); + deoptimize(); + if (!testCase.isOsr) { + for (int level = 1; level <= COMP_LEVEL_MAX; ++level) { + if (IS_AVAILABLE_COMPLEVEL.test(level)) { + testAvailableLevel(level, bci); + } else { + testUnavailableLevel(level, bci); + } + } + } else { + System.out.println("skip other levels testing in OSR"); + testAvailableLevel(AVAILABLE_COMP_LEVEL, bci); + } + } +} diff --git a/hotspot/test/compiler/tiered/TieredLevelsTest.java b/hotspot/test/compiler/tiered/TieredLevelsTest.java new file mode 100644 index 00000000000..9d3112aa274 --- /dev/null +++ b/hotspot/test/compiler/tiered/TieredLevelsTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2013, 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. + */ + +/** + * @test TieredLevelsTest + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build TieredLevelsTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:CompileCommand=compileonly,TestCase$Helper::* + * TieredLevelsTest + * @summary Verify that all levels < 'TieredStopAtLevel' can be used + * @author igor.ignatyev@oracle.com + */ +public class TieredLevelsTest extends CompLevelsTest { + public static void main(String[] args) throws Exception { + if (!TIERED_COMPILATION) { + System.err.println("Test isn't applicable w/ disabled " + + "TieredCompilation. Skip test."); + return; + } + for (TestCase test : TestCase.values()) { + new TieredLevelsTest(test).runTest(); + } + } + + private TieredLevelsTest(TestCase testCase) { + super(testCase); + // to prevent inlining of #method + WHITE_BOX.testSetDontInlineMethod(method, true); + } + + @Override + protected void test() throws Exception { + checkNotCompiled(); + compile(); + checkCompiled(); + + int compLevel = getCompLevel(); + if (compLevel > TIERED_STOP_AT_LEVEL) { + throw new RuntimeException("method.compLevel[" + compLevel + + "] > TieredStopAtLevel [" + TIERED_STOP_AT_LEVEL + "]"); + } + int bci = WHITE_BOX.getMethodEntryBci(method); + deoptimize(); + + for (int testedTier = 1; testedTier <= TIERED_STOP_AT_LEVEL; + ++testedTier) { + testAvailableLevel(testedTier, bci); + } + for (int testedTier = TIERED_STOP_AT_LEVEL + 1; + testedTier <= COMP_LEVEL_MAX; ++testedTier) { + testUnavailableLevel(testedTier, bci); + } + } + + + @Override + protected void checkLevel(int expected, int actual) { + if (expected == COMP_LEVEL_FULL_PROFILE + && actual == COMP_LEVEL_LIMITED_PROFILE) { + // for simple method full_profile may be replaced by limited_profile + return; + } + super.checkLevel(expected, actual); + } +} diff --git a/hotspot/test/compiler/types/TypeSpeculation.java b/hotspot/test/compiler/types/TypeSpeculation.java new file mode 100644 index 00000000000..e47de9203d9 --- /dev/null +++ b/hotspot/test/compiler/types/TypeSpeculation.java @@ -0,0 +1,428 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8024070 + * @summary Test that type speculation doesn't cause incorrect execution + * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:TypeProfileLevel=222 TypeSpeculation + * + */ + +public class TypeSpeculation { + + interface I { + } + + static class A { + int m() { + return 1; + } + } + + static class B extends A implements I { + int m() { + return 2; + } + } + + static class C extends B { + int m() { + return 3; + } + } + + static int test1_invokevirtual(A a) { + return a.m(); + } + + static int test1_1(A a) { + return test1_invokevirtual(a); + } + + static boolean test1() { + A a = new A(); + B b = new B(); + C c = new C(); + + // pollute profile at test1_invokevirtual to make sure the + // compiler cannot rely on it + for (int i = 0; i < 5000; i++) { + test1_invokevirtual(a); + test1_invokevirtual(b); + test1_invokevirtual(c); + } + + // profiling + speculation should make test1_invokevirtual + // inline A.m() with a guard + for (int i = 0; i < 20000; i++) { + int res = test1_1(b); + if (res != b.m()) { + System.out.println("test1 failed with class B"); + return false; + } + } + // check that the guard works as expected by passing a + // different type + int res = test1_1(a); + if (res != a.m()) { + System.out.println("test1 failed with class A"); + return false; + } + return true; + } + + static int test2_invokevirtual(A a) { + return a.m(); + } + + static int test2_1(A a, boolean t) { + A aa; + if (t) { + aa = (B)a; + } else { + aa = a; + } + // if a of type B is passed to test2_1, the static type of aa + // here is no better than A but the profiled type is B so this + // should inline + return test2_invokevirtual(aa); + } + + static boolean test2() { + A a = new A(); + B b = new B(); + C c = new C(); + + // pollute profile at test2_invokevirtual to make sure the + // compiler cannot rely on it + for (int i = 0; i < 5000; i++) { + test2_invokevirtual(a); + test2_invokevirtual(b); + test2_invokevirtual(c); + } + + // profiling + speculation should make test2_invokevirtual + // inline A.m() with a guard + for (int i = 0; i < 20000; i++) { + int res = test2_1(b, (i % 2) == 0); + if (res != b.m()) { + System.out.println("test2 failed with class B"); + return false; + } + } + // check that the guard works as expected by passing a + // different type + int res = test2_1(a, false); + if (res != a.m()) { + System.out.println("test2 failed with class A"); + return false; + } + return true; + } + + static int test3_invokevirtual(A a) { + return a.m(); + } + + static void test3_2(A a) { + } + + static int test3_1(A a, int i) { + if (i == 0) { + return 0; + } + // If we come here and a is of type B but parameter profiling + // is polluted, both branches of the if below should have + // profiling that tell us and inlining of the virtual call + // should happen + if (i == 1) { + test3_2(a); + } else { + test3_2(a); + } + return test3_invokevirtual(a); + } + + static boolean test3() { + A a = new A(); + B b = new B(); + C c = new C(); + + // pollute profile at test3_invokevirtual and test3_1 to make + // sure the compiler cannot rely on it + for (int i = 0; i < 3000; i++) { + test3_invokevirtual(a); + test3_invokevirtual(b); + test3_invokevirtual(c); + test3_1(a, 0); + test3_1(b, 0); + } + + // profiling + speculation should make test3_invokevirtual + // inline A.m() with a guard + for (int i = 0; i < 20000; i++) { + int res = test3_1(b, (i % 2) + 1); + if (res != b.m()) { + System.out.println("test3 failed with class B"); + return false; + } + } + // check that the guard works as expected by passing a + // different type + int res = test3_1(a, 1); + if (res != a.m()) { + System.out.println("test3 failed with class A"); + return false; + } + return true; + } + + // Mix 2 incompatible profiled types + static int test4_invokevirtual(A a) { + return a.m(); + } + + static void test4_2(A a) { + } + + static int test4_1(A a, boolean b) { + if (b) { + test4_2(a); + } else { + test4_2(a); + } + // shouldn't inline + return test4_invokevirtual(a); + } + + static boolean test4() { + A a = new A(); + B b = new B(); + C c = new C(); + + // pollute profile at test3_invokevirtual and test3_1 to make + // sure the compiler cannot rely on it + for (int i = 0; i < 3000; i++) { + test4_invokevirtual(a); + test4_invokevirtual(b); + test4_invokevirtual(c); + } + + for (int i = 0; i < 20000; i++) { + if ((i % 2) == 0) { + int res = test4_1(a, true); + if (res != a.m()) { + System.out.println("test4 failed with class A"); + return false; + } + } else { + int res = test4_1(b, false); + if (res != b.m()) { + System.out.println("test4 failed with class B"); + return false; + } + } + } + return true; + } + + // Mix one profiled type with an incompatible type + static int test5_invokevirtual(A a) { + return a.m(); + } + + static void test5_2(A a) { + } + + static int test5_1(A a, boolean b) { + if (b) { + test5_2(a); + } else { + A aa = (B)a; + } + // shouldn't inline + return test5_invokevirtual(a); + } + + static boolean test5() { + A a = new A(); + B b = new B(); + C c = new C(); + + // pollute profile at test3_invokevirtual and test3_1 to make + // sure the compiler cannot rely on it + for (int i = 0; i < 3000; i++) { + test5_invokevirtual(a); + test5_invokevirtual(b); + test5_invokevirtual(c); + } + + for (int i = 0; i < 20000; i++) { + if ((i % 2) == 0) { + int res = test5_1(a, true); + if (res != a.m()) { + System.out.println("test5 failed with class A"); + return false; + } + } else { + int res = test5_1(b, false); + if (res != b.m()) { + System.out.println("test5 failed with class B"); + return false; + } + } + } + return true; + } + + // Mix incompatible profiled types + static void test6_2(Object o) { + } + + static Object test6_1(Object o, boolean b) { + if (b) { + test6_2(o); + } else { + test6_2(o); + } + return o; + } + + static boolean test6() { + A a = new A(); + A[] aa = new A[10]; + + for (int i = 0; i < 20000; i++) { + if ((i % 2) == 0) { + test6_1(a, true); + } else { + test6_1(aa, false); + } + } + return true; + } + + // Mix a profiled type with an incompatible type + static void test7_2(Object o) { + } + + static Object test7_1(Object o, boolean b) { + if (b) { + test7_2(o); + } else { + Object oo = (A[])o; + } + return o; + } + + static boolean test7() { + A a = new A(); + A[] aa = new A[10]; + + for (int i = 0; i < 20000; i++) { + if ((i % 2) == 0) { + test7_1(a, true); + } else { + test7_1(aa, false); + } + } + return true; + } + + // Mix a profiled type with an interface + static void test8_2(Object o) { + } + + static I test8_1(Object o) { + test8_2(o); + return (I)o; + } + + static boolean test8() { + A a = new A(); + B b = new B(); + C c = new C(); + + for (int i = 0; i < 20000; i++) { + test8_1(b); + } + return true; + } + + // Mix a profiled type with a constant + static void test9_2(Object o) { + } + + static Object test9_1(Object o, boolean b) { + Object oo; + if (b) { + test9_2(o); + oo = o; + } else { + oo = "some string"; + } + return oo; + } + + static boolean test9() { + A a = new A(); + + for (int i = 0; i < 20000; i++) { + if ((i % 2) == 0) { + test9_1(a, true); + } else { + test9_1(a, false); + } + } + return true; + } + + static public void main(String[] args) { + boolean success = true; + + success = test1() && success; + + success = test2() && success; + + success = test3() && success; + + success = test4() && success; + + success = test5() && success; + + success = test6() && success; + + success = test7() && success; + + success = test8() && success; + + success = test9() && success; + + if (success) { + System.out.println("TEST PASSED"); + } else { + throw new RuntimeException("TEST FAILED: erroneous bound check elimination"); + } + } +} diff --git a/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java b/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java index 0058981be21..5265947a3fc 100644 --- a/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java +++ b/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java @@ -80,8 +80,7 @@ public abstract class CompilerWhiteBoxTest { static { if (TIERED_COMPILATION) { - THRESHOLD = 150000; - BACKEDGE_THRESHOLD = 0xFFFFFFFFL; + BACKEDGE_THRESHOLD = THRESHOLD = 150000; } else { THRESHOLD = COMPILE_THRESHOLD; BACKEDGE_THRESHOLD = COMPILE_THRESHOLD * Long.parseLong(getVMOption( @@ -364,7 +363,7 @@ enum TestCase { /** OSR constructor test case */ OSR_CONSTRUCTOR_TEST(Helper.OSR_CONSTRUCTOR, Helper.OSR_CONSTRUCTOR_CALLABLE, true), - /** OSR method test case */ + /** OSR method test case */ OSR_METOD_TEST(Helper.OSR_METHOD, Helper.OSR_METHOD_CALLABLE, true), /** OSR static method test case */ OSR_STATIC_TEST(Helper.OSR_STATIC, Helper.OSR_STATIC_CALLABLE, true); @@ -373,7 +372,7 @@ enum TestCase { final Executable executable; /** object to invoke {@linkplain #executable} */ final Callable callable; - /** flag for OSR test case */ + /** flag for OSR test case */ final boolean isOsr; private TestCase(Executable executable, Callable callable, diff --git a/hotspot/test/gc/TestSystemGC.java b/hotspot/test/gc/TestSystemGC.java new file mode 100644 index 00000000000..b882f9fc72d --- /dev/null +++ b/hotspot/test/gc/TestSystemGC.java @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2013, 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. +*/ + +/* + * @test TestSystemGC + * @key gc + * @summary Runs System.gc() with different flags. + * @run main/othervm TestSystemGC + * @run main/othervm -XX:+UseSerialGC TestSystemGC + * @run main/othervm -XX:+UseParNewGC TestSystemGC + * @run main/othervm -XX:+UseParallelGC TestSystemGC + * @run main/othervm -XX:+UseParallelGC -XX:-UseParallelOldGC TestSystemGC + * @run main/othervm -XX:+UseConcMarkSweepGC TestSystemGC + * @run main/othervm -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent TestSystemGC + * @run main/othervm -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent -XX:-UseParNewGC TestSystemGC + * @run main/othervm -XX:+UseG1GC TestSystemGC + * @run main/othervm -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent TestSystemGC + * @run main/othervm -XX:+UseLargePages TestSystemGC + * @run main/othervm -XX:+UseLargePages -XX:+UseLargePagesInMetaspace TestSystemGC + */ + +public class TestSystemGC { + public static void main(String args[]) throws Exception { + System.gc(); + } +} diff --git a/hotspot/test/gc/startup_warnings/TestCMSForegroundFlags.java b/hotspot/test/gc/startup_warnings/TestCMSForegroundFlags.java new file mode 100644 index 00000000000..ead8788524a --- /dev/null +++ b/hotspot/test/gc/startup_warnings/TestCMSForegroundFlags.java @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2013, 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. +*/ + +/* +* @test TestCMSForegroundFlags +* @key gc +* @bug 8027132 +* @summary Test that the deprecated CMS foreground collector flags print warning messages +* @library /testlibrary +* @run main TestCMSForegroundFlags -XX:-UseCMSCompactAtFullCollection UseCMSCompactAtFullCollection +* @run main TestCMSForegroundFlags -XX:CMSFullGCsBeforeCompaction=4 CMSFullGCsBeforeCompaction +* @run main TestCMSForegroundFlags -XX:-UseCMSCollectionPassing UseCMSCollectionPassing +*/ + +import com.oracle.java.testlibrary.OutputAnalyzer; +import com.oracle.java.testlibrary.ProcessTools; + +public class TestCMSForegroundFlags { + public static void main(String[] args) throws Exception { + if (args.length != 2) { + throw new Exception("Expected two arguments,flagValue and flagName"); + } + String flagValue = args[0]; + String flagName = args[1]; + + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flagValue, "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("warning: " + flagName + " is deprecated and will likely be removed in a future release."); + output.shouldNotContain("error"); + output.shouldHaveExitValue(0); + } +} diff --git a/hotspot/test/runtime/8024804/RegisterNatives.java b/hotspot/test/runtime/8024804/RegisterNatives.java new file mode 100644 index 00000000000..8a5772a88b9 --- /dev/null +++ b/hotspot/test/runtime/8024804/RegisterNatives.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8024804 + * @summary registerNatives() interface resolution should receive IAE + * @run main RegisterNatives + */ +public class RegisterNatives { + interface I { void registerNatives(); } + interface J extends I {} + static class B implements J { public void registerNatives() { System.out.println("B"); } } + public static void main(String... args) { + System.out.println("Regression test for JDK-8024804, crash when InterfaceMethodref resolves to Object.registerNatives\n"); + J val = new B(); + try { + val.registerNatives(); + } catch (IllegalAccessError e) { + System.out.println("TEST PASSES - according to current JVM spec, IAE expected\n"); + return; + } + System.out.println("TEST FAILS - no IAE resulted\n"); + System.exit(1); + } +} diff --git a/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java b/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java new file mode 100644 index 00000000000..c3de30edf86 --- /dev/null +++ b/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026365 + * @summary Test invokespecial of host class method from an anonymous class + * @author Robert Field + * @library /testlibrary + * @compile -XDignore.symbol.file InvokeSpecialAnonTest.java + * @run main ClassFileInstaller InvokeSpecialAnonTest AnonTester + * @run main/othervm -Xbootclasspath/a:. -Xverify:all InvokeSpecialAnonTest + */ +import jdk.internal.org.objectweb.asm.*; +import java.lang.reflect.Constructor; +import sun.misc.Unsafe; + +public class InvokeSpecialAnonTest implements Opcodes { + + static byte[] anonClassBytes() throws Exception { + ClassWriter cw = new ClassWriter(0); + MethodVisitor mv; + + cw.visit(V1_8, ACC_FINAL + ACC_SUPER, "Anon", null, "java/lang/Object", null); + + { + mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V"); + mv.visitInsn(RETURN); + mv.visitMaxs(2, 2); + mv.visitEnd(); + } + { + mv = cw.visitMethod(ACC_PUBLIC, "m", "(LInvokeSpecialAnonTest;)I", null, null); + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKESPECIAL, "InvokeSpecialAnonTest", "privMethod", "()I"); + mv.visitInsn(IRETURN); + mv.visitMaxs(2, 3); + mv.visitEnd(); + } + cw.visitEnd(); + + return cw.toByteArray(); + } + + private int privMethod() { return 1234; } + + public static void main(String[] args) throws Exception { + Class klass = InvokeSpecialAnonTest.class; + try { + Class result = AnonTester.defineTest(klass, anonClassBytes()); + System.out.println("Passed."); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } +} + + +class AnonTester { + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + + public static Class defineTest(Class targetClass, byte[] classBytes) throws Exception { + return UNSAFE.defineAnonymousClass(targetClass, classBytes, null); + } +} diff --git a/hotspot/test/runtime/8026394/InterfaceObjectTest.java b/hotspot/test/runtime/8026394/InterfaceObjectTest.java new file mode 100644 index 00000000000..03ae6300bc1 --- /dev/null +++ b/hotspot/test/runtime/8026394/InterfaceObjectTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8026394 + * @summary clone() and finalize() interface resolution should not receive IAE + * @run main InterfaceObjectTest + */ +interface IClone extends Cloneable { + void finalize() throws Throwable; + Object clone(); +} + +interface ICloneExtend extends IClone { } + +public class InterfaceObjectTest implements ICloneExtend { + + public Object clone() { + System.out.println("In InterfaceObjectTest's clone() method\n"); + return null; + } + + public void finalize() throws Throwable { + try { + System.out.println("In InterfaceObjectTest's finalize() method\n"); + } catch (Throwable t) { + throw new AssertionError(t); + } + } + + public static void tryIt(ICloneExtend o1) { + try { + Object o2 = o1.clone(); + o1.finalize(); + } catch (Throwable t) { + if (t instanceof IllegalAccessError) { + System.out.println("TEST FAILS - IAE resulted\n"); + System.exit(1); + } + } + } + + public static void main(String[] args) { + InterfaceObjectTest o1 = new InterfaceObjectTest(); + tryIt(o1); + System.out.println("TEST PASSES - no IAE resulted\n"); + } +} diff --git a/hotspot/test/runtime/CommandLine/PrintGCApplicationConcurrentTime.java b/hotspot/test/runtime/CommandLine/PrintGCApplicationConcurrentTime.java new file mode 100644 index 00000000000..e6cf34962a4 --- /dev/null +++ b/hotspot/test/runtime/CommandLine/PrintGCApplicationConcurrentTime.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013, 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. + */ + + /* + * @test + * @bug 8026041 + * @run main/othervm -XX:+PrintGCApplicationConcurrentTime -Xcomp PrintGCApplicationConcurrentTime + */ + +public class PrintGCApplicationConcurrentTime { + + public static void main(String args[]) throws Exception { + } +} diff --git a/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java b/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java new file mode 100644 index 00000000000..1892e6fd0b5 --- /dev/null +++ b/hotspot/test/runtime/CompressedOops/CompressedClassPointers.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2013, 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. + */ + +/* + * @test + * @bug 8024927 + * @summary Testing address of compressed class pointer space as best as possible. + * @library /testlibrary + */ + +import com.oracle.java.testlibrary.*; + +public class CompressedClassPointers { + + public static void smallHeapTest() throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedBaseAddress=8g", + "-Xmx128m", + "-XX:+PrintCompressedOopsMode", + "-XX:+VerifyBeforeGC", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("Narrow klass base: 0x0000000000000000"); + output.shouldHaveExitValue(0); + } + + public static void smallHeapTestWith3G() throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:CompressedClassSpaceSize=3g", + "-Xmx128m", + "-XX:+PrintCompressedOopsMode", + "-XX:+VerifyBeforeGC", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("Narrow klass base: 0x0000000000000000, Narrow klass shift: 3"); + output.shouldHaveExitValue(0); + } + + public static void largeHeapTest() throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-Xmx30g", + "-XX:+PrintCompressedOopsMode", + "-XX:+VerifyBeforeGC", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("Narrow klass base: 0x0000000000000000"); + output.shouldContain("Narrow klass shift: 0"); + output.shouldHaveExitValue(0); + } + + public static void largePagesTest() throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-Xmx128m", + "-XX:+UseLargePages", + "-XX:+PrintCompressedOopsMode", + "-XX:+VerifyBeforeGC", "-version"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("Narrow klass base:"); + output.shouldHaveExitValue(0); + } + + public static void sharingTest() throws Exception { + // Test small heaps + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=./sample.jsa", + "-Xmx128m", + "-XX:SharedBaseAddress=8g", + "-XX:+PrintCompressedOopsMode", + "-XX:+VerifyBeforeGC", + "-Xshare:dump"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + try { + output.shouldContain("Loading classes to share"); + output.shouldHaveExitValue(0); + + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=./sample.jsa", + "-Xmx128m", + "-XX:SharedBaseAddress=8g", + "-XX:+PrintCompressedOopsMode", + "-Xshare:on", + "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("sharing"); + output.shouldHaveExitValue(0); + + } catch (RuntimeException e) { + output.shouldContain("Unable to use shared archive"); + output.shouldHaveExitValue(1); + } + } + + public static void main(String[] args) throws Exception { + if (!Platform.is64bit()) { + // Can't test this on 32 bit, just pass + System.out.println("Skipping test on 32bit"); + return; + } + // Solaris 10 can't mmap compressed oops space without a base + if (Platform.isSolaris()) { + String name = System.getProperty("os.version"); + if (name.equals("5.10")) { + System.out.println("Skipping test on Solaris 10"); + return; + } + } + smallHeapTest(); + smallHeapTestWith3G(); + largeHeapTest(); + largePagesTest(); + sharingTest(); + } +} diff --git a/hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java b/hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java index 7871bd2ce2f..4534a8fe2f6 100644 --- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java +++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/JDKToolLauncher.java @@ -100,7 +100,7 @@ public class JDKToolLauncher { * @return The JDKToolLauncher instance */ public JDKToolLauncher addVMArg(String arg) { - vmArgs.add("-J" + arg); + vmArgs.add(arg); return this; } @@ -124,7 +124,10 @@ public class JDKToolLauncher { public String[] getCommand() { List command = new ArrayList(); command.add(executable); - command.addAll(vmArgs); + // Add -J in front of all vmArgs + for (String arg : vmArgs) { + command.add("-J" + arg); + } command.addAll(toolArgs); return command.toArray(new String[command.size()]); } diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 7621bc5f5a1..d3911b41c9c 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -234,3 +234,5 @@ d6a32e3831aab20a9a3bc78cdc0a60aaad725c6c jdk8-b107 4c84c5b447b09aff27f3b72667ab3a5401e85968 jdk8-b110 17ee0d3e97fdb412e48f14d87f504946a708f846 jdk8-b111 c1f9158fbb9c2da50f6946fffd974e8236e08447 jdk8-b112 +0046d2278204b7eff76803fc4623cb48c7e6384d jdk8-b113 +1b1e12117fe2840e5d21ae9a4b309e4f981f3ea8 jdk8-b114 diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java b/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java index f4a80afacfe..c3f3a915f96 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/XalanConstants.java @@ -187,6 +187,19 @@ public final class XalanConstants { public static final String XML_SECURITY_PROPERTY_MANAGER = ORACLE_JAXP_PROPERTY_PREFIX + "xmlSecurityPropertyManager"; + /** + * Feature enableExtensionFunctions + */ + public static final String ORACLE_ENABLE_EXTENSION_FUNCTION = + ORACLE_JAXP_PROPERTY_PREFIX + "enableExtensionFunctions"; + public static final String SP_ORACLE_ENABLE_EXTENSION_FUNCTION = "javax.xml.enableExtensionFunctions"; + + /** + * Values for a feature + */ + public static final String FEATURE_TRUE = "true"; + public static final String FEATURE_FALSE = "false"; + /** * Check if we're in jdk8 or above */ diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/utils/FeatureManager.java b/jaxp/src/com/sun/org/apache/xalan/internal/utils/FeatureManager.java new file mode 100644 index 00000000000..644e3c14c2d --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xalan/internal/utils/FeatureManager.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.org.apache.xalan.internal.utils; + + +import com.sun.org.apache.xalan.internal.XalanConstants; + +/** + * This class manages security related properties + * + */ +public final class FeatureManager extends FeaturePropertyBase { + + /** + * States of the settings of a property, in the order: default value, value + * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system + * properties, and jaxp api properties + */ + public static enum State { + //this order reflects the overriding order + DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY + } + + /** + * Xalan Features + */ + public static enum Feature { + ORACLE_ENABLE_EXTENSION_FUNCTION(XalanConstants.ORACLE_ENABLE_EXTENSION_FUNCTION, + "true"); + + final String name; + final String defaultValue; + + Feature(String name, String value) { + this.name = name; + this.defaultValue = value; + } + + public boolean equalsName(String propertyName) { + return (propertyName == null) ? false : name.equals(propertyName); + } + + String defaultValue() { + return defaultValue; + } + } + + /** + * Default constructor. Establishes default values + */ + public FeatureManager() { + values = new String[Feature.values().length]; + for (Feature feature : Feature.values()) { + values[feature.ordinal()] = feature.defaultValue(); + } + //read system properties or jaxp.properties + readSystemProperties(); + } + + + /** + * Check if the feature is enabled + * @param feature name of the feature + * @return true if enabled, false otherwise + */ + public boolean isFeatureEnabled(Feature feature) { + return Boolean.parseBoolean(values[feature.ordinal()]); + } + + /** + * Check if the feature is enabled + * @param propertyName name of the feature + * @return true if enabled, false otherwise + */ + public boolean isFeatureEnabled(String propertyName) { + return Boolean.parseBoolean(values[getIndex(propertyName)]); + } + + /** + * Get the index by property name + * @param propertyName property name + * @return the index of the property if found; return -1 if not + */ + public int getIndex(String propertyName){ + for (Feature feature : Feature.values()) { + if (feature.equalsName(propertyName)) { + return feature.ordinal(); + } + } + return -1; + } + + /** + * Read from system properties, or those in jaxp.properties + */ + private void readSystemProperties() { + getSystemProperty(Feature.ORACLE_ENABLE_EXTENSION_FUNCTION, + XalanConstants.SP_ORACLE_ENABLE_EXTENSION_FUNCTION); + } + +} diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java b/jaxp/src/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java new file mode 100644 index 00000000000..a831d33fff2 --- /dev/null +++ b/jaxp/src/com/sun/org/apache/xalan/internal/utils/FeaturePropertyBase.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.org.apache.xalan.internal.utils; + +import com.sun.org.apache.xalan.internal.XalanConstants; + +/** + * This is the base class for features and properties + * + */ +public abstract class FeaturePropertyBase { + + /** + * States of the settings of a property, in the order: default value, value + * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system + * properties, and jaxp api properties + */ + public static enum State { + //this order reflects the overriding order + DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY + } + + + /** + * Values of the properties as defined in enum Properties + */ + String[] values = null; + /** + * States of the settings for each property in Properties above + */ + State[] states = {State.DEFAULT, State.DEFAULT}; + + + /** + * Set the value for a specific property. + * + * @param property the property + * @param state the state of the property + * @param value the value of the property + */ + public void setValue(Enum property, State state, String value) { + //only update if it shall override + if (state.compareTo(states[property.ordinal()]) >= 0) { + values[property.ordinal()] = value; + states[property.ordinal()] = state; + } + } + + /** + * Set the value of a property by its index + * @param index the index of the property + * @param state the state of the property + * @param value the value of the property + */ + public void setValue(int index, State state, String value) { + //only update if it shall override + if (state.compareTo(states[index]) >= 0) { + values[index] = value; + states[index] = state; + } + } + + /** + * Set value by property name and state + * @param propertyName property name + * @param state the state of the property + * @param value the value of the property + * @return true if the property is managed by the security property manager; + * false if otherwise. + */ + public boolean setValue(String propertyName, State state, Object value) { + int index = getIndex(propertyName); + if (index > -1) { + setValue(index, state, (String)value); + return true; + } + return false; + } + + /** + * Set value by property name and state + * @param propertyName property name + * @param state the state of the property + * @param value the value of the property + * @return true if the property is managed by the security property manager; + * false if otherwise. + */ + public boolean setValue(String propertyName, State state, boolean value) { + int index = getIndex(propertyName); + if (index > -1) { + if (value) { + setValue(index, state, XalanConstants.FEATURE_TRUE); + } else { + setValue(index, state, XalanConstants.FEATURE_FALSE); + } + return true; + } + return false; + } + + /** + * Return the value of the specified property + * + * @param property the property + * @return the value of the property + */ + public String getValue(Enum property) { + return values[property.ordinal()]; + } + + /** + * Return the value of the specified property + * + * @param property the property + * @return the value of the property + */ + public String getValue(String property) { + int index = getIndex(property); + if (index > -1) { + return getValueByIndex(index); + } + return null; + } + + /** + * Return the value of the specified property. + * + * @param propertyName the property name + * @return the value of the property as a string. If a property is managed + * by this manager, its value shall not be null. + */ + public String getValueAsString(String propertyName) { + int index = getIndex(propertyName); + if (index > -1) { + return getValueByIndex(index); + } + + return null; + } + + /** + * Return the value of a property by its ordinal + * @param index the index of a property + * @return value of a property + */ + public String getValueByIndex(int index) { + return values[index]; + } + + /** + * Get the index by property name + * @param propertyName property name + * @return the index of the property if found; return -1 if not + */ + public abstract int getIndex(String propertyName); + + public > int getIndex(Class property, String propertyName) { + for (Enum enumItem : property.getEnumConstants()) { + if (enumItem.toString().equals(propertyName)) { + //internally, ordinal is used as index + return enumItem.ordinal(); + } + } + return -1; + }; + + + /** + * Read from system properties, or those in jaxp.properties + * + * @param property the property + * @param systemProperty the name of the system property + */ + void getSystemProperty(Enum property, String systemProperty) { + try { + String value = SecuritySupport.getSystemProperty(systemProperty); + if (value != null) { + values[property.ordinal()] = value; + states[property.ordinal()] = State.SYSTEMPROPERTY; + return; + } + + value = SecuritySupport.readJAXPProperty(systemProperty); + if (value != null) { + values[property.ordinal()] = value; + states[property.ordinal()] = State.JAXPDOTPROPERTIES; + } + } catch (NumberFormatException e) { + //invalid setting ignored + } + } +} diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java b/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java index 99a8e2d5f69..e861c21c3a0 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityManager.java @@ -1,42 +1,28 @@ /* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. + * 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). * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. + * 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. * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. + * 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 com.sun.org.apache.xalan.internal.utils; import com.sun.org.apache.xalan.internal.XalanConstants; diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java b/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java index 35dc9a5d04b..611120baffc 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/utils/XMLSecurityPropertyManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -33,20 +33,10 @@ import javax.xml.XMLConstants; * This class manages security related properties * */ -public final class XMLSecurityPropertyManager { +public final class XMLSecurityPropertyManager extends FeaturePropertyBase { /** - * States of the settings of a property, in the order: default value, value - * set by FEATURE_SECURE_PROCESSING, jaxp.properties file, jaxp system - * properties, and jaxp api properties - */ - public static enum State { - //this order reflects the overriding order - DEFAULT, FSP, JAXPDOTPROPERTIES, SYSTEMPROPERTY, APIPROPERTY - } - - /** - * Limits managed by the security manager + * Properties managed by the security property manager */ public static enum Property { ACCESS_EXTERNAL_DTD(XMLConstants.ACCESS_EXTERNAL_DTD, @@ -72,15 +62,6 @@ public final class XMLSecurityPropertyManager { } - /** - * Values of the properties as defined in enum Properties - */ - private final String[] values; - /** - * States of the settings for each property in Properties above - */ - private State[] states = {State.DEFAULT, State.DEFAULT}; - /** * Default constructor. Establishes default values */ @@ -93,86 +74,6 @@ public final class XMLSecurityPropertyManager { readSystemProperties(); } - /** - * Set limit by property name and state - * @param propertyName property name - * @param state the state of the property - * @param value the value of the property - * @return true if the property is managed by the security property manager; - * false if otherwise. - */ - public boolean setValue(String propertyName, State state, Object value) { - int index = getIndex(propertyName); - if (index > -1) { - setValue(index, state, (String)value); - return true; - } - return false; - } - - /** - * Set the value for a specific property. - * - * @param property the property - * @param state the state of the property - * @param value the value of the property - */ - public void setValue(Property property, State state, String value) { - //only update if it shall override - if (state.compareTo(states[property.ordinal()]) >= 0) { - values[property.ordinal()] = value; - states[property.ordinal()] = state; - } - } - - /** - * Set the value of a property by its index - * @param index the index of the property - * @param state the state of the property - * @param value the value of the property - */ - public void setValue(int index, State state, String value) { - //only update if it shall override - if (state.compareTo(states[index]) >= 0) { - values[index] = value; - states[index] = state; - } - } - - /** - * Return the value of the specified property - * - * @param propertyName the property name - * @return the value of the property as a string - */ - public String getValue(String propertyName) { - int index = getIndex(propertyName); - if (index > -1) { - return getValueByIndex(index); - } - - return null; - } - - /** - * Return the value of the specified property - * - * @param property the property - * @return the value of the property - */ - public String getValue(Property property) { - return values[property.ordinal()]; - } - - /** - * Return the value of a property by its ordinal - * @param index the index of a property - * @return value of a property - */ - public String getValueByIndex(int index) { - return values[index]; - } - /** * Get the index by property name * @param propertyName property name @@ -198,28 +99,4 @@ public final class XMLSecurityPropertyManager { XalanConstants.SP_ACCESS_EXTERNAL_STYLESHEET); } - /** - * Read from system properties, or those in jaxp.properties - * - * @param property the property - * @param systemProperty the name of the system property - */ - private void getSystemProperty(Property property, String systemProperty) { - try { - String value = SecuritySupport.getSystemProperty(systemProperty); - if (value != null) { - values[property.ordinal()] = value; - states[property.ordinal()] = State.SYSTEMPROPERTY; - return; - } - - value = SecuritySupport.readJAXPProperty(systemProperty); - if (value != null) { - values[property.ordinal()] = value; - states[property.ordinal()] = State.JAXPDOTPROPERTIES; - } - } catch (NumberFormatException e) { - //invalid setting ignored - } - } } diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java index b6cdff01c0b..9ab7e30bec6 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/cmdline/Compile.java @@ -23,6 +23,7 @@ package com.sun.org.apache.xalan.internal.xsltc.cmdline; +import com.sun.org.apache.xalan.internal.utils.FeatureManager; import java.io.File; import java.net.URL; import java.util.Vector; @@ -77,7 +78,7 @@ public final class Compile { final GetOpt getopt = new GetOpt(args, "o:d:j:p:uxhsinv"); if (args.length < 1) printUsage(); - final XSLTC xsltc = new XSLTC(true); + final XSLTC xsltc = new XSLTC(true, new FeatureManager()); xsltc.init(); int c; diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java index 76c4643f21b..56bebd88e2c 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java @@ -42,6 +42,7 @@ import com.sun.org.apache.bcel.internal.generic.InvokeInstruction; import com.sun.org.apache.bcel.internal.generic.LocalVariableGen; import com.sun.org.apache.bcel.internal.generic.NEW; import com.sun.org.apache.bcel.internal.generic.PUSH; +import com.sun.org.apache.xalan.internal.utils.FeatureManager; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; @@ -717,6 +718,8 @@ class FunctionCall extends Expression { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); final boolean isSecureProcessing = classGen.getParser().getXSLTC().isSecureProcessing(); + final boolean isExtensionFunctionEnabled = classGen.getParser().getXSLTC() + .getFeature(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION); int index; // Translate calls to methods in the BasisLibrary @@ -760,7 +763,7 @@ class FunctionCall extends Expression { il.append(new INVOKESTATIC(index)); } else if (_isExtConstructor) { - if (isSecureProcessing) + if (isSecureProcessing && !isExtensionFunctionEnabled) translateUnallowedExtension(cpg, il); final String clazz = @@ -822,7 +825,7 @@ class FunctionCall extends Expression { } // Invoke function calls that are handled in separate classes else { - if (isSecureProcessing) + if (isSecureProcessing && !isExtensionFunctionEnabled) translateUnallowedExtension(cpg, il); final String clazz = _chosenMethod.getDeclaringClass().getName(); diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java index 10823f14689..b6f81f7ba97 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java @@ -43,6 +43,8 @@ import javax.xml.XMLConstants; import com.sun.org.apache.bcel.internal.classfile.JavaClass; import com.sun.org.apache.xalan.internal.XalanConstants; +import com.sun.org.apache.xalan.internal.utils.FeatureManager; +import com.sun.org.apache.xalan.internal.utils.FeatureManager.Feature; import com.sun.org.apache.xalan.internal.utils.SecuritySupport; import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg; @@ -148,11 +150,14 @@ public final class XSLTC { private XMLSecurityManager _xmlSecurityManager; + private final FeatureManager _featureManager; + /** * XSLTC compiler constructor */ - public XSLTC(boolean useServicesMechanism) { + public XSLTC(boolean useServicesMechanism, FeatureManager featureManager) { _parser = new Parser(this, useServicesMechanism); + _featureManager = featureManager; } /** @@ -182,6 +187,15 @@ public final class XSLTC { _useServicesMechanism = flag; } + /** + * Return the value of the specified feature + * @param name name of the feature + * @return true if the feature is enabled, false otherwise + */ + public boolean getFeature(Feature name) { + return _featureManager.isFeatureEnabled(name); + } + /** * Return allowed protocols for accessing external stylesheet. */ diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2DOM.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2DOM.java index a26f093ee08..8cf62c05fa0 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2DOM.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2DOM.java @@ -74,12 +74,12 @@ public class SAX2DOM implements ContentHandler, LexicalHandler, Constants { DocumentBuilderFactory.newInstance(); private boolean _internal = true; - public SAX2DOM(boolean useServicesMachnism) throws ParserConfigurationException { - _document = createDocument(useServicesMachnism); + public SAX2DOM(boolean useServicesMechanism) throws ParserConfigurationException { + _document = createDocument(useServicesMechanism); _root = _document; } - public SAX2DOM(Node root, Node nextSibling, boolean useServicesMachnism) throws ParserConfigurationException { + public SAX2DOM(Node root, Node nextSibling, boolean useServicesMechanism) throws ParserConfigurationException { _root = root; if (root instanceof Document) { _document = (Document)root; @@ -88,15 +88,15 @@ public class SAX2DOM implements ContentHandler, LexicalHandler, Constants { _document = root.getOwnerDocument(); } else { - _document = createDocument(useServicesMachnism); + _document = createDocument(useServicesMechanism); _root = _document; } _nextSibling = nextSibling; } - public SAX2DOM(Node root, boolean useServicesMachnism) throws ParserConfigurationException { - this(root, null, useServicesMachnism); + public SAX2DOM(Node root, boolean useServicesMechanism) throws ParserConfigurationException { + this(root, null, useServicesMechanism); } public Node getDOM() { @@ -308,18 +308,19 @@ public class SAX2DOM implements ContentHandler, LexicalHandler, Constants { public void startDTD(String name, String publicId, String systemId) throws SAXException {} - private Document createDocument(boolean useServicesMachnism) throws ParserConfigurationException { + private Document createDocument(boolean useServicesMechanism) throws ParserConfigurationException { if (_factory == null) { - if (useServicesMachnism) + if (useServicesMechanism) { _factory = DocumentBuilderFactory.newInstance(); if (!(_factory instanceof com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl)) { _internal = false; } - else + } else { _factory = DocumentBuilderFactory.newInstance( "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", SAX2DOM.class.getClassLoader() ); + } } Document doc; if (_internal) { diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java index ff43ca9410f..8bbc5410695 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TemplatesHandlerImpl.java @@ -95,7 +95,7 @@ public class TemplatesHandlerImpl _tfactory = tfactory; // Instantiate XSLTC and get reference to parser object - XSLTC xsltc = new XSLTC(tfactory.useServicesMechnism()); + XSLTC xsltc = new XSLTC(tfactory.useServicesMechnism(), tfactory.getFeatureManager()); if (tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) xsltc.setSecureProcessing(true); diff --git a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java index 9b6589d7aa8..46866fdb0ad 100644 --- a/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java @@ -25,12 +25,14 @@ package com.sun.org.apache.xalan.internal.xsltc.trax; import com.sun.org.apache.xalan.internal.XalanConstants; import com.sun.org.apache.xalan.internal.utils.FactoryImpl; +import com.sun.org.apache.xalan.internal.utils.FeatureManager; +import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase; import com.sun.org.apache.xalan.internal.utils.ObjectFactory; import com.sun.org.apache.xalan.internal.utils.SecuritySupport; import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager; import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager; import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager.Property; -import com.sun.org.apache.xalan.internal.utils.XMLSecurityPropertyManager.State; +import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase.State; import com.sun.org.apache.xalan.internal.xsltc.compiler.Constants; import com.sun.org.apache.xalan.internal.xsltc.compiler.SourceLoader; import com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC; @@ -227,6 +229,8 @@ public class TransformerFactoryImpl private XMLSecurityPropertyManager _xmlSecurityPropertyMgr; private XMLSecurityManager _xmlSecurityManager; + private final FeatureManager _featureManager; + /** * javax.xml.transform.sax.TransformerFactory implementation. */ @@ -240,10 +244,13 @@ public class TransformerFactoryImpl private TransformerFactoryImpl(boolean useServicesMechanism) { this._useServicesMechanism = useServicesMechanism; + _featureManager = new FeatureManager(); if (System.getSecurityManager() != null) { _isSecureMode = true; _isNotSecureProcessing = false; + _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION, + FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE); } _xmlSecurityPropertyMgr = new XMLSecurityPropertyManager(); @@ -504,6 +511,10 @@ public class TransformerFactoryImpl Property.ACCESS_EXTERNAL_STYLESHEET); } + if (value && _featureManager != null) { + _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION, + FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE); + } return; } else if (name.equals(XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM)) { @@ -512,6 +523,11 @@ public class TransformerFactoryImpl _useServicesMechanism = value; } else { + if (_featureManager != null && + _featureManager.setValue(name, State.APIPROPERTY, value)) { + return; + } + // unknown feature ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_UNSUPPORTED_FEATURE, name); throw new TransformerConfigurationException(err.toString()); @@ -561,6 +577,13 @@ public class TransformerFactoryImpl return !_isNotSecureProcessing; } + /** Check to see if the property is managed by the security manager **/ + String propertyValue = (_featureManager != null) ? + _featureManager.getValueAsString(name) : null; + if (propertyValue != null) { + return Boolean.parseBoolean(propertyValue); + } + // Feature not supported return false; } @@ -571,6 +594,13 @@ public class TransformerFactoryImpl return _useServicesMechanism; } + /** + * @return the feature manager + */ + public FeatureManager getFeatureManager() { + return _featureManager; + } + /** * javax.xml.transform.sax.TransformerFactory implementation. * Get the object that is used by default during the transformation to @@ -857,7 +887,7 @@ public class TransformerFactoryImpl } // Create and initialize a stylesheet compiler - final XSLTC xsltc = new XSLTC(_useServicesMechanism); + final XSLTC xsltc = new XSLTC(_useServicesMechanism, _featureManager); if (_debug) xsltc.setDebug(true); if (_enableInlining) xsltc.setTemplateInlining(true); diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java index 600527daa93..fe1f63f89ed 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java @@ -569,32 +569,13 @@ public class XMLDocumentFragmentScannerImpl // xerces features fReportCdataEvent = componentManager.getFeature(Constants.STAX_REPORT_CDATA_EVENT, true); - fSecurityManager = (XMLSecurityManager)componentManager.getProperty(Constants.SECURITY_MANAGER, null); - fLimitAnalyzer = fSecurityManager.getLimitAnalyzer(); - - fElementAttributeLimit = (fSecurityManager != null)? - fSecurityManager.getLimit(XMLSecurityManager.Limit.ELEMENT_ATTRIBUTE_LIMIT):0; - fNotifyBuiltInRefs = componentManager.getFeature(NOTIFY_BUILTIN_REFS, false); Object resolver = componentManager.getProperty(ENTITY_RESOLVER, null); fExternalSubsetResolver = (resolver instanceof ExternalSubsetResolver) ? (ExternalSubsetResolver) resolver : null; - // initialize vars - fMarkupDepth = 0; - fCurrentElement = null; - fElementStack.clear(); - fHasExternalDTD = false; - fStandaloneSet = false; - fStandalone = false; - fInScanContent = false; - //skipping algorithm - fShouldSkip = false; - fAdd = false; - fSkip = false; - //attribute fReadingAttributes = false; //xxx: external entities are supported in Xerces @@ -606,9 +587,6 @@ public class XMLDocumentFragmentScannerImpl // setup Driver setScannerState(SCANNER_STATE_CONTENT); setDriver(fContentDriver); - fEntityStore = fEntityManager.getEntityStore(); - - dtdGrammarUtil = null; // JAXP 1.5 features and properties XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager) @@ -617,6 +595,7 @@ public class XMLDocumentFragmentScannerImpl fStrictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT, false); + resetCommon(); //fEntityManager.test(); } // reset(XMLComponentManager) @@ -630,17 +609,7 @@ public class XMLDocumentFragmentScannerImpl fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue(); fNotifyBuiltInRefs = false ; - // initialize vars - fMarkupDepth = 0; - fCurrentElement = null; - fShouldSkip = false; - fAdd = false; - fSkip = false; - fElementStack.clear(); //fElementStack2.clear(); - fHasExternalDTD = false; - fStandaloneSet = false; - fStandalone = false; //fReplaceEntityReferences = true; //fSupportExternalEntities = true; Boolean bo = (Boolean)propertyManager.getProperty(XMLInputFactoryImpl.IS_REPLACING_ENTITY_REFERENCES); @@ -661,20 +630,43 @@ public class XMLDocumentFragmentScannerImpl //we dont need to do this -- nb. //setScannerState(SCANNER_STATE_CONTENT); //setDriver(fContentDriver); - fEntityStore = fEntityManager.getEntityStore(); //fEntityManager.test(); - dtdGrammarUtil = null; - // JAXP 1.5 features and properties XMLSecurityPropertyManager spm = (XMLSecurityPropertyManager) propertyManager.getProperty(XML_SECURITY_PROPERTY_MANAGER); fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD); fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(Constants.SECURITY_MANAGER); - fLimitAnalyzer = fSecurityManager.getLimitAnalyzer(); + resetCommon(); } // reset(XMLComponentManager) + void resetCommon() { + // initialize vars + fMarkupDepth = 0; + fCurrentElement = null; + fElementStack.clear(); + fHasExternalDTD = false; + fStandaloneSet = false; + fStandalone = false; + fInScanContent = false; + //skipping algorithm + fShouldSkip = false; + fAdd = false; + fSkip = false; + + fEntityStore = fEntityManager.getEntityStore(); + dtdGrammarUtil = null; + + if (fSecurityManager != null) { + fLimitAnalyzer = fSecurityManager.getLimitAnalyzer(); + fElementAttributeLimit = fSecurityManager.getLimit(XMLSecurityManager.Limit.ELEMENT_ATTRIBUTE_LIMIT); + } else { + fLimitAnalyzer = null; + fElementAttributeLimit = 0; + } + } + /** * Returns a list of feature identifiers that are recognized by * this component. This method may return null if no features @@ -1328,7 +1320,7 @@ public class XMLDocumentFragmentScannerImpl fAttributes.getLength() > fElementAttributeLimit){ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "ElementAttributeLimit", - new Object[]{rawname, new Integer(fAttributes.getLength()) }, + new Object[]{rawname, fElementAttributeLimit }, XMLErrorReporter.SEVERITY_FATAL_ERROR ); } diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java index 464511c368c..f658d09e175 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/XMLNSDocumentScannerImpl.java @@ -256,7 +256,7 @@ public class XMLNSDocumentScannerImpl fAttributes.getLength() > fElementAttributeLimit){ fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, "ElementAttributeLimit", - new Object[]{rawname, new Integer(fAttributes.getLength()) }, + new Object[]{rawname, fElementAttributeLimit }, XMLErrorReporter.SEVERITY_FATAL_ERROR ); } diff --git a/jaxp/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java b/jaxp/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java index 995105902f1..613d651594f 100644 --- a/jaxp/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java +++ b/jaxp/src/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java @@ -211,7 +211,7 @@ public final class SecuritySupport { if (i > 0) { return uri.substring(i+1, uri.length()); } - return ""; + return uri; } /** diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/JAXPExtensionsProvider.java b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/JAXPExtensionsProvider.java index 0eac5f0c255..fee057ff361 100644 --- a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/JAXPExtensionsProvider.java +++ b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/JAXPExtensionsProvider.java @@ -33,6 +33,7 @@ import com.sun.org.apache.xpath.internal.objects.XObject; import com.sun.org.apache.xpath.internal.objects.XNodeSet; import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; import com.sun.org.apache.xalan.internal.res.XSLMessages; +import com.sun.org.apache.xalan.internal.utils.FeatureManager; import com.sun.org.apache.xpath.internal.functions.FuncExtFunction; import java.util.Vector; @@ -54,9 +55,12 @@ public class JAXPExtensionsProvider implements ExtensionsProvider { } public JAXPExtensionsProvider(XPathFunctionResolver resolver, - boolean featureSecureProcessing ) { + boolean featureSecureProcessing, FeatureManager featureManager ) { this.resolver = resolver; - this.extensionInvocationDisabled = featureSecureProcessing; + if (featureSecureProcessing && + !featureManager.isFeatureEnabled(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION)) { + this.extensionInvocationDisabled = true; + } } /** diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java index 2d7671ee8c7..925ce9c1234 100644 --- a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java +++ b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathExpressionImpl.java @@ -30,6 +30,7 @@ import com.sun.org.apache.xml.internal.utils.PrefixResolver; import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; import com.sun.org.apache.xalan.internal.res.XSLMessages; import com.sun.org.apache.xalan.internal.utils.FactoryImpl; +import com.sun.org.apache.xalan.internal.utils.FeatureManager; import javax.xml.namespace.NamespaceContext; import javax.xml.namespace.QName; @@ -67,33 +68,36 @@ public class XPathExpressionImpl implements javax.xml.xpath.XPathExpression{ private boolean featureSecureProcessing = false; private boolean useServicesMechanism = true; + + private final FeatureManager featureManager; + /** Protected constructor to prevent direct instantiation; use compile() * from the context. */ - protected XPathExpressionImpl() { }; - - protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath, - JAXPPrefixResolver prefixResolver, - XPathFunctionResolver functionResolver, - XPathVariableResolver variableResolver ) { - this.xpath = xpath; - this.prefixResolver = prefixResolver; - this.functionResolver = functionResolver; - this.variableResolver = variableResolver; - this.featureSecureProcessing = false; + protected XPathExpressionImpl() { + this(null, null, null, null, + false, true, new FeatureManager()); }; protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath, JAXPPrefixResolver prefixResolver, XPathFunctionResolver functionResolver, - XPathVariableResolver variableResolver, - boolean featureSecureProcessing, boolean useServicesMechanism ) { + XPathVariableResolver variableResolver ) { + this(xpath, prefixResolver, functionResolver, variableResolver, + false, true, new FeatureManager()); + }; + + protected XPathExpressionImpl(com.sun.org.apache.xpath.internal.XPath xpath, + JAXPPrefixResolver prefixResolver,XPathFunctionResolver functionResolver, + XPathVariableResolver variableResolver, boolean featureSecureProcessing, + boolean useServicesMechanism, FeatureManager featureManager ) { this.xpath = xpath; this.prefixResolver = prefixResolver; this.functionResolver = functionResolver; this.variableResolver = variableResolver; this.featureSecureProcessing = featureSecureProcessing; this.useServicesMechanism = useServicesMechanism; + this.featureManager = featureManager; }; public void setXPath (com.sun.org.apache.xpath.internal.XPath xpath ) { @@ -111,7 +115,7 @@ public class XPathExpressionImpl implements javax.xml.xpath.XPathExpression{ com.sun.org.apache.xpath.internal.XPathContext xpathSupport = null; if ( functionResolver != null ) { JAXPExtensionsProvider jep = new JAXPExtensionsProvider( - functionResolver, featureSecureProcessing ); + functionResolver, featureSecureProcessing, featureManager ); xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext( jep ); } else { xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext(); diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java index 7159896c27d..b050af44674 100644 --- a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java +++ b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathFactoryImpl.java @@ -24,6 +24,8 @@ package com.sun.org.apache.xpath.internal.jaxp; import com.sun.org.apache.xalan.internal.XalanConstants; import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; import com.sun.org.apache.xalan.internal.res.XSLMessages; +import com.sun.org.apache.xalan.internal.utils.FeatureManager; +import com.sun.org.apache.xalan.internal.utils.FeaturePropertyBase; import javax.xml.XMLConstants; import javax.xml.xpath.XPathFactory; @@ -68,6 +70,8 @@ public class XPathFactoryImpl extends XPathFactory { private boolean _useServicesMechanism = true; + private final FeatureManager _featureManager; + public XPathFactoryImpl() { this(true); } @@ -77,9 +81,12 @@ public class XPathFactoryImpl extends XPathFactory { } public XPathFactoryImpl(boolean useServicesMechanism) { + _featureManager = new FeatureManager(); if (System.getSecurityManager() != null) { _isSecureMode = true; _isNotSecureProcessing = false; + _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION, + FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE); } this._useServicesMechanism = useServicesMechanism; } @@ -131,7 +138,8 @@ public class XPathFactoryImpl extends XPathFactory { public javax.xml.xpath.XPath newXPath() { return new com.sun.org.apache.xpath.internal.jaxp.XPathImpl( xPathVariableResolver, xPathFunctionResolver, - !_isNotSecureProcessing, _useServicesMechanism ); + !_isNotSecureProcessing, _useServicesMechanism, + _featureManager ); } /** @@ -181,6 +189,10 @@ public class XPathFactoryImpl extends XPathFactory { } _isNotSecureProcessing = !value; + if (value && _featureManager != null) { + _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION, + FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE); + } // all done processing feature return; @@ -192,6 +204,11 @@ public class XPathFactoryImpl extends XPathFactory { return; } + if (_featureManager != null && + _featureManager.setValue(name, FeaturePropertyBase.State.APIPROPERTY, value)) { + return; + } + // unknown feature String fmsg = XSLMessages.createXPATHMessage( XPATHErrorResources.ER_FEATURE_UNKNOWN, @@ -240,6 +257,14 @@ public class XPathFactoryImpl extends XPathFactory { if (name.equals(XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM)) { return _useServicesMechanism; } + + /** Check to see if the property is managed by the security manager **/ + String propertyValue = (_featureManager != null) ? + _featureManager.getValueAsString(name) : null; + if (propertyValue != null) { + return _featureManager.isFeatureEnabled(name); + } + // unknown feature String fmsg = XSLMessages.createXPATHMessage( XPATHErrorResources.ER_GETTING_UNKNOWN_FEATURE, diff --git a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java index 6b8082586b0..af82f378917 100644 --- a/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java +++ b/jaxp/src/com/sun/org/apache/xpath/internal/jaxp/XPathImpl.java @@ -35,6 +35,7 @@ import com.sun.org.apache.xpath.internal.objects.XObject; import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; import com.sun.org.apache.xalan.internal.res.XSLMessages; import com.sun.org.apache.xalan.internal.utils.FactoryImpl; +import com.sun.org.apache.xalan.internal.utils.FeatureManager; import org.w3c.dom.Node; import org.w3c.dom.Document; @@ -70,18 +71,20 @@ public class XPathImpl implements javax.xml.xpath.XPath { // extensions function need to throw XPathFunctionException private boolean featureSecureProcessing = false; private boolean useServiceMechanism = true; + private final FeatureManager featureManager; XPathImpl( XPathVariableResolver vr, XPathFunctionResolver fr ) { - this.origVariableResolver = this.variableResolver = vr; - this.origFunctionResolver = this.functionResolver = fr; + this(vr, fr, false, true, new FeatureManager()); } XPathImpl( XPathVariableResolver vr, XPathFunctionResolver fr, - boolean featureSecureProcessing, boolean useServiceMechanism ) { + boolean featureSecureProcessing, boolean useServiceMechanism, + FeatureManager featureManager) { this.origVariableResolver = this.variableResolver = vr; this.origFunctionResolver = this.functionResolver = fr; this.featureSecureProcessing = featureSecureProcessing; this.useServiceMechanism = useServiceMechanism; + this.featureManager = featureManager; } /** @@ -190,7 +193,7 @@ public class XPathImpl implements javax.xml.xpath.XPath { com.sun.org.apache.xpath.internal.XPathContext xpathSupport = null; if ( functionResolver != null ) { JAXPExtensionsProvider jep = new JAXPExtensionsProvider( - functionResolver, featureSecureProcessing ); + functionResolver, featureSecureProcessing, featureManager ); xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext( jep ); } else { xpathSupport = new com.sun.org.apache.xpath.internal.XPathContext(); @@ -391,7 +394,7 @@ public class XPathImpl implements javax.xml.xpath.XPath { // Can have errorListener XPathExpressionImpl ximpl = new XPathExpressionImpl (xpath, prefixResolver, functionResolver, variableResolver, - featureSecureProcessing, useServiceMechanism ); + featureSecureProcessing, useServiceMechanism, featureManager ); return ximpl; } catch ( javax.xml.transform.TransformerException te ) { throw new XPathExpressionException ( te ) ; diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 74b6fb898b4..dc8b2a85477 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -234,3 +234,5 @@ df5d4d01642572e77fd3c01e4c8703ed3f6eec87 jdk8-b109 cc682329886be2fc26220fc30597ee4e5bba43ed jdk8-b110 32edc7a2c86696dfcbdb6ffae641ff153f8e34bd jdk8-b111 dbdd5c76250928582cb5342bcf7b299a6007d538 jdk8-b112 +9261f342aa73a79bbd1a817ae72fa72b15ef30bc jdk8-b113 +9ad289610fc6effe9076280b7920d0f16470709f jdk8-b114 diff --git a/jdk/.hgtags b/jdk/.hgtags index f93b4c85fc5..0804e08a7d0 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -235,3 +235,5 @@ eea685b9ccaa1980e0a7e07d6a3a84bcc7e9ab82 jdk8-b107 719befd87c7b96ae103c05730ca555227bfc0116 jdk8-b111 f002f5f3a16cca62e139cb8eed05ffaeb373587d jdk8-b112 5b4261b4b72af53e8e178933ef6bc6c7f8cdbc60 jdk8-b113 +f26a0c8071bde1e3b923713c75156e4a58955623 jdk8-b114 +f82b730c798b6bf38946baaba8a7d80fd5efaa70 jdk8-b115 diff --git a/jdk/make/tools/src/build/tools/tzdb/TzdbZoneRulesCompiler.java b/jdk/make/tools/src/build/tools/tzdb/TzdbZoneRulesCompiler.java index be0204eeeef..9f1204ca7fe 100644 --- a/jdk/make/tools/src/build/tools/tzdb/TzdbZoneRulesCompiler.java +++ b/jdk/make/tools/src/build/tools/tzdb/TzdbZoneRulesCompiler.java @@ -618,6 +618,11 @@ public final class TzdbZoneRulesCompiler { // remove ROC, which is not supported in j.u.tz builtZones.remove("ROC"); links.remove("ROC"); + // remove EST, HST and MST. They are supported via + // the short-id mapping + builtZones.remove("EST"); + builtZones.remove("HST"); + builtZones.remove("MST"); } /** diff --git a/jdk/makefiles/BuildJdk.gmk b/jdk/makefiles/BuildJdk.gmk index 9a42d01277d..eeb4a533220 100644 --- a/jdk/makefiles/BuildJdk.gmk +++ b/jdk/makefiles/BuildJdk.gmk @@ -80,7 +80,11 @@ genclasses-only: # to execute launchers. +$(MAKE) -f GenerateClasses.gmk -jdk: genclasses +securityjars: genclasses securityjars-only +securityjars-only: + +$(MAKE) -f CreateSecurityJars.gmk + +jdk: securityjars # Now we have a complete jdk, which you can run. # It is not yet wrapped up as an installed image. diff --git a/jdk/makefiles/CompileJavaClasses.gmk b/jdk/makefiles/CompileJavaClasses.gmk index bc830d5c711..740222661b3 100644 --- a/jdk/makefiles/CompileJavaClasses.gmk +++ b/jdk/makefiles/CompileJavaClasses.gmk @@ -96,11 +96,7 @@ ifneq ($(OPENJDK_TARGET_OS), solaris) EXCLUDES += com/oracle/security endif -# In the old build, this isn't excluded on macosx, even though it probably -# should be. -ifneq ($(OPENJDK_TARGET_OS), macosx) - EXFILES += WrapperGenerator.java -endif +EXFILES += WrapperGenerator.java ifneq ($(OPENJDK_TARGET_OS), windows) # Exclude Window security related files in src/share/classes @@ -169,7 +165,11 @@ ifeq (, $(filter $(OPENJDK_TARGET_OS), windows macosx)) EXFILES += sun/awt/AWTCharset.java endif -ifneq ($(OPENJDK_TARGET_OS), macosx) +ifeq ($(OPENJDK_TARGET_OS), macosx) + # exclude all X11 on Mac, we can't exclude some like below or we'll have compilation errors + EXCLUDES += sun/awt/X11 +else + # TBD: figure out how to eliminate this long list EXFILES += sun/awt/X11/ScreenFormat.java \ sun/awt/X11/XArc.java \ sun/awt/X11/XChar2b.java \ @@ -281,6 +281,19 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) EXCLUDES += com/apple/jobjc endif +# The security classes should not end up in the classes directory as that will prevent them +# from working when running the exploded jdk image. Compile them separately to a different +# directory from where the jars can be created. +SECURITY_PKGS := \ + com/oracle/security/ucrypto \ + com/sun/crypto/provider \ + javax/crypto \ + sun/security/ec \ + sun/security/internal \ + sun/security/mscapi \ + sun/security/pkcs11 \ + # + # The exception handling of swing beaninfo # These resources violates the convention of having code and resources together under # $(JDK_TOPDIR)/src/.../classes directories @@ -293,22 +306,46 @@ $(JDK_OUTPUTDIR)/classes/javax/swing/beaninfo/images/%.gif: $(JDK_TOPDIR)/make/t # space separated list. JDK_USER_DEFINED_FILTER := $(strip $(subst $(COMMA),$(SPACE), $(JDK_FILTER))) -$(eval $(call SetupJavaCompilation,BUILD_JDK, \ +ifeq ($(ENABLE_SJAVAC),yes) + # With sjavac enabled, excluded sources are not even considered for linking. + # Explicitly add the security sources to sourcepath for linking. + BUILD_JDK_SOURCEPATH:=$(patsubst %,-i$(SPACE)%.*,$(subst /,.,$(SECURITY_PKGS))) \ + -sourcepath $(JDK_TOPDIR)/src/share/classes +endif + +$(eval $(call SetupJavaCompilation,BUILD_JDK,\ + SETUP:=GENERATE_JDKBYTECODE,\ + SRC:=$(JDK_TOPDIR)/src/share/classes \ + $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes \ + $(MACOSX_SRC_DIRS) \ + $(JDK_OUTPUTDIR)/gensrc \ + $(JDK_OUTPUTDIR)/gensrc_no_srczip \ + $(CLOSED_SRC_DIRS),\ + INCLUDES:=$(JDK_USER_DEFINED_FILTER),\ + EXCLUDES:=$(EXCLUDES) $(SECURITY_PKGS),\ + EXCLUDE_FILES:=$(EXFILES),\ + BIN:=$(JDK_OUTPUTDIR)/classes,\ + COPY:=$(COPY_PATTERNS),\ + COPY_FILES:=$(COPY_FILES),\ + HEADERS:=$(JDK_OUTPUTDIR)/gensrc_headers,\ + ADD_JAVAC_FLAGS:=$(BUILD_JDK_SOURCEPATH))) + +########################################################################################## + +$(eval $(call SetupJavaCompilation,BUILD_SECURITY, \ SETUP := GENERATE_JDKBYTECODE, \ SRC := $(JDK_TOPDIR)/src/share/classes \ - $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes \ - $(MACOSX_SRC_DIRS) \ - $(JDK_OUTPUTDIR)/gensrc \ - $(JDK_OUTPUTDIR)/gensrc_no_srczip \ - $(CLOSED_SRC_DIRS), \ - INCLUDES := $(JDK_USER_DEFINED_FILTER), \ + $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/classes \ + $(MACOSX_SRC_DIRS) \ + $(CLOSED_SRC_DIRS), \ + INCLUDES := $(SECURITY_PKGS), \ EXCLUDES := $(EXCLUDES), \ EXCLUDE_FILES := $(EXFILES), \ - BIN := $(JDK_OUTPUTDIR)/classes, \ - COPY := $(COPY_PATTERNS), \ - COPY_FILES := $(COPY_FILES), \ + BIN := $(JDK_OUTPUTDIR)/classes_security, \ HEADERS := $(JDK_OUTPUTDIR)/gensrc_headers)) +$(BUILD_SECURITY): $(BUILD_JDK) + ########################################################################################## $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin: @@ -393,7 +430,7 @@ endif ########################################################################################## -all: $(BUILD_JDK) $(BUILD_JOBJC) $(BUILD_JOBJC_HEADERS) $(COPY_EXTRA) \ +all: $(BUILD_JDK) $(BUILD_SECURITY) $(BUILD_JOBJC) $(BUILD_JOBJC_HEADERS) $(COPY_EXTRA) \ $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin \ $(BUILD_ACCESSBRIDGE_32) $(BUILD_ACCESSBRIDGE_64) \ $(BUILD_ACCESSBRIDGE_LEGACY) diff --git a/jdk/makefiles/CopyFiles.gmk b/jdk/makefiles/CopyFiles.gmk index 02bafafbbe8..0ac509cc7be 100644 --- a/jdk/makefiles/CopyFiles.gmk +++ b/jdk/makefiles/CopyFiles.gmk @@ -48,7 +48,7 @@ H_TARGET_FILES = $(INCLUDEDIR)/jdwpTransport.h \ $(INCLUDEDIR)/%.h: $(JDK_TOPDIR)/src/share/javavm/export/%.h $(call install-file) -$(OPENJDK_TARGET_OS_INCLUDE)/%.h: $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export/%.h +$(OPENJDK_TARGET_OS_INCLUDE)/%.h: $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_EXPORT_DIR)/javavm/export/%.h $(call install-file) COPY_FILES = $(H_TARGET_FILES) diff --git a/jdk/makefiles/CreateJars.gmk b/jdk/makefiles/CreateJars.gmk index b3595ab0344..8b965466d4e 100644 --- a/jdk/makefiles/CreateJars.gmk +++ b/jdk/makefiles/CreateJars.gmk @@ -102,7 +102,6 @@ $(eval $(call SetupArchive,BUILD_LOCALEDATA_JAR, , \ # This value should exclude types destined for jars other than rt.jar and resources.jar. # When building a Profile this value augments the profile specific exclusions RT_JAR_EXCLUDES += \ - com/oracle/security \ com/sun/codemodel \ com/sun/crypto/provider \ com/sun/istack/internal/tools \ @@ -414,86 +413,6 @@ $(eval $(call SetupArchive,BUILD_JSSE_JAR, , \ MANIFEST := $(MAINMANIFEST), \ CHECK_COMPRESS_JAR := true)) -########################################################################################## -# Create manifest for security jars - -# -# Include these extra attributes for now, should probably take out. -# -JCE_MANIFEST := $(IMAGES_OUTPUTDIR)/lib/_the.security.manifest.mf -$(JCE_MANIFEST): $(MAINMANIFEST) - $(MKDIR) -p $(@D) - $(RM) $@ $@.tmp - $(SED) -e "s#@@RELEASE@@#$(JDK_VERSION)#" \ - -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \ - $(MAINMANIFEST) >> $@.tmp - $(ECHO) "Extension-Name: javax.crypto" >> $@.tmp - $(ECHO) "Implementation-Vendor-Id: com.sun" >> $@.tmp - $(MV) $@.tmp $@ - -########################################################################################## -# For security and crypto jars, always build the jar, but for closed, install the prebuilt -# signed version instead of the newly built jar. Unsigned jars are treated as intermediate -# targets and explicitly added to the JARS list. For open, signing is not needed. See -# SignJars.gmk for more information. -# -# The source for the crypto jars is not available for all licensees. The BUILD_CRYPTO -# variable is set to no if these jars can't be built to skip that step of the build. -# Note that for OPENJDK, the build will fail if BUILD_CRYPTO=no since then there is no -# other way to get the jars than to build them. - -SUNPKCS11_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunpkcs11.jar -SUNPKCS11_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/sunpkcs11.jar - -$(eval $(call SetupArchive,BUILD_SUNPKCS11_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/classes, \ - SUFFIXES := .class, \ - INCLUDES := sun/security/pkcs11, \ - JAR := $(SUNPKCS11_JAR_UNSIGNED), \ - MANIFEST := $(JCE_MANIFEST), \ - SKIP_METAINF := true)) - -$(SUNPKCS11_JAR_UNSIGNED): $(JCE_MANIFEST) - -ifndef OPENJDK - SUNPKCS11_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/pkcs11/sunpkcs11.jar - $(SUNPKCS11_JAR_DST): $(SUNPKCS11_JAR_SRC) - @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunPKCS11 provider..." - $(install-file) -else - $(SUNPKCS11_JAR_DST): $(SUNPKCS11_JAR_UNSIGNED) - $(install-file) -endif - -JARS += $(SUNPKCS11_JAR_UNSIGNED) - -########################################################################################## - -SUNEC_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunec.jar -SUNEC_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/sunec.jar - -$(eval $(call SetupArchive,BUILD_SUNEC_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/classes, \ - SUFFIXES := .class, \ - INCLUDES := sun/security/ec, \ - JAR := $(SUNEC_JAR_UNSIGNED), \ - MANIFEST := $(JCE_MANIFEST), \ - SKIP_METAINF := true)) - -$(SUNEC_JAR_UNSIGNED): $(JCE_MANIFEST) - -ifndef OPENJDK - SUNEC_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/ec/sunec.jar - $(SUNEC_JAR_DST): $(SUNEC_JAR_SRC) - @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunEC provider..." - $(install-file) -else - $(SUNEC_JAR_DST): $(SUNEC_JAR_UNSIGNED) - $(install-file) -endif - -JARS += $(SUNEC_JAR_UNSIGNED) - ########################################################################################## $(eval $(call SetupArchive,BUILD_SWINGBEANS_JAR, , \ @@ -507,208 +426,6 @@ $(eval $(call SetupArchive,BUILD_SWINGBEANS_JAR, , \ ########################################################################################## -SUNJCE_PROVIDER_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunjce_provider.jar -SUNJCE_PROVIDER_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/sunjce_provider.jar - -ifneq ($(BUILD_CRYPTO), no) - $(eval $(call SetupArchive,BUILD_SUNJCE_PROVIDER_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/classes, \ - SUFFIXES := .class, \ - INCLUDES := com/sun/crypto/provider, \ - JAR := $(SUNJCE_PROVIDER_JAR_UNSIGNED), \ - MANIFEST := $(JCE_MANIFEST), \ - SKIP_METAINF := true)) - - $(SUNJCE_PROVIDER_JAR_UNSIGNED): $(JCE_MANIFEST) - - JARS += $(SUNJCE_PROVIDER_JAR_UNSIGNED) -endif - -ifndef OPENJDK - SUNJCE_PROVIDER_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/jce/sunjce_provider.jar - $(SUNJCE_PROVIDER_JAR_DST): $(SUNJCE_PROVIDER_JAR_SRC) - @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunJCE provider..." - $(install-file) -else - $(SUNJCE_PROVIDER_JAR_DST): $(SUNJCE_PROVIDER_JAR_UNSIGNED) - $(install-file) -endif - -########################################################################################## - -JCE_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/jce.jar -JCE_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/jce.jar - -ifneq ($(BUILD_CRYPTO), no) - $(eval $(call SetupArchive,BUILD_JCE_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/classes, \ - SUFFIXES := .class, \ - INCLUDES := javax/crypto sun/security/internal, \ - JAR := $(JCE_JAR_UNSIGNED), \ - MANIFEST := $(JCE_MANIFEST), \ - SKIP_METAINF := true)) - - $(JCE_JAR_UNSIGNED): $(JCE_MANIFEST) - - JARS += $(JCE_JAR_UNSIGNED) -endif - -ifndef OPENJDK - JCE_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/jce/jce.jar - $(JCE_JAR_DST): $(JCE_JAR_SRC) - @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt jce.jar..." - $(install-file) -else - $(JCE_JAR_DST): $(JCE_JAR_UNSIGNED) - $(install-file) -endif - -########################################################################################## - -US_EXPORT_POLICY_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/security/US_export_policy.jar -US_EXPORT_POLICY_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/US_export_policy.jar - -ifneq ($(BUILD_CRYPTO), no) - # - # TODO fix so that SetupArchive does not write files into SRCS - # then we don't need this extra copying - - # NOTE: We currently do not place restrictions on our limited export - # policy. This was not a typo. - # - US_EXPORT_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited - US_EXPORT_POLICY_JAR_TMP := $(IMAGES_OUTPUTDIR)/US_export_policy_jar.tmp - - $(US_EXPORT_POLICY_JAR_TMP)/%: $(US_EXPORT_POLICY_JAR_SRC_DIR)/% - $(install-file) - - US_EXPORT_POLICY_JAR_DEPS := $(US_EXPORT_POLICY_JAR_TMP)/default_US_export.policy - - $(eval $(call SetupArchive,BUILD_US_EXPORT_POLICY_JAR, $(US_EXPORT_POLICY_JAR_DEPS), \ - SRCS := $(US_EXPORT_POLICY_JAR_TMP), \ - SUFFIXES := .policy, \ - JAR := $(US_EXPORT_POLICY_JAR_UNSIGNED), \ - EXTRA_MANIFEST_ATTR := Crypto-Strength: unlimited, \ - SKIP_METAINF := true)) - - JARS += $(US_EXPORT_POLICY_JAR_UNSIGNED) -endif - -ifndef OPENJDK - $(US_EXPORT_POLICY_JAR_DST): $(JDK_TOPDIR)/make/closed/tools/crypto/jce/US_export_policy.jar - $(ECHO) $(LOG_INFO) Copying $(@F) - $(install-file) -else - $(US_EXPORT_POLICY_JAR_DST): $(US_EXPORT_POLICY_JAR_UNSIGNED) - $(install-file) -endif - -########################################################################################## - -LOCAL_POLICY_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/security/local_policy.jar -LOCAL_POLICY_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/local_policy.jar - -ifneq ($(BUILD_CRYPTO), no) - # - # TODO fix so that SetupArchive does not write files into SRCS - # then we don't need this extra copying - # - LOCAL_POLICY_JAR_TMP := $(IMAGES_OUTPUTDIR)/local_policy_jar.tmp - - ifeq ($(UNLIMITED_CRYPTO), true) - LOCAL_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited - LOCAL_POLICY_JAR_DEPS := $(LOCAL_POLICY_JAR_TMP)/default_local.policy - LOCAL_POLICY_JAR_ATTR := Crypto-Strength: unlimited - else - LOCAL_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/limited - LOCAL_POLICY_JAR_DEPS := $(LOCAL_POLICY_JAR_TMP)/exempt_local.policy \ - $(LOCAL_POLICY_JAR_TMP)/default_local.policy - LOCAL_POLICY_JAR_ATTR := Crypto-Strength: limited - endif - - $(LOCAL_POLICY_JAR_TMP)/%: $(LOCAL_POLICY_JAR_SRC_DIR)/% - $(install-file) - - $(eval $(call SetupArchive,BUILD_LOCAL_POLICY_JAR, $(LOCAL_POLICY_JAR_DEPS), \ - SRCS := $(LOCAL_POLICY_JAR_TMP), \ - SUFFIXES := .policy, \ - JAR := $(LOCAL_POLICY_JAR_UNSIGNED), \ - EXTRA_MANIFEST_ATTR := $(LOCAL_POLICY_JAR_ATTR), \ - SKIP_METAINF := true)) - - JARS += $(LOCAL_POLICY_JAR_UNSIGNED) -endif - -ifndef OPENJDK - $(LOCAL_POLICY_JAR_DST): $(JDK_TOPDIR)/make/closed/tools/crypto/jce/local_policy.jar - $(ECHO) $(LOG_INFO) Copying $(@F) - $(install-file) -else - $(LOCAL_POLICY_JAR_DST): $(LOCAL_POLICY_JAR_UNSIGNED) - $(install-file) -endif - -########################################################################################## - -ifeq ($(OPENJDK_TARGET_OS), windows) - - SUNMSCAPI_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/sunmscapi.jar - SUNMSCAPI_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/sunmscapi.jar - - $(eval $(call SetupArchive,BUILD_SUNMSCAPI_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/classes, \ - SUFFIXES := .class, \ - INCLUDES := sun/security/mscapi, \ - JAR := $(SUNMSCAPI_JAR_UNSIGNED), \ - MANIFEST := $(JCE_MANIFEST), \ - SKIP_METAINF := true)) - - $(SUNMSCAPI_JAR_UNSIGNED): $(JCE_MANIFEST) - - ifndef OPENJDK - SUNMSCAPI_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/mscapi/sunmscapi.jar - $(SUNMSCAPI_JAR_DST): $(SUNMSCAPI_JAR_SRC) - @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunMSCAPI provider..." - $(install-file) - else - $(SUNMSCAPI_JAR_DST): $(SUNMSCAPI_JAR_UNSIGNED) - $(install-file) - endif - - JARS += $(SUNMSCAPI_JAR_UNSIGNED) - -endif - -########################################################################################## - -ifeq ($(OPENJDK_TARGET_OS), solaris) - ifndef OPENJDK - - UCRYPTO_JAR_DST := $(IMAGES_OUTPUTDIR)/lib/ext/ucrypto.jar - UCRYPTO_JAR_UNSIGNED := $(IMAGES_OUTPUTDIR)/unsigned/ucrypto.jar - UCRYPTO_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/ucrypto/ucrypto.jar - - $(eval $(call SetupArchive,BUILD_UCRYPTO_JAR, , \ - SRCS := $(JDK_OUTPUTDIR)/classes, \ - SUFFIXES := .class, \ - INCLUDES := com/oracle/security/ucrypto, \ - JAR := $(UCRYPTO_JAR_UNSIGNED), \ - MANIFEST := $(JCE_MANIFEST), \ - SKIP_METAINF := true)) - - $(UCRYPTO_JAR_UNSIGNED): $(JCE_MANIFEST) - - $(UCRYPTO_JAR_DST): $(UCRYPTO_JAR_SRC) - @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt OracleUcrypto provider..." - $(install-file) - - JARS += $(UCRYPTO_JAR_UNSIGNED) - - endif -endif - -########################################################################################## - # Get the CLDRVERSION include gensrc/GensrcCLDR.gmk @@ -1047,6 +764,13 @@ endif ########################################################################################## +# This rule copies all jars from jdk/lib/... to images/lib/... to avoid having to track +# which jars are where +$(IMAGES_OUTPUTDIR)/lib/%: $(JDK_OUTPUTDIR)/lib/% + $(install-file) + +########################################################################################## + # Import nashorn.jar from nashorn dist dir. $(IMAGES_OUTPUTDIR)/lib/ext/nashorn.jar: $(NASHORN_DIST)/nashorn.jar $(install-file) diff --git a/jdk/makefiles/CreateSecurityJars.gmk b/jdk/makefiles/CreateSecurityJars.gmk new file mode 100644 index 00000000000..f7e54160232 --- /dev/null +++ b/jdk/makefiles/CreateSecurityJars.gmk @@ -0,0 +1,329 @@ +# +# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +default: all + +include $(SPEC) +include MakeBase.gmk +include JavaCompilation.gmk +include Setup.gmk + +# The jars created in this file are required for the exploded jdk image to function and +# cannot wait to be built in the images target. + +########################################################################################## +# Create manifest for security jars +# +# Include these extra attributes for now, should probably take out. +# +MAINMANIFEST := $(JDK_TOPDIR)/make/tools/manifest.mf +JCE_MANIFEST := $(JDK_OUTPUTDIR)/lib/_the.security.manifest.mf + +$(JCE_MANIFEST): $(MAINMANIFEST) + $(MKDIR) -p $(@D) + $(RM) $@ $@.tmp + $(SED) -e "s#@@RELEASE@@#$(JDK_VERSION)#" \ + -e "s#@@COMPANY_NAME@@#$(COMPANY_NAME)#" \ + $(MAINMANIFEST) >> $@.tmp + $(ECHO) "Extension-Name: javax.crypto" >> $@.tmp + $(ECHO) "Implementation-Vendor-Id: com.sun" >> $@.tmp + $(MV) $@.tmp $@ + +########################################################################################## +# For security and crypto jars, always build the jar, but for closed, install the prebuilt +# signed version instead of the newly built jar. Unsigned jars are treated as intermediate +# targets and explicitly added to the JARS list. For open, signing is not needed. See +# SignJars.gmk for more information. +# +# The source for the crypto jars is not available for all licensees. The BUILD_CRYPTO +# variable is set to no if these jars can't be built to skip that step of the build. +# Note that for OPENJDK, the build will fail if BUILD_CRYPTO=no since then there is no +# other way to get the jars than to build them. + +SUNPKCS11_JAR_DST := $(JDK_OUTPUTDIR)/lib/ext/sunpkcs11.jar +SUNPKCS11_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/unsigned/sunpkcs11.jar + +$(eval $(call SetupArchive,BUILD_SUNPKCS11_JAR, , \ + SRCS := $(JDK_OUTPUTDIR)/classes_security, \ + SUFFIXES := .class, \ + INCLUDES := sun/security/pkcs11, \ + JAR := $(SUNPKCS11_JAR_UNSIGNED), \ + MANIFEST := $(JCE_MANIFEST), \ + SKIP_METAINF := true)) + +$(SUNPKCS11_JAR_UNSIGNED): $(JCE_MANIFEST) + +ifndef OPENJDK + SUNPKCS11_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/pkcs11/sunpkcs11.jar + $(SUNPKCS11_JAR_DST): $(SUNPKCS11_JAR_SRC) + @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunPKCS11 provider..." + $(install-file) +else + $(SUNPKCS11_JAR_DST): $(SUNPKCS11_JAR_UNSIGNED) + $(install-file) +endif + +JARS += $(SUNPKCS11_JAR_UNSIGNED) $(SUNPKCS11_JAR_DST) + +########################################################################################## + +SUNEC_JAR_DST := $(JDK_OUTPUTDIR)/lib/ext/sunec.jar +SUNEC_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/unsigned/sunec.jar + +$(eval $(call SetupArchive,BUILD_SUNEC_JAR, , \ + SRCS := $(JDK_OUTPUTDIR)/classes_security, \ + SUFFIXES := .class, \ + INCLUDES := sun/security/ec, \ + JAR := $(SUNEC_JAR_UNSIGNED), \ + MANIFEST := $(JCE_MANIFEST), \ + SKIP_METAINF := true)) + +$(SUNEC_JAR_UNSIGNED): $(JCE_MANIFEST) + +ifndef OPENJDK + SUNEC_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/ec/sunec.jar + $(SUNEC_JAR_DST): $(SUNEC_JAR_SRC) + @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunEC provider..." + $(install-file) +else + $(SUNEC_JAR_DST): $(SUNEC_JAR_UNSIGNED) + $(install-file) +endif + +JARS += $(SUNEC_JAR_UNSIGNED) $(SUNEC_JAR_DST) + +########################################################################################## + +SUNJCE_PROVIDER_JAR_DST := $(JDK_OUTPUTDIR)/lib/ext/sunjce_provider.jar +SUNJCE_PROVIDER_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/unsigned/sunjce_provider.jar + +ifneq ($(BUILD_CRYPTO), no) + $(eval $(call SetupArchive,BUILD_SUNJCE_PROVIDER_JAR, , \ + SRCS := $(JDK_OUTPUTDIR)/classes_security, \ + SUFFIXES := .class, \ + INCLUDES := com/sun/crypto/provider, \ + JAR := $(SUNJCE_PROVIDER_JAR_UNSIGNED), \ + MANIFEST := $(JCE_MANIFEST), \ + SKIP_METAINF := true)) + + $(SUNJCE_PROVIDER_JAR_UNSIGNED): $(JCE_MANIFEST) + + JARS += $(SUNJCE_PROVIDER_JAR_UNSIGNED) +endif + +ifndef OPENJDK + SUNJCE_PROVIDER_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/jce/sunjce_provider.jar + $(SUNJCE_PROVIDER_JAR_DST): $(SUNJCE_PROVIDER_JAR_SRC) + @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunJCE provider..." + $(install-file) +else + $(SUNJCE_PROVIDER_JAR_DST): $(SUNJCE_PROVIDER_JAR_UNSIGNED) + $(install-file) +endif + +JARS += $(SUNJCE_PROVIDER_JAR_DST) + +########################################################################################## + +JCE_JAR_DST := $(JDK_OUTPUTDIR)/lib/jce.jar +JCE_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/unsigned/jce.jar + +ifneq ($(BUILD_CRYPTO), no) + $(eval $(call SetupArchive,BUILD_JCE_JAR, , \ + SRCS := $(JDK_OUTPUTDIR)/classes_security, \ + SUFFIXES := .class, \ + INCLUDES := javax/crypto sun/security/internal, \ + JAR := $(JCE_JAR_UNSIGNED), \ + MANIFEST := $(JCE_MANIFEST), \ + SKIP_METAINF := true)) + + $(JCE_JAR_UNSIGNED): $(JCE_MANIFEST) + + JARS += $(JCE_JAR_UNSIGNED) +endif + +ifndef OPENJDK + JCE_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/jce/jce.jar + $(JCE_JAR_DST): $(JCE_JAR_SRC) + @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt jce.jar..." + $(install-file) +else + $(JCE_JAR_DST): $(JCE_JAR_UNSIGNED) + $(install-file) +endif + +JARS += $(JCE_JAR_DST) + +########################################################################################## + +US_EXPORT_POLICY_JAR_DST := $(JDK_OUTPUTDIR)/lib/security/US_export_policy.jar +US_EXPORT_POLICY_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/unsigned/US_export_policy.jar + +ifneq ($(BUILD_CRYPTO), no) + # + # TODO fix so that SetupArchive does not write files into SRCS + # then we don't need this extra copying + # + # NOTE: We currently do not place restrictions on our limited export + # policy. This was not a typo. + # + US_EXPORT_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited + US_EXPORT_POLICY_JAR_TMP := $(JDK_OUTPUTDIR)/US_export_policy_jar.tmp + + $(US_EXPORT_POLICY_JAR_TMP)/%: $(US_EXPORT_POLICY_JAR_SRC_DIR)/% + $(install-file) + + US_EXPORT_POLICY_JAR_DEPS := $(US_EXPORT_POLICY_JAR_TMP)/default_US_export.policy + + $(eval $(call SetupArchive,BUILD_US_EXPORT_POLICY_JAR, $(US_EXPORT_POLICY_JAR_DEPS), \ + SRCS := $(US_EXPORT_POLICY_JAR_TMP), \ + SUFFIXES := .policy, \ + JAR := $(US_EXPORT_POLICY_JAR_UNSIGNED), \ + EXTRA_MANIFEST_ATTR := Crypto-Strength: unlimited, \ + SKIP_METAINF := true)) + + JARS += $(US_EXPORT_POLICY_JAR_UNSIGNED) +endif + +ifndef OPENJDK + $(US_EXPORT_POLICY_JAR_DST): $(JDK_TOPDIR)/make/closed/tools/crypto/jce/US_export_policy.jar + $(ECHO) $(LOG_INFO) Copying $(@F) + $(install-file) +else + $(US_EXPORT_POLICY_JAR_DST): $(US_EXPORT_POLICY_JAR_UNSIGNED) + $(install-file) +endif + +JARS += $(US_EXPORT_POLICY_JAR_DST) + +########################################################################################## + +LOCAL_POLICY_JAR_DST := $(JDK_OUTPUTDIR)/lib/security/local_policy.jar +LOCAL_POLICY_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/unsigned/local_policy.jar + +ifneq ($(BUILD_CRYPTO), no) + # + # TODO fix so that SetupArchive does not write files into SRCS + # then we don't need this extra copying + # + LOCAL_POLICY_JAR_TMP := $(JDK_OUTPUTDIR)/local_policy_jar.tmp + + ifeq ($(UNLIMITED_CRYPTO), true) + LOCAL_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/unlimited + LOCAL_POLICY_JAR_DEPS := $(LOCAL_POLICY_JAR_TMP)/default_local.policy + LOCAL_POLICY_JAR_ATTR := Crypto-Strength: unlimited + else + LOCAL_POLICY_JAR_SRC_DIR := $(JDK_TOPDIR)/make/javax/crypto/policy/limited + LOCAL_POLICY_JAR_DEPS := $(LOCAL_POLICY_JAR_TMP)/exempt_local.policy \ + $(LOCAL_POLICY_JAR_TMP)/default_local.policy + LOCAL_POLICY_JAR_ATTR := Crypto-Strength: limited + endif + + $(LOCAL_POLICY_JAR_TMP)/%: $(LOCAL_POLICY_JAR_SRC_DIR)/% + $(install-file) + + $(eval $(call SetupArchive,BUILD_LOCAL_POLICY_JAR, $(LOCAL_POLICY_JAR_DEPS), \ + SRCS := $(LOCAL_POLICY_JAR_TMP), \ + SUFFIXES := .policy, \ + JAR := $(LOCAL_POLICY_JAR_UNSIGNED), \ + EXTRA_MANIFEST_ATTR := $(LOCAL_POLICY_JAR_ATTR), \ + SKIP_METAINF := true)) + + JARS += $(LOCAL_POLICY_JAR_UNSIGNED) +endif + +ifndef OPENJDK + $(LOCAL_POLICY_JAR_DST): $(JDK_TOPDIR)/make/closed/tools/crypto/jce/local_policy.jar + $(ECHO) $(LOG_INFO) Copying $(@F) + $(install-file) +else + $(LOCAL_POLICY_JAR_DST): $(LOCAL_POLICY_JAR_UNSIGNED) + $(install-file) +endif + +JARS += $(LOCAL_POLICY_JAR_DST) + +########################################################################################## + +ifeq ($(OPENJDK_TARGET_OS), windows) + + SUNMSCAPI_JAR_DST := $(JDK_OUTPUTDIR)/lib/ext/sunmscapi.jar + SUNMSCAPI_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/unsigned/sunmscapi.jar + + $(eval $(call SetupArchive,BUILD_SUNMSCAPI_JAR, , \ + SRCS := $(JDK_OUTPUTDIR)/classes_security, \ + SUFFIXES := .class, \ + INCLUDES := sun/security/mscapi, \ + JAR := $(SUNMSCAPI_JAR_UNSIGNED), \ + MANIFEST := $(JCE_MANIFEST), \ + SKIP_METAINF := true)) + + $(SUNMSCAPI_JAR_UNSIGNED): $(JCE_MANIFEST) + + ifndef OPENJDK + SUNMSCAPI_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/mscapi/sunmscapi.jar + $(SUNMSCAPI_JAR_DST): $(SUNMSCAPI_JAR_SRC) + @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt SunMSCAPI provider..." + $(install-file) + else + $(SUNMSCAPI_JAR_DST): $(SUNMSCAPI_JAR_UNSIGNED) + $(install-file) + endif + + JARS += $(SUNMSCAPI_JAR_UNSIGNED) $(SUNMSCAPI_JAR_DST) + +endif + +########################################################################################## + +ifeq ($(OPENJDK_TARGET_OS), solaris) + ifndef OPENJDK + + UCRYPTO_JAR_DST := $(JDK_OUTPUTDIR)/lib/ext/ucrypto.jar + UCRYPTO_JAR_UNSIGNED := $(JDK_OUTPUTDIR)/unsigned/ucrypto.jar + UCRYPTO_JAR_SRC := $(JDK_TOPDIR)/make/closed/tools/crypto/ucrypto/ucrypto.jar + + $(eval $(call SetupArchive,BUILD_UCRYPTO_JAR, , \ + SRCS := $(JDK_OUTPUTDIR)/classes_security, \ + SUFFIXES := .class, \ + INCLUDES := com/oracle/security/ucrypto, \ + JAR := $(UCRYPTO_JAR_UNSIGNED), \ + MANIFEST := $(JCE_MANIFEST), \ + SKIP_METAINF := true)) + + $(UCRYPTO_JAR_UNSIGNED): $(JCE_MANIFEST) + + $(UCRYPTO_JAR_DST): $(UCRYPTO_JAR_SRC) + @$(ECHO) $(LOG_INFO) "\n>>>Installing prebuilt OracleUcrypto provider..." + $(install-file) + + JARS += $(UCRYPTO_JAR_UNSIGNED) $(UCRYPTO_JAR_DST) + + endif +endif + +all: $(JARS) + +.PHONY: default all diff --git a/jdk/makefiles/GenerateSources.gmk b/jdk/makefiles/GenerateSources.gmk index 5246cc97698..7674fcd3744 100644 --- a/jdk/makefiles/GenerateSources.gmk +++ b/jdk/makefiles/GenerateSources.gmk @@ -66,15 +66,17 @@ include gensrc/GensrcExceptions.gmk GENSRC += $(GENSRC_EXCEPTIONS) ifneq ($(OPENJDK_TARGET_OS), windows) -include gensrc/GensrcIcons.gmk -GENSRC += $(GENSRC_AWT_ICONS) + include gensrc/GensrcIcons.gmk + GENSRC += $(GENSRC_AWT_ICONS) -ifeq ($(OPENJDK_TARGET_OS), macosx) -GENSRC += $(GENSRC_OSX_ICONS) -endif + ifeq ($(OPENJDK_TARGET_OS), macosx) + GENSRC += $(GENSRC_OSX_ICONS) + endif -include gensrc/GensrcX11Wrappers.gmk -GENSRC += $(GENSRC_X11WRAPPERS) + ifneq ($(OPENJDK_TARGET_OS), macosx) + include gensrc/GensrcX11Wrappers.gmk + GENSRC += $(GENSRC_X11WRAPPERS) + endif endif include gensrc/GensrcCLDR.gmk diff --git a/jdk/makefiles/Import.gmk b/jdk/makefiles/Import.gmk index 50164b9f5d3..46c64d4d468 100644 --- a/jdk/makefiles/Import.gmk +++ b/jdk/makefiles/Import.gmk @@ -120,11 +120,11 @@ $(eval $(call CopyDir,HOTSPOT0, $(HOTSPOT_LIB_DIR), $(INSTALL_LIBRARIES_HERE), $ $(eval $(call CopyDir,HOTSPOT1, $(HOTSPOT_DIST)/lib, $(JDK_OUTPUTDIR)/lib, $(HOTSPOT_IMPORT_FILES))) ifeq ($(OPENJDK_TARGET_OS), macosx) - JSIG_DEBUGINFO := $(strip $(wildcard $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.dSYM) \ - $(wildcard $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.diz) ) + JSIG_DEBUGINFO := $(strip $(wildcard $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig$(SHARED_LIBRARY_SUFFIX).dSYM) \ + $(wildcard $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.diz) ) else - JSIG_DEBUGINFO := $(strip $(wildcard $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.debuginfo) \ - $(wildcard $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.diz) ) + JSIG_DEBUGINFO := $(strip $(wildcard $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.debuginfo) \ + $(wildcard $(HOTSPOT_DIST)/jre/lib$(OPENJDK_TARGET_CPU_LIBDIR)/libjsig.diz) ) endif ifneq ($(OPENJDK_TARGET_OS), windows) @@ -140,14 +140,14 @@ ifneq ($(OPENJDK_TARGET_OS), windows) IMPORT_TARGET_FILES += $(INSTALL_LIBRARIES_HERE)/client/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I)) endif endif - ifneq ($(OPENJDK_TARGET_OS), macosx) - ifeq ($(JVM_VARIANT_MINIMAL1), true) - IMPORT_TARGET_FILES += $(INSTALL_LIBRARIES_HERE)/minimal/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) - ifneq (,$(JSIG_DEBUGINFO)) - IMPORT_TARGET_FILES += $(INSTALL_LIBRARIES_HERE)/minimal/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I)) - endif - endif + ifneq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(JVM_VARIANT_MINIMAL1), true) + IMPORT_TARGET_FILES += $(INSTALL_LIBRARIES_HERE)/minimal/$(LIBRARY_PREFIX)jsig$(SHARED_LIBRARY_SUFFIX) + ifneq (,$(JSIG_DEBUGINFO)) + IMPORT_TARGET_FILES += $(INSTALL_LIBRARIES_HERE)/minimal/$(foreach I,$(JSIG_DEBUGINFO),$(notdir $I)) + endif endif + endif endif $(INSTALL_LIBRARIES_HERE)/server/%$(SHARED_LIBRARY_SUFFIX): $(INSTALL_LIBRARIES_HERE)/%$(SHARED_LIBRARY_SUFFIX) @@ -156,26 +156,26 @@ $(INSTALL_LIBRARIES_HERE)/server/%$(SHARED_LIBRARY_SUFFIX): $(INSTALL_LIBRARIES_ $(LN) -s ../$(@F) $@ ifeq ($(OPENJDK_TARGET_OS), macosx) -$(INSTALL_LIBRARIES_HERE)/server/%.dSYM : $(INSTALL_LIBRARIES_HERE)/%.dSYM + $(INSTALL_LIBRARIES_HERE)/server/%.dSYM : $(INSTALL_LIBRARIES_HERE)/%.dSYM $(MKDIR) -p $(@D) $(RM) $@ $(LN) -s ../$(@F) $@ -$(INSTALL_LIBRARIES_HERE)/server/%.diz : $(INSTALL_LIBRARIES_HERE)/%.diz + $(INSTALL_LIBRARIES_HERE)/server/%.diz : $(INSTALL_LIBRARIES_HERE)/%.diz $(MKDIR) -p $(@D) $(RM) $@ - $(RM) $@.tmp $(basename $@).dSYM - $(LN) -s ../$(basename $(@F)).dSYM $(basename $@).dSYM - $(CD) $(@D) && $(ZIP) -q -y $@.tmp $(basename $(@F)).dSYM - $(RM) $(basename $@).dSYM + $(RM) $@.tmp $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM + $(LN) -s ../$(basename $(@F))$(SHARED_LIBRARY_SUFFIX).dSYM $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM + $(CD) $(@D) && $(ZIP) -q -y $@.tmp $(basename $(@F))$(SHARED_LIBRARY_SUFFIX).dSYM + $(RM) $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM $(MV) $@.tmp $@ else -$(INSTALL_LIBRARIES_HERE)/server/%.debuginfo: $(INSTALL_LIBRARIES_HERE)/%.debuginfo + $(INSTALL_LIBRARIES_HERE)/server/%.debuginfo: $(INSTALL_LIBRARIES_HERE)/%.debuginfo $(MKDIR) -p $(@D) $(RM) $@ $(LN) -s ../$(@F) $@ -$(INSTALL_LIBRARIES_HERE)/server/%.diz: $(INSTALL_LIBRARIES_HERE)/%.diz + $(INSTALL_LIBRARIES_HERE)/server/%.diz: $(INSTALL_LIBRARIES_HERE)/%.diz $(MKDIR) -p $(@D) $(RM) $@ $(RM) $@.tmp $(basename $@).debuginfo @@ -191,26 +191,26 @@ $(INSTALL_LIBRARIES_HERE)/client/%$(SHARED_LIBRARY_SUFFIX): $(INSTALL_LIBRARIES_ $(LN) -s ../$(@F) $@ ifeq ($(OPENJDK_TARGET_OS), macosx) -$(INSTALL_LIBRARIES_HERE)/client/%.dSYM : $(INSTALL_LIBRARIES_HERE)/%.dSYM + $(INSTALL_LIBRARIES_HERE)/client/%.dSYM : $(INSTALL_LIBRARIES_HERE)/%.dSYM $(MKDIR) -p $(@D) $(RM) $@ $(LN) -s ../$(@F) $@ -$(INSTALL_LIBRARIES_HERE)/client/%.diz : $(INSTALL_LIBRARIES_HERE)/%.diz + $(INSTALL_LIBRARIES_HERE)/client/%.diz : $(INSTALL_LIBRARIES_HERE)/%.diz $(MKDIR) -p $(@D) $(RM) $@ - $(RM) $@.tmp $(basename $@).dSYM - $(LN) -s ../$(basename $(@F)).dSYM $(basename $@).dSYM - $(CD) $(@D) && $(ZIP) -q -y $@.tmp $(basename $(@F)).dSYM - $(RM) $(basename $@).dSYM + $(RM) $@.tmp $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM + $(LN) -s ../$(basename $(@F))$(SHARED_LIBRARY_SUFFIX).dSYM $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM + $(CD) $(@D) && $(ZIP) -q -y $@.tmp $(basename $(@F))$(SHARED_LIBRARY_SUFFIX).dSYM + $(RM) $(basename $@)$(SHARED_LIBRARY_SUFFIX).dSYM $(MV) $@.tmp $@ else -$(INSTALL_LIBRARIES_HERE)/client/%.debuginfo: $(INSTALL_LIBRARIES_HERE)/%.debuginfo + $(INSTALL_LIBRARIES_HERE)/client/%.debuginfo: $(INSTALL_LIBRARIES_HERE)/%.debuginfo $(MKDIR) -p $(@D) $(RM) $@ $(LN) -s ../$(@F) $@ -$(INSTALL_LIBRARIES_HERE)/client/%.diz: $(INSTALL_LIBRARIES_HERE)/%.diz + $(INSTALL_LIBRARIES_HERE)/client/%.diz: $(INSTALL_LIBRARIES_HERE)/%.diz $(MKDIR) -p $(@D) $(RM) $@ $(RM) $@.tmp $(basename $@).debuginfo @@ -226,12 +226,12 @@ $(INSTALL_LIBRARIES_HERE)/minimal/%$(SHARED_LIBRARY_SUFFIX): $(INSTALL_LIBRARIES $(LN) -s ../$(@F) $@ ifneq ($(OPENJDK_TARGET_OS), macosx) -$(INSTALL_LIBRARIES_HERE)/minimal/%.debuginfo: $(INSTALL_LIBRARIES_HERE)/%.debuginfo + $(INSTALL_LIBRARIES_HERE)/minimal/%.debuginfo: $(INSTALL_LIBRARIES_HERE)/%.debuginfo $(MKDIR) -p $(@D) $(RM) $@ $(LN) -s ../$(@F) $@ -$(INSTALL_LIBRARIES_HERE)/minimal/%.diz: $(INSTALL_LIBRARIES_HERE)/%.diz + $(INSTALL_LIBRARIES_HERE)/minimal/%.diz: $(INSTALL_LIBRARIES_HERE)/%.diz $(MKDIR) -p $(@D) $(RM) $@ $(RM) $@.tmp $(basename $@).debuginfo diff --git a/jdk/makefiles/Setup.gmk b/jdk/makefiles/Setup.gmk index b624afb6025..d2e706f6a1b 100644 --- a/jdk/makefiles/Setup.gmk +++ b/jdk/makefiles/Setup.gmk @@ -27,7 +27,7 @@ DISABLE_WARNINGS := -Xlint:all,-deprecation,-unchecked,-rawtypes,-cast,-serial,- # To build with all warnings enabled, do the following: # make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000" -JAVAC_WARNINGS := -Xlint:-unchecked,-deprecation,-overrides,classfile,dep-ann,divzero,varargs -Werror +JAVAC_WARNINGS := -Xlint:-unchecked,-deprecation,-overrides,auxiliaryclass,classfile,dep-ann,divzero,empty,try,varargs -Werror # Any java code executed during a JDK build to build other parts of the JDK must be # executed by the bootstrap JDK (probably with -Xbootclasspath/p: ) and for this diff --git a/jdk/makefiles/SignJars.gmk b/jdk/makefiles/SignJars.gmk index 4e4233d419b..4005ab736f3 100644 --- a/jdk/makefiles/SignJars.gmk +++ b/jdk/makefiles/SignJars.gmk @@ -78,7 +78,7 @@ check-keystore: exit 2; \ fi -$(JCE_OUTPUTDIR)/%: $(IMAGES_OUTPUTDIR)/unsigned/% +$(JCE_OUTPUTDIR)/%: $(JDK_OUTPUTDIR)/unsigned/% $(call install-file) $(JARSIGNER) -keystore $(SIGNING_KEYSTORE) \ $@ $(SIGNING_ALIAS) < $(SIGNING_PASSPHRASE) diff --git a/jdk/makefiles/Tools.gmk b/jdk/makefiles/Tools.gmk index 49a3c61448a..d6d994a1582 100644 --- a/jdk/makefiles/Tools.gmk +++ b/jdk/makefiles/Tools.gmk @@ -32,7 +32,7 @@ TOOLS_SRC := $(JDK_TOPDIR)/make/tools/src \ $(JDK_TOPDIR)/makefiles/sun/osxapp \ $(JDK_TOPDIR)/make/tools/swing-beans -ifneq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) TOOLS_SRC += $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator endif diff --git a/jdk/makefiles/gensrc/GensrcX11Wrappers.gmk b/jdk/makefiles/gensrc/GensrcX11Wrappers.gmk index c6f7da80f74..4da4f37b2d9 100644 --- a/jdk/makefiles/gensrc/GensrcX11Wrappers.gmk +++ b/jdk/makefiles/gensrc/GensrcX11Wrappers.gmk @@ -99,7 +99,7 @@ ifneq ($(COMPILE_TYPE), cross) $(X_LIBS) \ -I$(JDK_OUTPUTDIR)/include \ -I$(JDK_TOPDIR)/src/share/javavm/export \ - -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \ + -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_EXPORT_DIR)/javavm/export \ -I$(JDK_TOPDIR)/src/share/native/common \ -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \ -I$(JDK_TOPDIR)/src/solaris/native/sun/awt \ diff --git a/jdk/makefiles/lib/Awt2dLibraries.gmk b/jdk/makefiles/lib/Awt2dLibraries.gmk index 9d1caa2ba98..c58187a2340 100644 --- a/jdk/makefiles/lib/Awt2dLibraries.gmk +++ b/jdk/makefiles/lib/Awt2dLibraries.gmk @@ -226,7 +226,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/windows \ $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d/windows \ $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d/d3d -else +else ifneq ($(OPENJDK_TARGET_OS), macosx) LIBAWT_DIRS += \ $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d/x11 endif @@ -509,15 +509,7 @@ BUILD_LIBRARIES += $(BUILD_LIBAWT) ########################################################################################## -# TODO!! -# Even though this variable as a general name, it is -# only used on macos, in fontpath.c, as prefix for where to find fonts. -# -# It's used for libawt_headless _and_ libawt_xawt -# -X11_PATH := /usr/X11R6 - -ifneq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),) ifndef BUILD_HEADLESS_ONLY LIBAWT_XAWT_DIRS := \ @@ -532,7 +524,7 @@ ifneq ($(OPENJDK_TARGET_OS), windows) $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/xawt \ LIBAWT_XAWT_CFLAGS := -DXAWT -DXAWT_HACK \ - -DX11_PATH=\"$(X11_PATH)\" -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \ + -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \ $(CUPS_CFLAGS) \ $(foreach dir, $(LIBAWT_XAWT_DIRS), -I$(dir)) \ -I$(JDK_TOPDIR)/src/share/native/sun/java2d \ @@ -627,11 +619,6 @@ ifneq ($(OPENJDK_TARGET_OS), windows) LIBAWT_XAWT_LDFLAGS += -lpthread endif - ifeq ($(OPENJDK_TARGET_OS), macosx) - LIBAWT_XAWT_LDFLAGS_SUFFIX += -lpthread - endif - - # On macosx, the shared library origin is set twice for this lib. $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_XAWT, \ LIBRARY := awt_xawt, \ OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \ @@ -653,10 +640,6 @@ ifneq ($(OPENJDK_TARGET_OS), windows) -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \ $(call SET_SHARED_LIBRARY_ORIGIN) \ $(call SET_SHARED_LIBRARY_ORIGIN,/..), \ - LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN) \ - $(call SET_SHARED_LIBRARY_ORIGIN). \ - $(call SET_SHARED_LIBRARY_ORIGIN) \ - $(call SET_SHARED_LIBRARY_ORIGIN)., \ LDFLAGS_SUFFIX := $(LIBAWT_XAWT_LDFLAGS_SUFFIX), \ VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \ RC_FLAGS := $(RC_FLAGS) \ @@ -788,6 +771,11 @@ ifeq ($(OPENJDK_TARGET_OS), windows) LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \ X11TextRenderer.c LIBFONTMANAGER_OPTIMIZATION := HIGHEST +else ifeq ($(OPENJDK_TARGET_OS), macosx) + LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \ + X11TextRenderer.c \ + fontpath.c \ + lcdglyph.c else LIBFONTMANAGER_EXCLUDE_FILES += fontpath.c \ lcdglyph.c @@ -845,7 +833,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \ $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT) -ifneq (, $(findstring $(OPENJDK_TARGET_OS), solaris macosx)) +ifeq ($(OPENJDK_TARGET_OS), solaris) $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT_XAWT) endif @@ -947,22 +935,21 @@ ifeq ($(OPENJDK_TARGET_OS), windows) else # OPENJDK_TARGET_OS not windows - JAWT_LIBS := - ifneq ($(OPENJDK_TARGET_OS), solaris) - JAWT_LIBS += -lawt - endif - - ifndef BUILD_HEADLESS_ONLY - JAWT_LIBS += -lawt_xawt - else - JAWT_LIBS += -lawt_headless - HEADLESS_CFLAG += -DHEADLESS - endif - - JAWT_FILES := jawt.c ifeq ($(OPENJDK_TARGET_OS), macosx) JAWT_FILES := jawt.m JAWT_LIBS := -lawt_lwawt + else + JAWT_FILES := jawt.c + JAWT_LIBS := + ifneq ($(OPENJDK_TARGET_OS), solaris) + JAWT_LIBS += -lawt + endif + ifndef BUILD_HEADLESS_ONLY + JAWT_LIBS += -lawt_xawt + else + JAWT_LIBS += -lawt_headless + HEADLESS_CFLAG += -DHEADLESS + endif endif $(eval $(call SetupNativeCompilation,BUILD_LIBJAWT, \ @@ -1094,7 +1081,8 @@ endif ########################################################################################## ifeq ($(BUILD_HEADLESS), true) - ifneq ($(OPENJDK_TARGET_OS), windows) + # Mac and Windows only use the native AWT lib, do not build libawt_headless + ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),) LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/share/native/sun/font \ $(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \ @@ -1108,7 +1096,7 @@ ifeq ($(BUILD_HEADLESS), true) endif LIBAWT_HEADLESS_CFLAGS := -DHEADLESS=true \ - -DX11_PATH=\"$(X11_PATH)\" -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \ + -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \ $(CUPS_CFLAGS) \ $(X_CFLAGS) \ -I$(JDK_TOPDIR)/src/share/native/sun/java2d \ @@ -1155,16 +1143,6 @@ ifeq ($(BUILD_HEADLESS), true) AccelGlyphCache.c \ CUPSfuncs.c - ifeq ($(OPENJDK_TARGET_OS), macosx) - LIBAWT_HEADLESS_FILES += \ - AWTFont.m \ - AWTStrike.m \ - CCharToGlyphMapper.m \ - CGGlyphImages.m \ - CGGlyphOutlines.m \ - CoreTextSupport.m - endif - LIBAWT_HEADLESS_REORDER := ifeq ($(OPENJDK_TARGET_OS), solaris) ifneq ($(OPENJDK_TARGET_CPU), x86_64) @@ -1191,13 +1169,6 @@ ifeq ($(BUILD_HEADLESS), true) REORDER := $(LIBAWT_HEADLESS_REORDER), \ LDFLAGS_SUFFIX_linux := -ljvm -lawt -lm $(LIBDL) -ljava, \ LDFLAGS_SUFFIX_solaris := $(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc, \ - LDFLAGS_SUFFIX_macosx := -ljvm $(LIBCXX) -lawt $(LIBDL) -ljava \ - -framework Accelerate \ - -framework ApplicationServices \ - -framework Cocoa \ - -F/System/Library/Frameworks/JavaVM.framework/Frameworks \ - -framework JavaNativeFoundation \ - -framework JavaRuntimeSupport, \ OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libawt_headless, \ DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES))) diff --git a/jdk/makefiles/mapfiles/libjava/mapfile-vers b/jdk/makefiles/mapfiles/libjava/mapfile-vers index 29ce7eb26df..7b4d5472b14 100644 --- a/jdk/makefiles/mapfiles/libjava/mapfile-vers +++ b/jdk/makefiles/mapfiles/libjava/mapfile-vers @@ -267,7 +267,8 @@ SUNWprivate_1.1 { Java_sun_misc_GC_maxObjectInspectionAge; Java_sun_reflect_NativeConstructorAccessorImpl_newInstance0; Java_sun_reflect_NativeMethodAccessorImpl_invoke0; - Java_sun_reflect_Reflection_getCallerClass; + Java_sun_reflect_Reflection_getCallerClass__; + Java_sun_reflect_Reflection_getCallerClass__I; Java_sun_reflect_Reflection_getClassAccessFlags; Java_sun_misc_Version_getJdkVersionInfo; Java_sun_misc_Version_getJdkSpecialVersion; diff --git a/jdk/makefiles/mapfiles/libjava/reorder-sparc b/jdk/makefiles/mapfiles/libjava/reorder-sparc index b64537e3edd..16573052576 100644 --- a/jdk/makefiles/mapfiles/libjava/reorder-sparc +++ b/jdk/makefiles/mapfiles/libjava/reorder-sparc @@ -27,7 +27,8 @@ text: .text%Java_java_io_FileInputStream_initIDs; text: .text%Java_java_io_FileDescriptor_initIDs; text: .text%Java_java_io_FileOutputStream_initIDs; text: .text%Java_java_lang_System_setIn0; -text: .text%Java_sun_reflect_Reflection_getCallerClass; +text: .text%Java_sun_reflect_Reflection_getCallerClass__; +text: .text%Java_sun_reflect_Reflection_getCallerClass__I; text: .text%Java_java_lang_Class_forName0; text: .text%Java_java_lang_Object_getClass; text: .text%Java_sun_reflect_Reflection_getClassAccessFlags; diff --git a/jdk/makefiles/mapfiles/libjava/reorder-sparcv9 b/jdk/makefiles/mapfiles/libjava/reorder-sparcv9 index 8e6d249a440..fe80fca8b59 100644 --- a/jdk/makefiles/mapfiles/libjava/reorder-sparcv9 +++ b/jdk/makefiles/mapfiles/libjava/reorder-sparcv9 @@ -26,7 +26,8 @@ text: .text%Java_java_io_FileInputStream_initIDs; text: .text%Java_java_io_FileDescriptor_initIDs; text: .text%Java_java_io_FileOutputStream_initIDs; text: .text%Java_java_lang_System_setIn0; -text: .text%Java_sun_reflect_Reflection_getCallerClass; +text: .text%Java_sun_reflect_Reflection_getCallerClass__; +text: .text%Java_sun_reflect_Reflection_getCallerClass__I; text: .text%Java_java_lang_Class_forName0; text: .text%Java_java_lang_String_intern; text: .text%Java_java_lang_Float_floatToIntBits; diff --git a/jdk/makefiles/mapfiles/libjava/reorder-x86 b/jdk/makefiles/mapfiles/libjava/reorder-x86 index ff4836f4612..839ee50caa8 100644 --- a/jdk/makefiles/mapfiles/libjava/reorder-x86 +++ b/jdk/makefiles/mapfiles/libjava/reorder-x86 @@ -28,7 +28,8 @@ text: .text%Java_java_io_FileInputStream_initIDs; text: .text%Java_java_io_FileDescriptor_initIDs; text: .text%Java_java_io_FileOutputStream_initIDs; text: .text%Java_java_lang_System_setIn0; -text: .text%Java_sun_reflect_Reflection_getCallerClass; +text: .text%Java_sun_reflect_Reflection_getCallerClass__; +text: .text%Java_sun_reflect_Reflection_getCallerClass__I; text: .text%Java_java_lang_Class_forName0; text: .text%Java_java_lang_String_intern; text: .text%Java_sun_reflect_NativeConstructorAccessorImpl_newInstance0; diff --git a/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java b/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java index b54a1baa2c5..0743c00ae63 100644 --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java @@ -233,6 +233,10 @@ public class CPrinterJob extends RasterPrinterJob { setAttributes(attributes); + // throw exception for invalid destination + if (destinationAttr != null) { + validateDestination(destinationAttr); + } /* Get the range of pages we are to print. If the * last page to print is unknown, then we print to diff --git a/jdk/src/macosx/javavm/export/jawt_md.h b/jdk/src/macosx/javavm/export/jawt_md.h new file mode 100644 index 00000000000..1d66461bf42 --- /dev/null +++ b/jdk/src/macosx/javavm/export/jawt_md.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1999, 2013 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#ifndef _JAVASOFT_JAWT_MD_H_ +#define _JAVASOFT_JAWT_MD_H_ + +#include "jawt.h" + +#ifdef __OBJC__ +#import +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Mac OS X specific declarations for AWT native interface. + * See notes in jawt.h for an example of use. + */ + +/* + * When calling JAWT_GetAWT with a JAWT version less than 1.7, you must pass this + * flag or you will not be able to get a valid drawing surface and JAWT_GetAWT will + * return false. This is to maintain compatibility with applications that used the + * interface with Java 6 which had multiple rendering models. This flag is not necessary + * when JAWT version 1.7 or greater is used as this is the only supported rendering mode. + * + * Example: + * JAWT awt; + * awt.version = JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER; + * jboolean success = JAWT_GetAWT(env, &awt); + */ +#define JAWT_MACOSX_USE_CALAYER 0x80000000 + +/* + * When the native Cocoa toolkit is in use, the pointer stored in + * JAWT_DrawingSurfaceInfo->platformInfo points to a NSObject that conforms to the + * JAWT_SurfaceLayers protocol. Setting the layer property of this object will cause the + * specified layer to be overlaid on the Components rectangle. If the window the + * Component belongs to has a CALayer attached to it, this layer will be accessible via + * the windowLayer property. + */ +#ifdef __OBJC__ +@protocol JAWT_SurfaceLayers +@property (readwrite, retain) CALayer *layer; +@property (readonly) CALayer *windowLayer; +@end +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !_JAVASOFT_JAWT_MD_H_ */ diff --git a/jdk/src/share/classes/java/lang/invoke/MagicLambdaImpl.java b/jdk/src/macosx/javavm/export/jni_md.h similarity index 63% rename from jdk/src/share/classes/java/lang/invoke/MagicLambdaImpl.java rename to jdk/src/macosx/javavm/export/jni_md.h index b78588bf8fa..9e47bedd61a 100644 --- a/jdk/src/share/classes/java/lang/invoke/MagicLambdaImpl.java +++ b/jdk/src/macosx/javavm/export/jni_md.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, 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 @@ -22,18 +22,21 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package java.lang.invoke; -/**

MagicLambdaImpl (named for similarity to MagicAccessorImpl and - others, not because it actually implements an interface) is a - marker class in the hierarchy. All subclasses of this class are - "magically" granted access by the VM to otherwise inaccessible - fields and methods of other classes. It is distinct from MagicAccessorImpl - because, while we want to bypass accessibility checks, we do not want to - bypass verification.

+#ifndef _JAVASOFT_JNI_MD_H_ +#define _JAVASOFT_JNI_MD_H_ -

Do not change the name of this class without also changing the - VM's code.

*/ +#define JNIEXPORT __attribute__((visibility("default"))) +#define JNIIMPORT __attribute__((visibility("default"))) +#define JNICALL -class MagicLambdaImpl { -} +typedef int jint; +#ifdef _LP64 /* 64-bit */ +typedef long jlong; +#else +typedef long long jlong; +#endif + +typedef signed char jbyte; + +#endif /* !_JAVASOFT_JNI_MD_H_ */ diff --git a/jdk/src/macosx/javavm/export/jvm_md.h b/jdk/src/macosx/javavm/export/jvm_md.h new file mode 100644 index 00000000000..012bb1babe2 --- /dev/null +++ b/jdk/src/macosx/javavm/export/jvm_md.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#ifndef _JAVASOFT_JVM_MD_H_ +#define _JAVASOFT_JVM_MD_H_ + +/* + * This file is currently collecting system-specific dregs for the + * JNI conversion, which should be sorted out later. + */ + +#include /* For DIR */ +#include /* For MAXPATHLEN */ +#include /* For F_OK, R_OK, W_OK */ +#include /* For ptrdiff_t */ +#include /* For uintptr_t */ + +#define JNI_ONLOAD_SYMBOLS {"JNI_OnLoad"} +#define JNI_ONUNLOAD_SYMBOLS {"JNI_OnUnload"} + +#define JNI_LIB_PREFIX "lib" +#define JNI_LIB_SUFFIX ".dylib" +#define VERSIONED_JNI_LIB_NAME(NAME, VERSION) JNI_LIB_PREFIX NAME "." VERSION JNI_LIB_SUFFIX +#define JNI_LIB_NAME(NAME) JNI_LIB_PREFIX NAME JNI_LIB_SUFFIX + +#define JVM_MAXPATHLEN MAXPATHLEN + +#define JVM_R_OK R_OK +#define JVM_W_OK W_OK +#define JVM_X_OK X_OK +#define JVM_F_OK F_OK + +/* + * File I/O + */ + +#include +#include +#include +#include +#include + +/* O Flags */ + +#define JVM_O_RDONLY O_RDONLY +#define JVM_O_WRONLY O_WRONLY +#define JVM_O_RDWR O_RDWR +#define JVM_O_O_APPEND O_APPEND +#define JVM_O_EXCL O_EXCL +#define JVM_O_CREAT O_CREAT +#define JVM_O_DELETE 0x10000 + +/* Signals */ + +#define JVM_SIGINT SIGINT +#define JVM_SIGTERM SIGTERM + + +#endif /* !_JAVASOFT_JVM_MD_H_ */ diff --git a/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.h b/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.h index 820be377358..58aec0b6126 100644 --- a/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.h +++ b/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.h @@ -23,8 +23,7 @@ * questions. */ -// REMIND: import -#import +#import /* * The CALayer-based rendering model returns an object conforming diff --git a/jdk/src/macosx/native/sun/awt/CMenuComponent.h b/jdk/src/macosx/native/sun/awt/CMenuComponent.h index 2e0a6454285..e5aff96c48b 100644 --- a/jdk/src/macosx/native/sun/awt/CMenuComponent.h +++ b/jdk/src/macosx/native/sun/awt/CMenuComponent.h @@ -24,7 +24,7 @@ */ #import -#import +#import @interface CMenuComponent : NSObject { diff --git a/jdk/src/macosx/native/sun/awt/CPrinterJob.m b/jdk/src/macosx/native/sun/awt/CPrinterJob.m index 3935240ff78..2b92c2250fb 100644 --- a/jdk/src/macosx/native/sun/awt/CPrinterJob.m +++ b/jdk/src/macosx/native/sun/awt/CPrinterJob.m @@ -359,7 +359,11 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj static JNF_CLASS_CACHE(jc_Pageable, "java/awt/print/Pageable"); static JNF_MEMBER_CACHE(jm_getCopies, sjc_CPrinterJob, "getCopiesInt", "()I"); static JNF_MEMBER_CACHE(jm_isCollated, sjc_CPrinterJob, "isCollated", "()Z"); + static JNF_MEMBER_CACHE(jm_getFromPage, sjc_CPrinterJob, "getFromPageAttrib", "()I"); + static JNF_MEMBER_CACHE(jm_getToPage, sjc_CPrinterJob, "getToPageAttrib", "()I"); + static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I"); static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I"); + static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;"); NSMutableDictionary* printingDictionary = [dst dictionary]; @@ -368,19 +372,35 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj jboolean collated = JNFCallBooleanMethod(env, srcPrinterJob, jm_isCollated); // AWT_THREADING Safe (known object) [printingDictionary setObject:[NSNumber numberWithBool:collated ? YES : NO] forKey:NSPrintMustCollate]; - jint jNumPages = JNFCallIntMethod(env, srcPageable, jm_getNumberOfPages); // AWT_THREADING Safe (!appKit) if (jNumPages != java_awt_print_Pageable_UNKNOWN_NUMBER_OF_PAGES) { - [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages]; + jint selectID = JNFCallIntMethod(env, srcPrinterJob, jm_getSelectAttrib); + if (selectID ==0) { + [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages]; + } else if (selectID == 2) { + // In Mac 10.7, Print ALL is deselected if PrintSelection is YES whether + // NSPrintAllPages is YES or NO + [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages]; + [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintSelectionOnly]; + } else { + [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages]; + } - [printingDictionary setObject:[NSNumber numberWithInteger:1] forKey:NSPrintFirstPage]; - [printingDictionary setObject:[NSNumber numberWithInteger:jNumPages] forKey:NSPrintLastPage]; + jint fromPage = JNFCallIntMethod(env, srcPrinterJob, jm_getFromPage); + jint toPage = JNFCallIntMethod(env, srcPrinterJob, jm_getToPage); + // setting fromPage and toPage will not be shown in the dialog if printing All pages + [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage]; + [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage]; } else { [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages]; } + jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat); + if (page != NULL) { + javaPageFormatToNSPrintInfo(env, NULL, page, dst); + } } /* diff --git a/jdk/src/macosx/native/sun/awt/jawt.m b/jdk/src/macosx/native/sun/awt/jawt.m index c295665fbf6..96669ef6e52 100644 --- a/jdk/src/macosx/native/sun/awt/jawt.m +++ b/jdk/src/macosx/native/sun/awt/jawt.m @@ -25,8 +25,7 @@ #import -// REMIND: import -#import +#import #import "awt_DrawingSurface.h" diff --git a/jdk/src/macosx/native/sun/font/CoreTextSupport.h b/jdk/src/macosx/native/sun/font/CoreTextSupport.h index 03735449266..467694d577a 100644 --- a/jdk/src/macosx/native/sun/font/CoreTextSupport.h +++ b/jdk/src/macosx/native/sun/font/CoreTextSupport.h @@ -24,7 +24,7 @@ */ #import -#import +#import #import #include "AWTFont.h" diff --git a/jdk/src/share/back/ThreadGroupReferenceImpl.c b/jdk/src/share/back/ThreadGroupReferenceImpl.c index 06ae01065d8..47b894a5894 100644 --- a/jdk/src/share/back/ThreadGroupReferenceImpl.c +++ b/jdk/src/share/back/ThreadGroupReferenceImpl.c @@ -47,7 +47,7 @@ name(PacketInputStream *in, PacketOutputStream *out) (void)memset(&info, 0, sizeof(info)); threadGroupInfo(group, &info); - (void)outStream_writeString(out, info.name); + (void)outStream_writeString(out, info.name == NULL ? "" : info.name); if ( info.name != NULL ) jvmtiDeallocate(info.name); diff --git a/jdk/src/share/back/outStream.c b/jdk/src/share/back/outStream.c index 8eeebc4c66e..b48d5591c20 100644 --- a/jdk/src/share/back/outStream.c +++ b/jdk/src/share/back/outStream.c @@ -298,17 +298,15 @@ jdwpError outStream_writeString(PacketOutputStream *stream, char *string) { jdwpError error; - jint length; + jint length = string != NULL ? (int)strlen(string) : 0; /* Options utf8=y/n controls if we want Standard UTF-8 or Modified */ if ( gdata->modifiedUtf8 ) { - length = (int)strlen(string); (void)outStream_writeInt(stream, length); error = writeBytes(stream, (jbyte *)string, length); } else { jint new_length; - length = (int)strlen(string); new_length = (gdata->npt->utf8mToUtf8sLength) (gdata->npt->utf, (jbyte*)string, length); if ( new_length == length ) { diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java index 94fd920ba31..b8c9a1e2b36 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java @@ -187,15 +187,24 @@ public class BMPImageReader extends ImageReader implements BMPConstants { return 1; } + @Override public int getWidth(int imageIndex) throws IOException { checkIndex(imageIndex); - readHeader(); + try { + readHeader(); + } catch (IllegalArgumentException e) { + throw new IIOException(I18N.getString("BMPImageReader6"), e); + } return width; } public int getHeight(int imageIndex) throws IOException { checkIndex(imageIndex); - readHeader(); + try { + readHeader(); + } catch (IllegalArgumentException e) { + throw new IIOException(I18N.getString("BMPImageReader6"), e); + } return height; } @@ -205,7 +214,18 @@ public class BMPImageReader extends ImageReader implements BMPConstants { } } - public void readHeader() throws IOException { + /** + * Process the image header. + * + * @exception IllegalStateException if source stream is not set. + * + * @exception IOException if image stream is corrupted. + * + * @exception IllegalArgumentException if the image stream does not contain + * a BMP image, or if a sample model instance to describe the + * image can not be created. + */ + protected void readHeader() throws IOException, IllegalArgumentException { if (gotHeader) return; @@ -307,6 +327,9 @@ public class BMPImageReader extends ImageReader implements BMPConstants { case BI_RLE4: // 4-bit RLE compression // Read in the palette + if (bitmapOffset < (size + 14)) { + throw new IIOException(I18N.getString("BMPImageReader7")); + } int numberOfEntries = (int)((bitmapOffset-14-size) / 4); int sizeOfPalette = numberOfEntries * 4; palette = new byte[sizeOfPalette]; @@ -375,7 +398,7 @@ public class BMPImageReader extends ImageReader implements BMPConstants { break; default: throw new - RuntimeException(I18N.getString("BMPImageReader2")); + IIOException(I18N.getString("BMPImageReader2")); } } else if (size == 108 || size == 124) { // Windows 4.x BMP @@ -478,7 +501,7 @@ public class BMPImageReader extends ImageReader implements BMPConstants { } } else { throw new - RuntimeException(I18N.getString("BMPImageReader3")); + IIOException(I18N.getString("BMPImageReader3")); } } @@ -660,7 +683,11 @@ public class BMPImageReader extends ImageReader implements BMPConstants { public Iterator getImageTypes(int imageIndex) throws IOException { checkIndex(imageIndex); - readHeader(); + try { + readHeader(); + } catch (IllegalArgumentException e) { + throw new IIOException(I18N.getString("BMPImageReader6"), e); + } ArrayList list = new ArrayList(1); list.add(new ImageTypeSpecifier(originalColorModel, originalSampleModel)); @@ -675,7 +702,11 @@ public class BMPImageReader extends ImageReader implements BMPConstants { throws IOException { checkIndex(imageIndex); if (metadata == null) { - readHeader(); + try { + readHeader(); + } catch (IllegalArgumentException e) { + throw new IIOException(I18N.getString("BMPImageReader6"), e); + } } return metadata; } @@ -686,7 +717,11 @@ public class BMPImageReader extends ImageReader implements BMPConstants { public boolean isRandomAccessEasy(int imageIndex) throws IOException { checkIndex(imageIndex); - readHeader(); + try { + readHeader(); + } catch (IllegalArgumentException e) { + throw new IIOException(I18N.getString("BMPImageReader6"), e); + } return metadata.compression == BI_RGB; } @@ -705,7 +740,11 @@ public class BMPImageReader extends ImageReader implements BMPConstants { param = getDefaultReadParam(); //read header - readHeader(); + try { + readHeader(); + } catch (IllegalArgumentException e) { + throw new IIOException(I18N.getString("BMPImageReader6"), e); + } sourceRegion = new Rectangle(0, 0, 0, 0); destinationRegion = new Rectangle(0, 0, 0, 0); @@ -817,7 +856,7 @@ public class BMPImageReader extends ImageReader implements BMPConstants { default: throw new - RuntimeException(I18N.getString("BMPImageReader1")); + IIOException(I18N.getString("BMPImageReader1")); } break; @@ -833,7 +872,7 @@ public class BMPImageReader extends ImageReader implements BMPConstants { default: throw new - RuntimeException(I18N.getString("BMPImageReader1")); + IIOException(I18N.getString("BMPImageReader1")); } break; @@ -874,7 +913,7 @@ public class BMPImageReader extends ImageReader implements BMPConstants { default: throw new - RuntimeException(I18N.getString("BMPImageReader1")); + IIOException(I18N.getString("BMPImageReader1")); } case VERSION_4_8_BIT: @@ -890,7 +929,7 @@ public class BMPImageReader extends ImageReader implements BMPConstants { default: throw new - RuntimeException(I18N.getString("BMPImageReader1")); + IIOException(I18N.getString("BMPImageReader1")); } break; diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/common/iio-plugin.properties b/jdk/src/share/classes/com/sun/imageio/plugins/common/iio-plugin.properties index 70a6f715211..85b108f8e3b 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/common/iio-plugin.properties +++ b/jdk/src/share/classes/com/sun/imageio/plugins/common/iio-plugin.properties @@ -21,6 +21,8 @@ BMPImageReader2=Invalid compression specified in BMP stream. BMPImageReader3=New BMP version not implemented yet. BMPImageReader4=No ImageIO-style reader is found for BMPImageReader5=Input has not been set. +BMPImageReader6=Unable to read the image header. +BMPImageReader7=Invalid bitmap offset. BMPImageWriter0=Output is not an ImageOutputStream. BMPImageWriter1=The image region to be encoded is empty. BMPImageWriter2=Only 1 or 3 band image is encoded. @@ -34,7 +36,7 @@ BMPMetadata0=The provided metadata format isn't recognized. BMPMetadata1=Metadata is read-only. -# WBMP plugin properties +# WBMP plugin properties WBMPImageReader0=Only one image exists in the stream. WBMPImageReader1=Input has not been set. WBMPImageReader2=Bad WBMP header. diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java index 0fbdefb8e0e..5e3d852275d 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java @@ -115,6 +115,8 @@ public class GIFImageReader extends ImageReader { // The current interlace pass, starting with 0. int interlacePass = 0; + private byte[] fallbackColorTable = null; + // End per-stream settings // Constants used to control interlacing. @@ -239,10 +241,22 @@ public class GIFImageReader extends ImageReader { byte[] colorTable; if (imageMetadata.localColorTable != null) { colorTable = imageMetadata.localColorTable; + fallbackColorTable = imageMetadata.localColorTable; } else { colorTable = streamMetadata.globalColorTable; } + if (colorTable == null) { + if (fallbackColorTable == null) { + this.processWarningOccurred("Use default color table."); + + // no color table, the spec allows to use any palette. + fallbackColorTable = getDefaultPalette(); + } + + colorTable = fallbackColorTable; + } + // Normalize color table length to 2^1, 2^2, 2^4, or 2^8 int length = colorTable.length/3; int bits; @@ -1036,5 +1050,34 @@ public class GIFImageReader extends ImageReader { streamY = -1; rowsDone = 0; interlacePass = 0; + + fallbackColorTable = null; + } + + private static byte[] defaultPalette = null; + + private static synchronized byte[] getDefaultPalette() { + if (defaultPalette == null) { + BufferedImage img = new BufferedImage(1, 1, + BufferedImage.TYPE_BYTE_INDEXED); + IndexColorModel icm = (IndexColorModel) img.getColorModel(); + + final int size = icm.getMapSize(); + byte[] r = new byte[size]; + byte[] g = new byte[size]; + byte[] b = new byte[size]; + icm.getReds(r); + icm.getGreens(g); + icm.getBlues(b); + + defaultPalette = new byte[size * 3]; + + for (int i = 0; i < size; i++) { + defaultPalette[3 * i + 0] = r[i]; + defaultPalette[3 * i + 1] = g[i]; + defaultPalette[3 * i + 2] = b[i]; + } + } + return defaultPalette; } } diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/MarkerSegment.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/MarkerSegment.java index fd8d1cd53c1..f38e30f3ae8 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/MarkerSegment.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/MarkerSegment.java @@ -28,6 +28,7 @@ package com.sun.imageio.plugins.jpeg; import javax.imageio.metadata.IIOInvalidTreeException; import javax.imageio.metadata.IIOMetadataNode; import javax.imageio.stream.ImageOutputStream; +import javax.imageio.IIOException; import java.io.IOException; @@ -60,6 +61,10 @@ class MarkerSegment implements Cloneable { length = (buffer.buf[buffer.bufPtr++] & 0xff) << 8; length |= buffer.buf[buffer.bufPtr++] & 0xff; length -= 2; // JPEG length includes itself, we don't + + if (length < 0) { + throw new IIOException("Invalid segment length: " + length); + } buffer.bufAvail -= 3; // Now that we know the true length, ensure that we've got it, // or at least a bufferful if length is too big. diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/SOFMarkerSegment.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/SOFMarkerSegment.java index c1359e7b09d..904fa73777c 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/SOFMarkerSegment.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/SOFMarkerSegment.java @@ -78,7 +78,7 @@ class SOFMarkerSegment extends MarkerSegment { numLines |= buffer.buf[buffer.bufPtr++] & 0xff; samplesPerLine = (buffer.buf[buffer.bufPtr++] & 0xff) << 8; samplesPerLine |= buffer.buf[buffer.bufPtr++] & 0xff; - int numComponents = buffer.buf[buffer.bufPtr++]; + int numComponents = buffer.buf[buffer.bufPtr++] & 0xff; componentSpecs = new ComponentSpec [numComponents]; for (int i = 0; i < numComponents; i++) { componentSpecs[i] = new ComponentSpec(buffer); diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java index e2ab9577dc4..abef6740f74 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java @@ -688,6 +688,21 @@ public class PNGImageReader extends ImageReader { loop: while (true) { int chunkLength = stream.readInt(); int chunkType = stream.readInt(); + int chunkCRC; + + // verify the chunk length + if (chunkLength < 0) { + throw new IIOException("Invalid chunk lenght " + chunkLength); + }; + + try { + stream.mark(); + stream.seek(stream.getStreamPosition() + chunkLength); + chunkCRC = stream.readInt(); + stream.reset(); + } catch (IOException e) { + throw new IIOException("Invalid chunk length " + chunkLength); + } switch (chunkType) { case IDAT_TYPE: @@ -762,7 +777,11 @@ public class PNGImageReader extends ImageReader { break; } - int chunkCRC = stream.readInt(); + // double check whether all chunk data were consumed + if (chunkCRC != stream.readInt()) { + throw new IIOException("Failed to read a chunk of type " + + chunkType); + } stream.flushBefore(stream.getStreamPosition()); } } catch (IOException e) { @@ -1277,6 +1296,16 @@ public class PNGImageReader extends ImageReader { is = new BufferedInputStream(is); this.pixelStream = new DataInputStream(is); + /* + * NB: the PNG spec declares that valid range for width + * and height is [1, 2^31-1], so here we may fail to allocate + * a buffer for destination image due to memory limitation. + * + * However, the recovery strategy for this case should be + * defined on the level of application, so we will not + * try to estimate the required amount of the memory and/or + * handle OOM in any way. + */ theImage = getDestination(param, getImageTypes(0), width, diff --git a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_de.properties b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_de.properties index c4eeded333f..a8985ce605f 100644 --- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_de.properties +++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/resources/gtk_de.properties @@ -41,7 +41,7 @@ FileChooser.saveDialogTitle.textAndMnemonic=Speichern FileChooser.openDialogTitle.textAndMnemonic=\u00D6ffnen FileChooser.pathLabel.textAndMnemonic=Aus&wahl: FileChooser.filterLabel.textAndMnemonic=Filter: -FileChooser.foldersLabel.textAndMnemonic=Or&dner +FileChooser.foldersLabel.textAndMnemonic=O&rdner FileChooser.filesLabel.textAndMnemonic=&Dateien FileChooser.cancelButtonToolTip.textAndMnemonic=Dialogfeld f\u00FCr Dateiauswahl schlie\u00DFen. diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java index 9ec7f7cd520..76af600386a 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java @@ -130,7 +130,7 @@ public class SnmpString extends SnmpValue { * @return The value. */ public byte[] byteValue() { - return value ; + return value.clone() ; } /** diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMib.java b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMib.java index df7587404ef..ac9c4bbd54f 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMib.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpMib.java @@ -476,8 +476,7 @@ public abstract class SnmpMib extends SnmpMibAgent implements Serializable { rootOid[i++]= val.longValue(); } } - return rootOid; - + return rootOid.clone(); } // -------------------------------------------------------------------- diff --git a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/CommunicatorServer.java b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/CommunicatorServer.java index b2634d8eee1..b0828e21be9 100644 --- a/jdk/src/share/classes/com/sun/jmx/snmp/daemon/CommunicatorServer.java +++ b/jdk/src/share/classes/com/sun/jmx/snmp/daemon/CommunicatorServer.java @@ -1248,7 +1248,7 @@ public abstract class CommunicatorServer "of this CommunicatorServer instance has changed."); } - return notifInfos; + return notifInfos.clone(); } /** diff --git a/jdk/src/share/classes/java/awt/image/ComponentSampleModel.java b/jdk/src/share/classes/java/awt/image/ComponentSampleModel.java index 9e2cd82e078..2a9def53a96 100644 --- a/jdk/src/share/classes/java/awt/image/ComponentSampleModel.java +++ b/jdk/src/share/classes/java/awt/image/ComponentSampleModel.java @@ -167,6 +167,7 @@ public class ComponentSampleModel extends SampleModel for (int i=0; i (Integer.MAX_VALUE - 1)) { + throw new IllegalArgumentException("Invalid band offset"); + } + + if (pixelStride < 0 || pixelStride > (Integer.MAX_VALUE / width)) { + throw new IllegalArgumentException("Invalid pixel stride"); + } + + if (scanlineStride < 0 || scanlineStride > (Integer.MAX_VALUE / height)) { + throw new IllegalArgumentException("Invalid scanline stride"); + } + + int size = maxBandOff + 1; + + int val = pixelStride * (width - 1); + + if (val > (Integer.MAX_VALUE - size)) { + throw new IllegalArgumentException("Invalid pixel stride"); + } + + size += val; + + val = scanlineStride * (height - 1); + + if (val > (Integer.MAX_VALUE - size)) { + throw new IllegalArgumentException("Invalid scan stride"); + } + + size += val; - long size = 0; - if (maxBandOff >= 0) - size += maxBandOff+1; - if (pixelStride > 0) - size += pixelStride * (width-1); - if (scanlineStride > 0) - size += scanlineStride*(height-1); return size; } @@ -409,7 +439,7 @@ public class ComponentSampleModel extends SampleModel public DataBuffer createDataBuffer() { DataBuffer dataBuffer = null; - int size = (int)getBufferSize(); + int size = getBufferSize(); switch (dataType) { case DataBuffer.TYPE_BYTE: dataBuffer = new DataBufferByte(size, numBanks); diff --git a/jdk/src/share/classes/java/io/ByteArrayInputStream.java b/jdk/src/share/classes/java/io/ByteArrayInputStream.java index e58c6e64a64..ce0b8d1f183 100644 --- a/jdk/src/share/classes/java/io/ByteArrayInputStream.java +++ b/jdk/src/share/classes/java/io/ByteArrayInputStream.java @@ -275,7 +275,6 @@ class ByteArrayInputStream extends InputStream { * Closing a ByteArrayInputStream has no effect. The methods in * this class can be called after the stream has been closed without * generating an IOException. - *

*/ public void close() throws IOException { } diff --git a/jdk/src/share/classes/java/io/ByteArrayOutputStream.java b/jdk/src/share/classes/java/io/ByteArrayOutputStream.java index d28d397b31c..cd3c139a27e 100644 --- a/jdk/src/share/classes/java/io/ByteArrayOutputStream.java +++ b/jdk/src/share/classes/java/io/ByteArrayOutputStream.java @@ -263,8 +263,6 @@ public class ByteArrayOutputStream extends OutputStream { * Closing a ByteArrayOutputStream has no effect. The methods in * this class can be called after the stream has been closed without * generating an IOException. - *

- * */ public void close() throws IOException { } diff --git a/jdk/src/share/classes/java/io/Closeable.java b/jdk/src/share/classes/java/io/Closeable.java index 530cde86171..b4a1c81f004 100644 --- a/jdk/src/share/classes/java/io/Closeable.java +++ b/jdk/src/share/classes/java/io/Closeable.java @@ -34,7 +34,6 @@ import java.io.IOException; * * @since 1.5 */ -@FunctionalInterface public interface Closeable extends AutoCloseable { /** diff --git a/jdk/src/share/classes/java/io/DataInput.java b/jdk/src/share/classes/java/io/DataInput.java index 58a3a2bfd3f..c61aeb58eda 100644 --- a/jdk/src/share/classes/java/io/DataInput.java +++ b/jdk/src/share/classes/java/io/DataInput.java @@ -155,7 +155,7 @@ interface DataInput { * to the length of {@code b}. *

* This method blocks until one of the - * following conditions occurs:

+ * following conditions occurs: *