diff --git a/.hgtags b/.hgtags index 36cbfa27702..a7ad329d42d 100644 --- a/.hgtags +++ b/.hgtags @@ -261,3 +261,5 @@ efe7dbc6088691757404e0c8745f894e3ca9c022 jdk9-b09 4a09f5d30be844ac6f714bdb0f63d8c3c08b9a98 jdk9-b16 410bccbded9e9cce80f1e13ad221e37ae97a3986 jdk9-b17 c5495e25c7258ab5f96a1ae14610887d76d2be63 jdk9-b18 +2dcf544eb7ed5ac6a3f7813a32e33acea7442405 jdk9-b19 +89731ae72a761afdf4262e8b9513f302f6563f89 jdk9-b20 diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 931d3b8d4c6..a6aef895743 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -261,3 +261,5 @@ b114474fb25af4e73cb7219f7c04bd8994da03a5 jdk9-b15 cf22a728521f91a4692b433d39d730a0a1b23155 jdk9-b16 24152ee0ee1abef54a8bab04c099261dba7bcca5 jdk9-b17 65abab59f783fcf02ff8e133431c252f9e5f07d5 jdk9-b18 +75a08df650eb3126bab0c4d15241f5886162393c jdk9-b19 +ee4fd72b2ec3d92497f37163352f294aa695c6fb jdk9-b20 diff --git a/common/autoconf/flags.m4 b/common/autoconf/flags.m4 index fc13f71b8aa..95fa6521575 100644 --- a/common/autoconf/flags.m4 +++ b/common/autoconf/flags.m4 @@ -116,15 +116,15 @@ AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS], AC_SUBST(RC_FLAGS) if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - # FIXME: likely bug, should be CCXXFLAGS_JDK? or one for C or CXX. - CCXXFLAGS="$CCXXFLAGS -nologo" + # silence copyright notice and other headers. + COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo" fi if test "x$SYSROOT" != "x"; then if test "x$TOOLCHAIN_TYPE" = xsolstudio; then if test "x$OPENJDK_TARGET_OS" = xsolaris; then # Solaris Studio does not have a concept of sysroot. Instead we must - # make sure the default include and lib dirs are appended to each + # make sure the default include and lib dirs are appended to each # compile and link command line. SYSROOT_CFLAGS="-I$SYSROOT/usr/include" SYSROOT_LDFLAGS="-L$SYSROOT/usr/lib$OPENJDK_TARGET_CPU_ISADIR \ @@ -302,6 +302,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], # Debug symbols if test "x$TOOLCHAIN_TYPE" = xgcc; then if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then + # reduce from default "-g2" option to save space CFLAGS_DEBUG_SYMBOLS="-g1" CXXFLAGS_DEBUG_SYMBOLS="-g1" else @@ -313,6 +314,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], CXXFLAGS_DEBUG_SYMBOLS="-g" elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then CFLAGS_DEBUG_SYMBOLS="-g -xs" + # FIXME: likely a bug, this disables debug symbols rather than enables them CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs" elif test "x$TOOLCHAIN_TYPE" = xxlc; then CFLAGS_DEBUG_SYMBOLS="-g" @@ -321,6 +323,31 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], AC_SUBST(CFLAGS_DEBUG_SYMBOLS) AC_SUBST(CXXFLAGS_DEBUG_SYMBOLS) + # bounds, memory and behavior checking options + if test "x$TOOLCHAIN_TYPE" = xgcc; then + case $DEBUG_LEVEL in + release ) + # no adjustment + ;; + fastdebug ) + # Add compile time bounds checks. + CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1" + CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1" + ;; + slowdebug ) + # Add runtime bounds checks and symbol info. + CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1" + CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1" + if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then + CFLAGS_DEBUG_OPTIONS="$CFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" + CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" + fi + ;; + esac + fi + AC_SUBST(CFLAGS_DEBUG_OPTIONS) + AC_SUBST(CXXFLAGS_DEBUG_OPTIONS) + # Optimization levels if test "x$TOOLCHAIN_TYPE" = xsolstudio; then CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil" @@ -330,10 +357,12 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr" C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr" C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr" + C_O_FLAG_DEBUG="-xregs=no%frameptr" C_O_FLAG_NONE="-xregs=no%frameptr" CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr" CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr" CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr" + CXX_O_FLAG_DEBUG="-xregs=no%frameptr" CXX_O_FLAG_NONE="-xregs=no%frameptr" if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium" @@ -343,10 +372,12 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra" C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0" C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0" + C_O_FLAG_DEBUG="" C_O_FLAG_NONE="" CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra" CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" + C_O_FLAG_DEBUG="" CXX_O_FLAG_NONE="" fi else @@ -359,13 +390,17 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], C_O_FLAG_HIGHEST="-Os" C_O_FLAG_HI="-Os" C_O_FLAG_NORM="-Os" - C_O_FLAG_NONE="" else C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="-O0" fi + if test "x$HAS_CFLAG_OPTIMIZE_DEBUG" = "xtrue"; then + C_O_FLAG_DEBUG="$CFLAG_OPTIMIZE_DEBUG_FLAG" + else + C_O_FLAG_DEBUG="-O0" + fi + C_O_FLAG_NONE="-O0" elif test "x$TOOLCHAIN_TYPE" = xclang; then if test "x$OPENJDK_TARGET_OS" = xmacosx; then # On MacOSX we optimize for size, something @@ -373,37 +408,63 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION], C_O_FLAG_HIGHEST="-Os" C_O_FLAG_HI="-Os" C_O_FLAG_NORM="-Os" - C_O_FLAG_NONE="" else C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="-O0" fi + C_O_FLAG_DEBUG="-O0" + C_O_FLAG_NONE="-O0" elif test "x$TOOLCHAIN_TYPE" = xxlc; then C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3 -qstrict" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="" + C_O_FLAG_DEBUG="-qnoopt" + C_O_FLAG_NONE="-qnoop" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then C_O_FLAG_HIGHEST="-O2" C_O_FLAG_HI="-O1" C_O_FLAG_NORM="-O1" + C_O_FLAG_DEBUG="-Od" C_O_FLAG_NONE="-Od" fi CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST" CXX_O_FLAG_HI="$C_O_FLAG_HI" CXX_O_FLAG_NORM="$C_O_FLAG_NORM" + CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG" CXX_O_FLAG_NONE="$C_O_FLAG_NONE" fi + # Adjust optimization flags according to debug level. + case $DEBUG_LEVEL in + release ) + # no adjustment + ;; + fastdebug ) + # Not quite so much optimization + C_O_FLAG_HI="$C_O_FLAG_NORM" + CXX_O_FLAG_HI="$CXX_O_FLAG_NORM" + ;; + slowdebug ) + # Disable optimization + C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG" + C_O_FLAG_HI="$C_O_FLAG_DEBUG" + C_O_FLAG_NORM="$C_O_FLAG_DEBUG" + CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG" + CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG" + CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG" + ;; + esac + AC_SUBST(C_O_FLAG_HIGHEST) AC_SUBST(C_O_FLAG_HI) AC_SUBST(C_O_FLAG_NORM) + AC_SUBST(C_O_FLAG_DEBUG) AC_SUBST(C_O_FLAG_NONE) AC_SUBST(CXX_O_FLAG_HIGHEST) AC_SUBST(CXX_O_FLAG_HI) AC_SUBST(CXX_O_FLAG_NORM) + AC_SUBST(CXX_O_FLAG_DEBUG) AC_SUBST(CXX_O_FLAG_NONE) ]) @@ -461,11 +522,12 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build. # - # Setup compiler/platform specific flags to CFLAGS_JDK, - # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?) + # Setup compiler/platform specific flags into + # CFLAGS_JDK - C Compiler flags + # CXXFLAGS_JDK - C++ Compiler flags + # COMMON_CCXXFLAGS_JDK - common to C and C++ if test "x$TOOLCHAIN_TYPE" = xgcc; then - # these options are used for both C and C++ compiles - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE" case $OPENJDK_TARGET_CPU_ARCH in arm ) @@ -477,31 +539,31 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" ;; * ) - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer" CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" ;; esac elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB" CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE" fi - + CFLAGS_JDK="$CFLAGS_JDK -xc99=%none -xCC -errshort=tags -Xa -v -mt -W0,-noglobal" CXXFLAGS_JDK="$CXXFLAGS_JDK -errtags=yes +w -mt -features=no%except -DCC_NOEX -norunpath -xnolib" elif test "x$TOOLCHAIN_TYPE" = xxlc; then CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \ -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \ -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \ -DWIN32 -DIAL" if test "x$OPENJDK_TARGET_CPU" = xx86_64; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86" fi fi @@ -509,28 +571,20 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # Adjust flags according to debug level. case $DEBUG_LEVEL in - fastdebug ) - CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS" - CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS" - C_O_FLAG_HI="$C_O_FLAG_NORM" - C_O_FLAG_NORM="$C_O_FLAG_NORM" - CXX_O_FLAG_HI="$CXX_O_FLAG_NORM" - CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM" + fastdebug | slowdebug ) + CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS" + CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS" JAVAC_FLAGS="$JAVAC_FLAGS -g" ;; - slowdebug ) - CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS" - CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS" - C_O_FLAG_HI="$C_O_FLAG_NONE" - C_O_FLAG_NORM="$C_O_FLAG_NONE" - CXX_O_FLAG_HI="$CXX_O_FLAG_NONE" - CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE" - JAVAC_FLAGS="$JAVAC_FLAGS -g" + release ) + ;; + * ) + AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL]) ;; esac # Setup LP64 - CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64" # Set some common defines. These works for all compilers, but assume # -D is universally accepted. @@ -543,49 +597,49 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # Note: -Dmacro is the same as #define macro 1 # -Dmacro= is the same as #define macro if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN=" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN=" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN" fi else # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they # are defined in the system? if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN=" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN=" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN" fi fi - + # Setup target OS define. Use OS target name but in upper case. OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE" # Setup target CPU - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" - + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" + # Setup debug/release defines if test "x$DEBUG_LEVEL" = xrelease; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG" if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED" fi else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG" fi # Setup release name - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" # Set some additional per-OS defines. if test "x$OPENJDK_TARGET_OS" = xmacosx; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" elif test "x$OPENJDK_TARGET_OS" = xaix; then # FIXME: PPC64 should not be here. - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DPPC64" elif test "x$OPENJDK_TARGET_OS" = xbsd; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE" fi # Additional macosx handling @@ -595,22 +649,22 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # FIXME: clean this up, and/or move it elsewhere. # Setting these parameters makes it an error to link to macosx APIs that are - # newer than the given OS version and makes the linked binaries compatible + # newer than the given OS version and makes the linked binaries compatible # even if built on a newer version of the OS. # The expected format is X.Y.Z MACOSX_VERSION_MIN=10.7.0 AC_SUBST(MACOSX_VERSION_MIN) - + # The macro takes the version with no dots, ex: 1070 # Let the flags variables get resolved in make for easier override on make # command line. - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" fi fi # Setup some hard coded includes - CCXXFLAGS_JDK="$CCXXFLAGS_JDK \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \ -I${JDK_OUTPUTDIR}/include \ -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \ -I${JDK_TOPDIR}/src/share/javavm/export \ @@ -619,12 +673,12 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common" # The shared libraries are compiled using the picflag. - CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA" - CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA " + CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA" + CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA " # Executable flags - CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK" - CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK" + CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK" + CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK" AC_SUBST(CFLAGS_JDKLIB) AC_SUBST(CFLAGS_JDKEXE) @@ -633,6 +687,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], # Setup LDFLAGS et al. # + # Now this is odd. The JDK native libraries have to link against libjvm.so # On 32-bit machines there is normally two distinct libjvm.so:s, client and server. # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library @@ -648,39 +703,93 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], fi # TODO: make -debug optional "--disable-full-debug-symbols" LDFLAGS_JDK="$LDFLAGS_JDK -debug" - LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib" - LDFLAGS_JDKLIB_SUFFIX="" + elif test "x$TOOLCHAIN_TYPE" = xgcc; then + # If this is a --hash-style=gnu system, use --hash-style=both, why? + # We have previously set HAS_GNU_HASH if this is the case + if test -n "$HAS_GNU_HASH"; then + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both" + fi + if test "x$OPENJDK_TARGET_OS" = xlinux; then + # And since we now know that the linker is gnu, then add -z defs, to forbid + # undefined symbols in object files. + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs" + case $DEBUG_LEVEL in + release ) + # tell linker to optimize libraries. + # Should this be supplied to the OSS linker as well? + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1" + ;; + slowdebug ) + if test "x$HAS_LINKER_NOW" = "xtrue"; then + # do relocations at load + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_NOW_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_NOW_FLAG" + fi + if test "x$HAS_LINKER_RELRO" = "xtrue"; then + # mark relocations read only + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG" + fi + ;; + fastdebug ) + if test "x$HAS_LINKER_RELRO" = "xtrue"; then + # mark relocations read only + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG" + fi + ;; + * ) + AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL]) + ;; + esac + fi + elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then + LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib" + fi + + if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then + # If undefined behaviour detection is enabled then we need to tell linker. + case $DEBUG_LEVEL in + release | fastdebug ) + ;; + slowdebug ) + AC_MSG_WARN([$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR]) + if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then + # enable undefined behaviour checking + LDFLAGS_JDK="$LDFLAGS_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/[ ]*\([^ ]\+\)/ -Xlinker \1/g"`" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/[ ]*\([^ ]\+\)/ -Xlinker \1/g"`" + fi + ;; + * ) + AC_MSG_ERROR([Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL]) + ;; + esac + fi + + # Customize LDFLAGS for executables + + LDFLAGS_JDKEXE="${LDFLAGS_JDK}" + + if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then LDFLAGS_STACK_SIZE=1048576 else LDFLAGS_STACK_SIZE=327680 fi - LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE" + LDFLAGS_JDKEXE="${LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE" + elif test "x$OPENJDK_TARGET_OS" = xlinux; then + LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined" + fi + + # Customize LDFLAGS for libs + LDFLAGS_JDKLIB="${LDFLAGS_JDK}" + + if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -dll -libpath:${JDK_OUTPUTDIR}/lib" + LDFLAGS_JDKLIB_SUFFIX="" else - if test "x$TOOLCHAIN_TYPE" = xgcc; then - # If this is a --hash-style=gnu system, use --hash-style=both, why? - # We have previously set HAS_GNU_HASH if this is the case - if test -n "$HAS_GNU_HASH"; then - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both " - fi - if test "x$OPENJDK_TARGET_OS" = xlinux; then - # And since we now know that the linker is gnu, then add -z defs, to forbid - # undefined symbols in object files. - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs" - if test "x$DEBUG_LEVEL" = "xrelease"; then - # When building release libraries, tell the linker optimize them. - # Should this be supplied to the OSS linker as well? - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1" - fi - fi - fi - - if test "x$TOOLCHAIN_TYPE" = xsolstudio; then - LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext" - LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib" - fi - - LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \ + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} ${SHARED_LIBRARY_FLAGS} \ -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}" # On some platforms (mac) the linker warns about non existing -L dirs. @@ -701,12 +810,8 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], if test "x$TOOLCHAIN_TYPE" = xsolstudio; then LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc" fi - - LDFLAGS_JDKEXE="${LDFLAGS_JDK}" - if test "x$OPENJDK_TARGET_OS" = xlinux; then - LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined" - fi fi + AC_SUBST(LDFLAGS_JDKLIB) AC_SUBST(LDFLAGS_JDKEXE) AC_SUBST(LDFLAGS_JDKLIB_SUFFIX) @@ -714,7 +819,6 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK], AC_SUBST(LDFLAGS_CXX_JDK) ]) - # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], # [RUN-IF-FALSE]) # ------------------------------------------------------------ @@ -727,7 +831,7 @@ AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS], saved_cflags="$CFLAGS" CFLAGS="$CFLAGS $1" AC_LANG_PUSH([C]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], [supports=no]) AC_LANG_POP([C]) CFLAGS="$saved_cflags" @@ -735,7 +839,7 @@ AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS], saved_cxxflags="$CXXFLAGS" CXXFLAGS="$CXXFLAG $1" AC_LANG_PUSH([C++]) - AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [], [supports=no]) AC_LANG_POP([C++]) CXXFLAGS="$saved_cxxflags" @@ -748,6 +852,31 @@ AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS], fi ]) +# FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], +# [RUN-IF-FALSE]) +# ------------------------------------------------------------ +# Check that the linker support an argument +AC_DEFUN([FLAGS_LINKER_CHECK_ARGUMENTS], +[ + AC_MSG_CHECKING([if linker supports "$1"]) + supports=yes + + saved_ldflags="$LDFLAGS" + LDFLAGS="$LDFLAGS $1" + AC_LANG_PUSH([C]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])], + [], [supports=no]) + AC_LANG_POP([C]) + LDFLAGS="$saved_ldflags" + + AC_MSG_RESULT([$supports]) + if test "x$supports" = "xyes" ; then + m4_ifval([$2], [$2], [:]) + else + m4_ifval([$3], [$3], [:]) + fi +]) + AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC], [ # Some Zero and Shark settings. diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 86905690fb7..4d95f64e34d 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -692,13 +692,17 @@ LEGACY_EXTRA_LDFLAGS LEGACY_EXTRA_CXXFLAGS LEGACY_EXTRA_CFLAGS CXX_O_FLAG_NONE +CXX_O_FLAG_DEBUG CXX_O_FLAG_NORM CXX_O_FLAG_HI CXX_O_FLAG_HIGHEST C_O_FLAG_NONE +C_O_FLAG_DEBUG C_O_FLAG_NORM C_O_FLAG_HI C_O_FLAG_HIGHEST +CXXFLAGS_DEBUG_OPTIONS +CFLAGS_DEBUG_OPTIONS CXXFLAGS_DEBUG_SYMBOLS CFLAGS_DEBUG_SYMBOLS CXX_FLAG_DEPS @@ -2346,6 +2350,52 @@ fi } # ac_fn_objc_try_compile +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + # ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES # --------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using @@ -3761,13 +3811,18 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. - # FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], # [RUN-IF-FALSE]) # ------------------------------------------------------------ # Check that the c and c++ compilers support an argument +# FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE], +# [RUN-IF-FALSE]) +# ------------------------------------------------------------ +# Check that the linker support an argument + + # @@ -4253,7 +4308,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1399969244 +DATE_WHEN_GENERATED=1402614845 ############################################################################### # @@ -40264,6 +40319,8 @@ $as_echo "$as_me: Rewriting BUILD_LD to \"$new_complete\"" >&6;} + + # The package path is used only on macosx? # FIXME: clean this up, and/or move it elsewhere. PACKAGE_PATH=/opt/local @@ -40289,6 +40346,242 @@ $as_echo "$as_me: Rewriting BUILD_LD to \"$new_complete\"" >&6;} # If this is a --hash-style=gnu system, use --hash-style=both, why? HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'` # This is later checked when setting flags. + + # "-Og" suppported for GCC 4.8 and later + CFLAG_OPTIMIZE_DEBUG_FLAG="-Og" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$CFLAG_OPTIMIZE_DEBUG_FLAG\"" >&5 +$as_echo_n "checking if compiler supports \"$CFLAG_OPTIMIZE_DEBUG_FLAG\"... " >&6; } + supports=yes + + saved_cflags="$CFLAGS" + CFLAGS="$CFLAGS $CFLAG_OPTIMIZE_DEBUG_FLAG" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CFLAGS="$saved_cflags" + + saved_cxxflags="$CXXFLAGS" + CXXFLAGS="$CXXFLAG $CFLAG_OPTIMIZE_DEBUG_FLAG" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CXXFLAGS="$saved_cxxflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + HAS_CFLAG_OPTIMIZE_DEBUG=true + else + HAS_CFLAG_OPTIMIZE_DEBUG=false + fi + + + # "-fsanitize=undefined" supported for GCC 4.9 and later + CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG="-fsanitize=undefined -fsanitize-recover" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG\"" >&5 +$as_echo_n "checking if compiler supports \"$CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG\"... " >&6; } + supports=yes + + saved_cflags="$CFLAGS" + CFLAGS="$CFLAGS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CFLAGS="$saved_cflags" + + saved_cxxflags="$CXXFLAGS" + CXXFLAGS="$CXXFLAG $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int i; +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CXXFLAGS="$saved_cxxflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=true + else + HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=false + fi + + + # "-z relro" supported in GNU binutils 2.17 and later + LINKER_RELRO_FLAG="-Xlinker -z -Xlinker relro" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports \"$LINKER_RELRO_FLAG\"" >&5 +$as_echo_n "checking if linker supports \"$LINKER_RELRO_FLAG\"... " >&6; } + supports=yes + + saved_ldflags="$LDFLAGS" + LDFLAGS="$LDFLAGS $LINKER_RELRO_FLAG" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + LDFLAGS="$saved_ldflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + HAS_LINKER_RELRO=true + else + HAS_LINKER_RELRO=false + fi + + + # "-z now" supported in GNU binutils 2.11 and later + LINKER_NOW_FLAG="-Xlinker -z -Xlinker now" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports \"$LINKER_NOW_FLAG\"" >&5 +$as_echo_n "checking if linker supports \"$LINKER_NOW_FLAG\"... " >&6; } + supports=yes + + saved_ldflags="$LDFLAGS" + LDFLAGS="$LDFLAGS $LINKER_NOW_FLAG" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + supports=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + LDFLAGS="$saved_ldflags" + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5 +$as_echo "$supports" >&6; } + if test "x$supports" = "xyes" ; then + HAS_LINKER_NOW=true + else + HAS_LINKER_NOW=false + fi + fi # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed @@ -40297,8 +40590,8 @@ $as_echo "$as_me: Rewriting BUILD_LD to \"$new_complete\"" >&6;} if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken SuSE 'ld' which only understands anonymous version tags in executables" >&5 $as_echo_n "checking for broken SuSE 'ld' which only understands anonymous version tags in executables... " >&6; } - echo "SUNWprivate_1.1 { local: *; };" > version-script.map - echo "int main() { }" > main.c + $ECHO "SUNWprivate_1.1 { local: *; };" > version-script.map + $ECHO "int main() { }" > main.c if $CXX -Xlinker -version-script=version-script.map main.c 2>&5 >&5; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } @@ -40768,8 +41061,8 @@ $as_echo "$tool_specified" >&6; } if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - # FIXME: likely bug, should be CCXXFLAGS_JDK? or one for C or CXX. - CCXXFLAGS="$CCXXFLAGS -nologo" + # silence copyright notice and other headers. + COMMON_CCXXFLAGS="$COMMON_CCXXFLAGS -nologo" fi if test "x$SYSROOT" != "x"; then @@ -40803,7 +41096,6 @@ $as_echo "$tool_specified" >&6; } # Now we can test some aspects on the target using configure macros. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : @@ -41488,6 +41780,7 @@ $as_echo "$ac_cv_c_bigendian" >&6; } # Debug symbols if test "x$TOOLCHAIN_TYPE" = xgcc; then if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" && test "x$DEBUG_LEVEL" = "xfastdebug"; then + # reduce from default "-g2" option to save space CFLAGS_DEBUG_SYMBOLS="-g1" CXXFLAGS_DEBUG_SYMBOLS="-g1" else @@ -41499,6 +41792,7 @@ $as_echo "$ac_cv_c_bigendian" >&6; } CXXFLAGS_DEBUG_SYMBOLS="-g" elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then CFLAGS_DEBUG_SYMBOLS="-g -xs" + # FIXME: likely a bug, this disables debug symbols rather than enables them CXXFLAGS_DEBUG_SYMBOLS="-g0 -xs" elif test "x$TOOLCHAIN_TYPE" = xxlc; then CFLAGS_DEBUG_SYMBOLS="-g" @@ -41507,6 +41801,31 @@ $as_echo "$ac_cv_c_bigendian" >&6; } + # bounds, memory and behavior checking options + if test "x$TOOLCHAIN_TYPE" = xgcc; then + case $DEBUG_LEVEL in + release ) + # no adjustment + ;; + fastdebug ) + # Add compile time bounds checks. + CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1" + CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1" + ;; + slowdebug ) + # Add runtime bounds checks and symbol info. + CFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1" + CXXFLAGS_DEBUG_OPTIONS="-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1" + if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then + CFLAGS_DEBUG_OPTIONS="$CFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" + CXXFLAGS_DEBUG_OPTIONS="$CXXFLAGS_DEBUG_OPTIONS $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG" + fi + ;; + esac + fi + + + # Optimization levels if test "x$TOOLCHAIN_TYPE" = xsolstudio; then CC_HIGHEST="$CC_HIGHEST -fns -fsimple -fsingle -xbuiltin=%all -xdepend -xrestrict -xlibmil" @@ -41516,10 +41835,12 @@ $as_echo "$ac_cv_c_bigendian" >&6; } C_O_FLAG_HIGHEST="-xO4 -Wu,-O4~yz $CC_HIGHEST -xalias_level=basic -xregs=no%frameptr" C_O_FLAG_HI="-xO4 -Wu,-O4~yz -xregs=no%frameptr" C_O_FLAG_NORM="-xO2 -Wu,-O2~yz -xregs=no%frameptr" + C_O_FLAG_DEBUG="-xregs=no%frameptr" C_O_FLAG_NONE="-xregs=no%frameptr" CXX_O_FLAG_HIGHEST="-xO4 -Qoption ube -O4~yz $CC_HIGHEST -xregs=no%frameptr" CXX_O_FLAG_HI="-xO4 -Qoption ube -O4~yz -xregs=no%frameptr" CXX_O_FLAG_NORM="-xO2 -Qoption ube -O2~yz -xregs=no%frameptr" + CXX_O_FLAG_DEBUG="-xregs=no%frameptr" CXX_O_FLAG_NONE="-xregs=no%frameptr" if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then C_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST -xchip=pentium" @@ -41529,10 +41850,12 @@ $as_echo "$ac_cv_c_bigendian" >&6; } C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 $CC_HIGHEST -xalias_level=basic -xprefetch=auto,explicit -xchip=ultra" C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0" C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0" + C_O_FLAG_DEBUG="" C_O_FLAG_NONE="" CXX_O_FLAG_HIGHEST="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0 $CC_HIGHEST -xprefetch=auto,explicit -xchip=ultra" CXX_O_FLAG_HI="-xO4 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" CXX_O_FLAG_NORM="-xO2 -Qoption cg -Qrm-s -Qoption cg -Qiselect-T0" + C_O_FLAG_DEBUG="" CXX_O_FLAG_NONE="" fi else @@ -41545,13 +41868,17 @@ $as_echo "$ac_cv_c_bigendian" >&6; } C_O_FLAG_HIGHEST="-Os" C_O_FLAG_HI="-Os" C_O_FLAG_NORM="-Os" - C_O_FLAG_NONE="" else C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="-O0" fi + if test "x$HAS_CFLAG_OPTIMIZE_DEBUG" = "xtrue"; then + C_O_FLAG_DEBUG="$CFLAG_OPTIMIZE_DEBUG_FLAG" + else + C_O_FLAG_DEBUG="-O0" + fi + C_O_FLAG_NONE="-O0" elif test "x$TOOLCHAIN_TYPE" = xclang; then if test "x$OPENJDK_TARGET_OS" = xmacosx; then # On MacOSX we optimize for size, something @@ -41559,30 +41886,56 @@ $as_echo "$ac_cv_c_bigendian" >&6; } C_O_FLAG_HIGHEST="-Os" C_O_FLAG_HI="-Os" C_O_FLAG_NORM="-Os" - C_O_FLAG_NONE="" else C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="-O0" fi + C_O_FLAG_DEBUG="-O0" + C_O_FLAG_NONE="-O0" elif test "x$TOOLCHAIN_TYPE" = xxlc; then C_O_FLAG_HIGHEST="-O3" C_O_FLAG_HI="-O3 -qstrict" C_O_FLAG_NORM="-O2" - C_O_FLAG_NONE="" + C_O_FLAG_DEBUG="-qnoopt" + C_O_FLAG_NONE="-qnoop" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then C_O_FLAG_HIGHEST="-O2" C_O_FLAG_HI="-O1" C_O_FLAG_NORM="-O1" + C_O_FLAG_DEBUG="-Od" C_O_FLAG_NONE="-Od" fi CXX_O_FLAG_HIGHEST="$C_O_FLAG_HIGHEST" CXX_O_FLAG_HI="$C_O_FLAG_HI" CXX_O_FLAG_NORM="$C_O_FLAG_NORM" + CXX_O_FLAG_DEBUG="$C_O_FLAG_DEBUG" CXX_O_FLAG_NONE="$C_O_FLAG_NONE" fi + # Adjust optimization flags according to debug level. + case $DEBUG_LEVEL in + release ) + # no adjustment + ;; + fastdebug ) + # Not quite so much optimization + C_O_FLAG_HI="$C_O_FLAG_NORM" + CXX_O_FLAG_HI="$CXX_O_FLAG_NORM" + ;; + slowdebug ) + # Disable optimization + C_O_FLAG_HIGHEST="$C_O_FLAG_DEBUG" + C_O_FLAG_HI="$C_O_FLAG_DEBUG" + C_O_FLAG_NORM="$C_O_FLAG_DEBUG" + CXX_O_FLAG_HIGHEST="$CXX_O_FLAG_DEBUG" + CXX_O_FLAG_HI="$CXX_O_FLAG_DEBUG" + CXX_O_FLAG_NORM="$CXX_O_FLAG_DEBUG" + ;; + esac + + + @@ -41660,11 +42013,12 @@ fi # Later we will also have CFLAGS and LDFLAGS for the hotspot subrepo build. # - # Setup compiler/platform specific flags to CFLAGS_JDK, - # CXXFLAGS_JDK and CCXXFLAGS_JDK (common to C and CXX?) + # Setup compiler/platform specific flags into + # CFLAGS_JDK - C Compiler flags + # CXXFLAGS_JDK - C++ Compiler flags + # COMMON_CCXXFLAGS_JDK - common to C and C++ if test "x$TOOLCHAIN_TYPE" = xgcc; then - # these options are used for both C and C++ compiles - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Wall -Wno-parentheses -Wextra -Wno-unused -Wno-unused-parameter -Wformat=2 \ -pipe -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE" case $OPENJDK_TARGET_CPU_ARCH in arm ) @@ -41676,14 +42030,14 @@ fi CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" ;; * ) - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -fno-omit-frame-pointer" CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing" ;; esac elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -DTRACING -DMACRO_MEMSYS_OPS -DBREAKPTS" if test "x$OPENJDK_TARGET_CPU_ARCH" = xx86; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DcpuIntel -Di586 -D$OPENJDK_TARGET_CPU_LEGACY_LIB" CFLAGS_JDK="$CFLAGS_JDK -erroff=E_BAD_PRAGMA_PACK_VALUE" fi @@ -41693,14 +42047,14 @@ fi CFLAGS_JDK="$CFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" CXXFLAGS_JDK="$CXXFLAGS_JDK -D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -DSTDC" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - CCXXFLAGS_JDK="$CCXXFLAGS $CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS $COMMON_CCXXFLAGS_JDK -Zi -MD -Zc:wchar_t- -W3 -wd4800 \ -D_STATIC_CPPLIB -D_DISABLE_DEPRECATE_STATIC_CPPLIB -DWIN32_LEAN_AND_MEAN \ -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE \ -DWIN32 -DIAL" if test "x$OPENJDK_TARGET_CPU" = xx86_64; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_AMD64_ -Damd64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_AMD64_ -Damd64" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_X86_ -Dx86" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_X86_ -Dx86" fi fi @@ -41708,28 +42062,20 @@ fi # Adjust flags according to debug level. case $DEBUG_LEVEL in - fastdebug ) - CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS" - CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS" - C_O_FLAG_HI="$C_O_FLAG_NORM" - C_O_FLAG_NORM="$C_O_FLAG_NORM" - CXX_O_FLAG_HI="$CXX_O_FLAG_NORM" - CXX_O_FLAG_NORM="$CXX_O_FLAG_NORM" + fastdebug | slowdebug ) + CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS" + CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS" JAVAC_FLAGS="$JAVAC_FLAGS -g" ;; - slowdebug ) - CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS" - CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS" - C_O_FLAG_HI="$C_O_FLAG_NONE" - C_O_FLAG_NORM="$C_O_FLAG_NONE" - CXX_O_FLAG_HI="$CXX_O_FLAG_NONE" - CXX_O_FLAG_NORM="$CXX_O_FLAG_NONE" - JAVAC_FLAGS="$JAVAC_FLAGS -g" + release ) + ;; + * ) + as_fn_error $? "Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL" "$LINENO" 5 ;; esac # Setup LP64 - CCXXFLAGS_JDK="$CCXXFLAGS_JDK $ADD_LP64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK $ADD_LP64" # Set some common defines. These works for all compilers, but assume # -D is universally accepted. @@ -41742,49 +42088,49 @@ fi # Note: -Dmacro is the same as #define macro 1 # -Dmacro= is the same as #define macro if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN=" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN=" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_LITTLE_ENDIAN" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_LITTLE_ENDIAN" fi else # Same goes for _BIG_ENDIAN. Do we really need to set *ENDIAN on Solaris if they # are defined in the system? if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN=" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN=" else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_BIG_ENDIAN" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_BIG_ENDIAN" fi fi # Setup target OS define. Use OS target name but in upper case. OPENJDK_TARGET_OS_UPPERCASE=`$ECHO $OPENJDK_TARGET_OS | $TR 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D$OPENJDK_TARGET_OS_UPPERCASE" # Setup target CPU - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DARCH='\"$OPENJDK_TARGET_CPU_LEGACY\"' -D$OPENJDK_TARGET_CPU_LEGACY" # Setup debug/release defines if test "x$DEBUG_LEVEL" = xrelease; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DNDEBUG" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DNDEBUG" if test "x$OPENJDK_TARGET_OS" = xsolaris; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DTRIMMED" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DTRIMMED" fi else - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DDEBUG" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG" fi # Setup release name - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DRELEASE='\"\$(RELEASE)\"'" # Set some additional per-OS defines. if test "x$OPENJDK_TARGET_OS" = xmacosx; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT" elif test "x$OPENJDK_TARGET_OS" = xaix; then # FIXME: PPC64 should not be here. - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DPPC64" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DPPC64" elif test "x$OPENJDK_TARGET_OS" = xbsd; then - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -D_ALLBSD_SOURCE" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE" fi # Additional macosx handling @@ -41803,13 +42149,13 @@ fi # The macro takes the version with no dots, ex: 1070 # Let the flags variables get resolved in make for easier override on make # command line. - CCXXFLAGS_JDK="$CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DMAC_OS_X_VERSION_MAX_ALLOWED=\$(subst .,,\$(MACOSX_VERSION_MIN)) -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" LDFLAGS_JDK="$LDFLAGS_JDK -mmacosx-version-min=\$(MACOSX_VERSION_MIN)" fi fi # Setup some hard coded includes - CCXXFLAGS_JDK="$CCXXFLAGS_JDK \ + COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \ -I${JDK_OUTPUTDIR}/include \ -I${JDK_OUTPUTDIR}/include/$OPENJDK_TARGET_OS \ -I${JDK_TOPDIR}/src/share/javavm/export \ @@ -41818,12 +42164,12 @@ fi -I${JDK_TOPDIR}/src/$OPENJDK_TARGET_OS_API_DIR/native/common" # The shared libraries are compiled using the picflag. - CFLAGS_JDKLIB="$CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA" - CXXFLAGS_JDKLIB="$CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA " + CFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK $PICFLAG $CFLAGS_JDKLIB_EXTRA" + CXXFLAGS_JDKLIB="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK $PICFLAG $CXXFLAGS_JDKLIB_EXTRA " # Executable flags - CFLAGS_JDKEXE="$CCXXFLAGS_JDK $CFLAGS_JDK" - CXXFLAGS_JDKEXE="$CCXXFLAGS_JDK $CXXFLAGS_JDK" + CFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CFLAGS_JDK" + CXXFLAGS_JDKEXE="$COMMON_CCXXFLAGS_JDK $CXXFLAGS_JDK" @@ -41832,6 +42178,7 @@ fi # Setup LDFLAGS et al. # + # Now this is odd. The JDK native libraries have to link against libjvm.so # On 32-bit machines there is normally two distinct libjvm.so:s, client and server. # Which should we link to? Are we lucky enough that the binary api to the libjvm.so library @@ -41847,39 +42194,94 @@ fi fi # TODO: make -debug optional "--disable-full-debug-symbols" LDFLAGS_JDK="$LDFLAGS_JDK -debug" - LDFLAGS_JDKLIB="${LDFLAGS_JDK} -dll -libpath:${JDK_OUTPUTDIR}/lib" - LDFLAGS_JDKLIB_SUFFIX="" + elif test "x$TOOLCHAIN_TYPE" = xgcc; then + # If this is a --hash-style=gnu system, use --hash-style=both, why? + # We have previously set HAS_GNU_HASH if this is the case + if test -n "$HAS_GNU_HASH"; then + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both" + fi + if test "x$OPENJDK_TARGET_OS" = xlinux; then + # And since we now know that the linker is gnu, then add -z defs, to forbid + # undefined symbols in object files. + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs" + case $DEBUG_LEVEL in + release ) + # tell linker to optimize libraries. + # Should this be supplied to the OSS linker as well? + LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1" + ;; + slowdebug ) + if test "x$HAS_LINKER_NOW" = "xtrue"; then + # do relocations at load + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_NOW_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_NOW_FLAG" + fi + if test "x$HAS_LINKER_RELRO" = "xtrue"; then + # mark relocations read only + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG" + fi + ;; + fastdebug ) + if test "x$HAS_LINKER_RELRO" = "xtrue"; then + # mark relocations read only + LDFLAGS_JDK="$LDFLAGS_JDK $LINKER_RELRO_FLAG" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK $LINKER_RELRO_FLAG" + fi + ;; + * ) + as_fn_error $? "Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL" "$LINENO" 5 + ;; + esac + fi + elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then + LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib" + fi + + if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang; then + # If undefined behaviour detection is enabled then we need to tell linker. + case $DEBUG_LEVEL in + release | fastdebug ) + ;; + slowdebug ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" >&5 +$as_echo "$as_me: WARNING: $HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" >&2;} + if test "x$HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR" = "xtrue"; then + # enable undefined behaviour checking + LDFLAGS_JDK="$LDFLAGS_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/ *\(^ \+\)/ -Xlinker \1/g"`" + LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK `$ECHO -n $CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG | sed -e "s/ *\(^ \+\)/ -Xlinker \1/g"`" + fi + ;; + * ) + as_fn_error $? "Unrecognized \$DEBUG_LEVEL: $DEBUG_LEVEL" "$LINENO" 5 + ;; + esac + fi + + # Customize LDFLAGS for executables + + LDFLAGS_JDKEXE="${LDFLAGS_JDK}" + + if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then if test "x$OPENJDK_TARGET_CPU_BITS" = "x64"; then LDFLAGS_STACK_SIZE=1048576 else LDFLAGS_STACK_SIZE=327680 fi - LDFLAGS_JDKEXE="${LDFLAGS_JDK} /STACK:$LDFLAGS_STACK_SIZE" + LDFLAGS_JDKEXE="${LDFLAGS_JDKEXE} /STACK:$LDFLAGS_STACK_SIZE" + elif test "x$OPENJDK_TARGET_OS" = xlinux; then + LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined" + fi + + # Customize LDFLAGS for libs + LDFLAGS_JDKLIB="${LDFLAGS_JDK}" + + if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} -dll -libpath:${JDK_OUTPUTDIR}/lib" + LDFLAGS_JDKLIB_SUFFIX="" else - if test "x$TOOLCHAIN_TYPE" = xgcc; then - # If this is a --hash-style=gnu system, use --hash-style=both, why? - # We have previously set HAS_GNU_HASH if this is the case - if test -n "$HAS_GNU_HASH"; then - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker --hash-style=both " - fi - if test "x$OPENJDK_TARGET_OS" = xlinux; then - # And since we now know that the linker is gnu, then add -z defs, to forbid - # undefined symbols in object files. - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -z -Xlinker defs" - if test "x$DEBUG_LEVEL" = "xrelease"; then - # When building release libraries, tell the linker optimize them. - # Should this be supplied to the OSS linker as well? - LDFLAGS_JDK="${LDFLAGS_JDK} -Xlinker -O1" - fi - fi - fi - - if test "x$TOOLCHAIN_TYPE" = xsolstudio; then - LDFLAGS_JDK="$LDFLAGS_JDK -z defs -xildoff -ztext" - LDFLAGS_CXX_JDK="$LDFLAGS_CXX_JDK -norunpath -xnolib" - fi - - LDFLAGS_JDKLIB="${LDFLAGS_JDK} $SHARED_LIBRARY_FLAGS \ + LDFLAGS_JDKLIB="${LDFLAGS_JDKLIB} ${SHARED_LIBRARY_FLAGS} \ -L${JDK_OUTPUTDIR}/lib${OPENJDK_TARGET_CPU_LIBDIR}" # On some platforms (mac) the linker warns about non existing -L dirs. @@ -41900,11 +42302,6 @@ fi if test "x$TOOLCHAIN_TYPE" = xsolstudio; then LDFLAGS_JDKLIB_SUFFIX="$LDFLAGS_JDKLIB_SUFFIX -lc" fi - - LDFLAGS_JDKEXE="${LDFLAGS_JDK}" - if test "x$OPENJDK_TARGET_OS" = xlinux; then - LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE -Xlinker --allow-shlib-undefined" - fi fi diff --git a/common/autoconf/toolchain.m4 b/common/autoconf/toolchain.m4 index b7c00d4f495..4686517151b 100644 --- a/common/autoconf/toolchain.m4 +++ b/common/autoconf/toolchain.m4 @@ -24,11 +24,11 @@ # ######################################################################## -# This file is responsible for detecting, verifying and setting up the -# toolchain, i.e. the compiler, linker and related utilities. It will setup +# This file is responsible for detecting, verifying and setting up the +# toolchain, i.e. the compiler, linker and related utilities. It will setup # proper paths to the binaries, but it will not setup any flags. # -# The binaries used is determined by the toolchain type, which is the family of +# The binaries used is determined by the toolchain type, which is the family of # compilers and related tools that are used. ######################################################################## @@ -83,7 +83,7 @@ AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS], AC_SUBST(SHARED_LIBRARY) AC_SUBST(STATIC_LIBRARY) AC_SUBST(OBJ_SUFFIX) - AC_SUBST(EXE_SUFFIX) + AC_SUBST(EXE_SUFFIX) ]) # Determine which toolchain type to use, and make sure it is valid for this @@ -117,7 +117,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], # First toolchain type in the list is the default DEFAULT_TOOLCHAIN=${VALID_TOOLCHAINS%% *} fi - + if test "x$with_toolchain_type" = xlist; then # List all toolchains AC_MSG_NOTICE([The following toolchains are valid on this platform:]) @@ -126,7 +126,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], TOOLCHAIN_DESCRIPTION=${!toolchain_var_name} $PRINTF " %-10s %s\n" $toolchain "$TOOLCHAIN_DESCRIPTION" done - + exit 0 elif test "x$with_toolchain_type" != x; then # User override; check that it is valid @@ -168,10 +168,10 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETERMINE_TOOLCHAIN_TYPE], AC_MSG_NOTICE([Using default toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)]) else AC_MSG_NOTICE([Using user selected toolchain $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION). Default toolchain is $DEFAULT_TOOLCHAIN.]) - fi + fi ]) -# Before we start detecting the toolchain executables, we might need some +# Before we start detecting the toolchain executables, we might need some # special setup, e.g. additional paths etc. AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION], [ @@ -184,7 +184,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION], ORG_OBJCFLAGS="$OBJCFLAGS" # On Windows, we need to detect the visual studio installation first. - # This will change the PATH, but we need to keep that new PATH even + # This will change the PATH, but we need to keep that new PATH even # after toolchain detection is done, since the compiler (on x86) uses # it for DLL resolution in runtime. if test "x$OPENJDK_BUILD_OS" = "xwindows" && test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then @@ -208,7 +208,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION], PATH="/usr/ccs/bin:$PATH" fi - # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to + # Finally add TOOLCHAIN_PATH at the beginning, to allow --with-tools-dir to # override all other locations. if test "x$TOOLCHAIN_PATH" != x; then PATH=$TOOLCHAIN_PATH:$PATH @@ -254,7 +254,7 @@ AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION], AC_MSG_NOTICE([The result from running with --version was: "$ALT_VERSION_OUTPUT"]) AC_MSG_ERROR([A $TOOLCHAIN_TYPE compiler is required. Try setting --with-tools-dir.]) fi - # Remove usage instructions (if present), and + # Remove usage instructions (if present), and # collapse compiler output into a single line COMPILER_VERSION_STRING=`$ECHO $COMPILER_VERSION_OUTPUT | \ $SED -e 's/ *@<:@Uu@:>@sage:.*//'` @@ -282,7 +282,7 @@ AC_DEFUN([TOOLCHAIN_CHECK_COMPILER_VERSION], # There is no specific version flag, but all output starts with a version string. # First line typically looks something like: # Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 - COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'` + COMPILER_VERSION_OUTPUT=`$COMPILER 2>&1 | $HEAD -n 1 | $TR -d '\r'` # Check that this is likely to be Microsoft CL.EXE. $ECHO "$COMPILER_VERSION_OUTPUT" | $GREP "Microsoft.*Compiler" > /dev/null if test $? -ne 0; then @@ -360,7 +360,7 @@ AC_DEFUN([TOOLCHAIN_FIND_COMPILER], AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1]) if test "x`basename [$]$1`" = "x[$]$1"; then # A command without a complete path is provided, search $PATH. - + AC_PATH_PROGS(POTENTIAL_$1, [$]$1) if test "x$POTENTIAL_$1" != x; then $1=$POTENTIAL_$1 @@ -375,12 +375,12 @@ AC_DEFUN([TOOLCHAIN_FIND_COMPILER], fi else # No user supplied value. Locate compiler ourselves. - + # If we are cross compiling, assume cross compilation tools follows the # cross compilation standard where they are prefixed with the autoconf - # standard name for the target. For example the binary + # standard name for the target. For example the binary # i686-sun-solaris2.10-gcc will cross compile for i686-sun-solaris2.10. - # If we are not cross compiling, then the default compiler name will be + # If we are not cross compiling, then the default compiler name will be # used. $1= @@ -450,9 +450,9 @@ AC_DEFUN([TOOLCHAIN_FIND_COMPILER], TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME]) ]) -# Detect the core components of the toolchain, i.e. the compilers (CC and CXX), -# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the -# archiver (AR). Verify that the compilers are correct according to the +# Detect the core components of the toolchain, i.e. the compilers (CC and CXX), +# preprocessor (CPP and CXXCPP), the linker (LD), the assembler (AS) and the +# archiver (AR). Verify that the compilers are correct according to the # toolchain type. AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE], [ @@ -529,7 +529,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_CORE], ]) # Setup additional tools that is considered a part of the toolchain, but not the -# core part. Many of these are highly platform-specific and do not exist, +# core part. Many of these are highly platform-specific and do not exist, # and/or are not needed on all platforms. AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], [ @@ -551,7 +551,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], AC_CHECK_PROG([DUMPBIN], [dumpbin], [dumpbin],,,) BASIC_FIXUP_EXECUTABLE(DUMPBIN) fi - + if test "x$OPENJDK_TARGET_OS" = xsolaris; then BASIC_PATH_PROGS(STRIP, strip) BASIC_FIXUP_EXECUTABLE(STRIP) @@ -559,7 +559,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], BASIC_FIXUP_EXECUTABLE(NM) BASIC_PATH_PROGS(GNM, gnm) BASIC_FIXUP_EXECUTABLE(GNM) - + BASIC_PATH_PROGS(MCS, mcs) BASIC_FIXUP_EXECUTABLE(MCS) elif test "x$OPENJDK_TARGET_OS" != xwindows; then @@ -592,17 +592,17 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA], # Setup the build tools (i.e, the compiler and linker used to build programs # that should be run on the build platform, not the target platform, as a build -# helper). Since the non-cross-compile case uses the normal, target compilers +# helper). Since the non-cross-compile case uses the normal, target compilers # for this, we can only do this after these have been setup. AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS], -[ +[ if test "x$COMPILE_TYPE" = "xcross"; then # Now we need to find a C/C++ compiler that can build executables for the # build platform. We can't use the AC_PROG_CC macro, since it can only be # used once. Also, we need to do this without adding a tools dir to the # path, otherwise we might pick up cross-compilers which don't use standard # naming. - + # FIXME: we should list the discovered compilers as an exclude pattern! # If we do that, we can do this detection before POST_DETECTION, and still # find the build compilers in the tools dir, if needed. @@ -690,15 +690,39 @@ AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS], # If this is a --hash-style=gnu system, use --hash-style=both, why? HAS_GNU_HASH=`$CC -dumpspecs 2>/dev/null | $GREP 'hash-style=gnu'` # This is later checked when setting flags. + + # "-Og" suppported for GCC 4.8 and later + CFLAG_OPTIMIZE_DEBUG_FLAG="-Og" + FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_OPTIMIZE_DEBUG_FLAG], + [HAS_CFLAG_OPTIMIZE_DEBUG=true], + [HAS_CFLAG_OPTIMIZE_DEBUG=false]) + + # "-fsanitize=undefined" supported for GCC 4.9 and later + CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG="-fsanitize=undefined -fsanitize-recover" + FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_DETECT_UNDEFINED_BEHAVIOR_FLAG], + [HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=true], + [HAS_CFLAG_DETECT_UNDEFINED_BEHAVIOR=false]) + + # "-z relro" supported in GNU binutils 2.17 and later + LINKER_RELRO_FLAG="-Xlinker -z -Xlinker relro" + FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_RELRO_FLAG], + [HAS_LINKER_RELRO=true], + [HAS_LINKER_RELRO=false]) + + # "-z now" supported in GNU binutils 2.11 and later + LINKER_NOW_FLAG="-Xlinker -z -Xlinker now" + FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_NOW_FLAG], + [HAS_LINKER_NOW=true], + [HAS_LINKER_NOW=false]) fi - # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed + # Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed # in executable.' USING_BROKEN_SUSE_LD=no if test "x$OPENJDK_TARGET_OS" = xlinux && test "x$TOOLCHAIN_TYPE" = xgcc; then AC_MSG_CHECKING([for broken SuSE 'ld' which only understands anonymous version tags in executables]) - echo "SUNWprivate_1.1 { local: *; };" > version-script.map - echo "int main() { }" > main.c + $ECHO "SUNWprivate_1.1 { local: *; };" > version-script.map + $ECHO "int main() { }" > main.c if $CXX -Xlinker -version-script=version-script.map main.c 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then AC_MSG_RESULT(no) USING_BROKEN_SUSE_LD=no diff --git a/corba/.hgtags b/corba/.hgtags index 66b823f5f9f..f9ed22e0c47 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -261,3 +261,5 @@ e54022d0dd92106fff7f7fe670010cd7e6517ee3 jdk9-b15 422ef9d29d84f571453f015c4cb8713c3af70ee4 jdk9-b16 4c75c2ca7cf3e0618315879acf17f42c8fcd0c09 jdk9-b17 77565aaaa2bb814e94817e92d680168052a25395 jdk9-b18 +eecc1b6adc7e193d00a0641eb0963add5a4c06e8 jdk9-b19 +87f36eecb1665012d01c5cf102494e591c943ea6 jdk9-b20 diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 77d8c723248..b4c3b90e4c2 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -421,3 +421,5 @@ bd333491bb6c012d7b606939406d0fa9a5ac7ffd jdk9-b14 b14e7c0b7d3ec04127f565cda1d84122e205680c jdk9-b16 14b656df31c2cb09c505921061e79977823de71a jdk9-b17 871fd128548480095e0dc3fc34c422666baeec75 jdk9-b18 +d4cffb3ae6213c66c7522ebffe0349360a45f0ef jdk9-b19 +c1af79d122ec9f715fa29312b5e91763f3a4dfc4 jdk9-b20 diff --git a/hotspot/make/bsd/makefiles/fastdebug.make b/hotspot/make/bsd/makefiles/fastdebug.make index 9ff25742f21..d57e545b5b0 100644 --- a/hotspot/make/bsd/makefiles/fastdebug.make +++ b/hotspot/make/bsd/makefiles/fastdebug.make @@ -24,37 +24,30 @@ # Sets make macros for making debug version of VM +# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make +# They may also specify FASTDEBUG_CFLAGS, but it defaults to DEBUG_CFLAGS. + +FASTDEBUG_CFLAGS$(FASTDEBUG_CFLAGS) = $(DEBUG_CFLAGS) + # Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) # (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) -ifeq ($(BUILDARCH), ia64) - # Bug in GCC, causes hang. -O1 will override the -O3 specified earlier - OPT_CFLAGS/callGenerator.o += -O1 - OPT_CFLAGS/ciTypeFlow.o += -O1 - OPT_CFLAGS/compile.o += -O1 - OPT_CFLAGS/concurrentMarkSweepGeneration.o += -O1 - OPT_CFLAGS/doCall.o += -O1 - OPT_CFLAGS/generateOopMap.o += -O1 - OPT_CFLAGS/generateOptoStub.o += -O1 - OPT_CFLAGS/graphKit.o += -O1 - OPT_CFLAGS/instanceKlass.o += -O1 - OPT_CFLAGS/interpreterRT_ia64.o += -O1 - OPT_CFLAGS/output.o += -O1 - OPT_CFLAGS/parse1.o += -O1 - OPT_CFLAGS/runtime.o += -O1 - OPT_CFLAGS/synchronizer.o += -O1 -endif - - # If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) # Set the environment variable HOTSPARC_GENERIC to "true" # to inhibit the effect of the previous line on CFLAGS. +# The following lines are copied from debug.make, except that we +# consult FASTDEBUG_CFLAGS instead of DEBUG_CFLAGS. +# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make +DEBUG_CFLAGS/DEFAULT= $(FASTDEBUG_CFLAGS) +DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@)) +CFLAGS += $(DEBUG_CFLAGS/BYFILE) + # Linker mapfile MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug ifeq ($(OS_VENDOR), Darwin) diff --git a/hotspot/make/bsd/makefiles/gcc.make b/hotspot/make/bsd/makefiles/gcc.make index 2a0eab17ef9..c96ff2a78b6 100644 --- a/hotspot/make/bsd/makefiles/gcc.make +++ b/hotspot/make/bsd/makefiles/gcc.make @@ -19,7 +19,7 @@ # 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. -# +# # OS_VENDOR = $(shell uname -s) @@ -80,7 +80,7 @@ ifeq ($(SPEC),) HOSTCC = $(CC) endif - AS = $(CC) -c + AS = $(CC) -c endif ifeq ($(OS_VENDOR), Darwin) @@ -100,7 +100,7 @@ else endif ifeq ($(USE_CLANG), true) - # clang has precompiled headers support by default, but the user can switch + # Clang has precompiled headers support by default, but the user can switch # it off by using 'USE_PRECOMPILED_HEADER=0'. ifdef LP64 ifeq ($(USE_PRECOMPILED_HEADER),) @@ -112,29 +112,29 @@ ifeq ($(USE_CLANG), true) # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit. USE_PRECOMPILED_HEADER=0 endif - + ifeq ($(USE_PRECOMPILED_HEADER),1) - + ifndef LP64 $(error " Precompiled Headers only supported on 64-bit platforms!") endif - + PRECOMPILED_HEADER_DIR=. PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch - + PCH_FLAG = -include precompiled.hpp PCH_FLAG/DEFAULT = $(PCH_FLAG) PCH_FLAG/NO_PCH = -DNO_PCH PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@)) - + VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE) VM_PCH_FLAG/AOUT = VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO)) - + # We only use precompiled headers for the JVM build CFLAGS += $(VM_PCH_FLAG) - + # The following files are compiled at various optimization # levels due to optimization issues encountered at the # 'OPT_CFLAGS_DEFAULT' level. The Clang compiler issues a compile @@ -149,7 +149,7 @@ ifeq ($(USE_CLANG), true) PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH) PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH) PCH_FLAG/unsafe.o = $(PCH_FLAG/NO_PCH) - + endif else # ($(USE_CLANG), true) # check for precompiled headers support @@ -272,21 +272,24 @@ endif CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) # Special cases -CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) +CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) # XXXDARWIN: for _dyld_bind_fully_image_containing_address ifeq ($(OS_VENDOR), Darwin) CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations endif +# optimization control flags (Used by fastdebug and release variants) +OPT_CFLAGS/NOOPT=-O0 +ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" + # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) + OPT_CFLAGS/DEBUG=-Og +else + # Allow no optimizations. + OPT_CFLAGS/DEBUG=-O0 +endif OPT_CFLAGS/SIZE=-Os OPT_CFLAGS/SPEED=-O3 -# Hotspot uses very unstrict aliasing turn this optimization off -# This option is added to CFLAGS rather than OPT_CFLAGS -# so that OPT_CFLAGS overrides get this option too. -CFLAGS += -fno-strict-aliasing - -# The flags to use for an Optimized g++ build ifeq ($(OS_VENDOR), Darwin) # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy # @@ -295,6 +298,11 @@ else OPT_CFLAGS_DEFAULT ?= SPEED endif +# Hotspot uses very unstrict aliasing turn this optimization off +# This option is added to CFLAGS rather than OPT_CFLAGS +# so that OPT_CFLAGS overrides get this option too. +CFLAGS += -fno-strict-aliasing + ifdef OPT_CFLAGS ifneq ("$(origin OPT_CFLAGS)", "command line") $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.") @@ -309,8 +317,6 @@ ifeq ($(BUILDARCH), ia64) OPT_CFLAGS += -fno-expensive-optimizations endif -OPT_CFLAGS/NOOPT=-O0 - # Work around some compiler bugs. ifeq ($(USE_CLANG), true) ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) @@ -338,7 +344,7 @@ CFLAGS += -DDONT_USE_PRECOMPILED_HEADER endif ifeq ($(OS_VENDOR), Darwin) - # Setting these parameters makes it an error to link to macosx APIs that are + # Setting these parameters makes it an error to link to macosx APIs that are # newer than the given OS version and makes the linked binaries compatible even # if built on a newer version of the OS. # The expected format is X.Y.Z @@ -371,10 +377,22 @@ endif ifeq ($(USE_CLANG),) # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. - ifneq ("${CC_VER_MAJOR}", "2") + ifneq ($(CC_VER_MAJOR), 2) STATIC_LIBGCC += -static-libgcc endif + ifneq ($(OS_VENDOR), Darwin) + ifneq (, findstring(debug,$(BUILD_FLAVOR))) + # for relocations read-only + LFLAGS += -Xlinker -z -Xlinker relro + + ifeq ($(BUILD_FLAVOR), debug) + # disable incremental relocations linking + LFLAGS += -Xlinker -z -Xlinker now + endif + endif + endif + ifeq ($(BUILDARCH), ia64) LFLAGS += -Wl,-relax endif @@ -425,6 +443,14 @@ ifeq ($(USE_CLANG), true) CFLAGS += -flimit-debug-info endif +ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" + # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) + DEBUG_CFLAGS=-Og +else + # Allow no optimizations. + DEBUG_CFLAGS=-O0 +endif + # DEBUG_BINARIES uses full -g debug information for all configs ifeq ($(DEBUG_BINARIES), true) CFLAGS += -g @@ -441,9 +467,14 @@ else DEBUG_CFLAGS/ppc = -g DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) - DEBUG_CFLAGS += -gstabs + ifeq ($(USE_CLANG), true) + # Clang doesn't understand -gstabs + DEBUG_CFLAGS += -g + else + DEBUG_CFLAGS += -gstabs + endif endif - + ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) FASTDEBUG_CFLAGS/ia64 = -g FASTDEBUG_CFLAGS/amd64 = -g @@ -458,7 +489,7 @@ else FASTDEBUG_CFLAGS += -gstabs endif endif - + OPT_CFLAGS/ia64 = -g OPT_CFLAGS/amd64 = -g OPT_CFLAGS/arm = -g @@ -475,6 +506,18 @@ else endif endif +ifeq ($(USE_CLANG),) + # Enable bounds checking. + # _FORTIFY_SOURCE appears in GCC 4.0+ + ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1" + # compile time size bounds checks + FASTDEBUG_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 + + # and runtime size bounds checks and paranoid stack smashing checks. + DEBUG_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1 + endif +endif + # If we are building HEADLESS, pass on to VM # so it can set the java.awt.headless property ifdef HEADLESS diff --git a/hotspot/make/linux/makefiles/fastdebug.make b/hotspot/make/linux/makefiles/fastdebug.make index c71e147fe4e..ebadd1986b3 100644 --- a/hotspot/make/linux/makefiles/fastdebug.make +++ b/hotspot/make/linux/makefiles/fastdebug.make @@ -24,6 +24,11 @@ # Sets make macros for making debug version of VM +# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make +# They may also specify FASTDEBUG_CFLAGS, but it defaults to DEBUG_CFLAGS. + +FASTDEBUG_CFLAGS$(FASTDEBUG_CFLAGS) = $(DEBUG_CFLAGS) + # Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) @@ -54,6 +59,12 @@ CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) # Set the environment variable HOTSPARC_GENERIC to "true" # to inhibit the effect of the previous line on CFLAGS. +# The following lines are copied from debug.make, except that we +# consult FASTDEBUG_CFLAGS instead of DEBUG_CFLAGS. +# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make +DEBUG_CFLAGS/DEFAULT= $(FASTDEBUG_CFLAGS) +DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@)) +CFLAGS += $(DEBUG_CFLAGS/BYFILE) # Linker mapfile MAPFILE = $(GAMMADIR)/make/linux/makefiles/mapfile-vers-debug diff --git a/hotspot/make/linux/makefiles/gcc.make b/hotspot/make/linux/makefiles/gcc.make index 9d321ea7dc7..df3f8bda26f 100644 --- a/hotspot/make/linux/makefiles/gcc.make +++ b/hotspot/make/linux/makefiles/gcc.make @@ -19,7 +19,7 @@ # 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. -# +# # #------------------------------------------------------------------------ @@ -62,7 +62,6 @@ else CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) endif - ifeq ($(USE_CLANG), true) # Clang has precompiled headers support by default, but the user can switch # it off by using 'USE_PRECOMPILED_HEADER=0'. @@ -104,7 +103,7 @@ ifeq ($(USE_CLANG), true) # But Clang doesn't support a precompiled header which was compiled with -O3 # to be used in a compilation unit which uses '-O0'. We could also prepare an # extra '-O0' PCH file for the opt build and use it here, but it's probably - # not worth the effoert as long as only two files need this special handling. + # not worth the effort as long as only two files need this special handling. PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH) PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH) PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH) @@ -226,19 +225,28 @@ ifeq ($(USE_CLANG),) endif CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) -# Special cases -CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) -# The flags to use for an Optimized g++ build +# Special cases +CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) + +# optimization control flags (Used by fastdebug and release variants) +OPT_CFLAGS/NOOPT=-O0 +ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" + # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) + OPT_CFLAGS/DEBUG=-Og +else + # Allow no optimizations. + OPT_CFLAGS/DEBUG=-O0 +endif OPT_CFLAGS/SIZE=-Os OPT_CFLAGS/SPEED=-O3 +OPT_CFLAGS_DEFAULT ?= SPEED + # Hotspot uses very unstrict aliasing turn this optimization off # This option is added to CFLAGS rather than OPT_CFLAGS # so that OPT_CFLAGS overrides get this option too. -CFLAGS += -fno-strict-aliasing - -OPT_CFLAGS_DEFAULT ?= SPEED +CFLAGS += -fno-strict-aliasing ifdef OPT_CFLAGS ifneq ("$(origin OPT_CFLAGS)", "command line") @@ -248,14 +256,12 @@ endif OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS) -# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp +# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp # if we use expensive-optimizations ifeq ($(BUILDARCH), ia64) OPT_CFLAGS += -fno-expensive-optimizations endif -OPT_CFLAGS/NOOPT=-O0 - # Work around some compiler bugs. ifeq ($(USE_CLANG), true) ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) @@ -271,7 +277,7 @@ endif # Flags for generating make dependency flags. DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) ifeq ($(USE_CLANG),) - ifneq ("${CC_VER_MAJOR}", "2") + ifneq ($(CC_VER_MAJOR), 2) DEPFLAGS += -fpch-deps endif endif @@ -282,21 +288,26 @@ endif # statically link libstdc++.so, work with gcc but ignored by g++ STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic +# Enable linker optimization +LFLAGS += -Xlinker -O1 + ifeq ($(USE_CLANG),) - # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. - ifneq ("${CC_VER_MAJOR}", "2") - STATIC_LIBGCC += -static-libgcc + STATIC_LIBGCC += -static-libgcc + + ifneq (, findstring(debug,$(BUILD_FLAVOR))) + # for relocations read-only + LFLAGS += -Xlinker -z -Xlinker relro + + ifeq ($(BUILD_FLAVOR), debug) + # disable incremental relocations linking + LFLAGS += -Xlinker -z -Xlinker now + endif endif ifeq ($(BUILDARCH), ia64) LFLAGS += -Wl,-relax endif -endif -# Enable linker optimization -LFLAGS += -Xlinker -O1 - -ifeq ($(USE_CLANG),) # If this is a --hash-style=gnu system, use --hash-style=both # The gnu .hash section won't work on some Linux systems like SuSE 10. _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu') @@ -333,6 +344,14 @@ ifeq ($(USE_CLANG), true) CFLAGS += -flimit-debug-info endif +ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" + # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) + DEBUG_CFLAGS=-Og +else + # Allow no optimizations. + DEBUG_CFLAGS=-O0 +endif + # DEBUG_BINARIES uses full -g debug information for all configs ifeq ($(DEBUG_BINARIES), true) CFLAGS += -g @@ -355,6 +374,18 @@ else endif endif +ifeq ($(USE_CLANG),) + # Enable bounds checking. + # _FORTIFY_SOURCE appears in GCC 4.0+ + ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1" + # compile time size bounds checks + FASTDEBUG_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 + + # and runtime size bounds checks and paranoid stack smashing checks. + DEBUG_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1 + endif +endif + # If we are building HEADLESS, pass on to VM # so it can set the java.awt.headless property ifdef HEADLESS diff --git a/hotspot/make/solaris/makefiles/gcc.make b/hotspot/make/solaris/makefiles/gcc.make index 94778592ece..801bb4ee08e 100644 --- a/hotspot/make/solaris/makefiles/gcc.make +++ b/hotspot/make/solaris/makefiles/gcc.make @@ -19,7 +19,7 @@ # 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. -# +# # #------------------------------------------------------------------------ @@ -40,7 +40,7 @@ Compiler = gcc CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) -# Check for the versions of C++ and C compilers ($CXX and $CC) used. +# Check for the versions of C++ and C compilers ($CXX and $CC) used. # Get the last thing on the line that looks like x.x+ (x is a digit). COMPILER_REV := \ @@ -98,7 +98,7 @@ ASFLAGS += $(ARCHFLAG) ifeq ($(BUILDARCH), amd64) ASFLAGS += -march=k8 -march=amd64 -LFLAGS += -march=k8 +LFLAGS += -march=k8 endif @@ -115,21 +115,44 @@ else endif -# Compiler warnings are treated as errors -WARNINGS_ARE_ERRORS = -Werror +# Compiler warnings are treated as errors +WARNINGS_ARE_ERRORS = -Werror + # Enable these warnings. See 'info gcc' about details on these options WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef -Wformat=2 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) -# Special cases -CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) -# The flags to use for an Optimized g++ build -OPT_CFLAGS += -O3 +# Special cases +CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) + +# optimization control flags (Used by fastdebug and release variants) +OPT_CFLAGS/NOOPT=-O0 +ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" + # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) + OPT_CFLAGS/DEBUG=-Og ++else + # Allow no optimizations. + OPT_CFLAGS/DEBUG=-O0 +endif +OPT_CFLAGS/SIZE=-Os +OPT_CFLAGS/SPEED=-O3 + +OPT_CFLAGS_DEFAULT ?= SPEED # Hotspot uses very unstrict aliasing turn this optimization off -OPT_CFLAGS += -fno-strict-aliasing +# This option is added to CFLAGS rather than OPT_CFLAGS +# so that OPT_CFLAGS overrides get this option too. +CFLAGS += -fno-strict-aliasing -# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp +ifdef OPT_CFLAGS + ifneq ("$(origin OPT_CFLAGS)", "command line") + $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.") + endif +endif + +OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS) + +# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp # if we use expensive-optimizations # Note: all ia64 setting reflect the ones for linux # No actial testing was performed: there is no Solaris on ia64 presently @@ -137,10 +160,20 @@ ifeq ($(BUILDARCH), ia64) OPT_CFLAGS/bytecodeInterpreter.o += -fno-expensive-optimizations endif -OPT_CFLAGS/NOOPT=-O0 +# Work around some compiler bugs. +ifeq ($(USE_CLANG), true) + ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) + OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) + endif +else + # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. + ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1) + OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT) + endif +endif # Flags for generating make dependency flags. -ifneq ("${CC_VER_MAJOR}", "2") +ifneq ($(CC_VER_MAJOR), 2) DEPFLAGS = -fpch-deps -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) endif @@ -155,26 +188,37 @@ endif # statically link libstdc++.so, work with gcc but ignored by g++ STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -# statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. -ifneq ("${CC_VER_MAJOR}", "2") -STATIC_LIBGCC += -static-libgcc -endif - -ifeq ($(BUILDARCH), ia64) -# Note: all ia64 setting reflect the ones for linux -# No actial testing was performed: there is no Solaris on ia64 presently -LFLAGS += -Wl,-relax -endif ifdef USE_GNULD -# Enable linker optimization -LFLAGS += -Xlinker -O1 + # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. + ifneq ($(CC_VER_MAJOR), 2) + STATIC_LIBGCC += -static-libgcc + endif -# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. -MAPFLAG = -Xlinker --version-script=FILENAME -else -MAPFLAG = -Xlinker -M -Xlinker FILENAME -endif + # Enable linker optimization + LFLAGS += -Xlinker -O1 + + ifneq (, findstring(debug,$(BUILD_FLAVOR))) + # for relocations read-only + LFLAGS += -Xlinker -z -Xlinker relro + + ifeq ($(BUILD_FLAVOR), debug) + # disable incremental relocations linking + LFLAGS += -Xlinker -z -Xlinker now + endif + endif + + ifeq ($(BUILDARCH), ia64) + # Note: all ia64 setting reflect the ones for linux + # No actual testing was performed: there is no Solaris on ia64 presently + LFLAGS += -Wl,-relax + endif + + # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. + MAPFLAG = -Xlinker --version-script=FILENAME +else + MAPFLAG = -Xlinker -M -Xlinker FILENAME +endif # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj SONAMEFLAG = -Xlinker -soname=SONAME @@ -185,15 +229,34 @@ SHARED_FLAG = -shared #------------------------------------------------------------------------ # Debug flags -# Use the stabs format for debugging information (this is the default -# on gcc-2.91). It's good enough, has all the information about line -# numbers and local variables, and libjvm.so is only about 16M. -# Change this back to "-g" if you want the most expressive format. -# (warning: that could easily inflate libjvm.so to 150M!) -# Note: The Itanium gcc compiler crashes when using -gstabs. -DEBUG_CFLAGS/ia64 = -g -DEBUG_CFLAGS/amd64 = -g -DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) -ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) -DEBUG_CFLAGS += -gstabs -endif +ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" + # Allow basic optimizations which don't distrupt debugging. (Principally dead code elimination) + DEBUG_CFLAGS=-Og +else + # Allow no optimizations. + DEBUG_CFLAGS=-O0 +endif + + +# Use the stabs format for debugging information (this is the default +# on gcc-2.91). It's good enough, has all the information about line +# numbers and local variables, and libjvm.so is only about 16M. +# Change this back to "-g" if you want the most expressive format. +# (warning: that could easily inflate libjvm.so to 150M!) +# Note: The Itanium gcc compiler crashes when using -gstabs. +DEBUG_CFLAGS/ia64 = -g +DEBUG_CFLAGS/amd64 = -g +DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) +ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) + DEBUG_CFLAGS += -gstabs +endif + +# Enable bounds checking. +# _FORTIFY_SOURCE appears in GCC 4.0+ +ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1" + # compile time size bounds checks + FASTDEBUG_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 + + # and runtime size bounds checks and paranoid stack smashing checks. + DEBUG_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all --param ssp-buffer-size=1 +endif diff --git a/hotspot/src/cpu/ppc/vm/ppc.ad b/hotspot/src/cpu/ppc/vm/ppc.ad index 214ea62029b..d2d51379a22 100644 --- a/hotspot/src/cpu/ppc/vm/ppc.ad +++ b/hotspot/src/cpu/ppc/vm/ppc.ad @@ -1285,9 +1285,9 @@ bool MachConstantBaseNode::requires_postalloc_expand() const { return true; } void MachConstantBaseNode::postalloc_expand(GrowableArray *nodes, PhaseRegAlloc *ra_) { Compile *C = ra_->C; - iRegPdstOper *op_dst = new (C) iRegPdstOper(); - MachNode *m1 = new (C) loadToc_hiNode(); - MachNode *m2 = new (C) loadToc_loNode(); + iRegPdstOper *op_dst = new iRegPdstOper(); + MachNode *m1 = new loadToc_hiNode(); + MachNode *m2 = new loadToc_loNode(); m1->add_req(NULL); m2->add_req(NULL, m1); @@ -2232,9 +2232,9 @@ const bool Matcher::isSimpleConstant64(jlong value) { MachTypeNode *Matcher::make_decode_node(Compile *C) { assert(Universe::narrow_oop_base() == NULL && Universe::narrow_oop_shift() == 0, "This method is only implemented for unscaled cOops mode so far"); - MachTypeNode *decode = new (C) decodeN_unscaledNode(); - decode->set_opnd_array(0, new (C) iRegPdstOper()); - decode->set_opnd_array(1, new (C) iRegNsrcOper()); + MachTypeNode *decode = new decodeN_unscaledNode(); + decode->set_opnd_array(0, new iRegPdstOper()); + decode->set_opnd_array(1, new iRegNsrcOper()); return decode; } */ @@ -2600,20 +2600,20 @@ loadConLNodesTuple loadConLNodesTuple_create(Compile *C, PhaseRegAlloc *ra_, Nod const bool large_constant_pool = true; // TODO: PPC port C->cfg()->_consts_size > 4000; if (large_constant_pool) { // Create new nodes. - loadConL_hiNode *m1 = new (C) loadConL_hiNode(); - loadConL_loNode *m2 = new (C) loadConL_loNode(); + loadConL_hiNode *m1 = new loadConL_hiNode(); + loadConL_loNode *m2 = new loadConL_loNode(); // inputs for new nodes m1->add_req(NULL, toc); m2->add_req(NULL, m1); // operands for new nodes - m1->_opnds[0] = new (C) iRegLdstOper(); // dst - m1->_opnds[1] = immSrc; // src - m1->_opnds[2] = new (C) iRegPdstOper(); // toc - m2->_opnds[0] = new (C) iRegLdstOper(); // dst - m2->_opnds[1] = immSrc; // src - m2->_opnds[2] = new (C) iRegLdstOper(); // base + m1->_opnds[0] = new iRegLdstOper(); // dst + m1->_opnds[1] = immSrc; // src + m1->_opnds[2] = new iRegPdstOper(); // toc + m2->_opnds[0] = new iRegLdstOper(); // dst + m2->_opnds[1] = immSrc; // src + m2->_opnds[2] = new iRegLdstOper(); // base // Initialize ins_attrib TOC fields. m1->_const_toc_offset = -1; @@ -2633,15 +2633,15 @@ loadConLNodesTuple loadConLNodesTuple_create(Compile *C, PhaseRegAlloc *ra_, Nod nodes._last = nodes._large_lo; assert(m2->bottom_type()->isa_long(), "must be long"); } else { - loadConLNode *m2 = new (C) loadConLNode(); + loadConLNode *m2 = new loadConLNode(); // inputs for new nodes m2->add_req(NULL, toc); // operands for new nodes - m2->_opnds[0] = new (C) iRegLdstOper(); // dst - m2->_opnds[1] = immSrc; // src - m2->_opnds[2] = new (C) iRegPdstOper(); // toc + m2->_opnds[0] = new iRegLdstOper(); // dst + m2->_opnds[1] = immSrc; // src + m2->_opnds[2] = new iRegPdstOper(); // toc // Initialize ins_attrib instruction offset. m2->_cbuf_insts_offset = -1; @@ -2750,20 +2750,20 @@ encode %{ const bool large_constant_pool = true; // TODO: PPC port C->cfg()->_consts_size > 4000; if (large_constant_pool) { // Create new nodes. - loadConP_hiNode *m1 = new (C) loadConP_hiNode(); - loadConP_loNode *m2 = new (C) loadConP_loNode(); + loadConP_hiNode *m1 = new loadConP_hiNode(); + loadConP_loNode *m2 = new loadConP_loNode(); // inputs for new nodes m1->add_req(NULL, n_toc); m2->add_req(NULL, m1); // operands for new nodes - m1->_opnds[0] = new (C) iRegPdstOper(); // dst - m1->_opnds[1] = op_src; // src - m1->_opnds[2] = new (C) iRegPdstOper(); // toc - m2->_opnds[0] = new (C) iRegPdstOper(); // dst - m2->_opnds[1] = op_src; // src - m2->_opnds[2] = new (C) iRegLdstOper(); // base + m1->_opnds[0] = new iRegPdstOper(); // dst + m1->_opnds[1] = op_src; // src + m1->_opnds[2] = new iRegPdstOper(); // toc + m2->_opnds[0] = new iRegPdstOper(); // dst + m2->_opnds[1] = op_src; // src + m2->_opnds[2] = new iRegLdstOper(); // base // Initialize ins_attrib TOC fields. m1->_const_toc_offset = -1; @@ -2777,15 +2777,15 @@ encode %{ nodes->push(m2); assert(m2->bottom_type()->isa_ptr(), "must be ptr"); } else { - loadConPNode *m2 = new (C) loadConPNode(); + loadConPNode *m2 = new loadConPNode(); // inputs for new nodes m2->add_req(NULL, n_toc); // operands for new nodes - m2->_opnds[0] = new (C) iRegPdstOper(); // dst - m2->_opnds[1] = op_src; // src - m2->_opnds[2] = new (C) iRegPdstOper(); // toc + m2->_opnds[0] = new iRegPdstOper(); // dst + m2->_opnds[1] = op_src; // src + m2->_opnds[2] = new iRegPdstOper(); // toc // Register allocation for new nodes. ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); @@ -2802,9 +2802,9 @@ encode %{ MachNode *m2; if (large_constant_pool) { - m2 = new (C) loadConFCompNode(); + m2 = new loadConFCompNode(); } else { - m2 = new (C) loadConFNode(); + m2 = new loadConFNode(); } // inputs for new nodes m2->add_req(NULL, n_toc); @@ -2812,7 +2812,7 @@ encode %{ // operands for new nodes m2->_opnds[0] = op_dst; m2->_opnds[1] = op_src; - m2->_opnds[2] = new (C) iRegPdstOper(); // constanttablebase + m2->_opnds[2] = new iRegPdstOper(); // constanttablebase // register allocation for new nodes ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); @@ -2826,9 +2826,9 @@ encode %{ MachNode *m2; if (large_constant_pool) { - m2 = new (C) loadConDCompNode(); + m2 = new loadConDCompNode(); } else { - m2 = new (C) loadConDNode(); + m2 = new loadConDNode(); } // inputs for new nodes m2->add_req(NULL, n_toc); @@ -2836,7 +2836,7 @@ encode %{ // operands for new nodes m2->_opnds[0] = op_dst; m2->_opnds[1] = op_src; - m2->_opnds[2] = new (C) iRegPdstOper(); // constanttablebase + m2->_opnds[2] = new iRegPdstOper(); // constanttablebase // register allocation for new nodes ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); @@ -2918,15 +2918,15 @@ encode %{ if (VM_Version::has_isel()) { // use isel instruction with Power 7 - cmpP_reg_imm16Node *n_compare = new (C) cmpP_reg_imm16Node(); - encodeP_subNode *n_sub_base = new (C) encodeP_subNode(); - encodeP_shiftNode *n_shift = new (C) encodeP_shiftNode(); - cond_set_0_oopNode *n_cond_set = new (C) cond_set_0_oopNode(); + cmpP_reg_imm16Node *n_compare = new cmpP_reg_imm16Node(); + encodeP_subNode *n_sub_base = new encodeP_subNode(); + encodeP_shiftNode *n_shift = new encodeP_shiftNode(); + cond_set_0_oopNode *n_cond_set = new cond_set_0_oopNode(); n_compare->add_req(n_region, n_src); n_compare->_opnds[0] = op_crx; n_compare->_opnds[1] = op_src; - n_compare->_opnds[2] = new (C) immL16Oper(0); + n_compare->_opnds[2] = new immL16Oper(0); n_sub_base->add_req(n_region, n_src); n_sub_base->_opnds[0] = op_dst; @@ -2956,10 +2956,10 @@ encode %{ } else { // before Power 7 - moveRegNode *n_move = new (C) moveRegNode(); - cmpP_reg_imm16Node *n_compare = new (C) cmpP_reg_imm16Node(); - encodeP_shiftNode *n_shift = new (C) encodeP_shiftNode(); - cond_sub_baseNode *n_sub_base = new (C) cond_sub_baseNode(); + moveRegNode *n_move = new moveRegNode(); + cmpP_reg_imm16Node *n_compare = new cmpP_reg_imm16Node(); + encodeP_shiftNode *n_shift = new encodeP_shiftNode(); + cond_sub_baseNode *n_sub_base = new cond_sub_baseNode(); n_move->add_req(n_region, n_src); n_move->_opnds[0] = op_dst; @@ -2971,7 +2971,7 @@ encode %{ n_compare->_opnds[0] = op_crx; n_compare->_opnds[1] = op_src; - n_compare->_opnds[2] = new (C) immL16Oper(0); + n_compare->_opnds[2] = new immL16Oper(0); n_sub_base->add_req(n_region, n_compare, n_src); n_sub_base->_opnds[0] = op_dst; @@ -3000,13 +3000,13 @@ encode %{ enc_class postalloc_expand_encode_oop_not_null(iRegNdst dst, iRegPdst src) %{ - encodeP_subNode *n1 = new (C) encodeP_subNode(); + encodeP_subNode *n1 = new encodeP_subNode(); n1->add_req(n_region, n_src); n1->_opnds[0] = op_dst; n1->_opnds[1] = op_src; n1->_bottom_type = _bottom_type; - encodeP_shiftNode *n2 = new (C) encodeP_shiftNode(); + encodeP_shiftNode *n2 = new encodeP_shiftNode(); n2->add_req(n_region, n1); n2->_opnds[0] = op_dst; n2->_opnds[1] = op_dst; @@ -3020,13 +3020,13 @@ encode %{ %} enc_class postalloc_expand_decode_oop(iRegPdst dst, iRegNsrc src, flagsReg crx) %{ - decodeN_shiftNode *n_shift = new (C) decodeN_shiftNode(); - cmpN_reg_imm0Node *n_compare = new (C) cmpN_reg_imm0Node(); + decodeN_shiftNode *n_shift = new decodeN_shiftNode(); + cmpN_reg_imm0Node *n_compare = new cmpN_reg_imm0Node(); n_compare->add_req(n_region, n_src); n_compare->_opnds[0] = op_crx; n_compare->_opnds[1] = op_src; - n_compare->_opnds[2] = new (C) immN_0Oper(TypeNarrowOop::NULL_PTR); + n_compare->_opnds[2] = new immN_0Oper(TypeNarrowOop::NULL_PTR); n_shift->add_req(n_region, n_src); n_shift->_opnds[0] = op_dst; @@ -3036,13 +3036,13 @@ encode %{ if (VM_Version::has_isel()) { // use isel instruction with Power 7 - decodeN_addNode *n_add_base = new (C) decodeN_addNode(); + decodeN_addNode *n_add_base = new decodeN_addNode(); n_add_base->add_req(n_region, n_shift); n_add_base->_opnds[0] = op_dst; n_add_base->_opnds[1] = op_dst; n_add_base->_bottom_type = _bottom_type; - cond_set_0_ptrNode *n_cond_set = new (C) cond_set_0_ptrNode(); + cond_set_0_ptrNode *n_cond_set = new cond_set_0_ptrNode(); n_cond_set->add_req(n_region, n_compare, n_add_base); n_cond_set->_opnds[0] = op_dst; n_cond_set->_opnds[1] = op_crx; @@ -3064,7 +3064,7 @@ encode %{ } else { // before Power 7 - cond_add_baseNode *n_add_base = new (C) cond_add_baseNode(); + cond_add_baseNode *n_add_base = new cond_add_baseNode(); n_add_base->add_req(n_region, n_compare, n_shift); n_add_base->_opnds[0] = op_dst; @@ -3086,13 +3086,13 @@ encode %{ %} enc_class postalloc_expand_decode_oop_not_null(iRegPdst dst, iRegNsrc src) %{ - decodeN_shiftNode *n1 = new (C) decodeN_shiftNode(); + decodeN_shiftNode *n1 = new decodeN_shiftNode(); n1->add_req(n_region, n_src); n1->_opnds[0] = op_dst; n1->_opnds[1] = op_src; n1->_bottom_type = _bottom_type; - decodeN_addNode *n2 = new (C) decodeN_addNode(); + decodeN_addNode *n2 = new decodeN_addNode(); n2->add_req(n_region, n1); n2->_opnds[0] = op_dst; n2->_opnds[1] = op_dst; @@ -3388,7 +3388,7 @@ encode %{ // Create new nodes. // Make an operand with the bit pattern to load as float. - immLOper *op_repl = new (C) immLOper((jlong)replicate_immF(op_src->constantF())); + immLOper *op_repl = new immLOper((jlong)replicate_immF(op_src->constantF())); loadConLNodesTuple loadConLNodes = loadConLNodesTuple_create(C, ra_, n_toc, op_repl, @@ -3611,11 +3611,11 @@ encode %{ // Create the nodes for loading the IC from the TOC. loadConLNodesTuple loadConLNodes_IC = - loadConLNodesTuple_create(C, ra_, n_toc, new (C) immLOper((jlong)Universe::non_oop_word()), + loadConLNodesTuple_create(C, ra_, n_toc, new immLOper((jlong)Universe::non_oop_word()), OptoReg::Name(R19_H_num), OptoReg::Name(R19_num)); // Create the call node. - CallDynamicJavaDirectSchedNode *call = new (C) CallDynamicJavaDirectSchedNode(); + CallDynamicJavaDirectSchedNode *call = new CallDynamicJavaDirectSchedNode(); call->_method_handle_invoke = _method_handle_invoke; call->_vtable_index = _vtable_index; call->_method = _method; @@ -3765,7 +3765,7 @@ encode %{ #if defined(ABI_ELFv2) jlong entry_address = (jlong) this->entry_point(); assert(entry_address, "need address here"); - loadConLNodes_Entry = loadConLNodesTuple_create(C, ra_, n_toc, new (C) immLOper(entry_address), + loadConLNodes_Entry = loadConLNodesTuple_create(C, ra_, n_toc, new immLOper(entry_address), OptoReg::Name(R12_H_num), OptoReg::Name(R12_num)); #else // Get the struct that describes the function we are about to call. @@ -3777,42 +3777,42 @@ encode %{ loadConLNodesTuple loadConLNodes_Toc; // Create nodes and operands for loading the entry point. - loadConLNodes_Entry = loadConLNodesTuple_create(C, ra_, n_toc, new (C) immLOper(entry_address), + loadConLNodes_Entry = loadConLNodesTuple_create(C, ra_, n_toc, new immLOper(entry_address), OptoReg::Name(R12_H_num), OptoReg::Name(R12_num)); // Create nodes and operands for loading the env pointer. if (fd->env() != NULL) { - loadConLNodes_Env = loadConLNodesTuple_create(C, ra_, n_toc, new (C) immLOper((jlong) fd->env()), + loadConLNodes_Env = loadConLNodesTuple_create(C, ra_, n_toc, new immLOper((jlong) fd->env()), OptoReg::Name(R11_H_num), OptoReg::Name(R11_num)); } else { loadConLNodes_Env._large_hi = NULL; loadConLNodes_Env._large_lo = NULL; loadConLNodes_Env._small = NULL; - loadConLNodes_Env._last = new (C) loadConL16Node(); - loadConLNodes_Env._last->_opnds[0] = new (C) iRegLdstOper(); - loadConLNodes_Env._last->_opnds[1] = new (C) immL16Oper(0); + loadConLNodes_Env._last = new loadConL16Node(); + loadConLNodes_Env._last->_opnds[0] = new iRegLdstOper(); + loadConLNodes_Env._last->_opnds[1] = new immL16Oper(0); ra_->set_pair(loadConLNodes_Env._last->_idx, OptoReg::Name(R11_H_num), OptoReg::Name(R11_num)); } // Create nodes and operands for loading the Toc point. - loadConLNodes_Toc = loadConLNodesTuple_create(C, ra_, n_toc, new (C) immLOper((jlong) fd->toc()), + loadConLNodes_Toc = loadConLNodesTuple_create(C, ra_, n_toc, new immLOper((jlong) fd->toc()), OptoReg::Name(R2_H_num), OptoReg::Name(R2_num)); #endif // ABI_ELFv2 // mtctr node - MachNode *mtctr = new (C) CallLeafDirect_mtctrNode(); + MachNode *mtctr = new CallLeafDirect_mtctrNode(); assert(loadConLNodes_Entry._last != NULL, "entry must exist"); mtctr->add_req(0, loadConLNodes_Entry._last); - mtctr->_opnds[0] = new (C) iRegLdstOper(); - mtctr->_opnds[1] = new (C) iRegLdstOper(); + mtctr->_opnds[0] = new iRegLdstOper(); + mtctr->_opnds[1] = new iRegLdstOper(); // call node - MachCallLeafNode *call = new (C) CallLeafDirectNode(); + MachCallLeafNode *call = new CallLeafDirectNode(); call->_opnds[0] = _opnds[0]; - call->_opnds[1] = new (C) methodOper((intptr_t) entry_address); // May get set later. + call->_opnds[1] = new methodOper((intptr_t) entry_address); // May get set later. // Make the new call node look like the old one. call->_name = _name; @@ -6050,9 +6050,9 @@ instruct loadConN_Ex(iRegNdst dst, immN src) %{ format %{ "LoadN $dst, $src \t// postalloc expanded" %} // mask postalloc_expand %{ - MachNode *m1 = new (C) loadConN_hiNode(); - MachNode *m2 = new (C) loadConN_loNode(); - MachNode *m3 = new (C) clearMs32bNode(); + MachNode *m1 = new loadConN_hiNode(); + MachNode *m2 = new loadConN_loNode(); + MachNode *m3 = new clearMs32bNode(); m1->add_req(NULL); m2->add_req(NULL, m1); m3->add_req(NULL, m2); @@ -6117,7 +6117,7 @@ instruct loadConNKlass_Ex(iRegNdst dst, immNKlass src) %{ format %{ "LoadN $dst, $src \t// postalloc expanded" %} // mask postalloc_expand %{ // Load high bits into register. Sign extended. - MachNode *m1 = new (C) loadConNKlass_hiNode(); + MachNode *m1 = new loadConNKlass_hiNode(); m1->add_req(NULL); m1->_opnds[0] = op_dst; m1->_opnds[1] = op_src; @@ -6127,7 +6127,7 @@ instruct loadConNKlass_Ex(iRegNdst dst, immNKlass src) %{ MachNode *m2 = m1; if (!Assembler::is_uimm((jlong)Klass::encode_klass((Klass *)op_src->constant()), 31)) { // Value might be 1-extended. Mask out these bits. - m2 = new (C) clearMs32bNode(); + m2 = new clearMs32bNode(); m2->add_req(NULL, m1); m2->_opnds[0] = op_dst; m2->_opnds[1] = op_dst; @@ -6135,7 +6135,7 @@ instruct loadConNKlass_Ex(iRegNdst dst, immNKlass src) %{ nodes->push(m2); } - MachNode *m3 = new (C) loadConNKlass_loNode(); + MachNode *m3 = new loadConNKlass_loNode(); m3->add_req(NULL, m2); m3->_opnds[0] = op_dst; m3->_opnds[1] = op_src; @@ -6987,14 +6987,14 @@ instruct encodePKlass_not_null_Ex(iRegNdst dst, iRegLsrc base, iRegPsrc src) %{ format %{ "EncodePKlass $dst, $src\t// $src != Null, postalloc expanded" %} postalloc_expand %{ - encodePKlass_sub_baseNode *n1 = new (C) encodePKlass_sub_baseNode(); + encodePKlass_sub_baseNode *n1 = new encodePKlass_sub_baseNode(); n1->add_req(n_region, n_base, n_src); n1->_opnds[0] = op_dst; n1->_opnds[1] = op_base; n1->_opnds[2] = op_src; n1->_bottom_type = _bottom_type; - encodePKlass_shiftNode *n2 = new (C) encodePKlass_shiftNode(); + encodePKlass_shiftNode *n2 = new encodePKlass_shiftNode(); n2->add_req(n_region, n1); n2->_opnds[0] = op_dst; n2->_opnds[1] = op_dst; @@ -7064,14 +7064,14 @@ instruct decodeNKlass_notNull_addBase_Ex(iRegPdst dst, iRegLsrc base, iRegNsrc s format %{ "DecodeNKlass $dst = $base + ($src << 3) \t// $src != NULL, postalloc expanded" %} postalloc_expand %{ - decodeNKlass_add_baseNode *n1 = new (C) decodeNKlass_add_baseNode(); + decodeNKlass_add_baseNode *n1 = new decodeNKlass_add_baseNode(); n1->add_req(n_region, n_base, n_src); n1->_opnds[0] = op_dst; n1->_opnds[1] = op_base; n1->_opnds[2] = op_src; n1->_bottom_type = _bottom_type; - decodeNKlass_shiftNode *n2 = new (C) decodeNKlass_shiftNode(); + decodeNKlass_shiftNode *n2 = new decodeNKlass_shiftNode(); n2->add_req(n_region, n1); n2->_opnds[0] = op_dst; n2->_opnds[1] = op_dst; @@ -9773,8 +9773,8 @@ instruct cmovI_bso_stackSlotL_conLvalue0_Ex(iRegIdst dst, flagsReg crx, stackSlo // // Create new nodes. - MachNode *m1 = new (C) loadConI16Node(); - MachNode *m2 = new (C) cmovI_bso_stackSlotLNode(); + MachNode *m1 = new loadConI16Node(); + MachNode *m2 = new cmovI_bso_stackSlotLNode(); // inputs for new nodes m1->add_req(n_region); @@ -9785,7 +9785,7 @@ instruct cmovI_bso_stackSlotL_conLvalue0_Ex(iRegIdst dst, flagsReg crx, stackSlo // operands for new nodes m1->_opnds[0] = op_dst; - m1->_opnds[1] = new (C) immI16Oper(0); + m1->_opnds[1] = new immI16Oper(0); m2->_opnds[0] = op_dst; m2->_opnds[1] = op_crx; @@ -9942,8 +9942,8 @@ instruct cmovL_bso_stackSlotL_conLvalue0_Ex(iRegLdst dst, flagsReg crx, stackSlo // // Create new nodes. - MachNode *m1 = new (C) loadConL16Node(); - MachNode *m2 = new (C) cmovL_bso_stackSlotLNode(); + MachNode *m1 = new loadConL16Node(); + MachNode *m2 = new cmovL_bso_stackSlotLNode(); // inputs for new nodes m1->add_req(n_region); @@ -9952,7 +9952,7 @@ instruct cmovL_bso_stackSlotL_conLvalue0_Ex(iRegLdst dst, flagsReg crx, stackSlo // operands for new nodes m1->_opnds[0] = op_dst; - m1->_opnds[1] = new (C) immL16Oper(0); + m1->_opnds[1] = new immL16Oper(0); m2->_opnds[0] = op_dst; m2->_opnds[1] = op_crx; m2->_opnds[2] = op_mem; @@ -10288,8 +10288,8 @@ instruct cmovI_conIvalueMinus1_conIvalue0_conIvalue1_Ex(iRegIdst dst, flagsReg c // // Create new nodes. - MachNode *m1 = new (C) loadConI16Node(); - MachNode *m2 = new (C) cmovI_conIvalueMinus1_conIvalue1Node(); + MachNode *m1 = new loadConI16Node(); + MachNode *m2 = new cmovI_conIvalueMinus1_conIvalue1Node(); // inputs for new nodes m1->add_req(n_region); @@ -10298,7 +10298,7 @@ instruct cmovI_conIvalueMinus1_conIvalue0_conIvalue1_Ex(iRegIdst dst, flagsReg c // operands for new nodes m1->_opnds[0] = op_dst; - m1->_opnds[1] = new (C) immI16Oper(0); + m1->_opnds[1] = new immI16Oper(0); m2->_opnds[0] = op_dst; m2->_opnds[1] = op_crx; @@ -10623,8 +10623,8 @@ instruct cmpF_reg_reg_Ex(flagsReg crx, regF src1, regF src2) %{ // // Create new nodes. - MachNode *m1 = new (C) cmpFUnordered_reg_regNode(); - MachNode *m2 = new (C) cmov_bns_lessNode(); + MachNode *m1 = new cmpFUnordered_reg_regNode(); + MachNode *m2 = new cmov_bns_lessNode(); // inputs for new nodes m1->add_req(n_region, n_src1, n_src2); @@ -10698,8 +10698,8 @@ instruct cmpD_reg_reg_Ex(flagsReg crx, regD src1, regD src2) %{ // // create new nodes - MachNode *m1 = new (C) cmpDUnordered_reg_regNode(); - MachNode *m2 = new (C) cmov_bns_lessNode(); + MachNode *m1 = new cmpDUnordered_reg_regNode(); + MachNode *m2 = new cmov_bns_lessNode(); // inputs for new nodes m1->add_req(n_region, n_src1, n_src2); diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp index db7ff9eca81..dd83b092f75 100644 --- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp @@ -123,6 +123,7 @@ class Assembler : public AbstractAssembler { fpop2_op3 = 0x35, impdep1_op3 = 0x36, aes3_op3 = 0x36, + sha_op3 = 0x36, alignaddr_op3 = 0x36, faligndata_op3 = 0x36, flog3_op3 = 0x36, @@ -223,7 +224,11 @@ class Assembler : public AbstractAssembler { mwtos_opf = 0x119, aes_kexpand0_opf = 0x130, - aes_kexpand2_opf = 0x131 + aes_kexpand2_opf = 0x131, + + sha1_opf = 0x141, + sha256_opf = 0x142, + sha512_opf = 0x143 }; enum op5s { @@ -595,6 +600,11 @@ class Assembler : public AbstractAssembler { // AES crypto instructions supported only on certain processors static void aes_only() { assert( VM_Version::has_aes(), "This instruction only works on SPARC with AES instructions support"); } + // SHA crypto instructions supported only on certain processors + static void sha1_only() { assert( VM_Version::has_sha1(), "This instruction only works on SPARC with SHA1"); } + static void sha256_only() { assert( VM_Version::has_sha256(), "This instruction only works on SPARC with SHA256"); } + static void sha512_only() { assert( VM_Version::has_sha512(), "This instruction only works on SPARC with SHA512"); } + // instruction only in VIS1 static void vis1_only() { assert( VM_Version::has_vis1(), "This instruction only works on SPARC with VIS1"); } @@ -1179,7 +1189,6 @@ public: u_field(3, 29, 25) | immed(true) | simm(simm13a, 13)); } inline void wrfprs( Register d) { v9_only(); emit_int32( op(arith_op) | rs1(d) | op3(wrreg_op3) | u_field(6, 29, 25)); } - // VIS1 instructions void alignaddr( Register s1, Register s2, Register d ) { vis1_only(); emit_int32( op(arith_op) | rd(d) | op3(alignaddr_op3) | rs1(s1) | opf(alignaddr_opf) | rs2(s2)); } @@ -1203,6 +1212,12 @@ public: void movwtos( Register s, FloatRegister d ) { vis3_only(); emit_int32( op(arith_op) | fd(d, FloatRegisterImpl::S) | op3(mftoi_op3) | opf(mwtos_opf) | rs2(s)); } void movxtod( Register s, FloatRegister d ) { vis3_only(); emit_int32( op(arith_op) | fd(d, FloatRegisterImpl::D) | op3(mftoi_op3) | opf(mxtod_opf) | rs2(s)); } + // Crypto SHA instructions + + void sha1() { sha1_only(); emit_int32( op(arith_op) | op3(sha_op3) | opf(sha1_opf)); } + void sha256() { sha256_only(); emit_int32( op(arith_op) | op3(sha_op3) | opf(sha256_opf)); } + void sha512() { sha512_only(); emit_int32( op(arith_op) | op3(sha_op3) | opf(sha512_opf)); } + // Creation Assembler(CodeBuffer* code) : AbstractAssembler(code) { #ifdef CHECK_DELAY diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp index 813cbf0fa03..0c733a7b1b9 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @@ -1612,13 +1612,10 @@ int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) { __ set((intptr_t)os::get_polling_page(), tmp->as_register()); if (info != NULL) { add_debug_info_for_branch(info); - } else { - __ relocate(relocInfo::poll_type); } - int offset = __ offset(); + __ relocate(relocInfo::poll_type); __ ld_ptr(tmp->as_register(), 0, G0); - return offset; } diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp index 4c6f0de0010..e91142ee011 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp @@ -872,21 +872,19 @@ void LIRGenerator::do_Convert(Convert* x) { void LIRGenerator::do_NewInstance(NewInstance* x) { + print_if_not_loaded(x); + // This instruction can be deoptimized in the slow path : use // O0 as result register. const LIR_Opr reg = result_register_for(x->type()); -#ifndef PRODUCT - if (PrintNotLoaded && !x->klass()->is_loaded()) { - tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci()); - } -#endif + CodeEmitInfo* info = state_for(x, x->state()); LIR_Opr tmp1 = FrameMap::G1_oop_opr; LIR_Opr tmp2 = FrameMap::G3_oop_opr; LIR_Opr tmp3 = FrameMap::G4_oop_opr; LIR_Opr tmp4 = FrameMap::O1_oop_opr; LIR_Opr klass_reg = FrameMap::G5_metadata_opr; - new_instance(reg, x->klass(), tmp1, tmp2, tmp3, tmp4, klass_reg, info); + new_instance(reg, x->klass(), x->is_unresolved(), tmp1, tmp2, tmp3, tmp4, klass_reg, info); LIR_Opr result = rlock_result(x); __ move(reg, result); } diff --git a/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp b/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp index 791331168d2..92d494fc0ca 100644 --- a/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp @@ -135,7 +135,7 @@ void CompiledStaticCall::set_to_interpreted(methodHandle callee, address entry) if (TraceICs) { ResourceMark rm; tty->print_cr("CompiledStaticCall@" INTPTR_FORMAT ": set_to_interpreted %s", - instruction_address(), + p2i(instruction_address()), callee->name_and_sig_as_C_string()); } diff --git a/hotspot/src/cpu/sparc/vm/debug_sparc.cpp b/hotspot/src/cpu/sparc/vm/debug_sparc.cpp index 05b8de24361..8be1072fc65 100644 --- a/hotspot/src/cpu/sparc/vm/debug_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/debug_sparc.cpp @@ -42,20 +42,24 @@ void pd_ps(frame f) { intptr_t *pc = NULL; intptr_t *next_pc = NULL; int count = 0; - tty->print("register window backtrace from %#x:\n", sp); + tty->print_cr("register window backtrace from " INTPTR_FORMAT ":", p2i(sp)); while (sp != NULL && ((intptr_t)sp & 7) == 0 && sp > prev_sp && sp < prev_sp+1000) { pc = next_pc; next_pc = (intptr_t*) sp[I7->sp_offset_in_saved_window()]; - tty->print("[%d] sp=%#x pc=", count, sp); + tty->print("[%d] sp=" INTPTR_FORMAT " pc=", count, p2i(sp)); findpc((intptr_t)pc); if (WizardMode && Verbose) { // print register window contents also - tty->print_cr(" L0..L7: {%#x %#x %#x %#x %#x %#x %#x %#x}", - sp[0+0],sp[0+1],sp[0+2],sp[0+3], - sp[0+4],sp[0+5],sp[0+6],sp[0+7]); - tty->print_cr(" I0..I7: {%#x %#x %#x %#x %#x %#x %#x %#x}", - sp[8+0],sp[8+1],sp[8+2],sp[8+3], - sp[8+4],sp[8+5],sp[8+6],sp[8+7]); + tty->print_cr(" L0..L7: {" + INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " + INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " ", + sp[0+0], sp[0+1], sp[0+2], sp[0+3], + sp[0+4], sp[0+5], sp[0+6], sp[0+7]); + tty->print_cr(" I0..I7: {" + INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " + INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT " ", + sp[8+0], sp[8+1], sp[8+2], sp[8+3], + sp[8+4], sp[8+5], sp[8+6], sp[8+7]); // (and print stack frame contents too??) CodeBlob *b = CodeCache::find_blob((address) pc); @@ -74,7 +78,7 @@ void pd_ps(frame f) { count += 1; } if (sp != NULL) - tty->print("[%d] sp=%#x [bogus sp!]", count, sp); + tty->print("[%d] sp=" INTPTR_FORMAT " [bogus sp!]", count, p2i(sp)); } #endif // PRODUCT diff --git a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp index 29b37f006a5..2feb5eb0925 100644 --- a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp @@ -557,7 +557,8 @@ void frame::patch_pc(Thread* thread, address pc) { // QQQ this assert is invalid (or too strong anyway) sice _pc could // be original pc and frame could have the deopt pc. // assert(_pc == *O7_addr() + pc_return_offset, "frame has wrong pc"); - tty->print_cr("patch_pc at address 0x%x [0x%x -> 0x%x] ", O7_addr(), _pc, pc); + tty->print_cr("patch_pc at address " INTPTR_FORMAT " [" INTPTR_FORMAT " -> " INTPTR_FORMAT "]", + p2i(O7_addr()), p2i(_pc), p2i(pc)); } _cb = CodeCache::find_blob(pc); *O7_addr() = pc - pc_return_offset; diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp index d7396f68fbe..1f4cf5654c6 100644 --- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp @@ -1202,7 +1202,7 @@ void RegistersForDebugging::print(outputStream* s) { if ( j != last ) s->print(" - f%d", last); s->print(" = %f", val); s->fill_to(25); - s->print_cr(" (0x%x)", val); + s->print_cr(" (0x%x)", *(int*)&val); j = last + 1; } s->cr(); diff --git a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp index af6d6289644..af2e4e1e96c 100644 --- a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp @@ -483,7 +483,7 @@ void trace_method_handle_stub(const char* adaptername, const char* mh_reg_name = has_mh ? "G3_mh" : "G3"; tty->print_cr("MH %s %s="INTPTR_FORMAT " saved_sp=" INTPTR_FORMAT " args=" INTPTR_FORMAT, adaptername, mh_reg_name, - (intptr_t) mh, saved_sp, args); + p2i(mh), p2i(saved_sp), p2i(args)); if (Verbose) { // dumping last frame with frame::describe diff --git a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.cpp b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.cpp index c15c3c0994f..2ec40f8fd0d 100644 --- a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.cpp @@ -78,7 +78,7 @@ void NativeInstruction::verify() { } void NativeInstruction::print() { - tty->print_cr(INTPTR_FORMAT ": 0x%x", addr_at(0), long_at(0)); + tty->print_cr(INTPTR_FORMAT ": 0x%x", p2i(addr_at(0)), long_at(0)); } void NativeInstruction::set_long_at(int offset, int i) { @@ -142,7 +142,7 @@ void NativeCall::verify() { } void NativeCall::print() { - tty->print_cr(INTPTR_FORMAT ": call " INTPTR_FORMAT, instruction_address(), destination()); + tty->print_cr(INTPTR_FORMAT ": call " INTPTR_FORMAT, p2i(instruction_address()), p2i(destination())); } @@ -271,7 +271,7 @@ bool NativeFarCall::is_call_at(address instr) { } void NativeFarCall::print() { - tty->print_cr(INTPTR_FORMAT ": call " INTPTR_FORMAT, instruction_address(), destination()); + tty->print_cr(INTPTR_FORMAT ": call " INTPTR_FORMAT, p2i(instruction_address()), p2i(destination())); } bool NativeFarCall::destination_is_compiled_verified_entry_point() { @@ -324,7 +324,7 @@ void NativeMovConstReg::verify() { void NativeMovConstReg::print() { - tty->print_cr(INTPTR_FORMAT ": mov reg, " INTPTR_FORMAT, instruction_address(), data()); + tty->print_cr(INTPTR_FORMAT ": mov reg, " INTPTR_FORMAT, p2i(instruction_address()), data()); } @@ -446,7 +446,7 @@ void NativeMovConstRegPatching::verify() { void NativeMovConstRegPatching::print() { - tty->print_cr(INTPTR_FORMAT ": mov reg, " INTPTR_FORMAT, instruction_address(), data()); + tty->print_cr(INTPTR_FORMAT ": mov reg, 0x%x", p2i(instruction_address()), data()); } @@ -585,9 +585,10 @@ void NativeMovRegMem::verify() { void NativeMovRegMem::print() { if (is_immediate()) { - tty->print_cr(INTPTR_FORMAT ": mov reg, [reg + %x]", instruction_address(), offset()); + // offset is a signed 13-bit immediate, so casting it to int will not lose significant bits + tty->print_cr(INTPTR_FORMAT ": mov reg, [reg + %d]", p2i(instruction_address()), (int)offset()); } else { - tty->print_cr(INTPTR_FORMAT ": mov reg, [reg + reg]", instruction_address()); + tty->print_cr(INTPTR_FORMAT ": mov reg, [reg + reg]", p2i(instruction_address())); } } @@ -689,149 +690,6 @@ void NativeMovRegMem::test() { // End code for unit testing implementation of NativeMovRegMem class -//-------------------------------------------------------------------------------- - - -void NativeMovRegMemPatching::copy_instruction_to(address new_instruction_address) { - Untested("copy_instruction_to"); - int instruction_size = next_instruction_address() - instruction_address(); - for (int i = 0; i < instruction_size; i += wordSize) { - *(long*)(new_instruction_address + i) = *(long*)(address(this) + i); - } -} - - -void NativeMovRegMemPatching::verify() { - NativeInstruction::verify(); - // make sure code pattern is actually a "ld" or "st" of some sort. - int i0 = long_at(0); - int op3 = inv_op3(i0); - - assert((int)nop_offset == (int)NativeMovConstReg::add_offset, "sethi size ok"); - - if (!(is_op(i0, Assembler::ldst_op) && - inv_immed(i0) && - 0 != (op3 < op3_ldst_int_limit - ? (1 << op3 ) & (op3_mask_ld | op3_mask_st) - : (1 << (op3 - op3_ldst_int_limit)) & (op3_mask_ldf | op3_mask_stf)))) { - int i1 = long_at(ldst_offset); - Register rd = inv_rd(i0); - - op3 = inv_op3(i1); - if (!is_op(i1, Assembler::ldst_op) && rd == inv_rs2(i1) && - 0 != (op3 < op3_ldst_int_limit - ? (1 << op3 ) & (op3_mask_ld | op3_mask_st) - : (1 << (op3 - op3_ldst_int_limit)) & (op3_mask_ldf | op3_mask_stf))) { - fatal("not a ld* or st* op"); - } - } -} - - -void NativeMovRegMemPatching::print() { - if (is_immediate()) { - tty->print_cr(INTPTR_FORMAT ": mov reg, [reg + %x]", instruction_address(), offset()); - } else { - tty->print_cr(INTPTR_FORMAT ": mov reg, [reg + reg]", instruction_address()); - } -} - - -// Code for unit testing implementation of NativeMovRegMemPatching class -void NativeMovRegMemPatching::test() { -#ifdef ASSERT - ResourceMark rm; - CodeBuffer cb("test", 1000, 1000); - MacroAssembler* a = new MacroAssembler(&cb); - NativeMovRegMemPatching* nm; - uint idx = 0; - uint idx1; - int offsets[] = { - 0x0, - 0xffffffff, - 0x7fffffff, - 0x80000000, - 4096, - 4097, - 0x20, - 0x4000, - }; - - VM_Version::allow_all(); - - AddressLiteral al(0xffffffff, relocInfo::external_word_type); - a->ldsw( G5, al.low10(), G4); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->ldsw( G5, I3, G4 ); idx++; - a->ldsb( G5, al.low10(), G4); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->ldsb( G5, I3, G4 ); idx++; - a->ldsh( G5, al.low10(), G4); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->ldsh( G5, I3, G4 ); idx++; - a->lduw( G5, al.low10(), G4); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->lduw( G5, I3, G4 ); idx++; - a->ldub( G5, al.low10(), G4); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->ldub( G5, I3, G4 ); idx++; - a->lduh( G5, al.low10(), G4); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->lduh( G5, I3, G4 ); idx++; - a->ldx( G5, al.low10(), G4); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->ldx( G5, I3, G4 ); idx++; - a->ldd( G5, al.low10(), G4); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->ldd( G5, I3, G4 ); idx++; - a->ldf( FloatRegisterImpl::D, O2, -1, F14 ); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->ldf( FloatRegisterImpl::S, O0, I3, F15 ); idx++; - - a->stw( G5, G4, al.low10()); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->stw( G5, G4, I3 ); idx++; - a->stb( G5, G4, al.low10()); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->stb( G5, G4, I3 ); idx++; - a->sth( G5, G4, al.low10()); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->sth( G5, G4, I3 ); idx++; - a->stx( G5, G4, al.low10()); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->stx( G5, G4, I3 ); idx++; - a->std( G5, G4, al.low10()); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->std( G5, G4, I3 ); idx++; - a->stf( FloatRegisterImpl::S, F18, O2, -1 ); idx++; - a->sethi(al, I3); a->nop(); a->add(I3, al.low10(), I3); - a->stf( FloatRegisterImpl::S, F15, O0, I3 ); idx++; - - nm = nativeMovRegMemPatching_at( cb.insts_begin() ); - nm->print(); - nm->set_offset( low10(0) ); - nm->print(); - nm->add_offset_in_bytes( low10(0xbb) * wordSize ); - nm->print(); - - while (--idx) { - nm = nativeMovRegMemPatching_at( nm->next_instruction_address() ); - nm->print(); - for (idx1 = 0; idx1 < ARRAY_SIZE(offsets); idx1++) { - nm->set_offset( nm->is_immediate() ? low10(offsets[idx1]) : offsets[idx1] ); - assert(nm->offset() == (nm->is_immediate() ? low10(offsets[idx1]) : offsets[idx1]), - "check unit test"); - nm->print(); - } - nm->add_offset_in_bytes( low10(0xbb) * wordSize ); - nm->print(); - } - - VM_Version::revert(); -#endif // ASSERT -} -// End code for unit testing implementation of NativeMovRegMemPatching class - //-------------------------------------------------------------------------------- @@ -863,7 +721,7 @@ void NativeJump::verify() { void NativeJump::print() { - tty->print_cr(INTPTR_FORMAT ": jmpl reg, " INTPTR_FORMAT, instruction_address(), jump_destination()); + tty->print_cr(INTPTR_FORMAT ": jmpl reg, " INTPTR_FORMAT, p2i(instruction_address()), p2i(jump_destination())); } diff --git a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp index 29273e7fe61..698b448de9a 100644 --- a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp @@ -38,7 +38,6 @@ // - - NativeMovConstReg // - - NativeMovConstRegPatching // - - NativeMovRegMem -// - - NativeMovRegMemPatching // - - NativeJump // - - NativeGeneralJump // - - NativeIllegalInstruction @@ -710,96 +709,6 @@ class NativeMovRegMem: public NativeInstruction { }; -// An interface for accessing/manipulating native memory ops -// ld* [reg + offset], reg -// st* reg, [reg + offset] -// sethi %hi(imm), reg; nop; add reg, %lo(imm), reg; ld* [reg1 + reg], reg2 -// sethi %hi(imm), reg; nop; add reg, %lo(imm), reg; st* reg2, [reg1 + reg] -// Ops covered: {lds,ldu,st}{w,b,h}, {ld,st}{d,x} -// -// Note that it is identical to NativeMovRegMem with the exception of a nop between the -// sethi and the add. The nop is required to be in the delay slot of the call instruction -// which overwrites the sethi during patching. -class NativeMovRegMemPatching; -inline NativeMovRegMemPatching* nativeMovRegMemPatching_at (address address); -class NativeMovRegMemPatching: public NativeInstruction { - public: - enum Sparc_specific_constants { - op3_mask_ld = 1 << Assembler::lduw_op3 | - 1 << Assembler::ldub_op3 | - 1 << Assembler::lduh_op3 | - 1 << Assembler::ldd_op3 | - 1 << Assembler::ldsw_op3 | - 1 << Assembler::ldsb_op3 | - 1 << Assembler::ldsh_op3 | - 1 << Assembler::ldx_op3, - op3_mask_st = 1 << Assembler::stw_op3 | - 1 << Assembler::stb_op3 | - 1 << Assembler::sth_op3 | - 1 << Assembler::std_op3 | - 1 << Assembler::stx_op3, - op3_ldst_int_limit = Assembler::ldf_op3, - op3_mask_ldf = 1 << (Assembler::ldf_op3 - op3_ldst_int_limit) | - 1 << (Assembler::lddf_op3 - op3_ldst_int_limit), - op3_mask_stf = 1 << (Assembler::stf_op3 - op3_ldst_int_limit) | - 1 << (Assembler::stdf_op3 - op3_ldst_int_limit), - - offset_width = 13, - sethi_offset = 0, -#ifdef _LP64 - nop_offset = 7 * BytesPerInstWord, -#else - nop_offset = 4, -#endif - add_offset = nop_offset + BytesPerInstWord, - ldst_offset = add_offset + BytesPerInstWord - }; - bool is_immediate() const { - // check if instruction is ld* [reg + offset], reg or st* reg, [reg + offset] - int i0 = long_at(0); - return (is_op(i0, Assembler::ldst_op)); - } - - address instruction_address() const { return addr_at(0); } - address next_instruction_address() const { - return addr_at(is_immediate()? 4 : 16); - } - int offset() const { - return is_immediate()? inv_simm(long_at(0), offset_width) : - nativeMovConstRegPatching_at(addr_at(0))->data(); - } - void set_offset(int x) { - if (is_immediate()) { - guarantee(fits_in_simm(x, offset_width), "data block offset overflow"); - set_long_at(0, set_simm(long_at(0), x, offset_width)); - } - else - nativeMovConstRegPatching_at(addr_at(0))->set_data(x); - } - - void add_offset_in_bytes(intptr_t radd_offset) { - set_offset (offset() + radd_offset); - } - - void copy_instruction_to(address new_instruction_address); - - void verify(); - void print (); - - // unit test stuff - static void test(); - - private: - friend inline NativeMovRegMemPatching* nativeMovRegMemPatching_at (address address) { - NativeMovRegMemPatching* test = (NativeMovRegMemPatching*)address; - #ifdef ASSERT - test->verify(); - #endif - return test; - } -}; - - // An interface for accessing/manipulating native jumps // jump_to addr // == sethi %hi22(addr), temp ; jumpl reg, %lo10(addr), G0 ; diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index 23026eaabb1..ca1d7137db5 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -1206,10 +1206,10 @@ void MachPrologNode::format( PhaseRegAlloc *ra_, outputStream *st ) const { } if (Assembler::is_simm13(-framesize)) { - st->print ("SAVE R_SP,-%d,R_SP",framesize); + st->print ("SAVE R_SP,-" SIZE_FORMAT ",R_SP",framesize); } else { - st->print_cr("SETHI R_SP,hi%%(-%d),R_G3",framesize); st->print("\t"); - st->print_cr("ADD R_G3,lo%%(-%d),R_G3",framesize); st->print("\t"); + st->print_cr("SETHI R_SP,hi%%(-" SIZE_FORMAT "),R_G3",framesize); st->print("\t"); + st->print_cr("ADD R_G3,lo%%(-" SIZE_FORMAT "),R_G3",framesize); st->print("\t"); st->print ("SAVE R_SP,R_G3,R_SP"); } diff --git a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp index 231d1f7d932..e4cc113c2e2 100644 --- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp @@ -4575,6 +4575,219 @@ class StubGenerator: public StubCodeGenerator { return start; } + address generate_sha1_implCompress(bool multi_block, const char *name) { + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", name); + address start = __ pc(); + + Label L_sha1_loop, L_sha1_unaligned_input, L_sha1_unaligned_input_loop; + int i; + + Register buf = O0; // byte[] source+offset + Register state = O1; // int[] SHA.state + Register ofs = O2; // int offset + Register limit = O3; // int limit + + // load state into F0-F4 + for (i = 0; i < 5; i++) { + __ ldf(FloatRegisterImpl::S, state, i*4, as_FloatRegister(i)); + } + + __ andcc(buf, 7, G0); + __ br(Assembler::notZero, false, Assembler::pn, L_sha1_unaligned_input); + __ delayed()->nop(); + + __ BIND(L_sha1_loop); + // load buf into F8-F22 + for (i = 0; i < 8; i++) { + __ ldf(FloatRegisterImpl::D, buf, i*8, as_FloatRegister(i*2 + 8)); + } + __ sha1(); + if (multi_block) { + __ add(ofs, 64, ofs); + __ add(buf, 64, buf); + __ cmp_and_brx_short(ofs, limit, Assembler::lessEqual, Assembler::pt, L_sha1_loop); + __ mov(ofs, O0); // to be returned + } + + // store F0-F4 into state and return + for (i = 0; i < 4; i++) { + __ stf(FloatRegisterImpl::S, as_FloatRegister(i), state, i*4); + } + __ retl(); + __ delayed()->stf(FloatRegisterImpl::S, F4, state, 0x10); + + __ BIND(L_sha1_unaligned_input); + __ alignaddr(buf, G0, buf); + + __ BIND(L_sha1_unaligned_input_loop); + // load buf into F8-F22 + for (i = 0; i < 9; i++) { + __ ldf(FloatRegisterImpl::D, buf, i*8, as_FloatRegister(i*2 + 8)); + } + for (i = 0; i < 8; i++) { + __ faligndata(as_FloatRegister(i*2 + 8), as_FloatRegister(i*2 + 10), as_FloatRegister(i*2 + 8)); + } + __ sha1(); + if (multi_block) { + __ add(ofs, 64, ofs); + __ add(buf, 64, buf); + __ cmp_and_brx_short(ofs, limit, Assembler::lessEqual, Assembler::pt, L_sha1_unaligned_input_loop); + __ mov(ofs, O0); // to be returned + } + + // store F0-F4 into state and return + for (i = 0; i < 4; i++) { + __ stf(FloatRegisterImpl::S, as_FloatRegister(i), state, i*4); + } + __ retl(); + __ delayed()->stf(FloatRegisterImpl::S, F4, state, 0x10); + + return start; + } + + address generate_sha256_implCompress(bool multi_block, const char *name) { + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", name); + address start = __ pc(); + + Label L_sha256_loop, L_sha256_unaligned_input, L_sha256_unaligned_input_loop; + int i; + + Register buf = O0; // byte[] source+offset + Register state = O1; // int[] SHA2.state + Register ofs = O2; // int offset + Register limit = O3; // int limit + + // load state into F0-F7 + for (i = 0; i < 8; i++) { + __ ldf(FloatRegisterImpl::S, state, i*4, as_FloatRegister(i)); + } + + __ andcc(buf, 7, G0); + __ br(Assembler::notZero, false, Assembler::pn, L_sha256_unaligned_input); + __ delayed()->nop(); + + __ BIND(L_sha256_loop); + // load buf into F8-F22 + for (i = 0; i < 8; i++) { + __ ldf(FloatRegisterImpl::D, buf, i*8, as_FloatRegister(i*2 + 8)); + } + __ sha256(); + if (multi_block) { + __ add(ofs, 64, ofs); + __ add(buf, 64, buf); + __ cmp_and_brx_short(ofs, limit, Assembler::lessEqual, Assembler::pt, L_sha256_loop); + __ mov(ofs, O0); // to be returned + } + + // store F0-F7 into state and return + for (i = 0; i < 7; i++) { + __ stf(FloatRegisterImpl::S, as_FloatRegister(i), state, i*4); + } + __ retl(); + __ delayed()->stf(FloatRegisterImpl::S, F7, state, 0x1c); + + __ BIND(L_sha256_unaligned_input); + __ alignaddr(buf, G0, buf); + + __ BIND(L_sha256_unaligned_input_loop); + // load buf into F8-F22 + for (i = 0; i < 9; i++) { + __ ldf(FloatRegisterImpl::D, buf, i*8, as_FloatRegister(i*2 + 8)); + } + for (i = 0; i < 8; i++) { + __ faligndata(as_FloatRegister(i*2 + 8), as_FloatRegister(i*2 + 10), as_FloatRegister(i*2 + 8)); + } + __ sha256(); + if (multi_block) { + __ add(ofs, 64, ofs); + __ add(buf, 64, buf); + __ cmp_and_brx_short(ofs, limit, Assembler::lessEqual, Assembler::pt, L_sha256_unaligned_input_loop); + __ mov(ofs, O0); // to be returned + } + + // store F0-F7 into state and return + for (i = 0; i < 7; i++) { + __ stf(FloatRegisterImpl::S, as_FloatRegister(i), state, i*4); + } + __ retl(); + __ delayed()->stf(FloatRegisterImpl::S, F7, state, 0x1c); + + return start; + } + + address generate_sha512_implCompress(bool multi_block, const char *name) { + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", name); + address start = __ pc(); + + Label L_sha512_loop, L_sha512_unaligned_input, L_sha512_unaligned_input_loop; + int i; + + Register buf = O0; // byte[] source+offset + Register state = O1; // long[] SHA5.state + Register ofs = O2; // int offset + Register limit = O3; // int limit + + // load state into F0-F14 + for (i = 0; i < 8; i++) { + __ ldf(FloatRegisterImpl::D, state, i*8, as_FloatRegister(i*2)); + } + + __ andcc(buf, 7, G0); + __ br(Assembler::notZero, false, Assembler::pn, L_sha512_unaligned_input); + __ delayed()->nop(); + + __ BIND(L_sha512_loop); + // load buf into F16-F46 + for (i = 0; i < 16; i++) { + __ ldf(FloatRegisterImpl::D, buf, i*8, as_FloatRegister(i*2 + 16)); + } + __ sha512(); + if (multi_block) { + __ add(ofs, 128, ofs); + __ add(buf, 128, buf); + __ cmp_and_brx_short(ofs, limit, Assembler::lessEqual, Assembler::pt, L_sha512_loop); + __ mov(ofs, O0); // to be returned + } + + // store F0-F14 into state and return + for (i = 0; i < 7; i++) { + __ stf(FloatRegisterImpl::D, as_FloatRegister(i*2), state, i*8); + } + __ retl(); + __ delayed()->stf(FloatRegisterImpl::D, F14, state, 0x38); + + __ BIND(L_sha512_unaligned_input); + __ alignaddr(buf, G0, buf); + + __ BIND(L_sha512_unaligned_input_loop); + // load buf into F16-F46 + for (i = 0; i < 17; i++) { + __ ldf(FloatRegisterImpl::D, buf, i*8, as_FloatRegister(i*2 + 16)); + } + for (i = 0; i < 16; i++) { + __ faligndata(as_FloatRegister(i*2 + 16), as_FloatRegister(i*2 + 18), as_FloatRegister(i*2 + 16)); + } + __ sha512(); + if (multi_block) { + __ add(ofs, 128, ofs); + __ add(buf, 128, buf); + __ cmp_and_brx_short(ofs, limit, Assembler::lessEqual, Assembler::pt, L_sha512_unaligned_input_loop); + __ mov(ofs, O0); // to be returned + } + + // store F0-F14 into state and return + for (i = 0; i < 7; i++) { + __ stf(FloatRegisterImpl::D, as_FloatRegister(i*2), state, i*8); + } + __ retl(); + __ delayed()->stf(FloatRegisterImpl::D, F14, state, 0x38); + + return start; + } + void generate_initial() { // Generates all stubs and initializes the entry points @@ -4647,6 +4860,20 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt(); StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt_Parallel(); } + + // generate SHA1/SHA256/SHA512 intrinsics code + if (UseSHA1Intrinsics) { + StubRoutines::_sha1_implCompress = generate_sha1_implCompress(false, "sha1_implCompress"); + StubRoutines::_sha1_implCompressMB = generate_sha1_implCompress(true, "sha1_implCompressMB"); + } + if (UseSHA256Intrinsics) { + StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress"); + StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB"); + } + if (UseSHA512Intrinsics) { + StubRoutines::_sha512_implCompress = generate_sha512_implCompress(false, "sha512_implCompress"); + StubRoutines::_sha512_implCompressMB = generate_sha512_implCompress(true, "sha512_implCompressMB"); + } } diff --git a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp index 880a0261996..f3b30e884c3 100644 --- a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp @@ -41,7 +41,7 @@ static bool returns_to_call_stub(address return_pc) { enum /* platform_dependent_constants */ { // %%%%%%%% May be able to shrink this a lot code_size1 = 20000, // simply increase if too small (assembler will crash if too small) - code_size2 = 22000 // simply increase if too small (assembler will crash if too small) + code_size2 = 23000 // simply increase if too small (assembler will crash if too small) }; class Sparc { diff --git a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp index 3c173f4d70f..c281e3bc005 100644 --- a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp @@ -1722,15 +1722,15 @@ void AbstractInterpreter::layout_activation(Method* method, if (caller->is_interpreted_frame()) { tty->print("interpreted "); } - tty->print_cr("caller fp=0x%x sp=0x%x", caller->fp(), caller->sp()); - tty->print_cr("save area = 0x%x, 0x%x", caller->sp(), caller->sp() + 16); - tty->print_cr("save area = 0x%x, 0x%x", caller->fp(), caller->fp() + 16); - tty->print_cr("interpreter fp=0x%x sp=0x%x", interpreter_frame->fp(), interpreter_frame->sp()); - tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->sp(), interpreter_frame->sp() + 16); - tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->fp(), interpreter_frame->fp() + 16); - tty->print_cr("Llocals = 0x%x", locals); - tty->print_cr("Lesp = 0x%x", esp); - tty->print_cr("Lmonitors = 0x%x", monitors); + tty->print_cr("caller fp=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, p2i(caller->fp()), p2i(caller->sp())); + tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(caller->sp()), p2i(caller->sp() + 16)); + tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(caller->fp()), p2i(caller->fp() + 16)); + tty->print_cr("interpreter fp=" INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(interpreter_frame->fp()), p2i(interpreter_frame->sp())); + tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(interpreter_frame->sp()), p2i(interpreter_frame->sp() + 16)); + tty->print_cr("save area = " INTPTR_FORMAT ", " INTPTR_FORMAT, p2i(interpreter_frame->fp()), p2i(interpreter_frame->fp() + 16)); + tty->print_cr("Llocals = " INTPTR_FORMAT, p2i(locals)); + tty->print_cr("Lesp = " INTPTR_FORMAT, p2i(esp)); + tty->print_cr("Lmonitors = " INTPTR_FORMAT, p2i(monitors)); } if (method->max_locals() > 0) { diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp index 1943705a558..841068b6072 100644 --- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp @@ -234,7 +234,7 @@ void VM_Version::initialize() { assert((OptoLoopAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size"); char buf[512]; - jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", (has_v9() ? ", v9" : (has_v8() ? ", v8" : "")), (has_hardware_popc() ? ", popc" : ""), (has_vis1() ? ", vis1" : ""), @@ -243,6 +243,9 @@ void VM_Version::initialize() { (has_blk_init() ? ", blk_init" : ""), (has_cbcond() ? ", cbcond" : ""), (has_aes() ? ", aes" : ""), + (has_sha1() ? ", sha1" : ""), + (has_sha256() ? ", sha256" : ""), + (has_sha512() ? ", sha512" : ""), (is_ultra3() ? ", ultra3" : ""), (is_sun4v() ? ", sun4v" : ""), (is_niagara_plus() ? ", niagara_plus" : (is_niagara() ? ", niagara" : "")), @@ -301,6 +304,58 @@ void VM_Version::initialize() { } } + // SHA1, SHA256, and SHA512 instructions were added to SPARC T-series at different times + if (has_sha1() || has_sha256() || has_sha512()) { + if (UseVIS > 0) { // SHA intrinsics use VIS1 instructions + if (FLAG_IS_DEFAULT(UseSHA)) { + FLAG_SET_DEFAULT(UseSHA, true); + } + } else { + if (UseSHA) { + warning("SPARC SHA intrinsics require VIS1 instruction support. Intrinsics will be disabled."); + FLAG_SET_DEFAULT(UseSHA, false); + } + } + } else if (UseSHA) { + warning("SHA instructions are not available on this CPU"); + FLAG_SET_DEFAULT(UseSHA, false); + } + + if (!UseSHA) { + FLAG_SET_DEFAULT(UseSHA1Intrinsics, false); + FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); + FLAG_SET_DEFAULT(UseSHA512Intrinsics, false); + } else { + if (has_sha1()) { + if (FLAG_IS_DEFAULT(UseSHA1Intrinsics)) { + FLAG_SET_DEFAULT(UseSHA1Intrinsics, true); + } + } else if (UseSHA1Intrinsics) { + warning("SHA1 instruction is not available on this CPU."); + FLAG_SET_DEFAULT(UseSHA1Intrinsics, false); + } + if (has_sha256()) { + if (FLAG_IS_DEFAULT(UseSHA256Intrinsics)) { + FLAG_SET_DEFAULT(UseSHA256Intrinsics, true); + } + } else if (UseSHA256Intrinsics) { + warning("SHA256 instruction (for SHA-224 and SHA-256) is not available on this CPU."); + FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); + } + + if (has_sha512()) { + if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) { + FLAG_SET_DEFAULT(UseSHA512Intrinsics, true); + } + } else if (UseSHA512Intrinsics) { + warning("SHA512 instruction (for SHA-384 and SHA-512) is not available on this CPU."); + FLAG_SET_DEFAULT(UseSHA512Intrinsics, false); + } + if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) { + FLAG_SET_DEFAULT(UseSHA, false); + } + } + if (FLAG_IS_DEFAULT(ContendedPaddingWidth) && (cache_line_size > ContendedPaddingWidth)) ContendedPaddingWidth = cache_line_size; diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp index eafb4856280..b20f8a69992 100644 --- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,10 @@ protected: T_family = 16, T1_model = 17, sparc5_instructions = 18, - aes_instructions = 19 + aes_instructions = 19, + sha1_instruction = 20, + sha256_instruction = 21, + sha512_instruction = 22 }; enum Feature_Flag_Set { @@ -77,6 +80,9 @@ protected: T1_model_m = 1 << T1_model, sparc5_instructions_m = 1 << sparc5_instructions, aes_instructions_m = 1 << aes_instructions, + sha1_instruction_m = 1 << sha1_instruction, + sha256_instruction_m = 1 << sha256_instruction, + sha512_instruction_m = 1 << sha512_instruction, generic_v8_m = v8_instructions_m | hardware_mul32_m | hardware_div32_m | hardware_fsmuld_m, generic_v9_m = generic_v8_m | v9_instructions_m, @@ -129,6 +135,9 @@ public: static bool has_cbcond() { return (_features & cbcond_instructions_m) != 0; } static bool has_sparc5_instr() { return (_features & sparc5_instructions_m) != 0; } static bool has_aes() { return (_features & aes_instructions_m) != 0; } + static bool has_sha1() { return (_features & sha1_instruction_m) != 0; } + static bool has_sha256() { return (_features & sha256_instruction_m) != 0; } + static bool has_sha512() { return (_features & sha512_instruction_m) != 0; } static bool supports_compare_and_exchange() { return has_v9(); } diff --git a/hotspot/src/cpu/sparc/vm/vtableStubs_sparc.cpp b/hotspot/src/cpu/sparc/vm/vtableStubs_sparc.cpp index cdbb57fbecd..6c0755bab32 100644 --- a/hotspot/src/cpu/sparc/vm/vtableStubs_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/vtableStubs_sparc.cpp @@ -111,7 +111,7 @@ VtableStub* VtableStubs::create_vtable_stub(int vtable_index) { if (PrintMiscellaneous && (WizardMode || Verbose)) { tty->print_cr("vtable #%d at "PTR_FORMAT"[%d] left over: %d", - vtable_index, s->entry_point(), + vtable_index, p2i(s->entry_point()), (int)(s->code_end() - s->entry_point()), (int)(s->code_end() - __ pc())); } @@ -206,7 +206,7 @@ VtableStub* VtableStubs::create_itable_stub(int itable_index) { if (PrintMiscellaneous && (WizardMode || Verbose)) { tty->print_cr("itable #%d at "PTR_FORMAT"[%d] left over: %d", - itable_index, s->entry_point(), + itable_index, p2i(s->entry_point()), (int)(s->code_end() - s->entry_point()), (int)(s->code_end() - __ pc())); } diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp index b4e8223e1f5..1ee690ea442 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @@ -1085,14 +1085,11 @@ void LIRGenerator::do_Convert(Convert* x) { void LIRGenerator::do_NewInstance(NewInstance* x) { -#ifndef PRODUCT - if (PrintNotLoaded && !x->klass()->is_loaded()) { - tty->print_cr(" ###class not loaded at new bci %d", x->printable_bci()); - } -#endif + print_if_not_loaded(x); + CodeEmitInfo* info = state_for(x, x->state()); LIR_Opr reg = result_register_for(x->type()); - new_instance(reg, x->klass(), + new_instance(reg, x->klass(), x->is_unresolved(), FrameMap::rcx_oop_opr, FrameMap::rdi_oop_opr, FrameMap::rsi_oop_opr, diff --git a/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp b/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp index 470e971fe48..4a4de7116bd 100644 --- a/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp +++ b/hotspot/src/cpu/x86/vm/nativeInst_x86.hpp @@ -327,18 +327,6 @@ inline NativeMovRegMem* nativeMovRegMem_at (address address) { return test; } -class NativeMovRegMemPatching: public NativeMovRegMem { - private: - friend NativeMovRegMemPatching* nativeMovRegMemPatching_at (address address) { - NativeMovRegMemPatching* test = (NativeMovRegMemPatching*)(address - instruction_offset); - #ifdef ASSERT - test->verify(); - #endif - return test; - } -}; - - // An interface for accessing/manipulating native leal instruction of form: // leal reg, [reg + offset] diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp index e09dba38b0d..4dd8f8cb935 100644 --- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp +++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp @@ -590,6 +590,17 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(UseAESIntrinsics, false); } + if (UseSHA) { + warning("SHA instructions are not available on this CPU"); + FLAG_SET_DEFAULT(UseSHA, false); + } + if (UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics) { + warning("SHA intrinsics are not available on this CPU"); + FLAG_SET_DEFAULT(UseSHA1Intrinsics, false); + FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); + FLAG_SET_DEFAULT(UseSHA512Intrinsics, false); + } + // Adjust RTM (Restricted Transactional Memory) flags if (!supports_rtm() && UseRTMLocking) { // Can't continue because UseRTMLocking affects UseBiasedLocking flag diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index 63a7a066304..c246f2d2deb 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -1401,22 +1401,22 @@ void Matcher::pd_implicit_null_fixup(MachNode *node, uint idx) { // No transformation necessary. return; case INDIRECT: - new_memory = new (C) indirect_win95_safeOper( ); + new_memory = new indirect_win95_safeOper( ); break; case INDOFFSET8: - new_memory = new (C) indOffset8_win95_safeOper(memory->disp(NULL, NULL, 0)); + new_memory = new indOffset8_win95_safeOper(memory->disp(NULL, NULL, 0)); break; case INDOFFSET32: - new_memory = new (C) indOffset32_win95_safeOper(memory->disp(NULL, NULL, 0)); + new_memory = new indOffset32_win95_safeOper(memory->disp(NULL, NULL, 0)); break; case INDINDEXOFFSET: - new_memory = new (C) indIndexOffset_win95_safeOper(memory->disp(NULL, NULL, 0)); + new_memory = new indIndexOffset_win95_safeOper(memory->disp(NULL, NULL, 0)); break; case INDINDEXSCALE: - new_memory = new (C) indIndexScale_win95_safeOper(memory->scale()); + new_memory = new indIndexScale_win95_safeOper(memory->scale()); break; case INDINDEXSCALEOFFSET: - new_memory = new (C) indIndexScaleOffset_win95_safeOper(memory->scale(), memory->disp(NULL, NULL, 0)); + new_memory = new indIndexScaleOffset_win95_safeOper(memory->scale(), memory->disp(NULL, NULL, 0)); break; case LOAD_LONG_INDIRECT: case LOAD_LONG_INDOFFSET32: diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index 377ff89eacb..e9d57c580ce 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -4734,10 +4734,8 @@ int os::PlatformEvent::park(jlong millis) { // // Thread.interrupt and object.notify{All} both call Event::set. // That is, we treat thread.interrupt as a special case of notification. - // The underlying Solaris implementation, cond_timedwait, admits - // spurious/premature wakeups, but the JLS/JVM spec prevents the - // JVM from making those visible to Java code. As such, we must - // filter out spurious wakeups. We assume all ETIME returns are valid. + // We ignore spurious OS wakeups unless FilterSpuriousWakeups is false. + // We assume all ETIME returns are valid. // // TODO: properly differentiate simultaneous notify+interrupt. // In that case, we should propagate the notify to another waiter. diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index c8313235d0c..9d817380e3e 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -4299,10 +4299,8 @@ int os::PlatformEvent::park(jlong millis) { // // Thread.interrupt and object.notify{All} both call Event::set. // That is, we treat thread.interrupt as a special case of notification. - // The underlying Solaris implementation, cond_timedwait, admits - // spurious/premature wakeups, but the JLS/JVM spec prevents the - // JVM from making those visible to Java code. As such, we must - // filter out spurious wakeups. We assume all ETIME returns are valid. + // We ignore spurious OS wakeups unless FilterSpuriousWakeups is false. + // We assume all ETIME returns are valid. // // TODO: properly differentiate simultaneous notify+interrupt. // In that case, we should propagate the notify to another waiter. diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 7941edf59ce..89ffc72d972 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -5538,10 +5538,8 @@ int os::PlatformEvent::park(jlong millis) { // // Thread.interrupt and object.notify{All} both call Event::set. // That is, we treat thread.interrupt as a special case of notification. - // The underlying Solaris implementation, cond_timedwait, admits - // spurious/premature wakeups, but the JLS/JVM spec prevents the - // JVM from making those visible to Java code. As such, we must - // filter out spurious wakeups. We assume all ETIME returns are valid. + // We ignore spurious OS wakeups unless FilterSpuriousWakeups is false. + // We assume all ETIME returns are valid. // // TODO: properly differentiate simultaneous notify+interrupt. // In that case, we should propagate the notify to another waiter. diff --git a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp index f8f23122d4d..6e364f4087a 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp @@ -234,7 +234,7 @@ void os::print_context(outputStream *st, void *context) { SIG_REGS(sc).u_regs[CON_G3], SIG_REGS(sc).u_regs[CON_G4]); st->print_cr(" G5=" INTPTR_FORMAT " G6=" INTPTR_FORMAT - " G7=" INTPTR_FORMAT " Y=" INTPTR_FORMAT, + " G7=" INTPTR_FORMAT " Y=0x%x", SIG_REGS(sc).u_regs[CON_G5], SIG_REGS(sc).u_regs[CON_G6], SIG_REGS(sc).u_regs[CON_G7], @@ -285,7 +285,7 @@ void os::print_context(outputStream *st, void *context) { st->cr(); st->cr(); - st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); + st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", p2i(sp)); print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t)); st->cr(); @@ -293,7 +293,7 @@ void os::print_context(outputStream *st, void *context) { // point to garbage if entry point in an nmethod is corrupted. Leave // this at the end, and hope for the best. address pc = os::Linux::ucontext_get_pc(uc); - st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); + st->print_cr("Instructions: (pc=" INTPTR_FORMAT ")", p2i(pc)); print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); } @@ -453,7 +453,7 @@ inline static bool checkVerifyOops(address pc, address fault, address* stub) { && pc < MacroAssembler::_verify_oop_implicit_branch[1] ) { *stub = MacroAssembler::_verify_oop_implicit_branch[2]; warning("fixed up memory fault in +VerifyOops at address " - INTPTR_FORMAT, fault); + INTPTR_FORMAT, p2i(fault)); return true; } return false; diff --git a/hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp index c3d244d987d..70dc8f0e5d8 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/vm_version_linux_sparc.cpp @@ -36,7 +36,7 @@ static bool detect_niagara() { } while (!feof(fp)) { - if (fscanf(fp, "cpu\t\t: %100[^\n]", &cpu) == 1) { + if (fscanf(fp, "cpu\t\t: %100[^\n]", cpu) == 1) { if (strstr(cpu, "Niagara") != NULL) { rv = true; } diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp index b6639c90b14..028e33f37d4 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -137,6 +137,21 @@ int VM_Version::platform_features(int features) { #endif if (av & AV_SPARC_AES) features |= aes_instructions_m; +#ifndef AV_SPARC_SHA1 +#define AV_SPARC_SHA1 0x00400000 /* sha1 instruction supported */ +#endif + if (av & AV_SPARC_SHA1) features |= sha1_instruction_m; + +#ifndef AV_SPARC_SHA256 +#define AV_SPARC_SHA256 0x00800000 /* sha256 instruction supported */ +#endif + if (av & AV_SPARC_SHA256) features |= sha256_instruction_m; + +#ifndef AV_SPARC_SHA512 +#define AV_SPARC_SHA512 0x01000000 /* sha512 instruction supported */ +#endif + if (av & AV_SPARC_SHA512) features |= sha512_instruction_m; + } else { // getisax(2) failed, use the old legacy code. #ifndef PRODUCT diff --git a/hotspot/src/share/vm/adlc/output_c.cpp b/hotspot/src/share/vm/adlc/output_c.cpp index bd2393c578c..6169c8f62b7 100644 --- a/hotspot/src/share/vm/adlc/output_c.cpp +++ b/hotspot/src/share/vm/adlc/output_c.cpp @@ -1000,7 +1000,7 @@ void ArchDesc::build_pipe_classes(FILE *fp_cpp) { fprintf(fp_cpp, "void Bundle::initialize_nops(MachNode * nop_list[%d], Compile *C) {\n", nopcnt); int i = 0; for ( _pipeline->_noplist.reset(); (nop = _pipeline->_noplist.iter()) != NULL; i++ ) { - fprintf(fp_cpp, " nop_list[%d] = (MachNode *) new (C) %sNode();\n", i, nop); + fprintf(fp_cpp, " nop_list[%d] = (MachNode *) new %sNode();\n", i, nop); } fprintf(fp_cpp, "};\n\n"); fprintf(fp_cpp, "#ifndef PRODUCT\n"); @@ -1328,7 +1328,7 @@ static void generate_peepreplace( FILE *fp, FormDict &globals, PeepMatch *pmatch preplace->next_instruction(root_inst); InstructForm *root_form = globals[root_inst]->is_instruction(); assert( root_form != NULL, "Replacement instruction was not previously defined"); - fprintf(fp, " %sNode *root = new (C) %sNode();\n", root_inst, root_inst); + fprintf(fp, " %sNode *root = new %sNode();\n", root_inst, root_inst); int inst_num; const char *op_name; @@ -1497,11 +1497,11 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { new_oper = frm->is_operand(); char *tmp = (char *)node->_exprule->_newopconst[new_id]; if (tmp == NULL) { - fprintf(fp," MachOper *op%d = new (C) %sOper();\n", + fprintf(fp," MachOper *op%d = new %sOper();\n", cnt, new_oper->_ident); } else { - fprintf(fp," MachOper *op%d = new (C) %sOper(%s);\n", + fprintf(fp," MachOper *op%d = new %sOper(%s);\n", cnt, new_oper->_ident, tmp); } } @@ -1566,7 +1566,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { } // Build the node for the instruction - fprintf(fp,"\n %sNode *n%d = new (C) %sNode();\n", new_id, cnt, new_id); + fprintf(fp,"\n %sNode *n%d = new %sNode();\n", new_id, cnt, new_id); // Add control edge for this node fprintf(fp," n%d->add_req(_in[0]);\n", cnt); // Build the operand for the value this node defines. @@ -1729,7 +1729,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { declared_def = true; } if (op && op->_interface && op->_interface->is_RegInterface()) { - fprintf(fp," def = new (C) MachTempNode(state->MachOperGenerator( %s, C ));\n", + fprintf(fp," def = new MachTempNode(state->MachOperGenerator( %s, C ));\n", machOperEnum(op->_ident)); fprintf(fp," add_req(def);\n"); // The operand for TEMP is already constructed during @@ -1760,7 +1760,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { } fprintf(fp," kill = "); - fprintf(fp,"new (C) MachProjNode( %s, %d, (%s), Op_%s );\n", + fprintf(fp,"new MachProjNode( %s, %d, (%s), Op_%s );\n", machNode, proj_no++, regmask, ideal_type); fprintf(fp," proj_list.push(kill);\n"); } @@ -2840,7 +2840,7 @@ static void defineIn_RegMask(FILE *fp, FormDict &globals, OperandForm &oper) { // generate code to create a clone for a class derived from MachOper // // (0) MachOper *MachOperXOper::clone(Compile* C) const { -// (1) return new (C) MachXOper( _ccode, _c0, _c1, ..., _cn); +// (1) return new MachXOper( _ccode, _c0, _c1, ..., _cn); // (2) } // static void defineClone(FILE *fp, FormDict &globalNames, OperandForm &oper) { @@ -2849,7 +2849,7 @@ static void defineClone(FILE *fp, FormDict &globalNames, OperandForm &oper) { const int num_consts = oper.num_consts(globalNames); const bool is_ideal_bool = oper.is_ideal_bool(); if( (num_consts > 0) ) { - fprintf(fp," return new (C) %sOper(", oper._ident); + fprintf(fp," return new %sOper(", oper._ident); // generate parameters for constants int i = 0; fprintf(fp,"_c%d", i); @@ -2861,7 +2861,7 @@ static void defineClone(FILE *fp, FormDict &globalNames, OperandForm &oper) { } else { assert( num_consts == 0, "Currently support zero or one constant per operand clone function"); - fprintf(fp," return new (C) %sOper();\n", oper._ident); + fprintf(fp," return new %sOper();\n", oper._ident); } // finish method fprintf(fp,"}\n"); @@ -3106,7 +3106,7 @@ void ArchDesc::defineClasses(FILE *fp) { defineIn_RegMask(_CPP_MISC_file._fp, _globalNames, *oper); fprintf(fp,"MachOper *%sOper::clone(Compile* C) const {\n", oper->_ident); - fprintf(fp," return new (C) %sOper(_label, _block_num);\n", oper->_ident); + fprintf(fp," return new %sOper(_label, _block_num);\n", oper->_ident); fprintf(fp,"}\n"); fprintf(fp,"uint %sOper::opcode() const { return %s; }\n", @@ -3125,7 +3125,7 @@ void ArchDesc::defineClasses(FILE *fp) { defineIn_RegMask(_CPP_MISC_file._fp, _globalNames, *oper); fprintf(fp,"MachOper *%sOper::clone(Compile* C) const {\n", oper->_ident); - fprintf(fp," return new (C) %sOper(_method);\n", oper->_ident); + fprintf(fp," return new %sOper(_method);\n", oper->_ident); fprintf(fp,"}\n"); fprintf(fp,"uint %sOper::opcode() const { return %s; }\n", @@ -3815,7 +3815,7 @@ static void genMachOperCase(FILE *fp, FormDict &globalNames, ArchDesc &AD, // Generate the case statement for this opcode fprintf(fp, " case %s:", opEnumName); - fprintf(fp, "\n return new (C) %sOper(", opName); + fprintf(fp, "\n return new %sOper(", opName); // Access parameters for constructor from the stat object // // Build access to condition code value @@ -3894,7 +3894,7 @@ void ArchDesc::buildMachNode(FILE *fp_cpp, InstructForm *inst, const char *inden const char *opClass = inst->_ident; // Create the MachNode object - fprintf(fp_cpp, "%s %sNode *node = new (C) %sNode();\n",indent, opClass,opClass); + fprintf(fp_cpp, "%s %sNode *node = new %sNode();\n",indent, opClass,opClass); if ( (inst->num_post_match_opnds() != 0) ) { // Instruction that contains operands which are not in match rule. @@ -3936,7 +3936,7 @@ void ArchDesc::buildMachNode(FILE *fp_cpp, InstructForm *inst, const char *inden // Check for multiple constants and then fill them in. // Just like MachOperGenerator const char *opName = inst->_matrule->_rChild->_opType; - fprintf(fp_cpp, "new (C) %sOper(", opName); + fprintf(fp_cpp, "new %sOper(", opName); // Grab operand form OperandForm *op = (_globalNames[opName])->is_operand(); // Look up the number of constants @@ -4010,7 +4010,7 @@ bool InstructForm::define_cisc_version(ArchDesc &AD, FILE *fp_cpp) { fprintf(fp_cpp, "// Build CISC version of this instruction\n"); fprintf(fp_cpp, "MachNode *%sNode::cisc_version( int offset, Compile* C ) {\n", this->_ident); // Create the MachNode object - fprintf(fp_cpp, " %sNode *node = new (C) %sNode();\n", name, name); + fprintf(fp_cpp, " %sNode *node = new %sNode();\n", name, name); // Fill in the bottom_type where requested if ( this->captures_bottom_type(AD.globalNames()) ) { fprintf(fp_cpp, " node->_bottom_type = bottom_type();\n"); @@ -4026,7 +4026,7 @@ bool InstructForm::define_cisc_version(ArchDesc &AD, FILE *fp_cpp) { fprintf(fp_cpp, " fill_new_machnode(node, C);\n"); // Construct operand to access [stack_pointer + offset] fprintf(fp_cpp, " // Construct operand to access [stack_pointer + offset]\n"); - fprintf(fp_cpp, " node->set_opnd_array(cisc_operand(), new (C) %sOper(offset));\n", cisc_oper_name); + fprintf(fp_cpp, " node->set_opnd_array(cisc_operand(), new %sOper(offset));\n", cisc_oper_name); fprintf(fp_cpp, "\n"); // Return result and exit scope @@ -4057,7 +4057,7 @@ bool InstructForm::define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp) { fprintf(fp_cpp, "// Build short branch version of this instruction\n"); fprintf(fp_cpp, "MachNode *%sNode::short_branch_version(Compile* C) {\n", this->_ident); // Create the MachNode object - fprintf(fp_cpp, " %sNode *node = new (C) %sNode();\n", name, name); + fprintf(fp_cpp, " %sNode *node = new %sNode();\n", name, name); if( is_ideal_if() ) { fprintf(fp_cpp, " node->_prob = _prob;\n"); fprintf(fp_cpp, " node->_fcnt = _fcnt;\n"); diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index ac62197debe..cada65e1a94 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -2054,7 +2054,7 @@ void GraphBuilder::new_instance(int klass_index) { bool will_link; ciKlass* klass = stream()->get_klass(will_link); assert(klass->is_instance_klass(), "must be an instance klass"); - NewInstance* new_instance = new NewInstance(klass->as_instance_klass(), state_before); + NewInstance* new_instance = new NewInstance(klass->as_instance_klass(), state_before, stream()->is_unresolved_klass()); _memory->new_instance(new_instance); apush(append_split(new_instance)); } diff --git a/hotspot/src/share/vm/c1/c1_Instruction.hpp b/hotspot/src/share/vm/c1/c1_Instruction.hpp index 19490bbc97b..3121088c9e6 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.hpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp @@ -1291,16 +1291,18 @@ LEAF(Invoke, StateSplit) LEAF(NewInstance, StateSplit) private: ciInstanceKlass* _klass; + bool _is_unresolved; public: // creation - NewInstance(ciInstanceKlass* klass, ValueStack* state_before) + NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved) : StateSplit(instanceType, state_before) - , _klass(klass) + , _klass(klass), _is_unresolved(is_unresolved) {} // accessors ciInstanceKlass* klass() const { return _klass; } + bool is_unresolved() const { return _is_unresolved; } virtual bool needs_exception_state() const { return false; } diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp index ef2b10623a4..5697e9046aa 100644 --- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp @@ -336,7 +336,6 @@ void LIR_Assembler::check_no_unbound_labels() { void LIR_Assembler::add_debug_info_for_branch(CodeEmitInfo* info) { - _masm->code_section()->relocate(pc(), relocInfo::poll_type); int pc_offset = code_offset(); flush_debug_info(pc_offset); info->record_debug_info(compilation()->debug_info_recorder(), pc_offset); diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index 4e4caaa26cb..bf0b6f2f1ea 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -466,8 +466,11 @@ CodeEmitInfo* LIRGenerator::state_for(Instruction* x) { } -void LIRGenerator::klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info) { - if (!obj->is_loaded() || PatchALot) { +void LIRGenerator::klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info, bool need_resolve) { + /* C2 relies on constant pool entries being resolved (ciTypeFlow), so if TieredCompilation + * is active and the class hasn't yet been resolved we need to emit a patch that resolves + * the class. */ + if ((TieredCompilation && need_resolve) || !obj->is_loaded() || PatchALot) { assert(info != NULL, "info must be set if class is not loaded"); __ klass2reg_patch(NULL, r, info); } else { @@ -660,9 +663,18 @@ void LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, L __ unlock_object(hdr, object, lock, scratch, slow_path); } +#ifndef PRODUCT +void LIRGenerator::print_if_not_loaded(const NewInstance* new_instance) { + if (PrintNotLoaded && !new_instance->klass()->is_loaded()) { + tty->print_cr(" ###class not loaded at new bci %d", new_instance->printable_bci()); + } else if (PrintNotLoaded && (TieredCompilation && new_instance->is_unresolved())) { + tty->print_cr(" ###class not resolved at new bci %d", new_instance->printable_bci()); + } +} +#endif -void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) { - klass2reg_with_patching(klass_reg, klass, info); +void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) { + klass2reg_with_patching(klass_reg, klass, info, is_unresolved); // If klass is not loaded we do not know if the klass has finalizers: if (UseFastNewInstance && klass->is_loaded() && !Klass::layout_helper_needs_slow_path(klass->layout_helper())) { diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp index 13446a9ebe9..ba003e5851f 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp @@ -169,6 +169,8 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { return this; } + void print_if_not_loaded(const NewInstance* new_instance) PRODUCT_RETURN; + #ifdef ASSERT LIR_List* lir(const char * file, int line) const { _lir->set_file_and_line(file, line); @@ -307,7 +309,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes); - void klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info); + void klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info, bool need_resolve = false); // this loads the length and compares against the index void array_range_check (LIR_Opr array, LIR_Opr index, CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info); @@ -325,7 +327,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { void monitor_enter (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info); void monitor_exit (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no); - void new_instance (LIR_Opr dst, ciInstanceKlass* klass, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info); + void new_instance (LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info); // machine dependent void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info); diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp index 1bafb67f69c..3c2e2ecf8fe 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp @@ -123,24 +123,24 @@ int Runtime1::_throw_incompatible_class_change_error_count = 0; int Runtime1::_throw_array_store_exception_count = 0; int Runtime1::_throw_count = 0; -static int _byte_arraycopy_cnt = 0; -static int _short_arraycopy_cnt = 0; -static int _int_arraycopy_cnt = 0; -static int _long_arraycopy_cnt = 0; -static int _oop_arraycopy_cnt = 0; +static int _byte_arraycopy_stub_cnt = 0; +static int _short_arraycopy_stub_cnt = 0; +static int _int_arraycopy_stub_cnt = 0; +static int _long_arraycopy_stub_cnt = 0; +static int _oop_arraycopy_stub_cnt = 0; address Runtime1::arraycopy_count_address(BasicType type) { switch (type) { case T_BOOLEAN: - case T_BYTE: return (address)&_byte_arraycopy_cnt; + case T_BYTE: return (address)&_byte_arraycopy_stub_cnt; case T_CHAR: - case T_SHORT: return (address)&_short_arraycopy_cnt; + case T_SHORT: return (address)&_short_arraycopy_stub_cnt; case T_FLOAT: - case T_INT: return (address)&_int_arraycopy_cnt; + case T_INT: return (address)&_int_arraycopy_stub_cnt; case T_DOUBLE: - case T_LONG: return (address)&_long_arraycopy_cnt; + case T_LONG: return (address)&_long_arraycopy_stub_cnt; case T_ARRAY: - case T_OBJECT: return (address)&_oop_arraycopy_cnt; + case T_OBJECT: return (address)&_oop_arraycopy_stub_cnt; default: ShouldNotReachHere(); return NULL; @@ -1479,13 +1479,13 @@ void Runtime1::print_statistics() { tty->print_cr(" _ic_miss_cnt: %d", SharedRuntime::_ic_miss_ctr); tty->print_cr(" _generic_arraycopy_cnt: %d", _generic_arraycopy_cnt); tty->print_cr(" _generic_arraycopystub_cnt: %d", _generic_arraycopystub_cnt); - tty->print_cr(" _byte_arraycopy_cnt: %d", _byte_arraycopy_cnt); - tty->print_cr(" _short_arraycopy_cnt: %d", _short_arraycopy_cnt); - tty->print_cr(" _int_arraycopy_cnt: %d", _int_arraycopy_cnt); - tty->print_cr(" _long_arraycopy_cnt: %d", _long_arraycopy_cnt); + tty->print_cr(" _byte_arraycopy_cnt: %d", _byte_arraycopy_stub_cnt); + tty->print_cr(" _short_arraycopy_cnt: %d", _short_arraycopy_stub_cnt); + tty->print_cr(" _int_arraycopy_cnt: %d", _int_arraycopy_stub_cnt); + tty->print_cr(" _long_arraycopy_cnt: %d", _long_arraycopy_stub_cnt); tty->print_cr(" _primitive_arraycopy_cnt: %d", _primitive_arraycopy_cnt); tty->print_cr(" _oop_arraycopy_cnt (C): %d", Runtime1::_oop_arraycopy_cnt); - tty->print_cr(" _oop_arraycopy_cnt (stub): %d", _oop_arraycopy_cnt); + tty->print_cr(" _oop_arraycopy_cnt (stub): %d", _oop_arraycopy_stub_cnt); tty->print_cr(" _arraycopy_slowcase_cnt: %d", _arraycopy_slowcase_cnt); tty->print_cr(" _arraycopy_checkcast_cnt: %d", _arraycopy_checkcast_cnt); tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%d", _arraycopy_checkcast_attempt_cnt); diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index 4d3ee6f08dd..e16a45d33ba 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -790,6 +790,26 @@ do_name( decrypt_name, "decrypt") \ do_signature(byteArray_int_int_byteArray_int_signature, "([BII[BI)I") \ \ + /* support for sun.security.provider.SHA */ \ + do_class(sun_security_provider_sha, "sun/security/provider/SHA") \ + do_intrinsic(_sha_implCompress, sun_security_provider_sha, implCompress_name, implCompress_signature, F_R) \ + do_name( implCompress_name, "implCompress") \ + do_signature(implCompress_signature, "([BI)V") \ + \ + /* support for sun.security.provider.SHA2 */ \ + do_class(sun_security_provider_sha2, "sun/security/provider/SHA2") \ + do_intrinsic(_sha2_implCompress, sun_security_provider_sha2, implCompress_name, implCompress_signature, F_R) \ + \ + /* support for sun.security.provider.SHA5 */ \ + do_class(sun_security_provider_sha5, "sun/security/provider/SHA5") \ + do_intrinsic(_sha5_implCompress, sun_security_provider_sha5, implCompress_name, implCompress_signature, F_R) \ + \ + /* support for sun.security.provider.DigestBase */ \ + do_class(sun_security_provider_digestbase, "sun/security/provider/DigestBase") \ + do_intrinsic(_digestBase_implCompressMB, sun_security_provider_digestbase, implCompressMB_name, implCompressMB_signature, F_R) \ + do_name( implCompressMB_name, "implCompressMultiBlock") \ + do_signature(implCompressMB_signature, "([BII)I") \ + \ /* support for java.util.zip */ \ do_class(java_util_zip_CRC32, "java/util/zip/CRC32") \ do_intrinsic(_updateCRC32, java_util_zip_CRC32, update_name, int2_int_signature, F_SN) \ diff --git a/hotspot/src/share/vm/code/relocInfo.cpp b/hotspot/src/share/vm/code/relocInfo.cpp index aa0ef6b106e..174a615deaf 100644 --- a/hotspot/src/share/vm/code/relocInfo.cpp +++ b/hotspot/src/share/vm/code/relocInfo.cpp @@ -877,11 +877,7 @@ address external_word_Relocation::target() { void internal_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { address target = _target; if (target == NULL) { - if (addr_in_const()) { - target = new_addr_for(*(address*)addr(), src, dest); - } else { - target = new_addr_for(pd_get_address_from_code(), src, dest); - } + target = new_addr_for(this->target(), src, dest); } set_value(target); } @@ -890,7 +886,11 @@ void internal_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, address internal_word_Relocation::target() { address target = _target; if (target == NULL) { - target = pd_get_address_from_code(); + if (addr_in_const()) { + target = *(address*)addr(); + } else { + target = pd_get_address_from_code(); + } } return target; } diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp index 44239d9b7e7..3b3814ff9c9 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsAdaptiveSizePolicy.cpp @@ -1341,13 +1341,14 @@ bool CMSAdaptiveSizePolicy::get_and_clear_first_after_collection() { bool CMSAdaptiveSizePolicy::print_adaptive_size_policy_on( outputStream* st) const { - if (!UseAdaptiveSizePolicy) return false; + if (!UseAdaptiveSizePolicy) { + return false; + } GenCollectedHeap* gch = GenCollectedHeap::heap(); - Generation* gen0 = gch->get_gen(0); - DefNewGeneration* def_new = gen0->as_DefNewGeneration(); - return - AdaptiveSizePolicy::print_adaptive_size_policy_on( + Generation* young = gch->get_gen(0); + DefNewGeneration* def_new = young->as_DefNewGeneration(); + return AdaptiveSizePolicy::print_adaptive_size_policy_on( st, def_new->tenuring_threshold()); } diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp index a236a10efb3..19d49f039a3 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/cmsCollectorPolicy.cpp @@ -60,21 +60,21 @@ void ConcurrentMarkSweepPolicy::initialize_generations() { if (UseParNewGC) { if (UseAdaptiveSizePolicy) { _generations[0] = new GenerationSpec(Generation::ASParNew, - _initial_gen0_size, _max_gen0_size); + _initial_young_size, _max_young_size); } else { _generations[0] = new GenerationSpec(Generation::ParNew, - _initial_gen0_size, _max_gen0_size); + _initial_young_size, _max_young_size); } } else { _generations[0] = new GenerationSpec(Generation::DefNew, - _initial_gen0_size, _max_gen0_size); + _initial_young_size, _max_young_size); } if (UseAdaptiveSizePolicy) { _generations[1] = new GenerationSpec(Generation::ASConcurrentMarkSweep, - _initial_gen1_size, _max_gen1_size); + _initial_old_size, _max_old_size); } else { _generations[1] = new GenerationSpec(Generation::ConcurrentMarkSweep, - _initial_gen1_size, _max_gen1_size); + _initial_old_size, _max_old_size); } if (_generations[0] == NULL || _generations[1] == NULL) { diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index dba6f8ca7d7..8cd65e36dca 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -1138,8 +1138,8 @@ static inline size_t percent_of_space(Space* space, HeapWord* addr) void CMSCollector::icms_update_allocation_limits() { - Generation* gen0 = GenCollectedHeap::heap()->get_gen(0); - EdenSpace* eden = gen0->as_DefNewGeneration()->eden(); + Generation* young = GenCollectedHeap::heap()->get_gen(0); + EdenSpace* eden = young->as_DefNewGeneration()->eden(); const unsigned int duty_cycle = stats().icms_update_duty_cycle(); if (CMSTraceIncrementalPacing) { diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp index 6cf2f4270b6..09740b6d57c 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp @@ -1193,10 +1193,9 @@ class ConcurrentMarkSweepGeneration: public CardGeneration { // Does a "full" (forced) collection invoked on this generation collect // all younger generations as well? Note that the second conjunct is a // hack to allow the collection of the younger gen first if the flag is - // set. This is better than using th policy's should_collect_gen0_first() - // since that causes us to do an extra unnecessary pair of restart-&-stop-world. + // set. virtual bool full_collects_younger_generations() const { - return UseCMSCompactAtFullCollection && !CollectGen0First; + return UseCMSCompactAtFullCollection && !ScavengeBeforeFullGC; } void space_iterate(SpaceClosure* blk, bool usedOnly = false); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index 83f819b3919..a1dbb6f1b18 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -3622,7 +3622,7 @@ void G1CollectedHeap::gc_threads_do(ThreadClosure* tc) const { void G1CollectedHeap::print_tracing_info() const { // We'll overload this to mean "trace GC pause statistics." - if (TraceGen0Time || TraceGen1Time) { + if (TraceYoungGenTime || TraceOldGenTime) { // The "G1CollectorPolicy" is keeping track of these stats, so delegate // to that. g1_policy()->print_tracing_info(); diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp index 89b6f3fa616..1c805c634b3 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp @@ -809,7 +809,7 @@ void G1CollectorPolicy::record_full_collection_end() { double full_gc_time_sec = end_sec - _full_collection_start_sec; double full_gc_time_ms = full_gc_time_sec * 1000.0; - _trace_gen1_time_data.record_full_collection(full_gc_time_ms); + _trace_old_gen_time_data.record_full_collection(full_gc_time_ms); update_recent_gc_times(end_sec, full_gc_time_ms); @@ -851,7 +851,7 @@ void G1CollectorPolicy::record_collection_pause_start(double start_time_sec) { _g1->used(), _g1->recalculate_used())); double s_w_t_ms = (start_time_sec - _stop_world_start) * 1000.0; - _trace_gen0_time_data.record_start_collection(s_w_t_ms); + _trace_young_gen_time_data.record_start_collection(s_w_t_ms); _stop_world_start = 0.0; record_heap_size_info_at_start(false /* full */); @@ -906,7 +906,7 @@ void G1CollectorPolicy::record_concurrent_mark_cleanup_completed() { void G1CollectorPolicy::record_concurrent_pause() { if (_stop_world_start > 0.0) { double yield_ms = (os::elapsedTime() - _stop_world_start) * 1000.0; - _trace_gen0_time_data.record_yield_time(yield_ms); + _trace_young_gen_time_data.record_yield_time(yield_ms); } } @@ -993,7 +993,7 @@ void G1CollectorPolicy::record_collection_pause_end(double pause_time_ms, Evacua evacuation_info.set_bytes_copied(_bytes_copied_during_gc); if (update_stats) { - _trace_gen0_time_data.record_end_collection(pause_time_ms, phase_times()); + _trace_young_gen_time_data.record_end_collection(pause_time_ms, phase_times()); // this is where we update the allocation rate of the application double app_time_ms = (phase_times()->cur_collection_start_sec() * 1000.0 - _prev_collection_pause_end_ms); @@ -1415,8 +1415,8 @@ size_t G1CollectorPolicy::expansion_amount() { } void G1CollectorPolicy::print_tracing_info() const { - _trace_gen0_time_data.print(); - _trace_gen1_time_data.print(); + _trace_young_gen_time_data.print(); + _trace_old_gen_time_data.print(); } void G1CollectorPolicy::print_yg_surv_rate_info() const { @@ -1973,9 +1973,9 @@ void G1CollectorPolicy::finalize_cset(double target_pause_time_ms, EvacuationInf _last_gc_was_young = gcs_are_young() ? true : false; if (_last_gc_was_young) { - _trace_gen0_time_data.increment_young_collection_count(); + _trace_young_gen_time_data.increment_young_collection_count(); } else { - _trace_gen0_time_data.increment_mixed_collection_count(); + _trace_young_gen_time_data.increment_mixed_collection_count(); } // The young list is laid with the survivor regions from the previous @@ -2156,20 +2156,20 @@ void G1CollectorPolicy::finalize_cset(double target_pause_time_ms, EvacuationInf evacuation_info.set_collectionset_regions(cset_region_length()); } -void TraceGen0TimeData::record_start_collection(double time_to_stop_the_world_ms) { - if(TraceGen0Time) { +void TraceYoungGenTimeData::record_start_collection(double time_to_stop_the_world_ms) { + if(TraceYoungGenTime) { _all_stop_world_times_ms.add(time_to_stop_the_world_ms); } } -void TraceGen0TimeData::record_yield_time(double yield_time_ms) { - if(TraceGen0Time) { +void TraceYoungGenTimeData::record_yield_time(double yield_time_ms) { + if(TraceYoungGenTime) { _all_yield_times_ms.add(yield_time_ms); } } -void TraceGen0TimeData::record_end_collection(double pause_time_ms, G1GCPhaseTimes* phase_times) { - if(TraceGen0Time) { +void TraceYoungGenTimeData::record_end_collection(double pause_time_ms, G1GCPhaseTimes* phase_times) { + if(TraceYoungGenTime) { _total.add(pause_time_ms); _other.add(pause_time_ms - phase_times->accounted_time_ms()); _root_region_scan_wait.add(phase_times->root_region_scan_wait_time_ms()); @@ -2194,34 +2194,34 @@ void TraceGen0TimeData::record_end_collection(double pause_time_ms, G1GCPhaseTim } } -void TraceGen0TimeData::increment_young_collection_count() { - if(TraceGen0Time) { +void TraceYoungGenTimeData::increment_young_collection_count() { + if(TraceYoungGenTime) { ++_young_pause_num; } } -void TraceGen0TimeData::increment_mixed_collection_count() { - if(TraceGen0Time) { +void TraceYoungGenTimeData::increment_mixed_collection_count() { + if(TraceYoungGenTime) { ++_mixed_pause_num; } } -void TraceGen0TimeData::print_summary(const char* str, - const NumberSeq* seq) const { +void TraceYoungGenTimeData::print_summary(const char* str, + const NumberSeq* seq) const { double sum = seq->sum(); gclog_or_tty->print_cr("%-27s = %8.2lf s (avg = %8.2lf ms)", str, sum / 1000.0, seq->avg()); } -void TraceGen0TimeData::print_summary_sd(const char* str, - const NumberSeq* seq) const { +void TraceYoungGenTimeData::print_summary_sd(const char* str, + const NumberSeq* seq) const { print_summary(str, seq); gclog_or_tty->print_cr("%+45s = %5d, std dev = %8.2lf ms, max = %8.2lf ms)", "(num", seq->num(), seq->sd(), seq->maximum()); } -void TraceGen0TimeData::print() const { - if (!TraceGen0Time) { +void TraceYoungGenTimeData::print() const { + if (!TraceYoungGenTime) { return; } @@ -2258,14 +2258,14 @@ void TraceGen0TimeData::print() const { print_summary_sd(" Yields", &_all_yield_times_ms); } -void TraceGen1TimeData::record_full_collection(double full_gc_time_ms) { - if (TraceGen1Time) { +void TraceOldGenTimeData::record_full_collection(double full_gc_time_ms) { + if (TraceOldGenTime) { _all_full_gc_times.add(full_gc_time_ms); } } -void TraceGen1TimeData::print() const { - if (!TraceGen1Time) { +void TraceOldGenTimeData::print() const { + if (!TraceOldGenTime) { return; } diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp index f2905097190..4f141892e1f 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp @@ -38,10 +38,10 @@ class HeapRegion; class CollectionSetChooser; class G1GCPhaseTimes; -// TraceGen0Time collects data on _both_ young and mixed evacuation pauses +// TraceYoungGenTime collects data on _both_ young and mixed evacuation pauses // (the latter may contain non-young regions - i.e. regions that are -// technically in Gen1) while TraceGen1Time collects data about full GCs. -class TraceGen0TimeData : public CHeapObj { +// technically in old) while TraceOldGenTime collects data about full GCs. +class TraceYoungGenTimeData : public CHeapObj { private: unsigned _young_pause_num; unsigned _mixed_pause_num; @@ -66,7 +66,7 @@ class TraceGen0TimeData : public CHeapObj { void print_summary_sd(const char* str, const NumberSeq* seq) const; public: - TraceGen0TimeData() : _young_pause_num(0), _mixed_pause_num(0) {}; + TraceYoungGenTimeData() : _young_pause_num(0), _mixed_pause_num(0) {}; void record_start_collection(double time_to_stop_the_world_ms); void record_yield_time(double yield_time_ms); void record_end_collection(double pause_time_ms, G1GCPhaseTimes* phase_times); @@ -75,7 +75,7 @@ public: void print() const; }; -class TraceGen1TimeData : public CHeapObj { +class TraceOldGenTimeData : public CHeapObj { private: NumberSeq _all_full_gc_times; @@ -187,8 +187,8 @@ private: TruncatedSeq* _concurrent_mark_remark_times_ms; TruncatedSeq* _concurrent_mark_cleanup_times_ms; - TraceGen0TimeData _trace_gen0_time_data; - TraceGen1TimeData _trace_gen1_time_data; + TraceYoungGenTimeData _trace_young_gen_time_data; + TraceOldGenTimeData _trace_old_gen_time_data; double _stop_world_start; @@ -202,20 +202,20 @@ private: // locker is active. This should be >= _young_list_target_length; uint _young_list_max_length; - bool _last_gc_was_young; + bool _last_gc_was_young; - bool _during_marking; - bool _in_marking_window; - bool _in_marking_window_im; + bool _during_marking; + bool _in_marking_window; + bool _in_marking_window_im; - SurvRateGroup* _short_lived_surv_rate_group; - SurvRateGroup* _survivor_surv_rate_group; + SurvRateGroup* _short_lived_surv_rate_group; + SurvRateGroup* _survivor_surv_rate_group; // add here any more surv rate groups - double _gc_overhead_perc; + double _gc_overhead_perc; double _reserve_factor; - uint _reserve_regions; + uint _reserve_regions; bool during_marking() { return _during_marking; diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.cpp index 468871ea5fc..4ad67face5e 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/adjoiningGenerations.cpp @@ -35,14 +35,14 @@ AdjoiningGenerations::AdjoiningGenerations(ReservedSpace old_young_rs, GenerationSizer* policy, size_t alignment) : - _virtual_spaces(old_young_rs, policy->min_gen1_size(), - policy->min_gen0_size(), alignment) { - size_t init_low_byte_size = policy->initial_gen1_size(); - size_t min_low_byte_size = policy->min_gen1_size(); - size_t max_low_byte_size = policy->max_gen1_size(); - size_t init_high_byte_size = policy->initial_gen0_size(); - size_t min_high_byte_size = policy->min_gen0_size(); - size_t max_high_byte_size = policy->max_gen0_size(); + _virtual_spaces(old_young_rs, policy->min_old_size(), + policy->min_young_size(), alignment) { + size_t init_low_byte_size = policy->initial_old_size(); + size_t min_low_byte_size = policy->min_old_size(); + size_t max_low_byte_size = policy->max_old_size(); + size_t init_high_byte_size = policy->initial_young_size(); + size_t min_high_byte_size = policy->min_young_size(); + size_t max_high_byte_size = policy->max_young_size(); assert(min_low_byte_size <= init_low_byte_size && init_low_byte_size <= max_low_byte_size, "Parameter check"); diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp index fd8b1332c7a..ff4b53057b8 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/generationSizer.cpp @@ -32,8 +32,8 @@ void GenerationSizer::trace_gen_sizes(const char* const str) { SIZE_FORMAT "," SIZE_FORMAT " " SIZE_FORMAT, str, - _min_gen1_size / K, _max_gen1_size / K, - _min_gen0_size / K, _max_gen0_size / K, + _min_old_size / K, _max_old_size / K, + _min_young_size / K, _max_young_size / K, _max_heap_byte_size / K); } } diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp index 5a2f4e79d95..b7d521a4884 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp @@ -623,11 +623,11 @@ void ParallelScavengeHeap::print_gc_threads_on(outputStream* st) const { } void ParallelScavengeHeap::print_tracing_info() const { - if (TraceGen0Time) { + if (TraceYoungGenTime) { double time = PSScavenge::accumulated_time()->seconds(); tty->print_cr("[Accumulated GC generation 0 time %3.7f secs]", time); } - if (TraceGen1Time) { + if (TraceOldGenTime) { double time = UseParallelOldGC ? PSParallelCompact::accumulated_time()->seconds() : PSMarkSweep::accumulated_time()->seconds(); tty->print_cr("[Accumulated GC generation 1 time %3.7f secs]", time); } diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp index 19eaf27aae5..bb829f99602 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp @@ -174,7 +174,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) { TraceCollectorStats tcs(counters()); TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); - if (TraceGen1Time) accumulated_time()->start(); + if (TraceOldGenTime) accumulated_time()->start(); // Let the size policy know we're starting size_policy->major_collection_begin(); @@ -354,7 +354,7 @@ bool PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) { // We collected the heap, recalculate the metaspace capacity MetaspaceGC::compute_new_size(); - if (TraceGen1Time) accumulated_time()->stop(); + if (TraceOldGenTime) accumulated_time()->stop(); if (PrintGC) { if (PrintGCDetails) { diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp index a9ffe54bd25..cba23adae9f 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @@ -2061,7 +2061,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { TraceCollectorStats tcs(counters()); TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); - if (TraceGen1Time) accumulated_time()->start(); + if (TraceOldGenTime) accumulated_time()->start(); // Let the size policy know we're starting size_policy->major_collection_begin(); @@ -2188,7 +2188,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { // Resize the metaspace capacity after a collection MetaspaceGC::compute_new_size(); - if (TraceGen1Time) accumulated_time()->stop(); + if (TraceOldGenTime) accumulated_time()->stop(); if (PrintGC) { if (PrintGCDetails) { diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp index fd3030462b8..e71122529b1 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp @@ -336,7 +336,7 @@ bool PSScavenge::invoke_no_policy() { TraceCollectorStats tcs(counters()); TraceMemoryManagerStats tms(false /* not full GC */,gc_cause); - if (TraceGen0Time) accumulated_time()->start(); + if (TraceYoungGenTime) accumulated_time()->start(); // Let the size policy know we're starting size_policy->minor_collection_begin(); @@ -660,7 +660,7 @@ bool PSScavenge::invoke_no_policy() { CardTableExtension::verify_all_young_refs_imprecise(); } - if (TraceGen0Time) accumulated_time()->stop(); + if (TraceYoungGenTime) accumulated_time()->stop(); if (PrintGC) { if (PrintGCDetails) { diff --git a/hotspot/src/share/vm/memory/collectorPolicy.cpp b/hotspot/src/share/vm/memory/collectorPolicy.cpp index 6d822a4b9e9..de33c9107d7 100644 --- a/hotspot/src/share/vm/memory/collectorPolicy.cpp +++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp @@ -196,13 +196,13 @@ size_t CollectorPolicy::compute_heap_alignment() { // GenCollectorPolicy methods GenCollectorPolicy::GenCollectorPolicy() : - _min_gen0_size(0), - _initial_gen0_size(0), - _max_gen0_size(0), + _min_young_size(0), + _initial_young_size(0), + _max_young_size(0), _gen_alignment(0), - _min_gen1_size(0), - _initial_gen1_size(0), - _max_gen1_size(0), + _min_old_size(0), + _initial_old_size(0), + _max_old_size(0), _generations(NULL) {} @@ -236,7 +236,7 @@ size_t GenCollectorPolicy::young_gen_size_lower_bound() { #ifdef ASSERT void GenCollectorPolicy::assert_flags() { CollectorPolicy::assert_flags(); - assert(NewSize >= _min_gen0_size, "Ergonomics decided on a too small young gen size"); + assert(NewSize >= _min_young_size, "Ergonomics decided on a too small young gen size"); assert(NewSize <= MaxNewSize, "Ergonomics decided on incompatible initial and maximum young gen sizes"); assert(FLAG_IS_DEFAULT(MaxNewSize) || MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young gen and heap sizes"); assert(NewSize % _gen_alignment == 0, "NewSize alignment"); @@ -249,28 +249,28 @@ void GenCollectorPolicy::assert_size_info() { CollectorPolicy::assert_size_info(); // GenCollectorPolicy::initialize_size_info may update the MaxNewSize assert(MaxNewSize < MaxHeapSize, "Ergonomics decided on incompatible maximum young and heap sizes"); - assert(NewSize == _initial_gen0_size, "Discrepancy between NewSize flag and local storage"); - assert(MaxNewSize == _max_gen0_size, "Discrepancy between MaxNewSize flag and local storage"); - assert(OldSize == _initial_gen1_size, "Discrepancy between OldSize flag and local storage"); - assert(_min_gen0_size <= _initial_gen0_size, "Ergonomics decided on incompatible minimum and initial young gen sizes"); - assert(_initial_gen0_size <= _max_gen0_size, "Ergonomics decided on incompatible initial and maximum young gen sizes"); - assert(_min_gen0_size % _gen_alignment == 0, "_min_gen0_size alignment"); - assert(_initial_gen0_size % _gen_alignment == 0, "_initial_gen0_size alignment"); - assert(_max_gen0_size % _gen_alignment == 0, "_max_gen0_size alignment"); - assert(_min_gen0_size <= bound_minus_alignment(_min_gen0_size, _min_heap_byte_size), + assert(NewSize == _initial_young_size, "Discrepancy between NewSize flag and local storage"); + assert(MaxNewSize == _max_young_size, "Discrepancy between MaxNewSize flag and local storage"); + assert(OldSize == _initial_old_size, "Discrepancy between OldSize flag and local storage"); + assert(_min_young_size <= _initial_young_size, "Ergonomics decided on incompatible minimum and initial young gen sizes"); + assert(_initial_young_size <= _max_young_size, "Ergonomics decided on incompatible initial and maximum young gen sizes"); + assert(_min_young_size % _gen_alignment == 0, "_min_young_size alignment"); + assert(_initial_young_size % _gen_alignment == 0, "_initial_young_size alignment"); + assert(_max_young_size % _gen_alignment == 0, "_max_young_size alignment"); + assert(_min_young_size <= bound_minus_alignment(_min_young_size, _min_heap_byte_size), "Ergonomics made minimum young generation larger than minimum heap"); - assert(_initial_gen0_size <= bound_minus_alignment(_initial_gen0_size, _initial_heap_byte_size), + assert(_initial_young_size <= bound_minus_alignment(_initial_young_size, _initial_heap_byte_size), "Ergonomics made initial young generation larger than initial heap"); - assert(_max_gen0_size <= bound_minus_alignment(_max_gen0_size, _max_heap_byte_size), + assert(_max_young_size <= bound_minus_alignment(_max_young_size, _max_heap_byte_size), "Ergonomics made maximum young generation lager than maximum heap"); - assert(_min_gen1_size <= _initial_gen1_size, "Ergonomics decided on incompatible minimum and initial old gen sizes"); - assert(_initial_gen1_size <= _max_gen1_size, "Ergonomics decided on incompatible initial and maximum old gen sizes"); - assert(_max_gen1_size % _gen_alignment == 0, "_max_gen1_size alignment"); - assert(_initial_gen1_size % _gen_alignment == 0, "_initial_gen1_size alignment"); - assert(_max_heap_byte_size <= (_max_gen0_size + _max_gen1_size), "Total maximum heap sizes must be sum of generation maximum sizes"); - assert(_min_gen0_size + _min_gen1_size <= _min_heap_byte_size, "Minimum generation sizes exceed minimum heap size"); - assert(_initial_gen0_size + _initial_gen1_size == _initial_heap_byte_size, "Initial generation sizes should match initial heap size"); - assert(_max_gen0_size + _max_gen1_size == _max_heap_byte_size, "Maximum generation sizes should match maximum heap size"); + assert(_min_old_size <= _initial_old_size, "Ergonomics decided on incompatible minimum and initial old gen sizes"); + assert(_initial_old_size <= _max_old_size, "Ergonomics decided on incompatible initial and maximum old gen sizes"); + assert(_max_old_size % _gen_alignment == 0, "_max_old_size alignment"); + assert(_initial_old_size % _gen_alignment == 0, "_initial_old_size alignment"); + assert(_max_heap_byte_size <= (_max_young_size + _max_old_size), "Total maximum heap sizes must be sum of generation maximum sizes"); + assert(_min_young_size + _min_old_size <= _min_heap_byte_size, "Minimum generation sizes exceed minimum heap size"); + assert(_initial_young_size + _initial_old_size == _initial_heap_byte_size, "Initial generation sizes should match initial heap size"); + assert(_max_young_size + _max_old_size == _max_heap_byte_size, "Maximum generation sizes should match maximum heap size"); } #endif // ASSERT @@ -323,8 +323,8 @@ void GenCollectorPolicy::initialize_flags() { // later when setting the initial and minimum young generation size. NewSize = bounded_new_size; } - _min_gen0_size = smallest_new_size; - _initial_gen0_size = NewSize; + _min_young_size = smallest_new_size; + _initial_young_size = NewSize; if (!FLAG_IS_DEFAULT(MaxNewSize)) { if (MaxNewSize >= MaxHeapSize) { @@ -338,14 +338,14 @@ void GenCollectorPolicy::initialize_flags() { FLAG_SET_ERGO(uintx, MaxNewSize, smaller_max_new_size); if (NewSize > MaxNewSize) { FLAG_SET_ERGO(uintx, NewSize, MaxNewSize); - _initial_gen0_size = NewSize; + _initial_young_size = NewSize; } - } else if (MaxNewSize < _initial_gen0_size) { - FLAG_SET_ERGO(uintx, MaxNewSize, _initial_gen0_size); + } else if (MaxNewSize < _initial_young_size) { + FLAG_SET_ERGO(uintx, MaxNewSize, _initial_young_size); } else if (!is_size_aligned(MaxNewSize, _gen_alignment)) { FLAG_SET_ERGO(uintx, MaxNewSize, align_size_down(MaxNewSize, _gen_alignment)); } - _max_gen0_size = MaxNewSize; + _max_young_size = MaxNewSize; } if (NewSize > MaxNewSize) { @@ -357,7 +357,7 @@ void GenCollectorPolicy::initialize_flags() { NewSize/K, MaxNewSize/K, NewSize/K); } FLAG_SET_ERGO(uintx, MaxNewSize, NewSize); - _max_gen0_size = MaxNewSize; + _max_young_size = MaxNewSize; } if (SurvivorRatio < 1 || NewRatio < 1) { @@ -393,7 +393,7 @@ void GenCollectorPolicy::initialize_flags() { double shrink_factor = (double) MaxHeapSize / calculated_size; uintx smaller_new_size = align_size_down((uintx)(NewSize * shrink_factor), _gen_alignment); FLAG_SET_ERGO(uintx, NewSize, MAX2(young_gen_size_lower_bound(), smaller_new_size)); - _initial_gen0_size = NewSize; + _initial_young_size = NewSize; // OldSize is already aligned because above we aligned MaxHeapSize to // _heap_alignment, and we just made sure that NewSize is aligned to @@ -406,16 +406,16 @@ void GenCollectorPolicy::initialize_flags() { } } - // Update NewSize, if possible, to avoid sizing gen0 to small when only + // Update NewSize, if possible, to avoid sizing the young gen too small when only // OldSize is set on the command line. if (FLAG_IS_CMDLINE(OldSize) && !FLAG_IS_CMDLINE(NewSize)) { if (OldSize < _initial_heap_byte_size) { size_t new_size = _initial_heap_byte_size - OldSize; - // Need to compare against the flag value for max since _max_gen0_size + // Need to compare against the flag value for max since _max_young_size // might not have been set yet. - if (new_size >= _min_gen0_size && new_size <= MaxNewSize) { + if (new_size >= _min_young_size && new_size <= MaxNewSize) { FLAG_SET_ERGO(uintx, NewSize, new_size); - _initial_gen0_size = NewSize; + _initial_young_size = NewSize; } } } @@ -444,97 +444,77 @@ void GenCollectorPolicy::initialize_flags() { void GenCollectorPolicy::initialize_size_info() { CollectorPolicy::initialize_size_info(); - // _space_alignment is used for alignment within a generation. - // There is additional alignment done down stream for some - // collectors that sometimes causes unwanted rounding up of - // generations sizes. + _initial_young_size = NewSize; + _max_young_size = MaxNewSize; + _initial_old_size = OldSize; - // Determine maximum size of gen0 + // Determine maximum size of the young generation. - size_t max_new_size = 0; - if (!FLAG_IS_DEFAULT(MaxNewSize)) { - max_new_size = MaxNewSize; - } else { - max_new_size = scale_by_NewRatio_aligned(_max_heap_byte_size); + if (FLAG_IS_DEFAULT(MaxNewSize)) { + _max_young_size = scale_by_NewRatio_aligned(_max_heap_byte_size); // Bound the maximum size by NewSize below (since it historically // would have been NewSize and because the NewRatio calculation could // yield a size that is too small) and bound it by MaxNewSize above. // Ergonomics plays here by previously calculating the desired // NewSize and MaxNewSize. - max_new_size = MIN2(MAX2(max_new_size, NewSize), MaxNewSize); + _max_young_size = MIN2(MAX2(_max_young_size, _initial_young_size), MaxNewSize); } - assert(max_new_size > 0, "All paths should set max_new_size"); - // Given the maximum gen0 size, determine the initial and - // minimum gen0 sizes. + // Given the maximum young size, determine the initial and + // minimum young sizes. if (_max_heap_byte_size == _initial_heap_byte_size) { - // The maxium and initial heap sizes are the same so the generation's + // The maximum and initial heap sizes are the same so the generation's // initial size must be the same as it maximum size. Use NewSize as the // size if set on command line. - size_t fixed_young_size = FLAG_IS_CMDLINE(NewSize) ? NewSize : max_new_size; - - _initial_gen0_size = fixed_young_size; - _max_gen0_size = fixed_young_size; + _max_young_size = FLAG_IS_CMDLINE(NewSize) ? NewSize : _max_young_size; + _initial_young_size = _max_young_size; // Also update the minimum size if min == initial == max. if (_max_heap_byte_size == _min_heap_byte_size) { - _min_gen0_size = fixed_young_size; + _min_young_size = _max_young_size; } } else { - size_t desired_new_size = 0; if (FLAG_IS_CMDLINE(NewSize)) { // If NewSize is set on the command line, we should use it as // the initial size, but make sure it is within the heap bounds. - desired_new_size = - MIN2(max_new_size, bound_minus_alignment(NewSize, _initial_heap_byte_size)); - _min_gen0_size = bound_minus_alignment(desired_new_size, _min_heap_byte_size); + _initial_young_size = + MIN2(_max_young_size, bound_minus_alignment(NewSize, _initial_heap_byte_size)); + _min_young_size = bound_minus_alignment(_initial_young_size, _min_heap_byte_size); } else { // For the case where NewSize is not set on the command line, use // NewRatio to size the initial generation size. Use the current // NewSize as the floor, because if NewRatio is overly large, the resulting // size can be too small. - desired_new_size = - MIN2(max_new_size, MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize)); + _initial_young_size = + MIN2(_max_young_size, MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize)); } - _initial_gen0_size = desired_new_size; - _max_gen0_size = max_new_size; - } - - // Write back to flags if necessary. - if (NewSize != _initial_gen0_size) { - FLAG_SET_ERGO(uintx, NewSize, _initial_gen0_size); - } - - if (MaxNewSize != _max_gen0_size) { - FLAG_SET_ERGO(uintx, MaxNewSize, _max_gen0_size); } if (PrintGCDetails && Verbose) { - gclog_or_tty->print_cr("1: Minimum gen0 " SIZE_FORMAT " Initial gen0 " - SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, - _min_gen0_size, _initial_gen0_size, _max_gen0_size); + gclog_or_tty->print_cr("1: Minimum young " SIZE_FORMAT " Initial young " + SIZE_FORMAT " Maximum young " SIZE_FORMAT, + _min_young_size, _initial_young_size, _max_young_size); } // At this point the minimum, initial and maximum sizes - // of the overall heap and of gen0 have been determined. - // The maximum gen1 size can be determined from the maximum gen0 + // of the overall heap and of the young generation have been determined. + // The maximum old size can be determined from the maximum young // and maximum heap size since no explicit flags exist - // for setting the gen1 maximum. - _max_gen1_size = MAX2(_max_heap_byte_size - _max_gen0_size, _gen_alignment); + // for setting the old generation maximum. + _max_old_size = MAX2(_max_heap_byte_size - _max_young_size, _gen_alignment); // If no explicit command line flag has been set for the - // gen1 size, use what is left for gen1 + // old generation size, use what is left. if (!FLAG_IS_CMDLINE(OldSize)) { // The user has not specified any value but the ergonomics // may have chosen a value (which may or may not be consistent // with the overall heap size). In either case make // the minimum, maximum and initial sizes consistent - // with the gen0 sizes and the overall heap sizes. - _min_gen1_size = _gen_alignment; - _initial_gen1_size = MIN2(_max_gen1_size, MAX2(_initial_heap_byte_size - _initial_gen0_size, _min_gen1_size)); - // _max_gen1_size has already been made consistent above - FLAG_SET_ERGO(uintx, OldSize, _initial_gen1_size); + // with the young sizes and the overall heap sizes. + _min_old_size = _gen_alignment; + _initial_old_size = MIN2(_max_old_size, MAX2(_initial_heap_byte_size - _initial_young_size, _min_old_size)); + // _max_old_size has already been made consistent above. } else { // OldSize has been explicitly set on the command line. Use it // for the initial size but make sure the minimum allow a young @@ -543,69 +523,68 @@ void GenCollectorPolicy::initialize_size_info() { // with other command line flags, issue a warning. // The generation minimums and the overall heap minimum should // be within one generation alignment. - if (OldSize > _max_gen1_size) { + if (_initial_old_size > _max_old_size) { warning("Inconsistency between maximum heap size and maximum " "generation sizes: using maximum heap = " SIZE_FORMAT " -XX:OldSize flag is being ignored", _max_heap_byte_size); - FLAG_SET_ERGO(uintx, OldSize, _max_gen1_size); + _initial_old_size = _max_old_size; } - _min_gen1_size = MIN2(OldSize, _min_heap_byte_size - _min_gen0_size); - _initial_gen1_size = OldSize; + _min_old_size = MIN2(_initial_old_size, _min_heap_byte_size - _min_young_size); } // The initial generation sizes should match the initial heap size, // if not issue a warning and resize the generations. This behavior // differs from JDK8 where the generation sizes have higher priority // than the initial heap size. - if ((_initial_gen1_size + _initial_gen0_size) != _initial_heap_byte_size) { + if ((_initial_old_size + _initial_young_size) != _initial_heap_byte_size) { warning("Inconsistency between generation sizes and heap size, resizing " "the generations to fit the heap."); - size_t desired_gen0_size = _initial_heap_byte_size - _initial_gen1_size; - if (_initial_heap_byte_size < _initial_gen1_size) { + size_t desired_young_size = _initial_heap_byte_size - _initial_old_size; + if (_initial_heap_byte_size < _initial_old_size) { // Old want all memory, use minimum for young and rest for old - _initial_gen0_size = _min_gen0_size; - _initial_gen1_size = _initial_heap_byte_size - _min_gen0_size; - } else if (desired_gen0_size > _max_gen0_size) { + _initial_young_size = _min_young_size; + _initial_old_size = _initial_heap_byte_size - _min_young_size; + } else if (desired_young_size > _max_young_size) { // Need to increase both young and old generation - _initial_gen0_size = _max_gen0_size; - _initial_gen1_size = _initial_heap_byte_size - _max_gen0_size; - } else if (desired_gen0_size < _min_gen0_size) { + _initial_young_size = _max_young_size; + _initial_old_size = _initial_heap_byte_size - _max_young_size; + } else if (desired_young_size < _min_young_size) { // Need to decrease both young and old generation - _initial_gen0_size = _min_gen0_size; - _initial_gen1_size = _initial_heap_byte_size - _min_gen0_size; + _initial_young_size = _min_young_size; + _initial_old_size = _initial_heap_byte_size - _min_young_size; } else { // The young generation boundaries allow us to only update the // young generation. - _initial_gen0_size = desired_gen0_size; + _initial_young_size = desired_young_size; } if (PrintGCDetails && Verbose) { - gclog_or_tty->print_cr("2: Minimum gen0 " SIZE_FORMAT " Initial gen0 " - SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT, - _min_gen0_size, _initial_gen0_size, _max_gen0_size); + gclog_or_tty->print_cr("2: Minimum young " SIZE_FORMAT " Initial young " + SIZE_FORMAT " Maximum young " SIZE_FORMAT, + _min_young_size, _initial_young_size, _max_young_size); } } - // Write back to flags if necessary - if (NewSize != _initial_gen0_size) { - FLAG_SET_ERGO(uintx, NewSize, _initial_gen0_size); + // Write back to flags if necessary. + if (NewSize != _initial_young_size) { + FLAG_SET_ERGO(uintx, NewSize, _initial_young_size); } - if (MaxNewSize != _max_gen0_size) { - FLAG_SET_ERGO(uintx, MaxNewSize, _max_gen0_size); + if (MaxNewSize != _max_young_size) { + FLAG_SET_ERGO(uintx, MaxNewSize, _max_young_size); } - if (OldSize != _initial_gen1_size) { - FLAG_SET_ERGO(uintx, OldSize, _initial_gen1_size); + if (OldSize != _initial_old_size) { + FLAG_SET_ERGO(uintx, OldSize, _initial_old_size); } if (PrintGCDetails && Verbose) { - gclog_or_tty->print_cr("Minimum gen1 " SIZE_FORMAT " Initial gen1 " - SIZE_FORMAT " Maximum gen1 " SIZE_FORMAT, - _min_gen1_size, _initial_gen1_size, _max_gen1_size); + gclog_or_tty->print_cr("Minimum old " SIZE_FORMAT " Initial old " + SIZE_FORMAT " Maximum old " SIZE_FORMAT, + _min_old_size, _initial_old_size, _max_old_size); } DEBUG_ONLY(GenCollectorPolicy::assert_size_info();) @@ -631,11 +610,11 @@ HeapWord* GenCollectorPolicy::mem_allocate_work(size_t size, HandleMark hm; // Discard any handles allocated in each iteration. // First allocation attempt is lock-free. - Generation *gen0 = gch->get_gen(0); - assert(gen0->supports_inline_contig_alloc(), + Generation *young = gch->get_gen(0); + assert(young->supports_inline_contig_alloc(), "Otherwise, must do alloc within heap lock"); - if (gen0->should_allocate(size, is_tlab)) { - result = gen0->par_allocate(size, is_tlab); + if (young->should_allocate(size, is_tlab)) { + result = young->par_allocate(size, is_tlab); if (result != NULL) { assert(gch->is_in_reserved(result), "result not in heap"); return result; @@ -917,8 +896,8 @@ MetaWord* CollectorPolicy::satisfy_failed_metadata_allocation( bool GenCollectorPolicy::should_try_older_generation_allocation( size_t word_size) const { GenCollectedHeap* gch = GenCollectedHeap::heap(); - size_t gen0_capacity = gch->get_gen(0)->capacity_before_gc(); - return (word_size > heap_word_size(gen0_capacity)) + size_t young_capacity = gch->get_gen(0)->capacity_before_gc(); + return (word_size > heap_word_size(young_capacity)) || GC_locker::is_active_and_needs_gc() || gch->incremental_collection_failed(); } @@ -940,11 +919,11 @@ void MarkSweepPolicy::initialize_generations() { } if (UseParNewGC) { - _generations[0] = new GenerationSpec(Generation::ParNew, _initial_gen0_size, _max_gen0_size); + _generations[0] = new GenerationSpec(Generation::ParNew, _initial_young_size, _max_young_size); } else { - _generations[0] = new GenerationSpec(Generation::DefNew, _initial_gen0_size, _max_gen0_size); + _generations[0] = new GenerationSpec(Generation::DefNew, _initial_young_size, _max_young_size); } - _generations[1] = new GenerationSpec(Generation::MarkSweepCompact, _initial_gen1_size, _max_gen1_size); + _generations[1] = new GenerationSpec(Generation::MarkSweepCompact, _initial_old_size, _max_old_size); if (_generations[0] == NULL || _generations[1] == NULL) { vm_exit_during_initialization("Unable to allocate gen spec"); @@ -978,18 +957,18 @@ public: flag_value = 20 * M; set_basic_flag_values(); FLAG_SET_CMDLINE(uintx, NewSize, flag_value); - verify_gen0_min(flag_value); + verify_young_min(flag_value); set_basic_flag_values(); FLAG_SET_CMDLINE(uintx, NewSize, flag_value); - verify_gen0_initial(flag_value); + verify_young_initial(flag_value); // If NewSize is set on command line, but is larger than the min // heap size, it should only be used for initial young size. flag_value = 80 * M; set_basic_flag_values(); FLAG_SET_CMDLINE(uintx, NewSize, flag_value); - verify_gen0_initial(flag_value); + verify_young_initial(flag_value); // If NewSize has been ergonomically set, the collector policy // should use it for min but calculate the initial young size @@ -997,11 +976,11 @@ public: flag_value = 20 * M; set_basic_flag_values(); FLAG_SET_ERGO(uintx, NewSize, flag_value); - verify_gen0_min(flag_value); + verify_young_min(flag_value); set_basic_flag_values(); FLAG_SET_ERGO(uintx, NewSize, flag_value); - verify_scaled_gen0_initial(InitialHeapSize); + verify_scaled_young_initial(InitialHeapSize); restore_flags(); } @@ -1016,11 +995,11 @@ public: flag_value = 20 * M; set_basic_flag_values(); FLAG_SET_CMDLINE(uintx, OldSize, flag_value); - verify_gen1_min(flag_value); + verify_old_min(flag_value); set_basic_flag_values(); FLAG_SET_CMDLINE(uintx, OldSize, flag_value); - verify_gen1_initial(flag_value); + verify_old_initial(flag_value); // If MaxNewSize is large, the maximum OldSize will be less than // what's requested on the command line and it should be reset @@ -1031,46 +1010,46 @@ public: FLAG_SET_CMDLINE(uintx, MaxNewSize, 170*M); // Calculate what we expect the flag to be. flag_value = MaxHeapSize - MaxNewSize; - verify_gen1_initial(flag_value); + verify_old_initial(flag_value); } - static void verify_gen0_min(size_t expected) { + static void verify_young_min(size_t expected) { MarkSweepPolicy msp; msp.initialize_all(); - assert(msp.min_gen0_size() <= expected, err_msg("%zu > %zu", msp.min_gen0_size(), expected)); + assert(msp.min_young_size() <= expected, err_msg("%zu > %zu", msp.min_young_size(), expected)); } - static void verify_gen0_initial(size_t expected) { + static void verify_young_initial(size_t expected) { MarkSweepPolicy msp; msp.initialize_all(); - assert(msp.initial_gen0_size() == expected, err_msg("%zu != %zu", msp.initial_gen0_size(), expected)); + assert(msp.initial_young_size() == expected, err_msg("%zu != %zu", msp.initial_young_size(), expected)); } - static void verify_scaled_gen0_initial(size_t initial_heap_size) { + static void verify_scaled_young_initial(size_t initial_heap_size) { MarkSweepPolicy msp; msp.initialize_all(); size_t expected = msp.scale_by_NewRatio_aligned(initial_heap_size); - assert(msp.initial_gen0_size() == expected, err_msg("%zu != %zu", msp.initial_gen0_size(), expected)); + assert(msp.initial_young_size() == expected, err_msg("%zu != %zu", msp.initial_young_size(), expected)); assert(FLAG_IS_ERGO(NewSize) && NewSize == expected, err_msg("NewSize should have been set ergonomically to %zu, but was %zu", expected, NewSize)); } - static void verify_gen1_min(size_t expected) { + static void verify_old_min(size_t expected) { MarkSweepPolicy msp; msp.initialize_all(); - assert(msp.min_gen1_size() <= expected, err_msg("%zu > %zu", msp.min_gen1_size(), expected)); + assert(msp.min_old_size() <= expected, err_msg("%zu > %zu", msp.min_old_size(), expected)); } - static void verify_gen1_initial(size_t expected) { + static void verify_old_initial(size_t expected) { MarkSweepPolicy msp; msp.initialize_all(); - assert(msp.initial_gen1_size() == expected, err_msg("%zu != %zu", msp.initial_gen1_size(), expected)); + assert(msp.initial_old_size() == expected, err_msg("%zu != %zu", msp.initial_old_size(), expected)); } diff --git a/hotspot/src/share/vm/memory/collectorPolicy.hpp b/hotspot/src/share/vm/memory/collectorPolicy.hpp index 1fc62b06c43..57f59b2bd92 100644 --- a/hotspot/src/share/vm/memory/collectorPolicy.hpp +++ b/hotspot/src/share/vm/memory/collectorPolicy.hpp @@ -219,12 +219,12 @@ class ClearedAllSoftRefs : public StackObj { class GenCollectorPolicy : public CollectorPolicy { friend class TestGenCollectorPolicy; protected: - size_t _min_gen0_size; - size_t _initial_gen0_size; - size_t _max_gen0_size; - size_t _min_gen1_size; - size_t _initial_gen1_size; - size_t _max_gen1_size; + size_t _min_young_size; + size_t _initial_young_size; + size_t _max_young_size; + size_t _min_old_size; + size_t _initial_old_size; + size_t _max_old_size; // _gen_alignment and _space_alignment will have the same value most of the // time. When using large pages they can differ. @@ -260,13 +260,13 @@ friend class TestGenCollectorPolicy; GenCollectorPolicy(); // Accessors - size_t min_gen0_size() { return _min_gen0_size; } - size_t initial_gen0_size() { return _initial_gen0_size; } - size_t max_gen0_size() { return _max_gen0_size; } - size_t gen_alignment() { return _gen_alignment; } - size_t min_gen1_size() { return _min_gen1_size; } - size_t initial_gen1_size() { return _initial_gen1_size; } - size_t max_gen1_size() { return _max_gen1_size; } + size_t min_young_size() { return _min_young_size; } + size_t initial_young_size() { return _initial_young_size; } + size_t max_young_size() { return _max_young_size; } + size_t gen_alignment() { return _gen_alignment; } + size_t min_old_size() { return _min_old_size; } + size_t initial_old_size() { return _initial_old_size; } + size_t max_old_size() { return _max_old_size; } int number_of_generations() { return 2; } @@ -298,7 +298,7 @@ friend class TestGenCollectorPolicy; size_t init_survivor_size); virtual void post_heap_initialize() { - assert(_max_gen0_size == MaxNewSize, "Should be taken care of by initialize_size_info"); + assert(_max_young_size == MaxNewSize, "Should be taken care of by initialize_size_info"); } BarrierSet::Name barrier_set_name() { return BarrierSet::CardTableModRef; } diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.cpp b/hotspot/src/share/vm/memory/genCollectedHeap.cpp index 0f75d779d2a..a774f4051e6 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp @@ -1119,10 +1119,10 @@ void GenCollectedHeap::print_on_error(outputStream* st) const { } void GenCollectedHeap::print_tracing_info() const { - if (TraceGen0Time) { + if (TraceYoungGenTime) { get_gen(0)->print_summary_info(); } - if (TraceGen1Time) { + if (TraceOldGenTime) { get_gen(1)->print_summary_info(); } } diff --git a/hotspot/src/share/vm/memory/tenuredGeneration.hpp b/hotspot/src/share/vm/memory/tenuredGeneration.hpp index 94a4330aca1..f9d621db54e 100644 --- a/hotspot/src/share/vm/memory/tenuredGeneration.hpp +++ b/hotspot/src/share/vm/memory/tenuredGeneration.hpp @@ -67,10 +67,9 @@ class TenuredGeneration: public OneContigSpaceCardGeneration { // Does a "full" (forced) collection invoked on this generation collect // all younger generations as well? Note that this is a // hack to allow the collection of the younger gen first if the flag is - // set. This is better than using th policy's should_collect_gen0_first() - // since that causes us to do an extra unnecessary pair of restart-&-stop-world. + // set. virtual bool full_collects_younger_generations() const { - return !CollectGen0First; + return !ScavengeBeforeFullGC; } virtual void gc_prologue(bool full); diff --git a/hotspot/src/share/vm/oops/cpCache.cpp b/hotspot/src/share/vm/oops/cpCache.cpp index 527b771fd68..d601367ba99 100644 --- a/hotspot/src/share/vm/oops/cpCache.cpp +++ b/hotspot/src/share/vm/oops/cpCache.cpp @@ -407,7 +407,7 @@ Method* ConstantPoolCacheEntry::method_if_resolved(constantPoolHandle cpool) { oop ConstantPoolCacheEntry::appendix_if_resolved(constantPoolHandle cpool) { - if (is_f1_null() || !has_appendix()) + if (!has_appendix()) return NULL; const int ref_index = f2_as_index() + _indy_resolved_references_appendix_offset; objArrayOop resolved_references = cpool->resolved_references(); @@ -416,7 +416,7 @@ oop ConstantPoolCacheEntry::appendix_if_resolved(constantPoolHandle cpool) { oop ConstantPoolCacheEntry::method_type_if_resolved(constantPoolHandle cpool) { - if (is_f1_null() || !has_method_type()) + if (!has_method_type()) return NULL; const int ref_index = f2_as_index() + _indy_resolved_references_method_type_offset; objArrayOop resolved_references = cpool->resolved_references(); diff --git a/hotspot/src/share/vm/oops/cpCache.hpp b/hotspot/src/share/vm/oops/cpCache.hpp index ee3a664b352..debd09136c7 100644 --- a/hotspot/src/share/vm/oops/cpCache.hpp +++ b/hotspot/src/share/vm/oops/cpCache.hpp @@ -348,8 +348,8 @@ class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC { bool is_final() const { return (_flags & (1 << is_final_shift)) != 0; } bool is_forced_virtual() const { return (_flags & (1 << is_forced_virtual_shift)) != 0; } bool is_vfinal() const { return (_flags & (1 << is_vfinal_shift)) != 0; } - bool has_appendix() const { return (_flags & (1 << has_appendix_shift)) != 0; } - bool has_method_type() const { return (_flags & (1 << has_method_type_shift)) != 0; } + bool has_appendix() const { return (!is_f1_null()) && (_flags & (1 << has_appendix_shift)) != 0; } + bool has_method_type() const { return (!is_f1_null()) && (_flags & (1 << has_method_type_shift)) != 0; } bool is_method_entry() const { return (_flags & (1 << is_field_entry_shift)) == 0; } bool is_field_entry() const { return (_flags & (1 << is_field_entry_shift)) != 0; } bool is_byte() const { return flag_state() == btos; } diff --git a/hotspot/src/share/vm/oops/methodData.hpp b/hotspot/src/share/vm/oops/methodData.hpp index be40bad175d..1c88ac55ffa 100644 --- a/hotspot/src/share/vm/oops/methodData.hpp +++ b/hotspot/src/share/vm/oops/methodData.hpp @@ -2053,7 +2053,7 @@ public: // Whole-method sticky bits and flags enum { - _trap_hist_limit = 20, // decoupled from Deoptimization::Reason_LIMIT + _trap_hist_limit = 21, // decoupled from Deoptimization::Reason_LIMIT _trap_hist_mask = max_jubyte, _extra_data_count = 4 // extra DataLayout headers, for trap history }; // Public flag values diff --git a/hotspot/src/share/vm/opto/addnode.cpp b/hotspot/src/share/vm/opto/addnode.cpp index a586eba1322..a88ee2e1d22 100644 --- a/hotspot/src/share/vm/opto/addnode.cpp +++ b/hotspot/src/share/vm/opto/addnode.cpp @@ -254,47 +254,46 @@ Node *AddINode::Ideal(PhaseGVN *phase, bool can_reshape) { const Type *t_sub1 = phase->type( in1->in(1) ); const Type *t_2 = phase->type( in2 ); if( t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP ) - return new (phase->C) SubINode(phase->makecon( add_ring( t_sub1, t_2 ) ), - in1->in(2) ); + return new SubINode(phase->makecon( add_ring( t_sub1, t_2 ) ), in1->in(2) ); // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)" if( op2 == Op_SubI ) { // Check for dead cycle: d = (a-b)+(c-d) assert( in1->in(2) != this && in2->in(2) != this, "dead loop in AddINode::Ideal" ); - Node *sub = new (phase->C) SubINode(NULL, NULL); - sub->init_req(1, phase->transform(new (phase->C) AddINode(in1->in(1), in2->in(1) ) )); - sub->init_req(2, phase->transform(new (phase->C) AddINode(in1->in(2), in2->in(2) ) )); + Node *sub = new SubINode(NULL, NULL); + sub->init_req(1, phase->transform(new AddINode(in1->in(1), in2->in(1) ) )); + sub->init_req(2, phase->transform(new AddINode(in1->in(2), in2->in(2) ) )); return sub; } // Convert "(a-b)+(b+c)" into "(a+c)" if( op2 == Op_AddI && in1->in(2) == in2->in(1) ) { assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddINode::Ideal"); - return new (phase->C) AddINode(in1->in(1), in2->in(2)); + return new AddINode(in1->in(1), in2->in(2)); } // Convert "(a-b)+(c+b)" into "(a+c)" if( op2 == Op_AddI && in1->in(2) == in2->in(2) ) { assert(in1->in(1) != this && in2->in(1) != this,"dead loop in AddINode::Ideal"); - return new (phase->C) AddINode(in1->in(1), in2->in(1)); + return new AddINode(in1->in(1), in2->in(1)); } // Convert "(a-b)+(b-c)" into "(a-c)" if( op2 == Op_SubI && in1->in(2) == in2->in(1) ) { assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddINode::Ideal"); - return new (phase->C) SubINode(in1->in(1), in2->in(2)); + return new SubINode(in1->in(1), in2->in(2)); } // Convert "(a-b)+(c-a)" into "(c-b)" if( op2 == Op_SubI && in1->in(1) == in2->in(2) ) { assert(in1->in(2) != this && in2->in(1) != this,"dead loop in AddINode::Ideal"); - return new (phase->C) SubINode(in2->in(1), in1->in(2)); + return new SubINode(in2->in(1), in1->in(2)); } } // Convert "x+(0-y)" into "(x-y)" if( op2 == Op_SubI && phase->type(in2->in(1)) == TypeInt::ZERO ) - return new (phase->C) SubINode(in1, in2->in(2) ); + return new SubINode(in1, in2->in(2) ); // Convert "(0-y)+x" into "(x-y)" if( op1 == Op_SubI && phase->type(in1->in(1)) == TypeInt::ZERO ) - return new (phase->C) SubINode( in2, in1->in(2) ); + return new SubINode( in2, in1->in(2) ); // Convert (x>>>z)+y into (x+(y<>>z for small constant z and y. // Helps with array allocation math constant folding @@ -315,8 +314,8 @@ Node *AddINode::Ideal(PhaseGVN *phase, bool can_reshape) { if( z < 5 && -5 < y && y < 0 ) { const Type *t_in11 = phase->type(in1->in(1)); if( t_in11 != Type::TOP && (t_in11->is_int()->_lo >= -(y << z)) ) { - Node *a = phase->transform( new (phase->C) AddINode( in1->in(1), phase->intcon(y<C) URShiftINode( a, in1->in(2) ); + Node *a = phase->transform( new AddINode( in1->in(1), phase->intcon(y<in(2) ); } } } @@ -387,47 +386,46 @@ Node *AddLNode::Ideal(PhaseGVN *phase, bool can_reshape) { const Type *t_sub1 = phase->type( in1->in(1) ); const Type *t_2 = phase->type( in2 ); if( t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP ) - return new (phase->C) SubLNode(phase->makecon( add_ring( t_sub1, t_2 ) ), - in1->in(2) ); + return new SubLNode(phase->makecon( add_ring( t_sub1, t_2 ) ), in1->in(2) ); // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)" if( op2 == Op_SubL ) { // Check for dead cycle: d = (a-b)+(c-d) assert( in1->in(2) != this && in2->in(2) != this, "dead loop in AddLNode::Ideal" ); - Node *sub = new (phase->C) SubLNode(NULL, NULL); - sub->init_req(1, phase->transform(new (phase->C) AddLNode(in1->in(1), in2->in(1) ) )); - sub->init_req(2, phase->transform(new (phase->C) AddLNode(in1->in(2), in2->in(2) ) )); + Node *sub = new SubLNode(NULL, NULL); + sub->init_req(1, phase->transform(new AddLNode(in1->in(1), in2->in(1) ) )); + sub->init_req(2, phase->transform(new AddLNode(in1->in(2), in2->in(2) ) )); return sub; } // Convert "(a-b)+(b+c)" into "(a+c)" if( op2 == Op_AddL && in1->in(2) == in2->in(1) ) { assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddLNode::Ideal"); - return new (phase->C) AddLNode(in1->in(1), in2->in(2)); + return new AddLNode(in1->in(1), in2->in(2)); } // Convert "(a-b)+(c+b)" into "(a+c)" if( op2 == Op_AddL && in1->in(2) == in2->in(2) ) { assert(in1->in(1) != this && in2->in(1) != this,"dead loop in AddLNode::Ideal"); - return new (phase->C) AddLNode(in1->in(1), in2->in(1)); + return new AddLNode(in1->in(1), in2->in(1)); } // Convert "(a-b)+(b-c)" into "(a-c)" if( op2 == Op_SubL && in1->in(2) == in2->in(1) ) { assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddLNode::Ideal"); - return new (phase->C) SubLNode(in1->in(1), in2->in(2)); + return new SubLNode(in1->in(1), in2->in(2)); } // Convert "(a-b)+(c-a)" into "(c-b)" if( op2 == Op_SubL && in1->in(1) == in1->in(2) ) { assert(in1->in(2) != this && in2->in(1) != this,"dead loop in AddLNode::Ideal"); - return new (phase->C) SubLNode(in2->in(1), in1->in(2)); + return new SubLNode(in2->in(1), in1->in(2)); } } // Convert "x+(0-y)" into "(x-y)" if( op2 == Op_SubL && phase->type(in2->in(1)) == TypeLong::ZERO ) - return new (phase->C) SubLNode( in1, in2->in(2) ); + return new SubLNode( in1, in2->in(2) ); // Convert "(0-y)+x" into "(x-y)" if( op1 == Op_SubL && phase->type(in1->in(1)) == TypeInt::ZERO ) - return new (phase->C) SubLNode( in2, in1->in(2) ); + return new SubLNode( in2, in1->in(2) ); // Convert "X+X+X+X+X...+X+Y" into "k*X+Y" or really convert "X+(X+Y)" // into "(X<<1)+Y" and let shift-folding happen. @@ -435,8 +433,8 @@ Node *AddLNode::Ideal(PhaseGVN *phase, bool can_reshape) { in2->in(1) == in1 && op1 != Op_ConL && 0 ) { - Node *shift = phase->transform(new (phase->C) LShiftLNode(in1,phase->intcon(1))); - return new (phase->C) AddLNode(shift,in2->in(2)); + Node *shift = phase->transform(new LShiftLNode(in1,phase->intcon(1))); + return new AddLNode(shift,in2->in(2)); } return AddNode::Ideal(phase, can_reshape); @@ -596,7 +594,7 @@ Node *AddPNode::Ideal(PhaseGVN *phase, bool can_reshape) { offset = phase->MakeConX(t2->get_con() + t12->get_con()); } else { // Else move the constant to the right. ((A+con)+B) into ((A+B)+con) - address = phase->transform(new (phase->C) AddPNode(in(Base),addp->in(Address),in(Offset))); + address = phase->transform(new AddPNode(in(Base),addp->in(Address),in(Offset))); offset = addp->in(Offset); } PhaseIterGVN *igvn = phase->is_IterGVN(); @@ -616,7 +614,7 @@ Node *AddPNode::Ideal(PhaseGVN *phase, bool can_reshape) { // If this is a NULL+long form (from unsafe accesses), switch to a rawptr. if (phase->type(in(Address)) == TypePtr::NULL_PTR) { Node* offset = in(Offset); - return new (phase->C) CastX2PNode(offset); + return new CastX2PNode(offset); } } @@ -628,7 +626,7 @@ Node *AddPNode::Ideal(PhaseGVN *phase, bool can_reshape) { if( add->Opcode() == Op_AddX && add->in(1) != add ) { const Type *t22 = phase->type( add->in(2) ); if( t22->singleton() && (t22 != Type::TOP) ) { // Right input is an add of a constant? - set_req(Address, phase->transform(new (phase->C) AddPNode(in(Base),in(Address),add->in(1)))); + set_req(Address, phase->transform(new AddPNode(in(Base),in(Address),add->in(1)))); set_req(Offset, add->in(2)); PhaseIterGVN *igvn = phase->is_IterGVN(); if (add->outcnt() == 0 && igvn) { @@ -858,7 +856,7 @@ Node *MinINode::Ideal(PhaseGVN *phase, bool can_reshape) { // to force a right-spline graph for the rest of MinINode::Ideal(). if( l->Opcode() == Op_MinI ) { assert( l != l->in(1), "dead loop in MinINode::Ideal" ); - r = phase->transform(new (phase->C) MinINode(l->in(2),r)); + r = phase->transform(new MinINode(l->in(2),r)); l = l->in(1); set_req(1, l); set_req(2, r); @@ -906,18 +904,18 @@ Node *MinINode::Ideal(PhaseGVN *phase, bool can_reshape) { } if( x->_idx > y->_idx ) - return new (phase->C) MinINode(r->in(1),phase->transform(new (phase->C) MinINode(l,r->in(2)))); + return new MinINode(r->in(1),phase->transform(new MinINode(l,r->in(2)))); // See if covers: MIN2(x+c0,MIN2(y+c1,z)) if( !phase->eqv(x,y) ) return NULL; // If (y == x) transform MIN2(x+c0, MIN2(x+c1,z)) into // MIN2(x+c0 or x+c1 which less, z). - return new (phase->C) MinINode(phase->transform(new (phase->C) AddINode(x,phase->intcon(MIN2(x_off,y_off)))),r->in(2)); + return new MinINode(phase->transform(new AddINode(x,phase->intcon(MIN2(x_off,y_off)))),r->in(2)); } else { // See if covers: MIN2(x+c0,y+c1) if( !phase->eqv(x,y) ) return NULL; // If (y == x) transform MIN2(x+c0,x+c1) into x+c0 or x+c1 which less. - return new (phase->C) AddINode(x,phase->intcon(MIN2(x_off,y_off))); + return new AddINode(x,phase->intcon(MIN2(x_off,y_off))); } } diff --git a/hotspot/src/share/vm/opto/block.cpp b/hotspot/src/share/vm/opto/block.cpp index 85598d636a3..7c32b68d015 100644 --- a/hotspot/src/share/vm/opto/block.cpp +++ b/hotspot/src/share/vm/opto/block.cpp @@ -373,7 +373,7 @@ PhaseCFG::PhaseCFG(Arena* arena, RootNode* root, Matcher& matcher) // I'll need a few machine-specific GotoNodes. Make an Ideal GotoNode, // then Match it into a machine-specific Node. Then clone the machine // Node on demand. - Node *x = new (C) GotoNode(NULL); + Node *x = new GotoNode(NULL); x->init_req(0, x); _goto = matcher.match_tree(x); assert(_goto != NULL, ""); @@ -426,7 +426,7 @@ uint PhaseCFG::build_cfg() { !p->is_block_start() ); // Make the block begin with one of Region or StartNode. if( !p->is_block_start() ) { - RegionNode *r = new (C) RegionNode( 2 ); + RegionNode *r = new RegionNode( 2 ); r->init_req(1, p); // Insert RegionNode in the way proj->set_req(0, r); // Insert RegionNode in the way p = r; @@ -501,7 +501,7 @@ void PhaseCFG::insert_goto_at(uint block_no, uint succ_no) { // get ProjNode corresponding to the succ_no'th successor of the in block ProjNode* proj = in->get_node(in->number_of_nodes() - in->_num_succs + succ_no)->as_Proj(); // create region for basic block - RegionNode* region = new (C) RegionNode(2); + RegionNode* region = new RegionNode(2); region->init_req(1, proj); // setup corresponding basic block Block* block = new (_block_arena) Block(_block_arena, region); diff --git a/hotspot/src/share/vm/opto/bytecodeInfo.cpp b/hotspot/src/share/vm/opto/bytecodeInfo.cpp index 101d5f73325..c4ee166a20c 100644 --- a/hotspot/src/share/vm/opto/bytecodeInfo.cpp +++ b/hotspot/src/share/vm/opto/bytecodeInfo.cpp @@ -361,11 +361,14 @@ bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method, set_msg("not an accessor"); return false; } + + // Limit inlining depth in case inlining is forced or + // _max_inline_level was increased to compensate for lambda forms. + if (inline_level() > MaxForceInlineLevel) { + set_msg("MaxForceInlineLevel"); + return false; + } if (inline_level() > _max_inline_level) { - if (callee_method->force_inline() && inline_level() > MaxForceInlineLevel) { - set_msg("MaxForceInlineLevel"); - return false; - } if (!callee_method->force_inline() || !IncrementalInline) { set_msg("inlining too deep"); return false; diff --git a/hotspot/src/share/vm/opto/c2_globals.hpp b/hotspot/src/share/vm/opto/c2_globals.hpp index 4f45d28666b..d745cbb022b 100644 --- a/hotspot/src/share/vm/opto/c2_globals.hpp +++ b/hotspot/src/share/vm/opto/c2_globals.hpp @@ -650,9 +650,6 @@ product(bool, UseMathExactIntrinsics, true, \ "Enables intrinsification of various java.lang.Math functions") \ \ - experimental(bool, ReplaceInParentMaps, false, \ - "Propagate type improvements in callers of inlinee if possible") \ - \ product(bool, UseTypeSpeculation, true, \ "Speculatively propagate types from profiles") \ \ diff --git a/hotspot/src/share/vm/opto/callGenerator.cpp b/hotspot/src/share/vm/opto/callGenerator.cpp index 249e0215c60..73282119981 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, Parse* parent_parser); + virtual JVMState* generate(JVMState* jvms); int is_osr() { return _is_osr; } }; -JVMState* ParseGenerator::generate(JVMState* jvms, Parse* parent_parser) { +JVMState* ParseGenerator::generate(JVMState* jvms) { Compile* C = Compile::current(); C->print_inlining_update(this); @@ -81,7 +81,7 @@ JVMState* ParseGenerator::generate(JVMState* jvms, Parse* parent_parser) { return NULL; // bailing out of the compile; do not try to parse } - Parse parser(jvms, method(), _expected_uses, parent_parser); + Parse parser(jvms, method(), _expected_uses); // Grab signature for matching/allocation #ifdef ASSERT if (parser.tf() != (parser.depth() == 1 ? C->tf() : tf())) { @@ -120,12 +120,12 @@ class DirectCallGenerator : public CallGenerator { _separate_io_proj(separate_io_proj) { } - virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); + virtual JVMState* generate(JVMState* jvms); CallStaticJavaNode* call_node() const { return _call_node; } }; -JVMState* DirectCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { +JVMState* DirectCallGenerator::generate(JVMState* jvms) { GraphKit kit(jvms); kit.C->print_inlining_update(this); bool is_static = method()->is_static(); @@ -136,7 +136,7 @@ JVMState* DirectCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { kit.C->log()->elem("direct_call bci='%d'", jvms->bci()); } - CallStaticJavaNode *call = new (kit.C) CallStaticJavaNode(kit.C, tf(), target, method(), kit.bci()); + CallStaticJavaNode *call = new CallStaticJavaNode(kit.C, tf(), target, method(), kit.bci()); _call_node = call; // Save the call node in case we need it later if (!is_static) { // Make an explicit receiver null_check as part of this call. @@ -173,10 +173,10 @@ public: vtable_index >= 0, "either invalid or usable"); } virtual bool is_virtual() const { return true; } - virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); + virtual JVMState* generate(JVMState* jvms); }; -JVMState* VirtualCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { +JVMState* VirtualCallGenerator::generate(JVMState* jvms) { GraphKit kit(jvms); Node* receiver = kit.argument(0); @@ -225,7 +225,7 @@ JVMState* VirtualCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { "no vtable calls if +UseInlineCaches "); address target = SharedRuntime::get_resolve_virtual_call_stub(); // Normal inline cache used for call - CallDynamicJavaNode *call = new (kit.C) CallDynamicJavaNode(tf(), target, method(), _vtable_index, kit.bci()); + CallDynamicJavaNode *call = new CallDynamicJavaNode(tf(), target, method(), _vtable_index, kit.bci()); kit.set_arguments_for_java_call(call); kit.set_edges_for_java_call(call); Node* ret = kit.set_results_for_java_call(call); @@ -283,7 +283,7 @@ class LateInlineCallGenerator : public DirectCallGenerator { // Convert the CallStaticJava into an inline virtual void do_late_inline(); - virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) { + virtual JVMState* generate(JVMState* jvms) { Compile *C = Compile::current(); C->log_inline_id(this); @@ -298,7 +298,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, parent_parser); + return DirectCallGenerator::generate(jvms); } virtual void print_inlining_late(const char* msg) { @@ -350,7 +350,7 @@ void LateInlineCallGenerator::do_late_inline() { JVMState* old_jvms = call->jvms(); JVMState* jvms = old_jvms->clone_shallow(C); uint size = call->req(); - SafePointNode* map = new (C) SafePointNode(size, jvms); + SafePointNode* map = new SafePointNode(size, jvms); for (uint i1 = 0; i1 < size; i1++) { map->init_req(i1, call->in(i1)); } @@ -399,7 +399,7 @@ void LateInlineCallGenerator::do_late_inline() { } // Now perform the inlining using the synthesized JVMState - JVMState* new_jvms = _inline_cg->generate(jvms, NULL); + JVMState* new_jvms = _inline_cg->generate(jvms); if (new_jvms == NULL) return; // no change if (C->failing()) return; @@ -417,7 +417,7 @@ void LateInlineCallGenerator::do_late_inline() { C->env()->notice_inlined_method(_inline_cg->method()); C->set_inlining_progress(true); - kit.replace_call(call, result); + kit.replace_call(call, result, true); } @@ -439,8 +439,8 @@ class LateInlineMHCallGenerator : public LateInlineCallGenerator { virtual bool is_mh_late_inline() const { return true; } - virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) { - JVMState* new_jvms = LateInlineCallGenerator::generate(jvms, parent_parser); + virtual JVMState* generate(JVMState* jvms) { + JVMState* new_jvms = LateInlineCallGenerator::generate(jvms); Compile* C = Compile::current(); if (_input_not_const) { @@ -486,14 +486,14 @@ class LateInlineStringCallGenerator : public LateInlineCallGenerator { LateInlineStringCallGenerator(ciMethod* method, CallGenerator* inline_cg) : LateInlineCallGenerator(method, inline_cg) {} - virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) { + virtual JVMState* generate(JVMState* jvms) { Compile *C = Compile::current(); C->log_inline_id(this); C->add_string_late_inline(this); - JVMState* new_jvms = DirectCallGenerator::generate(jvms, parent_parser); + JVMState* new_jvms = DirectCallGenerator::generate(jvms); return new_jvms; } @@ -510,14 +510,14 @@ class LateInlineBoxingCallGenerator : public LateInlineCallGenerator { LateInlineBoxingCallGenerator(ciMethod* method, CallGenerator* inline_cg) : LateInlineCallGenerator(method, inline_cg) {} - virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) { + virtual JVMState* generate(JVMState* jvms) { Compile *C = Compile::current(); C->log_inline_id(this); C->add_boxing_late_inline(this); - JVMState* new_jvms = DirectCallGenerator::generate(jvms, parent_parser); + JVMState* new_jvms = DirectCallGenerator::generate(jvms); return new_jvms; } }; @@ -553,7 +553,7 @@ public: virtual bool is_virtual() const { return _is_virtual; } virtual bool is_deferred() const { return true; } - virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); + virtual JVMState* generate(JVMState* jvms); }; @@ -563,14 +563,14 @@ CallGenerator* CallGenerator::for_warm_call(WarmCallInfo* ci, return new WarmCallGenerator(ci, if_cold, if_hot); } -JVMState* WarmCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { +JVMState* WarmCallGenerator::generate(JVMState* jvms) { Compile* C = Compile::current(); C->print_inlining_update(this); if (C->log() != NULL) { C->log()->elem("warm_call bci='%d'", jvms->bci()); } - jvms = _if_cold->generate(jvms, parent_parser); + jvms = _if_cold->generate(jvms); if (jvms != NULL) { Node* m = jvms->map()->control(); if (m->is_CatchProj()) m = m->in(0); else m = C->top(); @@ -631,7 +631,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, Parse* parent_parser); + virtual JVMState* generate(JVMState* jvms); }; @@ -643,14 +643,13 @@ CallGenerator* CallGenerator::for_predicted_call(ciKlass* predicted_receiver, } -JVMState* PredictedCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { +JVMState* PredictedCallGenerator::generate(JVMState* jvms) { GraphKit kit(jvms); kit.C->print_inlining_update(this); PhaseGVN& gvn = kit.gvn(); // We need an explicit receiver null_check before checking its type. // We share a map with the caller, so his JVMS gets adjusted. Node* receiver = kit.argument(0); - CompileLog* log = kit.C->log(); if (log != NULL) { log->elem("predicted_call bci='%d' klass='%d'", @@ -662,6 +661,10 @@ JVMState* PredictedCallGenerator::generate(JVMState* jvms, Parse* parent_parser) return kit.transfer_exceptions_into_jvms(); } + // Make a copy of the replaced nodes in case we need to restore them + ReplacedNodes replaced_nodes = kit.map()->replaced_nodes(); + replaced_nodes.clone(); + Node* exact_receiver = receiver; // will get updated in place... Node* slow_ctl = kit.type_check_receiver(receiver, _predicted_receiver, _hit_prob, @@ -672,7 +675,7 @@ JVMState* PredictedCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { PreserveJVMState pjvms(&kit); kit.set_control(slow_ctl); if (!kit.stopped()) { - slow_jvms = _if_missed->generate(kit.sync_jvms(), parent_parser); + slow_jvms = _if_missed->generate(kit.sync_jvms()); if (kit.failing()) return NULL; // might happen because of NodeCountInliningCutoff assert(slow_jvms != NULL, "must be"); @@ -693,12 +696,12 @@ JVMState* PredictedCallGenerator::generate(JVMState* jvms, Parse* parent_parser) kit.replace_in_map(receiver, exact_receiver); // Make the hot call: - JVMState* new_jvms = _if_hit->generate(kit.sync_jvms(), parent_parser); + JVMState* new_jvms = _if_hit->generate(kit.sync_jvms()); 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(), parent_parser); + new_jvms = cg->generate(kit.sync_jvms()); } kit.add_exception_states_from(new_jvms); kit.set_jvms(new_jvms); @@ -715,16 +718,29 @@ JVMState* PredictedCallGenerator::generate(JVMState* jvms, Parse* parent_parser) return kit.transfer_exceptions_into_jvms(); } + // There are 2 branches and the replaced nodes are only valid on + // one: restore the replaced nodes to what they were before the + // branch. + kit.map()->set_replaced_nodes(replaced_nodes); + // Finish the diamond. kit.C->set_has_split_ifs(true); // Has chance for split-if optimization - RegionNode* region = new (kit.C) RegionNode(3); + RegionNode* region = new RegionNode(3); region->init_req(1, kit.control()); region->init_req(2, slow_map->control()); kit.set_control(gvn.transform(region)); Node* iophi = PhiNode::make(region, kit.i_o(), Type::ABIO); iophi->set_req(2, slow_map->i_o()); kit.set_i_o(gvn.transform(iophi)); + // Merge memory kit.merge_memory(slow_map->merged_memory(), region, 2); + // Transform new memory Phis. + for (MergeMemStream mms(kit.merged_memory()); mms.next_non_empty();) { + Node* phi = mms.memory(); + if (phi->is_Phi() && phi->in(0) == region) { + mms.set_memory(gvn.transform(phi)); + } + } uint tos = kit.jvms()->stkoff() + kit.sp(); uint limit = slow_map->req(); for (uint i = TypeFunc::Parms; i < limit; i++) { @@ -825,7 +841,7 @@ CallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod* const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr(); const Type* sig_type = TypeOopPtr::make_from_klass(signature->accessing_klass()); if (arg_type != NULL && !arg_type->higher_equal(sig_type)) { - Node* cast_obj = gvn.transform(new (C) CheckCastPPNode(kit.control(), arg, sig_type)); + Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type)); kit.set_argument(0, cast_obj); } } @@ -837,7 +853,7 @@ CallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod* const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr(); const Type* sig_type = TypeOopPtr::make_from_klass(t->as_klass()); if (arg_type != NULL && !arg_type->higher_equal(sig_type)) { - Node* cast_obj = gvn.transform(new (C) CheckCastPPNode(kit.control(), arg, sig_type)); + Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, sig_type)); kit.set_argument(receiver_skip + i, cast_obj); } } @@ -882,15 +898,15 @@ CallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod* } -//------------------------PredictedIntrinsicGenerator------------------------------ -// Internal class which handles all predicted Intrinsic calls. -class PredictedIntrinsicGenerator : public CallGenerator { +//------------------------PredicatedIntrinsicGenerator------------------------------ +// Internal class which handles all predicated Intrinsic calls. +class PredicatedIntrinsicGenerator : public CallGenerator { CallGenerator* _intrinsic; CallGenerator* _cg; public: - PredictedIntrinsicGenerator(CallGenerator* intrinsic, - CallGenerator* cg) + PredicatedIntrinsicGenerator(CallGenerator* intrinsic, + CallGenerator* cg) : CallGenerator(cg->method()) { _intrinsic = intrinsic; @@ -901,108 +917,186 @@ public: virtual bool is_inlined() const { return true; } virtual bool is_intrinsic() const { return true; } - virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); + virtual JVMState* generate(JVMState* jvms); }; -CallGenerator* CallGenerator::for_predicted_intrinsic(CallGenerator* intrinsic, - CallGenerator* cg) { - return new PredictedIntrinsicGenerator(intrinsic, cg); +CallGenerator* CallGenerator::for_predicated_intrinsic(CallGenerator* intrinsic, + CallGenerator* cg) { + return new PredicatedIntrinsicGenerator(intrinsic, cg); } -JVMState* PredictedIntrinsicGenerator::generate(JVMState* jvms, Parse* parent_parser) { +JVMState* PredicatedIntrinsicGenerator::generate(JVMState* jvms) { + // The code we want to generate here is: + // if (receiver == NULL) + // uncommon_Trap + // if (predicate(0)) + // do_intrinsic(0) + // else + // if (predicate(1)) + // do_intrinsic(1) + // ... + // else + // do_java_comp + GraphKit kit(jvms); PhaseGVN& gvn = kit.gvn(); CompileLog* log = kit.C->log(); if (log != NULL) { - log->elem("predicted_intrinsic bci='%d' method='%d'", + log->elem("predicated_intrinsic bci='%d' method='%d'", jvms->bci(), log->identify(method())); } - Node* slow_ctl = _intrinsic->generate_predicate(kit.sync_jvms()); - if (kit.failing()) - return NULL; // might happen because of NodeCountInliningCutoff - - kit.C->print_inlining_update(this); - SafePointNode* slow_map = NULL; - JVMState* slow_jvms; - if (slow_ctl != NULL) { - PreserveJVMState pjvms(&kit); - kit.set_control(slow_ctl); - if (!kit.stopped()) { - 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"); - kit.add_exception_states_from(slow_jvms); - kit.set_map(slow_jvms->map()); - if (!kit.stopped()) - slow_map = kit.stop(); - } - } - - if (kit.stopped()) { - // Predicate is always false. - kit.set_jvms(slow_jvms); - return kit.transfer_exceptions_into_jvms(); - } - - // Generate intrinsic code: - 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(), parent_parser); - } else { - kit.set_jvms(slow_jvms); + if (!method()->is_static()) { + // We need an explicit receiver null_check before checking its type in predicate. + // We share a map with the caller, so his JVMS gets adjusted. + Node* receiver = kit.null_check_receiver_before_call(method()); + if (kit.stopped()) { return kit.transfer_exceptions_into_jvms(); } } - kit.add_exception_states_from(new_jvms); - kit.set_jvms(new_jvms); - // Need to merge slow and fast? - if (slow_map == NULL) { - // The fast path is the only path remaining. + int n_predicates = _intrinsic->predicates_count(); + assert(n_predicates > 0, "sanity"); + + JVMState** result_jvms = NEW_RESOURCE_ARRAY(JVMState*, (n_predicates+1)); + + // Region for normal compilation code if intrinsic failed. + Node* slow_region = new RegionNode(1); + + int results = 0; + for (int predicate = 0; (predicate < n_predicates) && !kit.stopped(); predicate++) { +#ifdef ASSERT + JVMState* old_jvms = kit.jvms(); + SafePointNode* old_map = kit.map(); + Node* old_io = old_map->i_o(); + Node* old_mem = old_map->memory(); + Node* old_exc = old_map->next_exception(); +#endif + Node* else_ctrl = _intrinsic->generate_predicate(kit.sync_jvms(), predicate); +#ifdef ASSERT + // Assert(no_new_memory && no_new_io && no_new_exceptions) after generate_predicate. + assert(old_jvms == kit.jvms(), "generate_predicate should not change jvm state"); + SafePointNode* new_map = kit.map(); + assert(old_io == new_map->i_o(), "generate_predicate should not change i_o"); + assert(old_mem == new_map->memory(), "generate_predicate should not change memory"); + assert(old_exc == new_map->next_exception(), "generate_predicate should not add exceptions"); +#endif + if (!kit.stopped()) { + PreserveJVMState pjvms(&kit); + // Generate intrinsic code: + JVMState* new_jvms = _intrinsic->generate(kit.sync_jvms()); + if (new_jvms == NULL) { + // Intrinsic failed, use normal compilation path for this predicate. + slow_region->add_req(kit.control()); + } else { + kit.add_exception_states_from(new_jvms); + kit.set_jvms(new_jvms); + if (!kit.stopped()) { + result_jvms[results++] = kit.jvms(); + } + } + } + if (else_ctrl == NULL) { + else_ctrl = kit.C->top(); + } + kit.set_control(else_ctrl); + } + if (!kit.stopped()) { + // Final 'else' after predicates. + slow_region->add_req(kit.control()); + } + if (slow_region->req() > 1) { + PreserveJVMState pjvms(&kit); + // Generate normal compilation code: + kit.set_control(gvn.transform(slow_region)); + JVMState* new_jvms = _cg->generate(kit.sync_jvms()); + if (kit.failing()) + return NULL; // might happen because of NodeCountInliningCutoff + assert(new_jvms != NULL, "must be"); + kit.add_exception_states_from(new_jvms); + kit.set_jvms(new_jvms); + if (!kit.stopped()) { + result_jvms[results++] = kit.jvms(); + } + } + + if (results == 0) { + // All paths ended in uncommon traps. + (void) kit.stop(); return kit.transfer_exceptions_into_jvms(); } - if (kit.stopped()) { - // Intrinsic method threw an exception, so it's just the slow path after all. - kit.set_jvms(slow_jvms); + if (results == 1) { // Only one path + kit.set_jvms(result_jvms[0]); return kit.transfer_exceptions_into_jvms(); } - // Finish the diamond. + // Merge all paths. kit.C->set_has_split_ifs(true); // Has chance for split-if optimization - RegionNode* region = new (kit.C) RegionNode(3); - region->init_req(1, kit.control()); - region->init_req(2, slow_map->control()); - kit.set_control(gvn.transform(region)); + RegionNode* region = new RegionNode(results + 1); Node* iophi = PhiNode::make(region, kit.i_o(), Type::ABIO); - iophi->set_req(2, slow_map->i_o()); + for (int i = 0; i < results; i++) { + JVMState* jvms = result_jvms[i]; + int path = i + 1; + SafePointNode* map = jvms->map(); + region->init_req(path, map->control()); + iophi->set_req(path, map->i_o()); + if (i == 0) { + kit.set_jvms(jvms); + } else { + kit.merge_memory(map->merged_memory(), region, path); + } + } + kit.set_control(gvn.transform(region)); kit.set_i_o(gvn.transform(iophi)); - kit.merge_memory(slow_map->merged_memory(), region, 2); + // Transform new memory Phis. + for (MergeMemStream mms(kit.merged_memory()); mms.next_non_empty();) { + Node* phi = mms.memory(); + if (phi->is_Phi() && phi->in(0) == region) { + mms.set_memory(gvn.transform(phi)); + } + } + + // Merge debug info. + Node** ins = NEW_RESOURCE_ARRAY(Node*, results); uint tos = kit.jvms()->stkoff() + kit.sp(); - uint limit = slow_map->req(); + Node* map = kit.map(); + uint limit = map->req(); for (uint i = TypeFunc::Parms; i < limit; i++) { // Skip unused stack slots; fast forward to monoff(); if (i == tos) { i = kit.jvms()->monoff(); if( i >= limit ) break; } - Node* m = kit.map()->in(i); - Node* n = slow_map->in(i); - if (m != n) { - const Type* t = gvn.type(m)->meet_speculative(gvn.type(n)); - Node* phi = PhiNode::make(region, m, t); - phi->set_req(2, n); - kit.map()->set_req(i, gvn.transform(phi)); + Node* n = map->in(i); + ins[0] = n; + const Type* t = gvn.type(n); + bool needs_phi = false; + for (int j = 1; j < results; j++) { + JVMState* jvms = result_jvms[j]; + Node* jmap = jvms->map(); + Node* m = NULL; + if (jmap->req() > i) { + m = jmap->in(i); + if (m != n) { + needs_phi = true; + t = t->meet_speculative(gvn.type(m)); + } + } + ins[j] = m; + } + if (needs_phi) { + Node* phi = PhiNode::make(region, n, t); + for (int j = 1; j < results; j++) { + phi->set_req(j + 1, ins[j]); + } + map->set_req(i, gvn.transform(phi)); } } + return kit.transfer_exceptions_into_jvms(); } @@ -1025,7 +1119,7 @@ public: virtual bool is_virtual() const { ShouldNotReachHere(); return false; } virtual bool is_trap() const { return true; } - virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); + virtual JVMState* generate(JVMState* jvms); }; @@ -1037,7 +1131,7 @@ CallGenerator::for_uncommon_trap(ciMethod* m, } -JVMState* UncommonTrapCallGenerator::generate(JVMState* jvms, Parse* parent_parser) { +JVMState* UncommonTrapCallGenerator::generate(JVMState* jvms) { GraphKit kit(jvms); kit.C->print_inlining_update(this); // Take the trap with arguments pushed on the stack. (Cf. null_check_receiver). diff --git a/hotspot/src/share/vm/opto/callGenerator.hpp b/hotspot/src/share/vm/opto/callGenerator.hpp index 707015ffa4e..238fba2ce4a 100644 --- a/hotspot/src/share/vm/opto/callGenerator.hpp +++ b/hotspot/src/share/vm/opto/callGenerator.hpp @@ -31,8 +31,6 @@ #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. @@ -63,8 +61,9 @@ class CallGenerator : public ResourceObj { virtual bool is_virtual() const { return false; } // is_deferred: The decision whether to inline or not is deferred. virtual bool is_deferred() const { return false; } - // is_predicted: Uses an explicit check against a predicted type. - virtual bool is_predicted() const { return false; } + // is_predicated: Uses an explicit check (predicate). + virtual bool is_predicated() const { return false; } + virtual int predicates_count() const { return 0; } // is_trap: Does not return to the caller. (E.g., uncommon trap.) virtual bool is_trap() const { return false; } // does_virtual_dispatch: Should try inlining as normal method first. @@ -114,7 +113,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, Parse* parent_parser) = 0; + virtual JVMState* generate(JVMState* jvms) = 0; // How to generate a call site that is inlined: static CallGenerator* for_inline(ciMethod* m, float expected_uses = -1); @@ -160,9 +159,9 @@ class CallGenerator : public ResourceObj { // Registry for intrinsics: static CallGenerator* for_intrinsic(ciMethod* m); static void register_intrinsic(ciMethod* m, CallGenerator* cg); - static CallGenerator* for_predicted_intrinsic(CallGenerator* intrinsic, - CallGenerator* cg); - virtual Node* generate_predicate(JVMState* jvms) { return NULL; }; + static CallGenerator* for_predicated_intrinsic(CallGenerator* intrinsic, + CallGenerator* cg); + virtual Node* generate_predicate(JVMState* jvms, int predicate) { return NULL; }; virtual void print_inlining_late(const char* msg) { ShouldNotReachHere(); } diff --git a/hotspot/src/share/vm/opto/callnode.cpp b/hotspot/src/share/vm/opto/callnode.cpp index b2cd166b4dd..275052bf8a9 100644 --- a/hotspot/src/share/vm/opto/callnode.cpp +++ b/hotspot/src/share/vm/opto/callnode.cpp @@ -74,20 +74,20 @@ Node *StartNode::match( const ProjNode *proj, const Matcher *match ) { case TypeFunc::Control: case TypeFunc::I_O: case TypeFunc::Memory: - return new (match->C) MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj); + return new MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj); case TypeFunc::FramePtr: - return new (match->C) MachProjNode(this,proj->_con,Matcher::c_frame_ptr_mask, Op_RegP); + return new MachProjNode(this,proj->_con,Matcher::c_frame_ptr_mask, Op_RegP); case TypeFunc::ReturnAdr: - return new (match->C) MachProjNode(this,proj->_con,match->_return_addr_mask,Op_RegP); + return new MachProjNode(this,proj->_con,match->_return_addr_mask,Op_RegP); case TypeFunc::Parms: default: { uint parm_num = proj->_con - TypeFunc::Parms; const Type *t = _domain->field_at(proj->_con); if (t->base() == Type::Half) // 2nd half of Longs and Doubles - return new (match->C) ConNode(Type::TOP); + return new ConNode(Type::TOP); uint ideal_reg = t->ideal_reg(); RegMask &rm = match->_calling_convention_mask[parm_num]; - return new (match->C) MachProjNode(this,proj->_con,rm,ideal_reg); + return new MachProjNode(this,proj->_con,rm,ideal_reg); } } return NULL; @@ -685,12 +685,12 @@ Node *CallNode::match( const ProjNode *proj, const Matcher *match ) { case TypeFunc::Control: case TypeFunc::I_O: case TypeFunc::Memory: - return new (match->C) MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj); + return new MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj); case TypeFunc::Parms+1: // For LONG & DOUBLE returns assert(tf()->_range->field_at(TypeFunc::Parms+1) == Type::HALF, ""); // 2nd half of doubles and longs - return new (match->C) MachProjNode(this,proj->_con, RegMask::Empty, (uint)OptoReg::Bad); + return new MachProjNode(this,proj->_con, RegMask::Empty, (uint)OptoReg::Bad); case TypeFunc::Parms: { // Normal returns uint ideal_reg = tf()->range()->field_at(TypeFunc::Parms)->ideal_reg(); @@ -700,7 +700,7 @@ Node *CallNode::match( const ProjNode *proj, const Matcher *match ) { RegMask rm = RegMask(regs.first()); if( OptoReg::is_valid(regs.second()) ) rm.Insert( regs.second() ); - return new (match->C) MachProjNode(this,proj->_con,rm,ideal_reg); + return new MachProjNode(this,proj->_con,rm,ideal_reg); } case TypeFunc::ReturnAdr: @@ -1090,6 +1090,7 @@ const Type *SafePointNode::Value( PhaseTransform *phase ) const { #ifndef PRODUCT void SafePointNode::dump_spec(outputStream *st) const { st->print(" SafePoint "); + _replaced_nodes.dump(st); } #endif @@ -1288,10 +1289,10 @@ Node* AllocateArrayNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node* nproj = catchproj->clone(); igvn->register_new_node_with_optimizer(nproj); - Node *frame = new (phase->C) ParmNode( phase->C->start(), TypeFunc::FramePtr ); + Node *frame = new ParmNode( phase->C->start(), TypeFunc::FramePtr ); frame = phase->transform(frame); // Halt & Catch Fire - Node *halt = new (phase->C) HaltNode( nproj, frame ); + Node *halt = new HaltNode( nproj, frame ); phase->C->root()->add_req(halt); phase->transform(halt); @@ -1333,7 +1334,7 @@ Node *AllocateArrayNode::make_ideal_length(const TypeOopPtr* oop_type, PhaseTran if (!allow_new_nodes) return NULL; // Create a cast which is control dependent on the initialization to // propagate the fact that the array length must be positive. - length = new (phase->C) CastIINode(length, narrow_length_type); + length = new CastIINode(length, narrow_length_type); length->set_req(0, initialization()->proj_out(0)); } } diff --git a/hotspot/src/share/vm/opto/callnode.hpp b/hotspot/src/share/vm/opto/callnode.hpp index 398cbfecff9..6eb78b0cb7b 100644 --- a/hotspot/src/share/vm/opto/callnode.hpp +++ b/hotspot/src/share/vm/opto/callnode.hpp @@ -30,6 +30,7 @@ #include "opto/multnode.hpp" #include "opto/opcodes.hpp" #include "opto/phaseX.hpp" +#include "opto/replacednodes.hpp" #include "opto/type.hpp" // Portions of code courtesy of Clifford Click @@ -335,6 +336,7 @@ public: OopMap* _oop_map; // Array of OopMap info (8-bit char) for GC JVMState* const _jvms; // Pointer to list of JVM State objects const TypePtr* _adr_type; // What type of memory does this node produce? + ReplacedNodes _replaced_nodes; // During parsing: list of pair of nodes from calls to GraphKit::replace_in_map() // Many calls take *all* of memory as input, // but some produce a limited subset of that memory as output. @@ -426,6 +428,37 @@ public: void set_next_exception(SafePointNode* n); bool has_exceptions() const { return next_exception() != NULL; } + // Helper methods to operate on replaced nodes + ReplacedNodes replaced_nodes() const { + return _replaced_nodes; + } + + void set_replaced_nodes(ReplacedNodes replaced_nodes) { + _replaced_nodes = replaced_nodes; + } + + void clone_replaced_nodes() { + _replaced_nodes.clone(); + } + void record_replaced_node(Node* initial, Node* improved) { + _replaced_nodes.record(initial, improved); + } + void transfer_replaced_nodes_from(SafePointNode* sfpt, uint idx = 0) { + _replaced_nodes.transfer_from(sfpt->_replaced_nodes, idx); + } + void delete_replaced_nodes() { + _replaced_nodes.reset(); + } + void apply_replaced_nodes() { + _replaced_nodes.apply(this); + } + void merge_replaced_nodes_with(SafePointNode* sfpt) { + _replaced_nodes.merge_with(sfpt->_replaced_nodes); + } + bool has_replaced_nodes() const { + return !_replaced_nodes.is_empty(); + } + // Standard Node stuff virtual int Opcode() const; virtual bool pinned() const { return true; } diff --git a/hotspot/src/share/vm/opto/castnode.cpp b/hotspot/src/share/vm/opto/castnode.cpp index b8a35a72df9..afaddaf72fb 100644 --- a/hotspot/src/share/vm/opto/castnode.cpp +++ b/hotspot/src/share/vm/opto/castnode.cpp @@ -228,11 +228,11 @@ static inline Node* addP_of_X2P(PhaseGVN *phase, Node* dispX, bool negate = false) { if (negate) { - dispX = new (phase->C) SubXNode(phase->MakeConX(0), phase->transform(dispX)); + dispX = new SubXNode(phase->MakeConX(0), phase->transform(dispX)); } - return new (phase->C) AddPNode(phase->C->top(), - phase->transform(new (phase->C) CastX2PNode(base)), - phase->transform(dispX)); + return new AddPNode(phase->C->top(), + phase->transform(new CastX2PNode(base)), + phase->transform(dispX)); } Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) { diff --git a/hotspot/src/share/vm/opto/cfgnode.cpp b/hotspot/src/share/vm/opto/cfgnode.cpp index 02ec25fda2d..d99118edc83 100644 --- a/hotspot/src/share/vm/opto/cfgnode.cpp +++ b/hotspot/src/share/vm/opto/cfgnode.cpp @@ -662,17 +662,17 @@ Node *RegionNode::Ideal(PhaseGVN *phase, bool can_reshape) { convf2i->in(1) == bot_in ) { // Matched pattern, including LShiftI; RShiftI, replace with integer compares // max test - Node *cmp = gvn->register_new_node_with_optimizer(new (phase->C) CmpINode( convf2i, min )); - Node *boo = gvn->register_new_node_with_optimizer(new (phase->C) BoolNode( cmp, BoolTest::lt )); - IfNode *iff = (IfNode*)gvn->register_new_node_with_optimizer(new (phase->C) IfNode( top_if->in(0), boo, PROB_UNLIKELY_MAG(5), top_if->_fcnt )); - Node *if_min= gvn->register_new_node_with_optimizer(new (phase->C) IfTrueNode (iff)); - Node *ifF = gvn->register_new_node_with_optimizer(new (phase->C) IfFalseNode(iff)); + Node *cmp = gvn->register_new_node_with_optimizer(new CmpINode( convf2i, min )); + Node *boo = gvn->register_new_node_with_optimizer(new BoolNode( cmp, BoolTest::lt )); + IfNode *iff = (IfNode*)gvn->register_new_node_with_optimizer(new IfNode( top_if->in(0), boo, PROB_UNLIKELY_MAG(5), top_if->_fcnt )); + Node *if_min= gvn->register_new_node_with_optimizer(new IfTrueNode (iff)); + Node *ifF = gvn->register_new_node_with_optimizer(new IfFalseNode(iff)); // min test - cmp = gvn->register_new_node_with_optimizer(new (phase->C) CmpINode( convf2i, max )); - boo = gvn->register_new_node_with_optimizer(new (phase->C) BoolNode( cmp, BoolTest::gt )); - iff = (IfNode*)gvn->register_new_node_with_optimizer(new (phase->C) IfNode( ifF, boo, PROB_UNLIKELY_MAG(5), bot_if->_fcnt )); - Node *if_max= gvn->register_new_node_with_optimizer(new (phase->C) IfTrueNode (iff)); - ifF = gvn->register_new_node_with_optimizer(new (phase->C) IfFalseNode(iff)); + cmp = gvn->register_new_node_with_optimizer(new CmpINode( convf2i, max )); + boo = gvn->register_new_node_with_optimizer(new BoolNode( cmp, BoolTest::gt )); + iff = (IfNode*)gvn->register_new_node_with_optimizer(new IfNode( ifF, boo, PROB_UNLIKELY_MAG(5), bot_if->_fcnt )); + Node *if_max= gvn->register_new_node_with_optimizer(new IfTrueNode (iff)); + ifF = gvn->register_new_node_with_optimizer(new IfFalseNode(iff)); // update input edges to region node set_req_X( min_idx, if_min, gvn ); set_req_X( max_idx, if_max, gvn ); @@ -731,7 +731,7 @@ const TypePtr* flatten_phi_adr_type(const TypePtr* at) { PhiNode* PhiNode::make(Node* r, Node* x, const Type *t, const TypePtr* at) { uint preds = r->req(); // Number of predecessor paths assert(t != Type::MEMORY || at == flatten_phi_adr_type(at), "flatten at"); - PhiNode* p = new (Compile::current()) PhiNode(r, t, at); + PhiNode* p = new PhiNode(r, t, at); for (uint j = 1; j < preds; j++) { // Fill in all inputs, except those which the region does not yet have if (r->in(j) != NULL) @@ -749,7 +749,7 @@ PhiNode* PhiNode::make_blank(Node* r, Node* x) { const Type* t = x->bottom_type(); const TypePtr* at = NULL; if (t == Type::MEMORY) at = flatten_phi_adr_type(x->adr_type()); - return new (Compile::current()) PhiNode(r, t, at); + return new PhiNode(r, t, at); } @@ -1258,9 +1258,9 @@ static Node *is_x2logic( PhaseGVN *phase, PhiNode *phi, int true_path ) { } else return NULL; // Build int->bool conversion - Node *n = new (phase->C) Conv2BNode( cmp->in(1) ); + Node *n = new Conv2BNode( cmp->in(1) ); if( flipped ) - n = new (phase->C) XorINode( phase->transform(n), phase->intcon(1) ); + n = new XorINode( phase->transform(n), phase->intcon(1) ); return n; } @@ -1320,9 +1320,9 @@ static Node* is_cond_add(PhaseGVN *phase, PhiNode *phi, int true_path) { if( q->is_Con() && phase->type(q) != TypeInt::ZERO && y->is_Con() ) return NULL; - Node *cmplt = phase->transform( new (phase->C) CmpLTMaskNode(p,q) ); - Node *j_and = phase->transform( new (phase->C) AndINode(cmplt,y) ); - return new (phase->C) AddINode(j_and,x); + Node *cmplt = phase->transform( new CmpLTMaskNode(p,q) ); + Node *j_and = phase->transform( new AndINode(cmplt,y) ); + return new AddINode(j_and,x); } //------------------------------is_absolute------------------------------------ @@ -1384,17 +1384,17 @@ static Node* is_absolute( PhaseGVN *phase, PhiNode *phi_root, int true_path) { if( sub->Opcode() != Op_SubF || sub->in(2) != x || phase->type(sub->in(1)) != tzero ) return NULL; - x = new (phase->C) AbsFNode(x); + x = new AbsFNode(x); if (flip) { - x = new (phase->C) SubFNode(sub->in(1), phase->transform(x)); + x = new SubFNode(sub->in(1), phase->transform(x)); } } else { if( sub->Opcode() != Op_SubD || sub->in(2) != x || phase->type(sub->in(1)) != tzero ) return NULL; - x = new (phase->C) AbsDNode(x); + x = new AbsDNode(x); if (flip) { - x = new (phase->C) SubDNode(sub->in(1), phase->transform(x)); + x = new SubDNode(sub->in(1), phase->transform(x)); } } @@ -1469,7 +1469,7 @@ static Node* split_flow_path(PhaseGVN *phase, PhiNode *phi) { // Now start splitting out the flow paths that merge the same value. // Split first the RegionNode. PhaseIterGVN *igvn = phase->is_IterGVN(); - RegionNode *newr = new (phase->C) RegionNode(hit+1); + RegionNode *newr = new RegionNode(hit+1); split_once(igvn, phi, val, r, newr); // Now split all other Phis than this one @@ -1781,13 +1781,13 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { } if (doit) { if (base == NULL) { - base = new (phase->C) PhiNode(in(0), type, NULL); + base = new PhiNode(in(0), type, NULL); for (uint i = 1; i < req(); i++) { base->init_req(i, in(i)->in(AddPNode::Base)); } phase->is_IterGVN()->register_new_node_with_optimizer(base); } - return new (phase->C) AddPNode(base, base, y); + return new AddPNode(base, base, y); } } } @@ -1864,7 +1864,7 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Phi(...MergeMem(m0, m1:AT1, m2:AT2)...) into // MergeMem(Phi(...m0...), Phi:AT1(...m1...), Phi:AT2(...m2...)) PhaseIterGVN *igvn = phase->is_IterGVN(); - Node* hook = new (phase->C) Node(1); + Node* hook = new Node(1); PhiNode* new_base = (PhiNode*) clone(); // Must eagerly register phis, since they participate in loops. if (igvn) { @@ -1961,7 +1961,7 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { } else { narrow_t = TypeNarrowKlass::make(this->bottom_type()->is_ptr()); } - PhiNode* new_phi = new (phase->C) PhiNode(r, narrow_t); + PhiNode* new_phi = new PhiNode(r, narrow_t); uint orig_cnt = req(); for (uint i=1; iC) EncodePNode(ii, narrow_t); + new_ii = new EncodePNode(ii, narrow_t); } else { - new_ii = new (phase->C) EncodePKlassNode(ii, narrow_t); + new_ii = new EncodePKlassNode(ii, narrow_t); } igvn->register_new_node_with_optimizer(new_ii); } @@ -1986,9 +1986,9 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { } igvn->register_new_node_with_optimizer(new_phi, this); if (is_decodeN) { - progress = new (phase->C) DecodeNNode(new_phi, bottom_type()); + progress = new DecodeNNode(new_phi, bottom_type()); } else { - progress = new (phase->C) DecodeNKlassNode(new_phi, bottom_type()); + progress = new DecodeNKlassNode(new_phi, bottom_type()); } } } diff --git a/hotspot/src/share/vm/opto/chaitin.cpp b/hotspot/src/share/vm/opto/chaitin.cpp index f6e2065e26d..822d83a9c23 100644 --- a/hotspot/src/share/vm/opto/chaitin.cpp +++ b/hotspot/src/share/vm/opto/chaitin.cpp @@ -1730,7 +1730,7 @@ Node *PhaseChaitin::find_base_for_derived( Node **derived_base_map, Node *derive // Now we see we need a base-Phi here to merge the bases const Type *t = base->bottom_type(); - base = new (C) PhiNode( derived->in(0), t ); + base = new PhiNode( derived->in(0), t ); for( i = 1; i < derived->req(); i++ ) { base->init_req(i, find_base_for_derived(derived_base_map, derived->in(i), maxlrg)); t = t->meet(base->in(i)->bottom_type()); @@ -1800,7 +1800,7 @@ bool PhaseChaitin::stretch_base_pointer_live_ranges(ResourceArea *a) { Block *phi_block = _cfg.get_block_for_node(phi); if (_cfg.get_block_for_node(phi_block->pred(2)) == block) { const RegMask *mask = C->matcher()->idealreg2spillmask[Op_RegI]; - Node *spill = new (C) MachSpillCopyNode(MachSpillCopyNode::LoopPhiInput, phi, *mask, *mask); + Node *spill = new MachSpillCopyNode(MachSpillCopyNode::LoopPhiInput, phi, *mask, *mask); insert_proj( phi_block, 1, spill, maxlrg++ ); n->set_req(1,spill); must_recompute_live = true; diff --git a/hotspot/src/share/vm/opto/coalesce.cpp b/hotspot/src/share/vm/opto/coalesce.cpp index 5579d90c485..57a20bcb638 100644 --- a/hotspot/src/share/vm/opto/coalesce.cpp +++ b/hotspot/src/share/vm/opto/coalesce.cpp @@ -291,7 +291,7 @@ void PhaseAggressiveCoalesce::insert_copies( Matcher &matcher ) { _phc.clone_projs(pred, pred->end_idx(), m, copy, _phc._lrg_map); } else { const RegMask *rm = C->matcher()->idealreg2spillmask[m->ideal_reg()]; - copy = new (C) MachSpillCopyNode(MachSpillCopyNode::PhiInput, m, *rm, *rm); + copy = new MachSpillCopyNode(MachSpillCopyNode::PhiInput, m, *rm, *rm); // Find a good place to insert. Kinda tricky, use a subroutine insert_copy_with_overlap(pred,copy,phi_name,src_name); } @@ -325,7 +325,7 @@ void PhaseAggressiveCoalesce::insert_copies( Matcher &matcher ) { l += _phc.clone_projs(b, l, m, copy, _phc._lrg_map); } else { const RegMask *rm = C->matcher()->idealreg2spillmask[m->ideal_reg()]; - copy = new (C) MachSpillCopyNode(MachSpillCopyNode::TwoAddress, m, *rm, *rm); + copy = new MachSpillCopyNode(MachSpillCopyNode::TwoAddress, m, *rm, *rm); // Insert the copy in the basic block, just before us b->insert_node(copy, l++); } @@ -372,7 +372,7 @@ void PhaseAggressiveCoalesce::insert_copies( Matcher &matcher ) { continue; // Live out; do not pre-split // Split the lrg at this use const RegMask *rm = C->matcher()->idealreg2spillmask[inp->ideal_reg()]; - Node* copy = new (C) MachSpillCopyNode(MachSpillCopyNode::DebugUse, inp, *rm, *rm); + Node* copy = new MachSpillCopyNode(MachSpillCopyNode::DebugUse, inp, *rm, *rm); // Insert the copy in the use-def chain n->set_req(inpidx, copy ); // Insert the copy in the basic block, just before us diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index 9c05d1da889..0036e76518e 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -95,7 +95,7 @@ // Constant table base node singleton. MachConstantBaseNode* Compile::mach_constant_base_node() { if (_mach_constant_base_node == NULL) { - _mach_constant_base_node = new (C) MachConstantBaseNode(); + _mach_constant_base_node = new MachConstantBaseNode(); _mach_constant_base_node->add_req(C->root()); } return _mach_constant_base_node; @@ -392,6 +392,11 @@ void Compile::remove_useless_nodes(Unique_Node_List &useful) { uint next = 0; while (next < useful.size()) { Node *n = useful.at(next++); + if (n->is_SafePoint()) { + // We're done with a parsing phase. Replaced nodes are not valid + // beyond that point. + n->as_SafePoint()->delete_replaced_nodes(); + } // Use raw traversal of out edges since this code removes out edges int max = n->outcnt(); for (int j = 0; j < max; ++j) { @@ -673,7 +678,6 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr _print_inlining_stream(NULL), _print_inlining_idx(0), _print_inlining_output(NULL), - _preserve_jvm_state(0), _interpreter_frame_size(0) { C = this; @@ -748,14 +752,14 @@ Compile::Compile( ciEnv* ci_env, C2Compiler* compiler, ciMethod* target, int osr const TypeTuple *domain = StartOSRNode::osr_domain(); const TypeTuple *range = TypeTuple::make_range(method()->signature()); init_tf(TypeFunc::make(domain, range)); - StartNode* s = new (this) StartOSRNode(root(), domain); + StartNode* s = new StartOSRNode(root(), domain); initial_gvn()->set_type_bottom(s); init_start(s); cg = CallGenerator::for_osr(method(), entry_bci()); } else { // Normal case. init_tf(TypeFunc::make(method())); - StartNode* s = new (this) StartNode(root(), tf()->domain()); + StartNode* s = new StartNode(root(), tf()->domain()); initial_gvn()->set_type_bottom(s); init_start(s); if (method()->intrinsic_id() == vmIntrinsics::_Reference_get && UseG1GC) { @@ -783,7 +787,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)) == NULL) { + if ((jvms = cg->generate(jvms)) == NULL) { record_method_not_compilable("method parse failed"); return; } @@ -980,7 +984,6 @@ Compile::Compile( ciEnv* ci_env, _print_inlining_stream(NULL), _print_inlining_idx(0), _print_inlining_output(NULL), - _preserve_jvm_state(0), _allowed_reasons(0), _interpreter_frame_size(0) { C = this; @@ -1061,9 +1064,9 @@ void Compile::Init(int aliaslevel) { // Globally visible Nodes // First set TOP to NULL to give safe behavior during creation of RootNode set_cached_top_node(NULL); - set_root(new (this) RootNode()); + set_root(new RootNode()); // Now that you have a Root to point to, create the real TOP - set_cached_top_node( new (this) ConNode(Type::TOP) ); + set_cached_top_node( new ConNode(Type::TOP) ); set_recent_alloc(NULL, NULL); // Create Debug Information Recorder to record scopes, oopmaps, etc. @@ -1914,6 +1917,8 @@ void Compile::inline_boxing_calls(PhaseIterGVN& igvn) { for_igvn()->clear(); gvn->replace_with(&igvn); + _late_inlines_pos = _late_inlines.length(); + while (_boxing_late_inlines.length() > 0) { CallGenerator* cg = _boxing_late_inlines.pop(); cg->do_late_inline(); @@ -1977,8 +1982,8 @@ void Compile::inline_incrementally(PhaseIterGVN& igvn) { if (live_nodes() > (uint)LiveNodeCountInliningCutoff) { if (low_live_nodes < (uint)LiveNodeCountInliningCutoff * 8 / 10) { // PhaseIdealLoop is expensive so we only try it once we are - // out of loop and we only try it again if the previous helped - // got the number of nodes down significantly + // out of live nodes and we only try it again if the previous + // helped got the number of nodes down significantly PhaseIdealLoop ideal_loop( igvn, false, true ); if (failing()) return; low_live_nodes = live_nodes(); @@ -2072,6 +2077,10 @@ void Compile::Optimize() { // Inline valueOf() methods now. inline_boxing_calls(igvn); + if (AlwaysIncrementalInline) { + inline_incrementally(igvn); + } + print_method(PHASE_INCREMENTAL_BOXING_INLINE, 2); if (failing()) return; @@ -2757,9 +2766,9 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { // Decode a narrow oop to match address // [R12 + narrow_oop_reg<<3 + offset] if (t->isa_oopptr()) { - nn = new (this) DecodeNNode(nn, t); + nn = new DecodeNNode(nn, t); } else { - nn = new (this) DecodeNKlassNode(nn, t); + nn = new DecodeNKlassNode(nn, t); } n->set_req(AddPNode::Base, nn); n->set_req(AddPNode::Address, nn); @@ -2880,7 +2889,7 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { } } if (new_in2 != NULL) { - Node* cmpN = new (this) CmpNNode(in1->in(1), new_in2); + Node* cmpN = new CmpNNode(in1->in(1), new_in2); n->subsume_by(cmpN, this); if (in1->outcnt() == 0) { in1->disconnect_inputs(NULL, this); @@ -2979,8 +2988,8 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { n->subsume_by(divmod->mod_proj(), this); } else { // replace a%b with a-((a/b)*b) - Node* mult = new (this) MulINode(d, d->in(2)); - Node* sub = new (this) SubINode(d->in(1), mult); + Node* mult = new MulINode(d, d->in(2)); + Node* sub = new SubINode(d->in(1), mult); n->subsume_by(sub, this); } } @@ -2999,8 +3008,8 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { n->subsume_by(divmod->mod_proj(), this); } else { // replace a%b with a-((a/b)*b) - Node* mult = new (this) MulLNode(d, d->in(2)); - Node* sub = new (this) SubLNode(d->in(1), mult); + Node* mult = new MulLNode(d, d->in(2)); + Node* sub = new SubLNode(d->in(1), mult); n->subsume_by(sub, this); } } @@ -3049,7 +3058,7 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { } } else { if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) { - Node* shift = new (this) AndINode(in2, ConNode::make(this, TypeInt::make(mask))); + Node* shift = new AndINode(in2, ConNode::make(this, TypeInt::make(mask))); n->set_req(2, shift); } } diff --git a/hotspot/src/share/vm/opto/compile.hpp b/hotspot/src/share/vm/opto/compile.hpp index 36ff03906f1..7d7dd653aaa 100644 --- a/hotspot/src/share/vm/opto/compile.hpp +++ b/hotspot/src/share/vm/opto/compile.hpp @@ -431,9 +431,6 @@ class Compile : public Phase { // 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; - void* _replay_inline_data; // Pointer to data loaded from file void print_inlining_init(); @@ -1198,21 +1195,6 @@ 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/connode.cpp b/hotspot/src/share/vm/opto/connode.cpp index 8485aba1303..485e8df7951 100644 --- a/hotspot/src/share/vm/opto/connode.cpp +++ b/hotspot/src/share/vm/opto/connode.cpp @@ -45,17 +45,17 @@ uint ConNode::hash() const { //------------------------------make------------------------------------------- ConNode *ConNode::make( Compile* C, const Type *t ) { switch( t->basic_type() ) { - case T_INT: return new (C) ConINode( t->is_int() ); - case T_LONG: return new (C) ConLNode( t->is_long() ); - case T_FLOAT: return new (C) ConFNode( t->is_float_constant() ); - case T_DOUBLE: return new (C) ConDNode( t->is_double_constant() ); - case T_VOID: return new (C) ConNode ( Type::TOP ); - case T_OBJECT: return new (C) ConPNode( t->is_ptr() ); - case T_ARRAY: return new (C) ConPNode( t->is_aryptr() ); - case T_ADDRESS: return new (C) ConPNode( t->is_ptr() ); - case T_NARROWOOP: return new (C) ConNNode( t->is_narrowoop() ); - case T_NARROWKLASS: return new (C) ConNKlassNode( t->is_narrowklass() ); - case T_METADATA: return new (C) ConPNode( t->is_ptr() ); + case T_INT: return new ConINode( t->is_int() ); + case T_LONG: return new ConLNode( t->is_long() ); + case T_FLOAT: return new ConFNode( t->is_float_constant() ); + case T_DOUBLE: return new ConDNode( t->is_double_constant() ); + case T_VOID: return new ConNode ( Type::TOP ); + case T_OBJECT: return new ConPNode( t->is_ptr() ); + case T_ARRAY: return new ConPNode( t->is_aryptr() ); + case T_ADDRESS: return new ConPNode( t->is_ptr() ); + case T_NARROWOOP: return new ConNNode( t->is_narrowoop() ); + case T_NARROWKLASS: return new ConNKlassNode( t->is_narrowklass() ); + case T_METADATA: return new ConPNode( t->is_ptr() ); // Expected cases: TypePtr::NULL_PTR, any is_rawptr() // Also seen: AnyPtr(TopPTR *+top); from command line: // r -XX:+PrintOpto -XX:CIStart=285 -XX:+CompileTheWorld -XX:CompileTheWorldStartAt=660 diff --git a/hotspot/src/share/vm/opto/connode.hpp b/hotspot/src/share/vm/opto/connode.hpp index a25e4c128a0..446b807a846 100644 --- a/hotspot/src/share/vm/opto/connode.hpp +++ b/hotspot/src/share/vm/opto/connode.hpp @@ -58,7 +58,7 @@ public: // Factory method: static ConINode* make( Compile* C, int con ) { - return new (C) ConINode( TypeInt::make(con) ); + return new ConINode( TypeInt::make(con) ); } }; @@ -73,9 +73,9 @@ public: // Factory methods: static ConPNode* make( Compile *C ,address con ) { if (con == NULL) - return new (C) ConPNode( TypePtr::NULL_PTR ) ; + return new ConPNode( TypePtr::NULL_PTR ) ; else - return new (C) ConPNode( TypeRawPtr::make(con) ); + return new ConPNode( TypeRawPtr::make(con) ); } }; @@ -106,7 +106,7 @@ public: // Factory method: static ConLNode* make( Compile *C ,jlong con ) { - return new (C) ConLNode( TypeLong::make(con) ); + return new ConLNode( TypeLong::make(con) ); } }; @@ -120,7 +120,7 @@ public: // Factory method: static ConFNode* make( Compile *C, float con ) { - return new (C) ConFNode( TypeF::make(con) ); + return new ConFNode( TypeF::make(con) ); } }; @@ -134,7 +134,7 @@ public: // Factory method: static ConDNode* make( Compile *C, double con ) { - return new (C) ConDNode( TypeD::make(con) ); + return new ConDNode( TypeD::make(con) ); } }; diff --git a/hotspot/src/share/vm/opto/convertnode.cpp b/hotspot/src/share/vm/opto/convertnode.cpp index bf09d3fbb90..8c42aaed679 100644 --- a/hotspot/src/share/vm/opto/convertnode.cpp +++ b/hotspot/src/share/vm/opto/convertnode.cpp @@ -374,11 +374,11 @@ Node *ConvI2LNode::Ideal(PhaseGVN *phase, bool can_reshape) { ryhi = -rylo0; } - Node* cx = phase->transform( new (phase->C) ConvI2LNode(x, TypeLong::make(rxlo, rxhi, widen)) ); - Node* cy = phase->transform( new (phase->C) ConvI2LNode(y, TypeLong::make(rylo, ryhi, widen)) ); + Node* cx = phase->transform( new ConvI2LNode(x, TypeLong::make(rxlo, rxhi, widen)) ); + Node* cy = phase->transform( new ConvI2LNode(y, TypeLong::make(rylo, ryhi, widen)) ); switch (op) { - case Op_AddI: return new (phase->C) AddLNode(cx, cy); - case Op_SubI: return new (phase->C) SubLNode(cx, cy); + case Op_AddI: return new AddLNode(cx, cy); + case Op_SubI: return new SubLNode(cx, cy); default: ShouldNotReachHere(); } } @@ -452,9 +452,9 @@ Node *ConvL2INode::Ideal(PhaseGVN *phase, bool can_reshape) { assert( x != andl && y != andl, "dead loop in ConvL2INode::Ideal" ); if (phase->type(x) == Type::TOP) return NULL; if (phase->type(y) == Type::TOP) return NULL; - Node *add1 = phase->transform(new (phase->C) ConvL2INode(x)); - Node *add2 = phase->transform(new (phase->C) ConvL2INode(y)); - return new (phase->C) AddINode(add1,add2); + Node *add1 = phase->transform(new ConvL2INode(x)); + Node *add2 = phase->transform(new ConvL2INode(y)); + return new AddINode(add1,add2); } // Disable optimization: LoadL->ConvL2I ==> LoadI. diff --git a/hotspot/src/share/vm/opto/divnode.cpp b/hotspot/src/share/vm/opto/divnode.cpp index 40bd21fbc4c..8a27c24e37e 100644 --- a/hotspot/src/share/vm/opto/divnode.cpp +++ b/hotspot/src/share/vm/opto/divnode.cpp @@ -106,7 +106,7 @@ static Node *transform_int_divide( PhaseGVN *phase, Node *dividend, jint divisor // division by +/- 1 if (!d_pos) { // Just negate the value - q = new (phase->C) SubINode(phase->intcon(0), dividend); + q = new SubINode(phase->intcon(0), dividend); } } else if ( is_power_of_2(d) ) { // division by +/- a power of 2 @@ -143,18 +143,18 @@ static Node *transform_int_divide( PhaseGVN *phase, Node *dividend, jint divisor // (-2+3)>>2 becomes 0, etc. // Compute 0 or -1, based on sign bit - Node *sign = phase->transform(new (phase->C) RShiftINode(dividend, phase->intcon(N - 1))); + Node *sign = phase->transform(new RShiftINode(dividend, phase->intcon(N - 1))); // Mask sign bit to the low sign bits - Node *round = phase->transform(new (phase->C) URShiftINode(sign, phase->intcon(N - l))); + Node *round = phase->transform(new URShiftINode(sign, phase->intcon(N - l))); // Round up before shifting - dividend = phase->transform(new (phase->C) AddINode(dividend, round)); + dividend = phase->transform(new AddINode(dividend, round)); } // Shift for division - q = new (phase->C) RShiftINode(dividend, phase->intcon(l)); + q = new RShiftINode(dividend, phase->intcon(l)); if (!d_pos) { - q = new (phase->C) SubINode(phase->intcon(0), phase->transform(q)); + q = new SubINode(phase->intcon(0), phase->transform(q)); } } else { // Attempt the jint constant divide -> multiply transform found in @@ -166,33 +166,33 @@ static Node *transform_int_divide( PhaseGVN *phase, Node *dividend, jint divisor jint shift_const; if (magic_int_divide_constants(d, magic_const, shift_const)) { Node *magic = phase->longcon(magic_const); - Node *dividend_long = phase->transform(new (phase->C) ConvI2LNode(dividend)); + Node *dividend_long = phase->transform(new ConvI2LNode(dividend)); // Compute the high half of the dividend x magic multiplication - Node *mul_hi = phase->transform(new (phase->C) MulLNode(dividend_long, magic)); + Node *mul_hi = phase->transform(new MulLNode(dividend_long, magic)); if (magic_const < 0) { - mul_hi = phase->transform(new (phase->C) RShiftLNode(mul_hi, phase->intcon(N))); - mul_hi = phase->transform(new (phase->C) ConvL2INode(mul_hi)); + mul_hi = phase->transform(new RShiftLNode(mul_hi, phase->intcon(N))); + mul_hi = phase->transform(new ConvL2INode(mul_hi)); // The magic multiplier is too large for a 32 bit constant. We've adjusted // it down by 2^32, but have to add 1 dividend back in after the multiplication. // This handles the "overflow" case described by Granlund and Montgomery. - mul_hi = phase->transform(new (phase->C) AddINode(dividend, mul_hi)); + mul_hi = phase->transform(new AddINode(dividend, mul_hi)); // Shift over the (adjusted) mulhi if (shift_const != 0) { - mul_hi = phase->transform(new (phase->C) RShiftINode(mul_hi, phase->intcon(shift_const))); + mul_hi = phase->transform(new RShiftINode(mul_hi, phase->intcon(shift_const))); } } else { // No add is required, we can merge the shifts together. - mul_hi = phase->transform(new (phase->C) RShiftLNode(mul_hi, phase->intcon(N + shift_const))); - mul_hi = phase->transform(new (phase->C) ConvL2INode(mul_hi)); + mul_hi = phase->transform(new RShiftLNode(mul_hi, phase->intcon(N + shift_const))); + mul_hi = phase->transform(new ConvL2INode(mul_hi)); } // Get a 0 or -1 from the sign of the dividend. Node *addend0 = mul_hi; - Node *addend1 = phase->transform(new (phase->C) RShiftINode(dividend, phase->intcon(N-1))); + Node *addend1 = phase->transform(new RShiftINode(dividend, phase->intcon(N-1))); // If the divisor is negative, swap the order of the input addends; // this has the effect of negating the quotient. @@ -202,7 +202,7 @@ static Node *transform_int_divide( PhaseGVN *phase, Node *dividend, jint divisor // Adjust the final quotient by subtracting -1 (adding 1) // from the mul_hi. - q = new (phase->C) SubINode(addend0, addend1); + q = new SubINode(addend0, addend1); } } @@ -261,7 +261,7 @@ static Node* long_by_long_mulhi(PhaseGVN* phase, Node* dividend, jlong magic_con // no need to synthesize it in ideal nodes. if (Matcher::has_match_rule(Op_MulHiL)) { Node* v = phase->longcon(magic_const); - return new (phase->C) MulHiLNode(dividend, v); + return new MulHiLNode(dividend, v); } // Taken from Hacker's Delight, Fig. 8-2. Multiply high signed. @@ -287,11 +287,11 @@ static Node* long_by_long_mulhi(PhaseGVN* phase, Node* dividend, jlong magic_con const int N = 64; // Dummy node to keep intermediate nodes alive during construction - Node* hook = new (phase->C) Node(4); + Node* hook = new Node(4); // u0 = u & 0xFFFFFFFF; u1 = u >> 32; - Node* u0 = phase->transform(new (phase->C) AndLNode(dividend, phase->longcon(0xFFFFFFFF))); - Node* u1 = phase->transform(new (phase->C) RShiftLNode(dividend, phase->intcon(N / 2))); + Node* u0 = phase->transform(new AndLNode(dividend, phase->longcon(0xFFFFFFFF))); + Node* u1 = phase->transform(new RShiftLNode(dividend, phase->intcon(N / 2))); hook->init_req(0, u0); hook->init_req(1, u1); @@ -300,29 +300,29 @@ static Node* long_by_long_mulhi(PhaseGVN* phase, Node* dividend, jlong magic_con Node* v1 = phase->longcon(magic_const >> (N / 2)); // w0 = u0*v0; - Node* w0 = phase->transform(new (phase->C) MulLNode(u0, v0)); + Node* w0 = phase->transform(new MulLNode(u0, v0)); // t = u1*v0 + (w0 >> 32); - Node* u1v0 = phase->transform(new (phase->C) MulLNode(u1, v0)); - Node* temp = phase->transform(new (phase->C) URShiftLNode(w0, phase->intcon(N / 2))); - Node* t = phase->transform(new (phase->C) AddLNode(u1v0, temp)); + Node* u1v0 = phase->transform(new MulLNode(u1, v0)); + Node* temp = phase->transform(new URShiftLNode(w0, phase->intcon(N / 2))); + Node* t = phase->transform(new AddLNode(u1v0, temp)); hook->init_req(2, t); // w1 = t & 0xFFFFFFFF; - Node* w1 = phase->transform(new (phase->C) AndLNode(t, phase->longcon(0xFFFFFFFF))); + Node* w1 = phase->transform(new AndLNode(t, phase->longcon(0xFFFFFFFF))); hook->init_req(3, w1); // w2 = t >> 32; - Node* w2 = phase->transform(new (phase->C) RShiftLNode(t, phase->intcon(N / 2))); + Node* w2 = phase->transform(new RShiftLNode(t, phase->intcon(N / 2))); // w1 = u0*v1 + w1; - Node* u0v1 = phase->transform(new (phase->C) MulLNode(u0, v1)); - w1 = phase->transform(new (phase->C) AddLNode(u0v1, w1)); + Node* u0v1 = phase->transform(new MulLNode(u0, v1)); + w1 = phase->transform(new AddLNode(u0v1, w1)); // return u1*v1 + w2 + (w1 >> 32); - Node* u1v1 = phase->transform(new (phase->C) MulLNode(u1, v1)); - Node* temp1 = phase->transform(new (phase->C) AddLNode(u1v1, w2)); - Node* temp2 = phase->transform(new (phase->C) RShiftLNode(w1, phase->intcon(N / 2))); + Node* u1v1 = phase->transform(new MulLNode(u1, v1)); + Node* temp1 = phase->transform(new AddLNode(u1v1, w2)); + Node* temp2 = phase->transform(new RShiftLNode(w1, phase->intcon(N / 2))); // Remove the bogus extra edges used to keep things alive PhaseIterGVN* igvn = phase->is_IterGVN(); @@ -334,7 +334,7 @@ static Node* long_by_long_mulhi(PhaseGVN* phase, Node* dividend, jlong magic_con } } - return new (phase->C) AddLNode(temp1, temp2); + return new AddLNode(temp1, temp2); } @@ -357,7 +357,7 @@ static Node *transform_long_divide( PhaseGVN *phase, Node *dividend, jlong divis // division by +/- 1 if (!d_pos) { // Just negate the value - q = new (phase->C) SubLNode(phase->longcon(0), dividend); + q = new SubLNode(phase->longcon(0), dividend); } } else if ( is_power_of_2_long(d) ) { @@ -396,18 +396,18 @@ static Node *transform_long_divide( PhaseGVN *phase, Node *dividend, jlong divis // (-2+3)>>2 becomes 0, etc. // Compute 0 or -1, based on sign bit - Node *sign = phase->transform(new (phase->C) RShiftLNode(dividend, phase->intcon(N - 1))); + Node *sign = phase->transform(new RShiftLNode(dividend, phase->intcon(N - 1))); // Mask sign bit to the low sign bits - Node *round = phase->transform(new (phase->C) URShiftLNode(sign, phase->intcon(N - l))); + Node *round = phase->transform(new URShiftLNode(sign, phase->intcon(N - l))); // Round up before shifting - dividend = phase->transform(new (phase->C) AddLNode(dividend, round)); + dividend = phase->transform(new AddLNode(dividend, round)); } // Shift for division - q = new (phase->C) RShiftLNode(dividend, phase->intcon(l)); + q = new RShiftLNode(dividend, phase->intcon(l)); if (!d_pos) { - q = new (phase->C) SubLNode(phase->longcon(0), phase->transform(q)); + q = new SubLNode(phase->longcon(0), phase->transform(q)); } } else if ( !Matcher::use_asm_for_ldiv_by_con(d) ) { // Use hardware DIV instruction when // it is faster than code generated below. @@ -427,17 +427,17 @@ static Node *transform_long_divide( PhaseGVN *phase, Node *dividend, jlong divis // The magic multiplier is too large for a 64 bit constant. We've adjusted // it down by 2^64, but have to add 1 dividend back in after the multiplication. // This handles the "overflow" case described by Granlund and Montgomery. - mul_hi = phase->transform(new (phase->C) AddLNode(dividend, mul_hi)); + mul_hi = phase->transform(new AddLNode(dividend, mul_hi)); } // Shift over the (adjusted) mulhi if (shift_const != 0) { - mul_hi = phase->transform(new (phase->C) RShiftLNode(mul_hi, phase->intcon(shift_const))); + mul_hi = phase->transform(new RShiftLNode(mul_hi, phase->intcon(shift_const))); } // Get a 0 or -1 from the sign of the dividend. Node *addend0 = mul_hi; - Node *addend1 = phase->transform(new (phase->C) RShiftLNode(dividend, phase->intcon(N-1))); + Node *addend1 = phase->transform(new RShiftLNode(dividend, phase->intcon(N-1))); // If the divisor is negative, swap the order of the input addends; // this has the effect of negating the quotient. @@ -447,7 +447,7 @@ static Node *transform_long_divide( PhaseGVN *phase, Node *dividend, jlong divis // Adjust the final quotient by subtracting -1 (adding 1) // from the mul_hi. - q = new (phase->C) SubLNode(addend0, addend1); + q = new SubLNode(addend0, addend1); } } @@ -737,7 +737,7 @@ Node *DivFNode::Ideal(PhaseGVN *phase, bool can_reshape) { assert( frexp((double)reciprocal, &exp) == 0.5, "reciprocal should be power of 2" ); // return multiplication by the reciprocal - return (new (phase->C) MulFNode(in(1), phase->makecon(TypeF::make(reciprocal)))); + return (new MulFNode(in(1), phase->makecon(TypeF::make(reciprocal)))); } //============================================================================= @@ -831,7 +831,7 @@ Node *DivDNode::Ideal(PhaseGVN *phase, bool can_reshape) { assert( frexp(reciprocal, &exp) == 0.5, "reciprocal should be power of 2" ); // return multiplication by the reciprocal - return (new (phase->C) MulDNode(in(1), phase->makecon(TypeD::make(reciprocal)))); + return (new MulDNode(in(1), phase->makecon(TypeD::make(reciprocal)))); } //============================================================================= @@ -858,7 +858,7 @@ Node *ModINode::Ideal(PhaseGVN *phase, bool can_reshape) { if( !ti->is_con() ) return NULL; jint con = ti->get_con(); - Node *hook = new (phase->C) Node(1); + Node *hook = new Node(1); // First, special check for modulo 2^k-1 if( con >= 0 && con < max_jint && is_power_of_2(con+1) ) { @@ -878,24 +878,24 @@ Node *ModINode::Ideal(PhaseGVN *phase, bool can_reshape) { hook->init_req(0, x); // Add a use to x to prevent him from dying // Generate code to reduce X rapidly to nearly 2^k-1. for( int i = 0; i < trip_count; i++ ) { - Node *xl = phase->transform( new (phase->C) AndINode(x,divisor) ); - Node *xh = phase->transform( new (phase->C) RShiftINode(x,phase->intcon(k)) ); // Must be signed - x = phase->transform( new (phase->C) AddINode(xh,xl) ); + Node *xl = phase->transform( new AndINode(x,divisor) ); + Node *xh = phase->transform( new RShiftINode(x,phase->intcon(k)) ); // Must be signed + x = phase->transform( new AddINode(xh,xl) ); hook->set_req(0, x); } // Generate sign-fixup code. Was original value positive? // int hack_res = (i >= 0) ? divisor : 1; - Node *cmp1 = phase->transform( new (phase->C) CmpINode( in(1), phase->intcon(0) ) ); - Node *bol1 = phase->transform( new (phase->C) BoolNode( cmp1, BoolTest::ge ) ); - Node *cmov1= phase->transform( new (phase->C) CMoveINode(bol1, phase->intcon(1), divisor, TypeInt::POS) ); + Node *cmp1 = phase->transform( new CmpINode( in(1), phase->intcon(0) ) ); + Node *bol1 = phase->transform( new BoolNode( cmp1, BoolTest::ge ) ); + Node *cmov1= phase->transform( new CMoveINode(bol1, phase->intcon(1), divisor, TypeInt::POS) ); // if( x >= hack_res ) x -= divisor; - Node *sub = phase->transform( new (phase->C) SubINode( x, divisor ) ); - Node *cmp2 = phase->transform( new (phase->C) CmpINode( x, cmov1 ) ); - Node *bol2 = phase->transform( new (phase->C) BoolNode( cmp2, BoolTest::ge ) ); + Node *sub = phase->transform( new SubINode( x, divisor ) ); + Node *cmp2 = phase->transform( new CmpINode( x, cmov1 ) ); + Node *bol2 = phase->transform( new BoolNode( cmp2, BoolTest::ge ) ); // Convention is to not transform the return value of an Ideal // since Ideal is expected to return a modified 'this' or a new node. - Node *cmov2= new (phase->C) CMoveINode(bol2, x, sub, TypeInt::INT); + Node *cmov2= new CMoveINode(bol2, x, sub, TypeInt::INT); // cmov2 is now the mod // Now remove the bogus extra edges used to keep things alive @@ -918,7 +918,7 @@ Node *ModINode::Ideal(PhaseGVN *phase, bool can_reshape) { jint pos_con = (con >= 0) ? con : -con; // integer Mod 1 is always 0 - if( pos_con == 1 ) return new (phase->C) ConINode(TypeInt::ZERO); + if( pos_con == 1 ) return new ConINode(TypeInt::ZERO); int log2_con = -1; @@ -931,7 +931,7 @@ Node *ModINode::Ideal(PhaseGVN *phase, bool can_reshape) { // See if this can be masked, if the dividend is non-negative if( dti && dti->_lo >= 0 ) - return ( new (phase->C) AndINode( in(1), phase->intcon( pos_con-1 ) ) ); + return ( new AndINode( in(1), phase->intcon( pos_con-1 ) ) ); } // Save in(1) so that it cannot be changed or deleted @@ -946,12 +946,12 @@ Node *ModINode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *mult = NULL; if( log2_con >= 0 ) - mult = phase->transform( new (phase->C) LShiftINode( divide, phase->intcon( log2_con ) ) ); + mult = phase->transform( new LShiftINode( divide, phase->intcon( log2_con ) ) ); else - mult = phase->transform( new (phase->C) MulINode( divide, phase->intcon( pos_con ) ) ); + mult = phase->transform( new MulINode( divide, phase->intcon( pos_con ) ) ); // Finally, subtract the multiplied divided value from the original - result = new (phase->C) SubINode( in(1), mult ); + result = new SubINode( in(1), mult ); } // Now remove the bogus extra edges used to keep things alive @@ -1029,7 +1029,7 @@ Node *ModLNode::Ideal(PhaseGVN *phase, bool can_reshape) { if( !tl->is_con() ) return NULL; jlong con = tl->get_con(); - Node *hook = new (phase->C) Node(1); + Node *hook = new Node(1); // Expand mod if( con >= 0 && con < max_jlong && is_power_of_2_long(con+1) ) { @@ -1051,24 +1051,24 @@ Node *ModLNode::Ideal(PhaseGVN *phase, bool can_reshape) { hook->init_req(0, x); // Add a use to x to prevent him from dying // Generate code to reduce X rapidly to nearly 2^k-1. for( int i = 0; i < trip_count; i++ ) { - Node *xl = phase->transform( new (phase->C) AndLNode(x,divisor) ); - Node *xh = phase->transform( new (phase->C) RShiftLNode(x,phase->intcon(k)) ); // Must be signed - x = phase->transform( new (phase->C) AddLNode(xh,xl) ); + Node *xl = phase->transform( new AndLNode(x,divisor) ); + Node *xh = phase->transform( new RShiftLNode(x,phase->intcon(k)) ); // Must be signed + x = phase->transform( new AddLNode(xh,xl) ); hook->set_req(0, x); // Add a use to x to prevent him from dying } // Generate sign-fixup code. Was original value positive? // long hack_res = (i >= 0) ? divisor : CONST64(1); - Node *cmp1 = phase->transform( new (phase->C) CmpLNode( in(1), phase->longcon(0) ) ); - Node *bol1 = phase->transform( new (phase->C) BoolNode( cmp1, BoolTest::ge ) ); - Node *cmov1= phase->transform( new (phase->C) CMoveLNode(bol1, phase->longcon(1), divisor, TypeLong::LONG) ); + Node *cmp1 = phase->transform( new CmpLNode( in(1), phase->longcon(0) ) ); + Node *bol1 = phase->transform( new BoolNode( cmp1, BoolTest::ge ) ); + Node *cmov1= phase->transform( new CMoveLNode(bol1, phase->longcon(1), divisor, TypeLong::LONG) ); // if( x >= hack_res ) x -= divisor; - Node *sub = phase->transform( new (phase->C) SubLNode( x, divisor ) ); - Node *cmp2 = phase->transform( new (phase->C) CmpLNode( x, cmov1 ) ); - Node *bol2 = phase->transform( new (phase->C) BoolNode( cmp2, BoolTest::ge ) ); + Node *sub = phase->transform( new SubLNode( x, divisor ) ); + Node *cmp2 = phase->transform( new CmpLNode( x, cmov1 ) ); + Node *bol2 = phase->transform( new BoolNode( cmp2, BoolTest::ge ) ); // Convention is to not transform the return value of an Ideal // since Ideal is expected to return a modified 'this' or a new node. - Node *cmov2= new (phase->C) CMoveLNode(bol2, x, sub, TypeLong::LONG); + Node *cmov2= new CMoveLNode(bol2, x, sub, TypeLong::LONG); // cmov2 is now the mod // Now remove the bogus extra edges used to keep things alive @@ -1091,7 +1091,7 @@ Node *ModLNode::Ideal(PhaseGVN *phase, bool can_reshape) { jlong pos_con = (con >= 0) ? con : -con; // integer Mod 1 is always 0 - if( pos_con == 1 ) return new (phase->C) ConLNode(TypeLong::ZERO); + if( pos_con == 1 ) return new ConLNode(TypeLong::ZERO); int log2_con = -1; @@ -1104,7 +1104,7 @@ Node *ModLNode::Ideal(PhaseGVN *phase, bool can_reshape) { // See if this can be masked, if the dividend is non-negative if( dtl && dtl->_lo >= 0 ) - return ( new (phase->C) AndLNode( in(1), phase->longcon( pos_con-1 ) ) ); + return ( new AndLNode( in(1), phase->longcon( pos_con-1 ) ) ); } // Save in(1) so that it cannot be changed or deleted @@ -1119,12 +1119,12 @@ Node *ModLNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *mult = NULL; if( log2_con >= 0 ) - mult = phase->transform( new (phase->C) LShiftLNode( divide, phase->intcon( log2_con ) ) ); + mult = phase->transform( new LShiftLNode( divide, phase->intcon( log2_con ) ) ); else - mult = phase->transform( new (phase->C) MulLNode( divide, phase->longcon( pos_con ) ) ); + mult = phase->transform( new MulLNode( divide, phase->longcon( pos_con ) ) ); // Finally, subtract the multiplied divided value from the original - result = new (phase->C) SubLNode( in(1), mult ); + result = new SubLNode( in(1), mult ); } // Now remove the bogus extra edges used to keep things alive @@ -1279,9 +1279,9 @@ DivModINode* DivModINode::make(Compile* C, Node* div_or_mod) { assert(n->Opcode() == Op_DivI || n->Opcode() == Op_ModI, "only div or mod input pattern accepted"); - DivModINode* divmod = new (C) DivModINode(n->in(0), n->in(1), n->in(2)); - Node* dproj = new (C) ProjNode(divmod, DivModNode::div_proj_num); - Node* mproj = new (C) ProjNode(divmod, DivModNode::mod_proj_num); + DivModINode* divmod = new DivModINode(n->in(0), n->in(1), n->in(2)); + Node* dproj = new ProjNode(divmod, DivModNode::div_proj_num); + Node* mproj = new ProjNode(divmod, DivModNode::mod_proj_num); return divmod; } @@ -1291,9 +1291,9 @@ DivModLNode* DivModLNode::make(Compile* C, Node* div_or_mod) { assert(n->Opcode() == Op_DivL || n->Opcode() == Op_ModL, "only div or mod input pattern accepted"); - DivModLNode* divmod = new (C) DivModLNode(n->in(0), n->in(1), n->in(2)); - Node* dproj = new (C) ProjNode(divmod, DivModNode::div_proj_num); - Node* mproj = new (C) ProjNode(divmod, DivModNode::mod_proj_num); + DivModLNode* divmod = new DivModLNode(n->in(0), n->in(1), n->in(2)); + Node* dproj = new ProjNode(divmod, DivModNode::div_proj_num); + Node* mproj = new ProjNode(divmod, DivModNode::mod_proj_num); return divmod; } @@ -1308,7 +1308,7 @@ Node *DivModINode::match( const ProjNode *proj, const Matcher *match ) { assert(proj->_con == mod_proj_num, "must be div or mod projection"); rm = match->modI_proj_mask(); } - return new (match->C)MachProjNode(this, proj->_con, rm, ideal_reg); + return new MachProjNode(this, proj->_con, rm, ideal_reg); } @@ -1323,5 +1323,5 @@ Node *DivModLNode::match( const ProjNode *proj, const Matcher *match ) { assert(proj->_con == mod_proj_num, "must be div or mod projection"); rm = match->modL_proj_mask(); } - return new (match->C)MachProjNode(this, proj->_con, rm, ideal_reg); + return new MachProjNode(this, proj->_con, rm, ideal_reg); } diff --git a/hotspot/src/share/vm/opto/doCall.cpp b/hotspot/src/share/vm/opto/doCall.cpp index 2c48e604497..72dc6b8a79c 100644 --- a/hotspot/src/share/vm/opto/doCall.cpp +++ b/hotspot/src/share/vm/opto/doCall.cpp @@ -119,12 +119,12 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool if (allow_inline && allow_intrinsics) { CallGenerator* cg = find_intrinsic(callee, call_does_dispatch); if (cg != NULL) { - if (cg->is_predicted()) { + if (cg->is_predicated()) { // Code without intrinsic but, hopefully, inlined. CallGenerator* inline_cg = this->call_generator(callee, 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); + cg = CallGenerator::for_predicated_intrinsic(cg, inline_cg); } } @@ -525,7 +525,7 @@ void Parse::do_call() { // because exceptions don't return to the call site.) profile_call(receiver); - JVMState* new_jvms = cg->generate(jvms, this); + JVMState* new_jvms = cg->generate(jvms); if (new_jvms == NULL) { // When inlining attempt fails (e.g., too many arguments), // it may contaminate the current compile state, making it @@ -539,7 +539,7 @@ void Parse::do_call() { // 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(), speculative_receiver_type, /* allow_intrinsics= */ false); - new_jvms = cg->generate(jvms, this); + new_jvms = cg->generate(jvms); if (new_jvms == NULL) { guarantee(failing(), "call failed to generate: calls should work"); return; @@ -596,7 +596,7 @@ void Parse::do_call() { const Type* sig_type = TypeOopPtr::make_from_klass(ctype->as_klass()); if (arg_type != NULL && !arg_type->higher_equal(sig_type)) { Node* retnode = pop(); - Node* cast_obj = _gvn.transform(new (C) CheckCastPPNode(control(), retnode, sig_type)); + Node* cast_obj = _gvn.transform(new CheckCastPPNode(control(), retnode, sig_type)); push(cast_obj); } } @@ -689,7 +689,7 @@ void Parse::catch_call_exceptions(ciExceptionHandlerStream& handlers) { } int len = bcis->length(); - CatchNode *cn = new (C) CatchNode(control(), i_o, len+1); + CatchNode *cn = new CatchNode(control(), i_o, len+1); Node *catch_ = _gvn.transform(cn); // now branch with the exception state to each of the (potential) @@ -700,14 +700,14 @@ void Parse::catch_call_exceptions(ciExceptionHandlerStream& handlers) { // Locals are just copied from before the call. // Get control from the CatchNode. int handler_bci = bcis->at(i); - Node* ctrl = _gvn.transform( new (C) CatchProjNode(catch_, i+1,handler_bci)); + Node* ctrl = _gvn.transform( new CatchProjNode(catch_, i+1,handler_bci)); // This handler cannot happen? if (ctrl == top()) continue; set_control(ctrl); // Create exception oop const TypeInstPtr* extype = extypes->at(i)->is_instptr(); - Node *ex_oop = _gvn.transform(new (C) CreateExNode(extypes->at(i), ctrl, i_o)); + Node *ex_oop = _gvn.transform(new CreateExNode(extypes->at(i), ctrl, i_o)); // Handle unloaded exception classes. if (saw_unloaded->contains(handler_bci)) { @@ -746,7 +746,7 @@ void Parse::catch_call_exceptions(ciExceptionHandlerStream& handlers) { // The first CatchProj is for the normal return. // (Note: If this is a call to rethrow_Java, this node goes dead.) - set_control(_gvn.transform( new (C) CatchProjNode(catch_, CatchProjNode::fall_through_index, CatchProjNode::no_handler_bci))); + set_control(_gvn.transform( new CatchProjNode(catch_, CatchProjNode::fall_through_index, CatchProjNode::no_handler_bci))); } @@ -797,7 +797,7 @@ void Parse::catch_inline_exceptions(SafePointNode* ex_map) { // I'm loading the class from, I can replace the LoadKlass with the // klass constant for the exception oop. if( ex_node->is_Phi() ) { - ex_klass_node = new (C) PhiNode( ex_node->in(0), TypeKlassPtr::OBJECT ); + ex_klass_node = new PhiNode( ex_node->in(0), TypeKlassPtr::OBJECT ); for( uint i = 1; i < ex_node->req(); i++ ) { Node* p = basic_plus_adr( ex_node->in(i), ex_node->in(i), oopDesc::klass_offset_in_bytes() ); Node* k = _gvn.transform( LoadKlassNode::make(_gvn, immutable_memory(), p, TypeInstPtr::KLASS, TypeKlassPtr::OBJECT) ); @@ -863,7 +863,7 @@ void Parse::catch_inline_exceptions(SafePointNode* ex_map) { PreserveJVMState pjvms(this); const TypeInstPtr* tinst = TypeOopPtr::make_from_klass_unique(klass)->cast_to_ptr_type(TypePtr::NotNull)->is_instptr(); assert(klass->has_subklass() || tinst->klass_is_exact(), "lost exactness"); - Node* ex_oop = _gvn.transform(new (C) CheckCastPPNode(control(), ex_node, tinst)); + Node* ex_oop = _gvn.transform(new CheckCastPPNode(control(), ex_node, tinst)); push_ex_oop(ex_oop); // Push exception oop for handler #ifndef PRODUCT if (PrintOpto && WizardMode) { diff --git a/hotspot/src/share/vm/opto/escape.cpp b/hotspot/src/share/vm/opto/escape.cpp index 883adef7c83..10791a5991d 100644 --- a/hotspot/src/share/vm/opto/escape.cpp +++ b/hotspot/src/share/vm/opto/escape.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -939,7 +939,13 @@ void ConnectionGraph::process_call_arguments(CallNode *call) { strcmp(call->as_CallLeaf()->_name, "aescrypt_encryptBlock") == 0 || strcmp(call->as_CallLeaf()->_name, "aescrypt_decryptBlock") == 0 || strcmp(call->as_CallLeaf()->_name, "cipherBlockChaining_encryptAESCrypt") == 0 || - strcmp(call->as_CallLeaf()->_name, "cipherBlockChaining_decryptAESCrypt") == 0) + strcmp(call->as_CallLeaf()->_name, "cipherBlockChaining_decryptAESCrypt") == 0 || + strcmp(call->as_CallLeaf()->_name, "sha1_implCompress") == 0 || + strcmp(call->as_CallLeaf()->_name, "sha1_implCompressMB") == 0 || + strcmp(call->as_CallLeaf()->_name, "sha256_implCompress") == 0 || + strcmp(call->as_CallLeaf()->_name, "sha256_implCompressMB") == 0 || + strcmp(call->as_CallLeaf()->_name, "sha512_implCompress") == 0 || + strcmp(call->as_CallLeaf()->_name, "sha512_implCompressMB") == 0) ))) { call->dump(); fatal(err_msg_res("EA unexpected CallLeaf %s", call->as_CallLeaf()->_name)); diff --git a/hotspot/src/share/vm/opto/generateOptoStub.cpp b/hotspot/src/share/vm/opto/generateOptoStub.cpp index f75110842b9..0472f45adeb 100644 --- a/hotspot/src/share/vm/opto/generateOptoStub.cpp +++ b/hotspot/src/share/vm/opto/generateOptoStub.cpp @@ -50,7 +50,7 @@ void GraphKit::gen_stub(address C_function, const TypeTuple *jrange = C->tf()->range(); // The procedure start - StartNode* start = new (C) StartNode(root(), jdomain); + StartNode* start = new StartNode(root(), jdomain); _gvn.set_type_bottom(start); // Make a map, with JVM state @@ -64,7 +64,7 @@ void GraphKit::gen_stub(address C_function, jvms->set_scloff(max_map); jvms->set_endoff(max_map); { - SafePointNode *map = new (C) SafePointNode( max_map, jvms ); + SafePointNode *map = new SafePointNode( max_map, jvms ); jvms->set_map(map); set_jvms(jvms); assert(map == this->map(), "kit.map is set"); @@ -73,7 +73,7 @@ void GraphKit::gen_stub(address C_function, // Make up the parameters uint i; for( i = 0; i < parm_cnt; i++ ) - map()->init_req(i, _gvn.transform(new (C) ParmNode(start, i))); + map()->init_req(i, _gvn.transform(new ParmNode(start, i))); for( ; ireq(); i++ ) map()->init_req(i, top()); // For nicer debugging @@ -81,7 +81,7 @@ void GraphKit::gen_stub(address C_function, set_all_memory(map()->memory()); // Get base of thread-local storage area - Node* thread = _gvn.transform( new (C) ThreadLocalNode() ); + Node* thread = _gvn.transform( new ThreadLocalNode() ); const int NoAlias = Compile::AliasIdxBot; @@ -166,8 +166,7 @@ void GraphKit::gen_stub(address C_function, //----------------------------- // Make the call node - CallRuntimeNode *call = new (C) - CallRuntimeNode(c_sig, C_function, name, TypePtr::BOTTOM); + CallRuntimeNode *call = new CallRuntimeNode(c_sig, C_function, name, TypePtr::BOTTOM); //----------------------------- // Fix-up the debug info for the call @@ -184,7 +183,7 @@ void GraphKit::gen_stub(address C_function, for (; i < parm_cnt; i++) { // Regular input arguments // Convert ints to longs if required. if (CCallingConventionRequiresIntsAsLongs && jdomain->field_at(i)->isa_int()) { - Node* int_as_long = _gvn.transform(new (C) ConvI2LNode(map()->in(i))); + Node* int_as_long = _gvn.transform(new ConvI2LNode(map()->in(i))); call->init_req(cnt++, int_as_long); // long call->init_req(cnt++, top()); // half } else { @@ -200,23 +199,23 @@ void GraphKit::gen_stub(address C_function, //----------------------------- // Now set up the return results - set_control( _gvn.transform( new (C) ProjNode(call,TypeFunc::Control)) ); - set_i_o( _gvn.transform( new (C) ProjNode(call,TypeFunc::I_O )) ); + set_control( _gvn.transform( new ProjNode(call,TypeFunc::Control)) ); + set_i_o( _gvn.transform( new ProjNode(call,TypeFunc::I_O )) ); set_all_memory_call(call); if (range->cnt() > TypeFunc::Parms) { - Node* retnode = _gvn.transform( new (C) ProjNode(call,TypeFunc::Parms) ); + Node* retnode = _gvn.transform( new ProjNode(call,TypeFunc::Parms) ); // C-land is allowed to return sub-word values. Convert to integer type. assert( retval != Type::TOP, "" ); if (retval == TypeInt::BOOL) { - retnode = _gvn.transform( new (C) AndINode(retnode, intcon(0xFF)) ); + retnode = _gvn.transform( new AndINode(retnode, intcon(0xFF)) ); } else if (retval == TypeInt::CHAR) { - retnode = _gvn.transform( new (C) AndINode(retnode, intcon(0xFFFF)) ); + retnode = _gvn.transform( new AndINode(retnode, intcon(0xFFFF)) ); } else if (retval == TypeInt::BYTE) { - retnode = _gvn.transform( new (C) LShiftINode(retnode, intcon(24)) ); - retnode = _gvn.transform( new (C) RShiftINode(retnode, intcon(24)) ); + retnode = _gvn.transform( new LShiftINode(retnode, intcon(24)) ); + retnode = _gvn.transform( new RShiftINode(retnode, intcon(24)) ); } else if (retval == TypeInt::SHORT) { - retnode = _gvn.transform( new (C) LShiftINode(retnode, intcon(16)) ); - retnode = _gvn.transform( new (C) RShiftINode(retnode, intcon(16)) ); + retnode = _gvn.transform( new LShiftINode(retnode, intcon(16)) ); + retnode = _gvn.transform( new RShiftINode(retnode, intcon(16)) ); } map()->set_req( TypeFunc::Parms, retnode ); } @@ -253,21 +252,21 @@ void GraphKit::gen_stub(address C_function, Node* exit_memory = reset_memory(); - Node* cmp = _gvn.transform( new (C) CmpPNode(pending, null()) ); - Node* bo = _gvn.transform( new (C) BoolNode(cmp, BoolTest::ne) ); + Node* cmp = _gvn.transform( new CmpPNode(pending, null()) ); + Node* bo = _gvn.transform( new BoolNode(cmp, BoolTest::ne) ); IfNode *iff = create_and_map_if(control(), bo, PROB_MIN, COUNT_UNKNOWN); - Node* if_null = _gvn.transform( new (C) IfFalseNode(iff) ); - Node* if_not_null = _gvn.transform( new (C) IfTrueNode(iff) ); + Node* if_null = _gvn.transform( new IfFalseNode(iff) ); + Node* if_not_null = _gvn.transform( new IfTrueNode(iff) ); assert (StubRoutines::forward_exception_entry() != NULL, "must be generated before"); Node *exc_target = makecon(TypeRawPtr::make( StubRoutines::forward_exception_entry() )); - Node *to_exc = new (C) TailCallNode(if_not_null, - i_o(), - exit_memory, - frameptr(), - returnadr(), - exc_target, null()); + Node *to_exc = new TailCallNode(if_not_null, + i_o(), + exit_memory, + frameptr(), + returnadr(), + exc_target, null()); root()->add_req(_gvn.transform(to_exc)); // bind to root to keep live C->init_start(start); @@ -277,27 +276,27 @@ void GraphKit::gen_stub(address C_function, switch( is_fancy_jump ) { case 0: // Make a return instruction // Return to caller, free any space for return address - ret = new (C) ReturnNode(TypeFunc::Parms, if_null, - i_o(), - exit_memory, - frameptr(), - returnadr()); + ret = new ReturnNode(TypeFunc::Parms, if_null, + i_o(), + exit_memory, + frameptr(), + returnadr()); if (C->tf()->range()->cnt() > TypeFunc::Parms) ret->add_req( map()->in(TypeFunc::Parms) ); break; case 1: // This is a fancy tail-call jump. Jump to computed address. // Jump to new callee; leave old return address alone. - ret = new (C) TailCallNode(if_null, - i_o(), - exit_memory, - frameptr(), - returnadr(), - target, map()->in(TypeFunc::Parms)); + ret = new TailCallNode(if_null, + i_o(), + exit_memory, + frameptr(), + returnadr(), + target, map()->in(TypeFunc::Parms)); break; case 2: // Pop return address & jump // Throw away old return address; jump to new computed address //assert(C_function == CAST_FROM_FN_PTR(address, OptoRuntime::rethrow_C), "fancy_jump==2 only for rethrow"); - ret = new (C) TailJumpNode(if_null, + ret = new TailJumpNode(if_null, i_o(), exit_memory, frameptr(), diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index 123e28fa95b..e7269aa514e 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -294,7 +294,7 @@ JVMState* GraphKit::transfer_exceptions_into_jvms() { JVMState* jvms = new (C) JVMState(_method, NULL); jvms->set_bci(_bci); jvms->set_sp(_sp); - jvms->set_map(new (C) SafePointNode(TypeFunc::Parms, jvms)); + jvms->set_map(new SafePointNode(TypeFunc::Parms, jvms)); set_jvms(jvms); for (uint i = 0; i < map()->req(); i++) map()->init_req(i, top()); set_all_memory(top()); @@ -347,7 +347,7 @@ void GraphKit::combine_exception_states(SafePointNode* ex_map, SafePointNode* ph if (region->in(0) != hidden_merge_mark) { // The control input is not (yet) a specially-marked region in phi_map. // Make it so, and build some phis. - region = new (C) RegionNode(2); + region = new RegionNode(2); _gvn.set_type(region, Type::CONTROL); region->set_req(0, hidden_merge_mark); // marks an internal ex-state region->init_req(1, phi_map->control()); @@ -432,6 +432,7 @@ void GraphKit::combine_exception_states(SafePointNode* ex_map, SafePointNode* ph } } } + phi_map->merge_replaced_nodes_with(ex_map); } //--------------------------use_exception_state-------------------------------- @@ -496,13 +497,13 @@ void GraphKit::uncommon_trap_if_should_post_on_exceptions(Deoptimization::DeoptR // take the uncommon_trap in the BuildCutout below. // first must access the should_post_on_exceptions_flag in this thread's JavaThread - Node* jthread = _gvn.transform(new (C) ThreadLocalNode()); + Node* jthread = _gvn.transform(new ThreadLocalNode()); Node* adr = basic_plus_adr(top(), jthread, in_bytes(JavaThread::should_post_on_exceptions_flag_offset())); Node* should_post_flag = make_load(control(), adr, TypeInt::INT, T_INT, Compile::AliasIdxRaw, MemNode::unordered); // Test the should_post_on_exceptions_flag vs. 0 - Node* chk = _gvn.transform( new (C) CmpINode(should_post_flag, intcon(0)) ); - Node* tst = _gvn.transform( new (C) BoolNode(chk, BoolTest::eq) ); + Node* chk = _gvn.transform( new CmpINode(should_post_flag, intcon(0)) ); + Node* tst = _gvn.transform( new BoolNode(chk, BoolTest::eq) ); // Branch to slow_path if should_post_on_exceptions_flag was true { BuildCutout unless(this, tst, PROB_MAX); @@ -645,7 +646,6 @@ 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(); @@ -663,7 +663,6 @@ PreserveJVMState::~PreserveJVMState() { #endif kit->set_map(_map); kit->set_sp(_sp); - Compile::current()->dec_preserve_jvm_state(); } @@ -675,8 +674,8 @@ BuildCutout::BuildCutout(GraphKit* kit, Node* p, float prob, float cnt) SafePointNode* outer_map = _map; // preserved map is caller's SafePointNode* inner_map = kit->map(); IfNode* iff = kit->create_and_map_if(outer_map->control(), p, prob, cnt); - outer_map->set_control(kit->gvn().transform( new (kit->C) IfTrueNode(iff) )); - inner_map->set_control(kit->gvn().transform( new (kit->C) IfFalseNode(iff) )); + outer_map->set_control(kit->gvn().transform( new IfTrueNode(iff) )); + inner_map->set_control(kit->gvn().transform( new IfFalseNode(iff) )); } BuildCutout::~BuildCutout() { GraphKit* kit = _kit; @@ -1118,7 +1117,7 @@ bool GraphKit::compute_stack_effects(int& inputs, int& depth) { Node* GraphKit::basic_plus_adr(Node* base, Node* ptr, Node* offset) { // short-circuit a common case if (offset == intcon(0)) return ptr; - return _gvn.transform( new (C) AddPNode(base, ptr, offset) ); + return _gvn.transform( new AddPNode(base, ptr, offset) ); } Node* GraphKit::ConvI2L(Node* offset) { @@ -1127,7 +1126,7 @@ Node* GraphKit::ConvI2L(Node* offset) { if (offset_con != Type::OffsetBot) { return longcon((jlong) offset_con); } - return _gvn.transform( new (C) ConvI2LNode(offset)); + return _gvn.transform( new ConvI2LNode(offset)); } Node* GraphKit::ConvI2UL(Node* offset) { @@ -1135,9 +1134,9 @@ Node* GraphKit::ConvI2UL(Node* offset) { if (offset_con != (juint) Type::OffsetBot) { return longcon((julong) offset_con); } - Node* conv = _gvn.transform( new (C) ConvI2LNode(offset)); + Node* conv = _gvn.transform( new ConvI2LNode(offset)); Node* mask = _gvn.transform( ConLNode::make(C, (julong) max_juint) ); - return _gvn.transform( new (C) AndLNode(conv, mask) ); + return _gvn.transform( new AndLNode(conv, mask) ); } Node* GraphKit::ConvL2I(Node* offset) { @@ -1146,7 +1145,7 @@ Node* GraphKit::ConvL2I(Node* offset) { if (offset_con != (jlong)Type::OffsetBot) { return intcon((int) offset_con); } - return _gvn.transform( new (C) ConvL2INode(offset)); + return _gvn.transform( new ConvL2INode(offset)); } //-------------------------load_object_klass----------------------------------- @@ -1165,7 +1164,7 @@ Node* GraphKit::load_array_length(Node* array) { Node *alen; if (alloc == NULL) { Node *r_adr = basic_plus_adr(array, arrayOopDesc::length_offset_in_bytes()); - alen = _gvn.transform( new (C) LoadRangeNode(0, immutable_memory(), r_adr, TypeInt::POS)); + alen = _gvn.transform( new LoadRangeNode(0, immutable_memory(), r_adr, TypeInt::POS)); } else { alen = alloc->Ideal_length(); Node* ccast = alloc->make_ideal_length(_gvn.type(array)->is_oopptr(), &_gvn); @@ -1199,8 +1198,8 @@ Node* GraphKit::null_check_common(Node* value, BasicType type, // Construct NULL check Node *chk = NULL; switch(type) { - case T_LONG : chk = new (C) CmpLNode(value, _gvn.zerocon(T_LONG)); break; - case T_INT : chk = new (C) CmpINode(value, _gvn.intcon(0)); break; + case T_LONG : chk = new CmpLNode(value, _gvn.zerocon(T_LONG)); break; + case T_INT : chk = new CmpINode(value, _gvn.intcon(0)); break; case T_ARRAY : // fall through type = T_OBJECT; // simplify further tests case T_OBJECT : { @@ -1247,7 +1246,7 @@ Node* GraphKit::null_check_common(Node* value, BasicType type, return value; // Elided null check quickly! } } - chk = new (C) CmpPNode( value, null() ); + chk = new CmpPNode( value, null() ); break; } @@ -1258,7 +1257,7 @@ Node* GraphKit::null_check_common(Node* value, BasicType type, chk = _gvn.transform(chk); BoolTest::mask btest = assert_null ? BoolTest::eq : BoolTest::ne; - BoolNode *btst = new (C) BoolNode( chk, btest); + BoolNode *btst = new BoolNode( chk, btest); Node *tst = _gvn.transform( btst ); //----------- @@ -1325,8 +1324,8 @@ Node* GraphKit::null_check_common(Node* value, BasicType type, if (null_control != NULL) { IfNode* iff = create_and_map_if(control(), tst, ok_prob, COUNT_UNKNOWN); - Node* null_true = _gvn.transform( new (C) IfFalseNode(iff)); - set_control( _gvn.transform( new (C) IfTrueNode(iff))); + Node* null_true = _gvn.transform( new IfFalseNode(iff)); + set_control( _gvn.transform( new IfTrueNode(iff))); if (null_true == top()) explicit_null_checks_elided++; (*null_control) = null_true; @@ -1378,7 +1377,7 @@ Node* GraphKit::cast_not_null(Node* obj, bool do_replace_in_map) { // Object is already not-null? if( t == t_not_null ) return obj; - Node *cast = new (C) CastPPNode(obj,t_not_null); + Node *cast = new CastPPNode(obj,t_not_null); cast->init_req(0, control()); cast = _gvn.transform( cast ); @@ -1403,60 +1402,17 @@ void GraphKit::replace_in_map(Node* old, Node* neww) { // on the map. This includes locals, stack, and monitors // of the current (innermost) JVM state. - if (!ReplaceInParentMaps) { + // don't let inconsistent types from profiling escape this + // method + + const Type* told = _gvn.type(old); + const Type* tnew = _gvn.type(neww); + + if (!tnew->higher_equal(told)) { 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(); - } + map()->record_replaced_node(old, neww); } @@ -1486,7 +1442,7 @@ void GraphKit::set_all_memory(Node* newmem) { //------------------------------set_all_memory_call---------------------------- void GraphKit::set_all_memory_call(Node* call, bool separate_io_proj) { - Node* newmem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory, separate_io_proj) ); + Node* newmem = _gvn.transform( new ProjNode(call, TypeFunc::Memory, separate_io_proj) ); set_all_memory(newmem); } @@ -1721,9 +1677,9 @@ Node* GraphKit::array_element_address(Node* ary, Node* idx, BasicType elembt, int index_max = max_jint - 1; // array size is max_jint, index is one less if (sizetype != NULL) index_max = sizetype->_hi - 1; const TypeLong* lidxtype = TypeLong::make(CONST64(0), index_max, Type::WidenMax); - idx = _gvn.transform( new (C) ConvI2LNode(idx, lidxtype) ); + idx = _gvn.transform( new ConvI2LNode(idx, lidxtype) ); #endif - Node* scale = _gvn.transform( new (C) LShiftXNode(idx, intcon(shift)) ); + Node* scale = _gvn.transform( new LShiftXNode(idx, intcon(shift)) ); return basic_plus_adr(ary, base, scale); } @@ -1771,8 +1727,8 @@ void GraphKit::set_edges_for_java_call(CallJavaNode* call, bool must_throw, bool // Re-use the current map to produce the result. - set_control(_gvn.transform(new (C) ProjNode(call, TypeFunc::Control))); - set_i_o( _gvn.transform(new (C) ProjNode(call, TypeFunc::I_O , separate_io_proj))); + set_control(_gvn.transform(new ProjNode(call, TypeFunc::Control))); + set_i_o( _gvn.transform(new ProjNode(call, TypeFunc::I_O , separate_io_proj))); set_all_memory_call(xcall, separate_io_proj); //return xcall; // no need, caller already has it @@ -1786,7 +1742,7 @@ Node* GraphKit::set_results_for_java_call(CallJavaNode* call, bool separate_io_p if (call->method() == NULL || call->method()->return_type()->basic_type() == T_VOID) ret = top(); - else ret = _gvn.transform(new (C) ProjNode(call, TypeFunc::Parms)); + else ret = _gvn.transform(new ProjNode(call, TypeFunc::Parms)); // Note: Since any out-of-line call can produce an exception, // we always insert an I_O projection from the call into the result. @@ -1797,8 +1753,8 @@ Node* GraphKit::set_results_for_java_call(CallJavaNode* call, bool separate_io_p // The caller requested separate projections be used by the fall // through and exceptional paths, so replace the projections for // the fall through path. - set_i_o(_gvn.transform( new (C) ProjNode(call, TypeFunc::I_O) )); - set_all_memory(_gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) )); + set_i_o(_gvn.transform( new ProjNode(call, TypeFunc::I_O) )); + set_all_memory(_gvn.transform( new ProjNode(call, TypeFunc::Memory) )); } return ret; } @@ -1838,13 +1794,13 @@ void GraphKit::set_predefined_output_for_runtime_call(Node* call, Node* keep_mem, const TypePtr* hook_mem) { // no i/o - set_control(_gvn.transform( new (C) ProjNode(call,TypeFunc::Control) )); + set_control(_gvn.transform( new ProjNode(call,TypeFunc::Control) )); if (keep_mem) { // First clone the existing memory state set_all_memory(keep_mem); if (hook_mem != NULL) { // Make memory for the call - Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) ); + Node* mem = _gvn.transform( new ProjNode(call, TypeFunc::Memory) ); // Set the RawPtr memory state only. This covers all the heap top/GC stuff // We also use hook_mem to extract specific effects from arraycopy stubs. set_memory(mem, hook_mem); @@ -1864,12 +1820,16 @@ void GraphKit::set_predefined_output_for_runtime_call(Node* call, // Replace the call with the current state of the kit. -void GraphKit::replace_call(CallNode* call, Node* result) { +void GraphKit::replace_call(CallNode* call, Node* result, bool do_replaced_nodes) { JVMState* ejvms = NULL; if (has_exceptions()) { ejvms = transfer_exceptions_into_jvms(); } + ReplacedNodes replaced_nodes = map()->replaced_nodes(); + ReplacedNodes replaced_nodes_exception; + Node* ex_ctl = top(); + SafePointNode* final_state = stop(); // Find all the needed outputs of this call @@ -1886,6 +1846,10 @@ void GraphKit::replace_call(CallNode* call, Node* result) { C->gvn_replace_by(callprojs.fallthrough_catchproj, final_ctl); } if (callprojs.fallthrough_memproj != NULL) { + if (final_mem->is_MergeMem()) { + // Parser's exits MergeMem was not transformed but may be optimized + final_mem = _gvn.transform(final_mem); + } C->gvn_replace_by(callprojs.fallthrough_memproj, final_mem); } if (callprojs.fallthrough_ioproj != NULL) { @@ -1917,10 +1881,13 @@ void GraphKit::replace_call(CallNode* call, Node* result) { // Load my combined exception state into the kit, with all phis transformed: SafePointNode* ex_map = ekit.combine_and_pop_all_exception_states(); + replaced_nodes_exception = ex_map->replaced_nodes(); Node* ex_oop = ekit.use_exception_state(ex_map); + if (callprojs.catchall_catchproj != NULL) { C->gvn_replace_by(callprojs.catchall_catchproj, ekit.control()); + ex_ctl = ekit.control(); } if (callprojs.catchall_memproj != NULL) { C->gvn_replace_by(callprojs.catchall_memproj, ekit.reset_memory()); @@ -1953,6 +1920,13 @@ void GraphKit::replace_call(CallNode* call, Node* result) { _gvn.transform(wl.pop()); } } + + if (callprojs.fallthrough_catchproj != NULL && !final_ctl->is_top() && do_replaced_nodes) { + replaced_nodes.apply(C, final_ctl); + } + if (!ex_ctl->is_top() && do_replaced_nodes) { + replaced_nodes_exception.apply(C, ex_ctl); + } } @@ -1968,7 +1942,7 @@ void GraphKit::increment_counter(Node* counter_addr) { int adr_type = Compile::AliasIdxRaw; Node* ctrl = control(); Node* cnt = make_load(ctrl, counter_addr, TypeInt::INT, T_INT, adr_type, MemNode::unordered); - Node* incr = _gvn.transform(new (C) AddINode(cnt, _gvn.intcon(1))); + Node* incr = _gvn.transform(new AddINode(cnt, _gvn.intcon(1))); store_to_memory(ctrl, counter_addr, incr, T_INT, adr_type, MemNode::unordered); } @@ -2087,7 +2061,7 @@ void GraphKit::uncommon_trap(int trap_request, // The debug info is the only real input to this call. // Halt-and-catch fire here. The above call should never return! - HaltNode* halt = new(C) HaltNode(control(), frameptr()); + HaltNode* halt = new HaltNode(control(), frameptr()); _gvn.set_type_bottom(halt); root()->add_req(halt); @@ -2169,7 +2143,7 @@ Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls, bool // 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) CheckCastPPNode(control(), n, current_type->remove_speculative()->join_speculative(spec_type)); + Node* cast = new CheckCastPPNode(control(), n, current_type->remove_speculative()->join_speculative(spec_type)); cast = _gvn.transform(cast); replace_in_map(n, cast); n = cast; @@ -2287,7 +2261,7 @@ void GraphKit::round_double_result(ciMethod* dest_method) { Node* GraphKit::precision_rounding(Node* n) { return UseStrictFP && _method->flags().is_strict() && UseSSE == 0 && Matcher::strict_fp_requires_explicit_rounding - ? _gvn.transform( new (C) RoundFloatNode(0, n) ) + ? _gvn.transform( new RoundFloatNode(0, n) ) : n; } @@ -2295,7 +2269,7 @@ Node* GraphKit::precision_rounding(Node* n) { Node* GraphKit::dprecision_rounding(Node *n) { return UseStrictFP && _method->flags().is_strict() && UseSSE <= 1 && Matcher::strict_fp_requires_explicit_rounding - ? _gvn.transform( new (C) RoundDoubleNode(0, n) ) + ? _gvn.transform( new RoundDoubleNode(0, n) ) : n; } @@ -2303,7 +2277,7 @@ Node* GraphKit::dprecision_rounding(Node *n) { Node* GraphKit::dstore_rounding(Node* n) { return Matcher::strict_fp_requires_explicit_rounding && UseSSE <= 1 - ? _gvn.transform( new (C) RoundDoubleNode(0, n) ) + ? _gvn.transform( new RoundDoubleNode(0, n) ) : n; } @@ -2382,11 +2356,11 @@ Node* GraphKit::opt_iff(Node* region, Node* iff) { IfNode *opt_iff = _gvn.transform(iff)->as_If(); // Fast path taken; set region slot 2 - Node *fast_taken = _gvn.transform( new (C) IfFalseNode(opt_iff) ); + Node *fast_taken = _gvn.transform( new IfFalseNode(opt_iff) ); region->init_req(2,fast_taken); // Capture fast-control // Fast path not-taken, i.e. slow path - Node *slow_taken = _gvn.transform( new (C) IfTrueNode(opt_iff) ); + Node *slow_taken = _gvn.transform( new IfTrueNode(opt_iff) ); return slow_taken; } @@ -2410,12 +2384,12 @@ Node* GraphKit::make_runtime_call(int flags, } CallNode* call; if (!is_leaf) { - call = new(C) CallStaticJavaNode(call_type, call_addr, call_name, + call = new CallStaticJavaNode(call_type, call_addr, call_name, bci(), adr_type); } else if (flags & RC_NO_FP) { - call = new(C) CallLeafNoFPNode(call_type, call_addr, call_name, adr_type); + call = new CallLeafNoFPNode(call_type, call_addr, call_name, adr_type); } else { - call = new(C) CallLeafNode(call_type, call_addr, call_name, adr_type); + call = new CallLeafNode(call_type, call_addr, call_name, adr_type); } // The following is similar to set_edges_for_java_call, @@ -2476,7 +2450,7 @@ Node* GraphKit::make_runtime_call(int flags, } if (has_io) { - set_i_o(_gvn.transform(new (C) ProjNode(call, TypeFunc::I_O))); + set_i_o(_gvn.transform(new ProjNode(call, TypeFunc::I_O))); } return call; @@ -2490,48 +2464,55 @@ void GraphKit::merge_memory(Node* new_mem, Node* region, int new_path) { Node* new_slice = mms.memory2(); if (old_slice != new_slice) { PhiNode* phi; - if (new_slice->is_Phi() && new_slice->as_Phi()->region() == region) { - phi = new_slice->as_Phi(); - #ifdef ASSERT - if (old_slice->is_Phi() && old_slice->as_Phi()->region() == region) - old_slice = old_slice->in(new_path); - // Caller is responsible for ensuring that any pre-existing - // phis are already aware of old memory. - int old_path = (new_path > 1) ? 1 : 2; // choose old_path != new_path - assert(phi->in(old_path) == old_slice, "pre-existing phis OK"); - #endif - mms.set_memory(phi); + if (old_slice->is_Phi() && old_slice->as_Phi()->region() == region) { + if (mms.is_empty()) { + // clone base memory Phi's inputs for this memory slice + assert(old_slice == mms.base_memory(), "sanity"); + phi = PhiNode::make(region, NULL, Type::MEMORY, mms.adr_type(C)); + _gvn.set_type(phi, Type::MEMORY); + for (uint i = 1; i < phi->req(); i++) { + phi->init_req(i, old_slice->in(i)); + } + } else { + phi = old_slice->as_Phi(); // Phi was generated already + } } else { phi = PhiNode::make(region, old_slice, Type::MEMORY, mms.adr_type(C)); _gvn.set_type(phi, Type::MEMORY); - phi->set_req(new_path, new_slice); - mms.set_memory(_gvn.transform(phi)); // assume it is complete } + phi->set_req(new_path, new_slice); + mms.set_memory(phi); } } } //------------------------------make_slow_call_ex------------------------------ // Make the exception handler hookups for the slow call -void GraphKit::make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj) { +void GraphKit::make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj, bool deoptimize) { if (stopped()) return; // Make a catch node with just two handlers: fall-through and catch-all - Node* i_o = _gvn.transform( new (C) ProjNode(call, TypeFunc::I_O, separate_io_proj) ); - Node* catc = _gvn.transform( new (C) CatchNode(control(), i_o, 2) ); - Node* norm = _gvn.transform( new (C) CatchProjNode(catc, CatchProjNode::fall_through_index, CatchProjNode::no_handler_bci) ); - Node* excp = _gvn.transform( new (C) CatchProjNode(catc, CatchProjNode::catch_all_index, CatchProjNode::no_handler_bci) ); + Node* i_o = _gvn.transform( new ProjNode(call, TypeFunc::I_O, separate_io_proj) ); + Node* catc = _gvn.transform( new CatchNode(control(), i_o, 2) ); + Node* norm = _gvn.transform( new CatchProjNode(catc, CatchProjNode::fall_through_index, CatchProjNode::no_handler_bci) ); + Node* excp = _gvn.transform( new CatchProjNode(catc, CatchProjNode::catch_all_index, CatchProjNode::no_handler_bci) ); { PreserveJVMState pjvms(this); set_control(excp); set_i_o(i_o); if (excp != top()) { - // Create an exception state also. - // Use an exact type if the caller has specified a specific exception. - const Type* ex_type = TypeOopPtr::make_from_klass_unique(ex_klass)->cast_to_ptr_type(TypePtr::NotNull); - Node* ex_oop = new (C) CreateExNode(ex_type, control(), i_o); - add_exception_state(make_exception_state(_gvn.transform(ex_oop))); + if (deoptimize) { + // Deoptimize if an exception is caught. Don't construct exception state in this case. + uncommon_trap(Deoptimization::Reason_unhandled, + Deoptimization::Action_none); + } else { + // Create an exception state also. + // Use an exact type if the caller has specified a specific exception. + const Type* ex_type = TypeOopPtr::make_from_klass_unique(ex_klass)->cast_to_ptr_type(TypePtr::NotNull); + Node* ex_oop = new CreateExNode(ex_type, control(), i_o); + add_exception_state(make_exception_state(_gvn.transform(ex_oop))); + } } } @@ -2580,11 +2561,11 @@ Node* GraphKit::gen_subtype_check(Node* subklass, Node* superklass) { case SSC_easy_test: { // Just do a direct pointer compare and be done. - Node* cmp = _gvn.transform( new(C) CmpPNode(subklass, superklass) ); - Node* bol = _gvn.transform( new(C) BoolNode(cmp, BoolTest::eq) ); + Node* cmp = _gvn.transform( new CmpPNode(subklass, superklass) ); + Node* bol = _gvn.transform( new BoolNode(cmp, BoolTest::eq) ); IfNode* iff = create_and_xform_if(control(), bol, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); - set_control( _gvn.transform( new(C) IfTrueNode (iff) ) ); - return _gvn.transform( new(C) IfFalseNode(iff) ); + set_control( _gvn.transform( new IfTrueNode (iff) ) ); + return _gvn.transform( new IfFalseNode(iff) ); } case SSC_full_test: break; @@ -2599,7 +2580,7 @@ Node* GraphKit::gen_subtype_check(Node* subklass, Node* superklass) { // First load the super-klass's check-offset Node *p1 = basic_plus_adr( superklass, superklass, in_bytes(Klass::super_check_offset_offset()) ); - Node *chk_off = _gvn.transform(new (C) LoadINode(NULL, memory(p1), p1, _gvn.type(p1)->is_ptr(), + Node *chk_off = _gvn.transform(new LoadINode(NULL, memory(p1), p1, _gvn.type(p1)->is_ptr(), TypeInt::INT, MemNode::unordered)); int cacheoff_con = in_bytes(Klass::secondary_super_cache_offset()); bool might_be_cache = (find_int_con(chk_off, cacheoff_con) == cacheoff_con); @@ -2611,7 +2592,7 @@ Node* GraphKit::gen_subtype_check(Node* subklass, Node* superklass) { // Worst-case type is a little odd: NULL is allowed as a result (usually // klass loads can never produce a NULL). Node *chk_off_X = ConvI2X(chk_off); - Node *p2 = _gvn.transform( new (C) AddPNode(subklass,subklass,chk_off_X) ); + Node *p2 = _gvn.transform( new AddPNode(subklass,subklass,chk_off_X) ); // For some types like interfaces the following loadKlass is from a 1-word // cache which is mutable so can't use immutable memory. Other // types load from the super-class display table which is immutable. @@ -2625,11 +2606,11 @@ Node* GraphKit::gen_subtype_check(Node* subklass, Node* superklass) { // See if we get an immediate positive hit. Happens roughly 83% of the // time. Test to see if the value loaded just previously from the subklass // is exactly the superklass. - Node *cmp1 = _gvn.transform( new (C) CmpPNode( superklass, nkls ) ); - Node *bol1 = _gvn.transform( new (C) BoolNode( cmp1, BoolTest::eq ) ); + Node *cmp1 = _gvn.transform( new CmpPNode( superklass, nkls ) ); + Node *bol1 = _gvn.transform( new BoolNode( cmp1, BoolTest::eq ) ); IfNode *iff1 = create_and_xform_if( control(), bol1, PROB_LIKELY(0.83f), COUNT_UNKNOWN ); - Node *iftrue1 = _gvn.transform( new (C) IfTrueNode ( iff1 ) ); - set_control( _gvn.transform( new (C) IfFalseNode( iff1 ) ) ); + Node *iftrue1 = _gvn.transform( new IfTrueNode ( iff1 ) ); + set_control( _gvn.transform( new IfFalseNode( iff1 ) ) ); // Compile speed common case: Check for being deterministic right now. If // chk_off is a constant and not equal to cacheoff then we are NOT a @@ -2642,9 +2623,9 @@ Node* GraphKit::gen_subtype_check(Node* subklass, Node* superklass) { } // Gather the various success & failures here - RegionNode *r_ok_subtype = new (C) RegionNode(4); + RegionNode *r_ok_subtype = new RegionNode(4); record_for_igvn(r_ok_subtype); - RegionNode *r_not_subtype = new (C) RegionNode(3); + RegionNode *r_not_subtype = new RegionNode(3); record_for_igvn(r_not_subtype); r_ok_subtype->init_req(1, iftrue1); @@ -2655,20 +2636,20 @@ Node* GraphKit::gen_subtype_check(Node* subklass, Node* superklass) { // cache. If it points to the display (and NOT the cache) and the display // missed then it's not a subtype. Node *cacheoff = _gvn.intcon(cacheoff_con); - Node *cmp2 = _gvn.transform( new (C) CmpINode( chk_off, cacheoff ) ); - Node *bol2 = _gvn.transform( new (C) BoolNode( cmp2, BoolTest::ne ) ); + Node *cmp2 = _gvn.transform( new CmpINode( chk_off, cacheoff ) ); + Node *bol2 = _gvn.transform( new BoolNode( cmp2, BoolTest::ne ) ); IfNode *iff2 = create_and_xform_if( control(), bol2, PROB_LIKELY(0.63f), COUNT_UNKNOWN ); - r_not_subtype->init_req(1, _gvn.transform( new (C) IfTrueNode (iff2) ) ); - set_control( _gvn.transform( new (C) IfFalseNode(iff2) ) ); + r_not_subtype->init_req(1, _gvn.transform( new IfTrueNode (iff2) ) ); + set_control( _gvn.transform( new IfFalseNode(iff2) ) ); // Check for self. Very rare to get here, but it is taken 1/3 the time. // No performance impact (too rare) but allows sharing of secondary arrays // which has some footprint reduction. - Node *cmp3 = _gvn.transform( new (C) CmpPNode( subklass, superklass ) ); - Node *bol3 = _gvn.transform( new (C) BoolNode( cmp3, BoolTest::eq ) ); + Node *cmp3 = _gvn.transform( new CmpPNode( subklass, superklass ) ); + Node *bol3 = _gvn.transform( new BoolNode( cmp3, BoolTest::eq ) ); IfNode *iff3 = create_and_xform_if( control(), bol3, PROB_LIKELY(0.36f), COUNT_UNKNOWN ); - r_ok_subtype->init_req(2, _gvn.transform( new (C) IfTrueNode ( iff3 ) ) ); - set_control( _gvn.transform( new (C) IfFalseNode( iff3 ) ) ); + r_ok_subtype->init_req(2, _gvn.transform( new IfTrueNode ( iff3 ) ) ); + set_control( _gvn.transform( new IfFalseNode( iff3 ) ) ); // -- Roads not taken here: -- // We could also have chosen to perform the self-check at the beginning @@ -2692,13 +2673,13 @@ Node* GraphKit::gen_subtype_check(Node* subklass, Node* superklass) { // The decision to inline or out-of-line this final check is platform // dependent, and is found in the AD file definition of PartialSubtypeCheck. Node* psc = _gvn.transform( - new (C) PartialSubtypeCheckNode(control(), subklass, superklass) ); + new PartialSubtypeCheckNode(control(), subklass, superklass) ); - Node *cmp4 = _gvn.transform( new (C) CmpPNode( psc, null() ) ); - Node *bol4 = _gvn.transform( new (C) BoolNode( cmp4, BoolTest::ne ) ); + Node *cmp4 = _gvn.transform( new CmpPNode( psc, null() ) ); + Node *bol4 = _gvn.transform( new BoolNode( cmp4, BoolTest::ne ) ); IfNode *iff4 = create_and_xform_if( control(), bol4, PROB_FAIR, COUNT_UNKNOWN ); - r_not_subtype->init_req(2, _gvn.transform( new (C) IfTrueNode (iff4) ) ); - r_ok_subtype ->init_req(3, _gvn.transform( new (C) IfFalseNode(iff4) ) ); + r_not_subtype->init_req(2, _gvn.transform( new IfTrueNode (iff4) ) ); + r_ok_subtype ->init_req(3, _gvn.transform( new IfFalseNode(iff4) ) ); // Return false path; set default control to true path. set_control( _gvn.transform(r_ok_subtype) ); @@ -2762,18 +2743,18 @@ Node* GraphKit::type_check_receiver(Node* receiver, ciKlass* klass, const TypeKlassPtr* tklass = TypeKlassPtr::make(klass); Node* recv_klass = load_object_klass(receiver); Node* want_klass = makecon(tklass); - Node* cmp = _gvn.transform( new(C) CmpPNode(recv_klass, want_klass) ); - Node* bol = _gvn.transform( new(C) BoolNode(cmp, BoolTest::eq) ); + Node* cmp = _gvn.transform( new CmpPNode(recv_klass, want_klass) ); + Node* bol = _gvn.transform( new BoolNode(cmp, BoolTest::eq) ); IfNode* iff = create_and_xform_if(control(), bol, prob, COUNT_UNKNOWN); - set_control( _gvn.transform( new(C) IfTrueNode (iff) )); - Node* fail = _gvn.transform( new(C) IfFalseNode(iff) ); + set_control( _gvn.transform( new IfTrueNode (iff) )); + Node* fail = _gvn.transform( new IfFalseNode(iff) ); const TypeOopPtr* recv_xtype = tklass->as_instance_type(); assert(recv_xtype->klass_is_exact(), ""); // Subsume downstream occurrences of receiver with a cast to // recv_xtype, since now we know what the type will be. - Node* cast = new(C) CheckCastPPNode(control(), receiver, recv_xtype); + Node* cast = new CheckCastPPNode(control(), receiver, recv_xtype); (*casted_receiver) = _gvn.transform(cast); // (User must make the replace_in_map call.) @@ -2920,8 +2901,8 @@ Node* GraphKit::gen_instanceof(Node* obj, Node* superklass, bool safe_for_replac // Make the merge point enum { _obj_path = 1, _fail_path, _null_path, PATH_LIMIT }; - RegionNode* region = new(C) RegionNode(PATH_LIMIT); - Node* phi = new(C) PhiNode(region, TypeInt::BOOL); + RegionNode* region = new RegionNode(PATH_LIMIT); + Node* phi = new PhiNode(region, TypeInt::BOOL); C->set_has_split_ifs(true); // Has chance for split-if optimization ciProfileData* data = NULL; @@ -3052,8 +3033,8 @@ Node* GraphKit::gen_checkcast(Node *obj, Node* superklass, // Make the merge point enum { _obj_path = 1, _null_path, PATH_LIMIT }; - RegionNode* region = new (C) RegionNode(PATH_LIMIT); - Node* phi = new (C) PhiNode(region, toop); + RegionNode* region = new RegionNode(PATH_LIMIT); + Node* phi = new PhiNode(region, toop); C->set_has_split_ifs(true); // Has chance for split-if optimization // Use null-cast information if it is available @@ -3114,8 +3095,7 @@ Node* GraphKit::gen_checkcast(Node *obj, Node* superklass, Node* not_subtype_ctrl = gen_subtype_check( obj_klass, superklass ); // Plug in success path into the merge - cast_obj = _gvn.transform(new (C) CheckCastPPNode(control(), - not_null_obj, toop)); + cast_obj = _gvn.transform(new CheckCastPPNode(control(), not_null_obj, toop)); // Failure path ends in uncommon trap (or may be dead - failure impossible) if (failure_control == NULL) { if (not_subtype_ctrl != top()) { // If failure is possible @@ -3168,7 +3148,7 @@ Node* GraphKit::insert_mem_bar(int opcode, Node* precedent) { mb->init_req(TypeFunc::Control, control()); mb->init_req(TypeFunc::Memory, reset_memory()); Node* membar = _gvn.transform(mb); - set_control(_gvn.transform(new (C) ProjNode(membar, TypeFunc::Control))); + set_control(_gvn.transform(new ProjNode(membar, TypeFunc::Control))); set_all_memory_call(membar); return membar; } @@ -3197,11 +3177,11 @@ Node* GraphKit::insert_mem_bar_volatile(int opcode, int alias_idx, Node* precede mb->set_req(TypeFunc::Memory, memory(alias_idx)); } Node* membar = _gvn.transform(mb); - set_control(_gvn.transform(new (C) ProjNode(membar, TypeFunc::Control))); + set_control(_gvn.transform(new ProjNode(membar, TypeFunc::Control))); if (alias_idx == Compile::AliasIdxBot) { - merged_memory()->set_base_memory(_gvn.transform(new (C) ProjNode(membar, TypeFunc::Memory))); + merged_memory()->set_base_memory(_gvn.transform(new ProjNode(membar, TypeFunc::Memory))); } else { - set_memory(_gvn.transform(new (C) ProjNode(membar, TypeFunc::Memory)),alias_idx); + set_memory(_gvn.transform(new ProjNode(membar, TypeFunc::Memory)),alias_idx); } return membar; } @@ -3221,10 +3201,10 @@ FastLockNode* GraphKit::shared_lock(Node* obj) { assert(dead_locals_are_killed(), "should kill locals before sync. point"); // Box the stack location - Node* box = _gvn.transform(new (C) BoxLockNode(next_monitor())); + Node* box = _gvn.transform(new BoxLockNode(next_monitor())); Node* mem = reset_memory(); - FastLockNode * flock = _gvn.transform(new (C) FastLockNode(0, obj, box) )->as_FastLock(); + FastLockNode * flock = _gvn.transform(new FastLockNode(0, obj, box) )->as_FastLock(); if (UseBiasedLocking && PrintPreciseBiasedLockingStatistics) { // Create the counters for this fast lock. flock->create_lock_counter(sync_jvms()); // sync_jvms used to get current bci @@ -3238,7 +3218,7 @@ FastLockNode* GraphKit::shared_lock(Node* obj) { map()->push_monitor( flock ); const TypeFunc *tf = LockNode::lock_type(); - LockNode *lock = new (C) LockNode(C, tf); + LockNode *lock = new LockNode(C, tf); lock->init_req( TypeFunc::Control, control() ); lock->init_req( TypeFunc::Memory , mem ); @@ -3292,7 +3272,7 @@ void GraphKit::shared_unlock(Node* box, Node* obj) { insert_mem_bar(Op_MemBarReleaseLock); const TypeFunc *tf = OptoRuntime::complete_monitor_exit_Type(); - UnlockNode *unlock = new (C) UnlockNode(C, tf); + UnlockNode *unlock = new UnlockNode(C, tf); uint raw_idx = Compile::AliasIdxRaw; unlock->init_req( TypeFunc::Control, control() ); unlock->init_req( TypeFunc::Memory , memory(raw_idx) ); @@ -3353,24 +3333,25 @@ static void hook_memory_on_init(GraphKit& kit, int alias_idx, //---------------------------set_output_for_allocation------------------------- Node* GraphKit::set_output_for_allocation(AllocateNode* alloc, - const TypeOopPtr* oop_type) { + const TypeOopPtr* oop_type, + bool deoptimize_on_exception) { int rawidx = Compile::AliasIdxRaw; alloc->set_req( TypeFunc::FramePtr, frameptr() ); add_safepoint_edges(alloc); Node* allocx = _gvn.transform(alloc); - set_control( _gvn.transform(new (C) ProjNode(allocx, TypeFunc::Control) ) ); + set_control( _gvn.transform(new ProjNode(allocx, TypeFunc::Control) ) ); // create memory projection for i_o - set_memory ( _gvn.transform( new (C) ProjNode(allocx, TypeFunc::Memory, true) ), rawidx ); - make_slow_call_ex(allocx, env()->Throwable_klass(), true); + set_memory ( _gvn.transform( new ProjNode(allocx, TypeFunc::Memory, true) ), rawidx ); + make_slow_call_ex(allocx, env()->Throwable_klass(), true, deoptimize_on_exception); // create a memory projection as for the normal control path - Node* malloc = _gvn.transform(new (C) ProjNode(allocx, TypeFunc::Memory)); + Node* malloc = _gvn.transform(new ProjNode(allocx, TypeFunc::Memory)); set_memory(malloc, rawidx); // a normal slow-call doesn't change i_o, but an allocation does // we create a separate i_o projection for the normal control path - set_i_o(_gvn.transform( new (C) ProjNode(allocx, TypeFunc::I_O, false) ) ); - Node* rawoop = _gvn.transform( new (C) ProjNode(allocx, TypeFunc::Parms) ); + set_i_o(_gvn.transform( new ProjNode(allocx, TypeFunc::I_O, false) ) ); + Node* rawoop = _gvn.transform( new ProjNode(allocx, TypeFunc::Parms) ); // put in an initialization barrier InitializeNode* init = insert_mem_bar_volatile(Op_Initialize, rawidx, @@ -3406,7 +3387,7 @@ Node* GraphKit::set_output_for_allocation(AllocateNode* alloc, } // Cast raw oop to the real thing... - Node* javaoop = new (C) CheckCastPPNode(control(), rawoop, oop_type); + Node* javaoop = new CheckCastPPNode(control(), rawoop, oop_type); javaoop = _gvn.transform(javaoop); C->set_recent_alloc(control(), javaoop); assert(just_allocated_object(control()) == javaoop, "just allocated"); @@ -3439,9 +3420,11 @@ Node* GraphKit::set_output_for_allocation(AllocateNode* alloc, // The optional arguments are for specialized use by intrinsics: // - If 'extra_slow_test' if not null is an extra condition for the slow-path. // - If 'return_size_val', report the the total object size to the caller. +// - deoptimize_on_exception controls how Java exceptions are handled (rethrow vs deoptimize) Node* GraphKit::new_instance(Node* klass_node, Node* extra_slow_test, - Node* *return_size_val) { + Node* *return_size_val, + bool deoptimize_on_exception) { // Compute size in doublewords // The size is always an integral number of doublewords, represented // as a positive bytewise size stored in the klass's layout_helper. @@ -3465,9 +3448,9 @@ Node* GraphKit::new_instance(Node* klass_node, // (It may be stress-tested by specifying StressReflectiveCode.) // Basically, we want to get into the VM is there's an illegal argument. Node* bit = intcon(Klass::_lh_instance_slow_path_bit); - initial_slow_test = _gvn.transform( new (C) AndINode(layout_val, bit) ); + initial_slow_test = _gvn.transform( new AndINode(layout_val, bit) ); if (extra_slow_test != intcon(0)) { - initial_slow_test = _gvn.transform( new (C) OrINode(initial_slow_test, extra_slow_test) ); + initial_slow_test = _gvn.transform( new OrINode(initial_slow_test, extra_slow_test) ); } // (Macro-expander will further convert this to a Bool, if necessary.) } @@ -3484,7 +3467,7 @@ Node* GraphKit::new_instance(Node* klass_node, // Clear the low bits to extract layout_helper_size_in_bytes: assert((int)Klass::_lh_instance_slow_path_bit < BytesPerLong, "clear bit"); Node* mask = MakeConX(~ (intptr_t)right_n_bits(LogBytesPerLong)); - size = _gvn.transform( new (C) AndXNode(size, mask) ); + size = _gvn.transform( new AndXNode(size, mask) ); } if (return_size_val != NULL) { (*return_size_val) = size; @@ -3504,13 +3487,12 @@ Node* GraphKit::new_instance(Node* klass_node, Node *mem = reset_memory(); set_all_memory(mem); // Create new memory state - AllocateNode* alloc - = new (C) AllocateNode(C, AllocateNode::alloc_type(Type::TOP), - control(), mem, i_o(), - size, klass_node, - initial_slow_test); + AllocateNode* alloc = new AllocateNode(C, AllocateNode::alloc_type(Type::TOP), + control(), mem, i_o(), + size, klass_node, + initial_slow_test); - return set_output_for_allocation(alloc, oop_type); + return set_output_for_allocation(alloc, oop_type, deoptimize_on_exception); } //-------------------------------new_array------------------------------------- @@ -3520,7 +3502,8 @@ Node* GraphKit::new_instance(Node* klass_node, Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable) Node* length, // number of array elements int nargs, // number of arguments to push back for uncommon trap - Node* *return_size_val) { + Node* *return_size_val, + bool deoptimize_on_exception) { jint layout_con = Klass::_lh_neutral_value; Node* layout_val = get_layout_helper(klass_node, layout_con); int layout_is_con = (layout_val == NULL); @@ -3531,8 +3514,8 @@ Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable) // Optimistically assume that it is a subtype of Object[], // so that we can fold up all the address arithmetic. layout_con = Klass::array_layout_helper(T_OBJECT); - Node* cmp_lh = _gvn.transform( new(C) CmpINode(layout_val, intcon(layout_con)) ); - Node* bol_lh = _gvn.transform( new(C) BoolNode(cmp_lh, BoolTest::eq) ); + Node* cmp_lh = _gvn.transform( new CmpINode(layout_val, intcon(layout_con)) ); + Node* bol_lh = _gvn.transform( new BoolNode(cmp_lh, BoolTest::eq) ); { BuildCutout unless(this, bol_lh, PROB_MAX); inc_sp(nargs); uncommon_trap(Deoptimization::Reason_class_check, @@ -3556,8 +3539,8 @@ Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable) fast_size_limit <<= (LogBytesPerLong - log2_esize); } - Node* initial_slow_cmp = _gvn.transform( new (C) CmpUNode( length, intcon( fast_size_limit ) ) ); - Node* initial_slow_test = _gvn.transform( new (C) BoolNode( initial_slow_cmp, BoolTest::gt ) ); + Node* initial_slow_cmp = _gvn.transform( new CmpUNode( length, intcon( fast_size_limit ) ) ); + Node* initial_slow_test = _gvn.transform( new BoolNode( initial_slow_cmp, BoolTest::gt ) ); if (initial_slow_test->is_Bool()) { // Hide it behind a CMoveI, or else PhaseIdealLoop::split_up will get sick. initial_slow_test = initial_slow_test->as_Bool()->as_int_value(&_gvn); @@ -3585,10 +3568,10 @@ Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable) } else { Node* hss = intcon(Klass::_lh_header_size_shift); Node* hsm = intcon(Klass::_lh_header_size_mask); - Node* hsize = _gvn.transform( new(C) URShiftINode(layout_val, hss) ); - hsize = _gvn.transform( new(C) AndINode(hsize, hsm) ); + Node* hsize = _gvn.transform( new URShiftINode(layout_val, hss) ); + hsize = _gvn.transform( new AndINode(hsize, hsm) ); Node* mask = intcon(round_mask); - header_size = _gvn.transform( new(C) AddINode(hsize, mask) ); + header_size = _gvn.transform( new AddINode(hsize, mask) ); } Node* elem_shift = NULL; @@ -3613,7 +3596,7 @@ Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable) jlong size_max = arrayOopDesc::max_array_length(T_BYTE); if (size_max > tllen->_hi) size_max = tllen->_hi; const TypeLong* tlcon = TypeLong::make(CONST64(0), size_max, Type::WidenMin); - lengthx = _gvn.transform( new (C) ConvI2LNode(length, tlcon)); + lengthx = _gvn.transform( new ConvI2LNode(length, tlcon)); } } #endif @@ -3624,11 +3607,11 @@ Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable) // after a successful allocation. Node* abody = lengthx; if (elem_shift != NULL) - abody = _gvn.transform( new(C) LShiftXNode(lengthx, elem_shift) ); - Node* size = _gvn.transform( new(C) AddXNode(headerx, abody) ); + abody = _gvn.transform( new LShiftXNode(lengthx, elem_shift) ); + Node* size = _gvn.transform( new AddXNode(headerx, abody) ); if (round_mask != 0) { Node* mask = MakeConX(~round_mask); - size = _gvn.transform( new(C) AndXNode(size, mask) ); + size = _gvn.transform( new AndXNode(size, mask) ); } // else if round_mask == 0, the size computation is self-rounding @@ -3646,11 +3629,11 @@ Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable) // Create the AllocateArrayNode and its result projections AllocateArrayNode* alloc - = new (C) AllocateArrayNode(C, AllocateArrayNode::alloc_type(TypeInt::INT), - control(), mem, i_o(), - size, klass_node, - initial_slow_test, - length); + = new AllocateArrayNode(C, AllocateArrayNode::alloc_type(TypeInt::INT), + control(), mem, i_o(), + size, klass_node, + initial_slow_test, + length); // Cast to correct type. Note that the klass_node may be constant or not, // and in the latter case the actual array type will be inexact also. @@ -3663,7 +3646,7 @@ Node* GraphKit::new_array(Node* klass_node, // array klass (maybe variable) ary_type = ary_type->is_aryptr()->cast_to_size(length_type); } - Node* javaoop = set_output_for_allocation(alloc, ary_type); + Node* javaoop = set_output_for_allocation(alloc, ary_type, deoptimize_on_exception); // Cast length on remaining path to be as narrow as possible if (map()->find_edge(length) >= 0) { @@ -3760,10 +3743,10 @@ void GraphKit::add_predicate_impl(Deoptimization::DeoptReason reason, int nargs) } Node *cont = _gvn.intcon(1); - Node* opq = _gvn.transform(new (C) Opaque1Node(C, cont)); - Node *bol = _gvn.transform(new (C) Conv2BNode(opq)); + Node* opq = _gvn.transform(new Opaque1Node(C, cont)); + Node *bol = _gvn.transform(new Conv2BNode(opq)); IfNode* iff = create_and_map_if(control(), bol, PROB_MAX, COUNT_UNKNOWN); - Node* iffalse = _gvn.transform(new (C) IfFalseNode(iff)); + Node* iffalse = _gvn.transform(new IfFalseNode(iff)); C->add_predicate_opaq(opq); { PreserveJVMState pjvms(this); @@ -3771,7 +3754,7 @@ void GraphKit::add_predicate_impl(Deoptimization::DeoptReason reason, int nargs) inc_sp(nargs); uncommon_trap(reason, Deoptimization::Action_maybe_recompile); } - Node* iftrue = _gvn.transform(new (C) IfTrueNode(iff)); + Node* iftrue = _gvn.transform(new IfTrueNode(iff)); set_control(iftrue); } @@ -3963,7 +3946,7 @@ void GraphKit::g1_write_barrier_pre(bool do_load, __ if_then(index, BoolTest::ne, zeroX, likely); { // decrement the index - Node* next_index = _gvn.transform(new (C) SubXNode(index, __ ConX(sizeof(intptr_t)))); + Node* next_index = _gvn.transform(new SubXNode(index, __ ConX(sizeof(intptr_t)))); // Now get the buffer location we will log the previous value into and store it Node *log_addr = __ AddP(no_base, buffer, next_index); @@ -4006,7 +3989,7 @@ void GraphKit::g1_mark_card(IdealKit& ideal, // Now do the queue work __ if_then(index, BoolTest::ne, zeroX); { - Node* next_index = _gvn.transform(new (C) SubXNode(index, __ ConX(sizeof(intptr_t)))); + Node* next_index = _gvn.transform(new SubXNode(index, __ ConX(sizeof(intptr_t)))); Node* log_addr = __ AddP(no_base, buffer, next_index); // Order, see storeCM. @@ -4213,5 +4196,5 @@ void GraphKit::store_String_length(Node* ctrl, Node* str, Node* value) { Node* GraphKit::cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type) { // Reify the property as a CastPP node in Ideal graph to comply with monotonicity // assumption of CCP analysis. - return _gvn.transform(new(C) CastPPNode(ary, ary_type->cast_to_stable(true))); + return _gvn.transform(new CastPPNode(ary, ary_type->cast_to_stable(true))); } diff --git a/hotspot/src/share/vm/opto/graphKit.hpp b/hotspot/src/share/vm/opto/graphKit.hpp index 0d2c6b07a81..683be5c9060 100644 --- a/hotspot/src/share/vm/opto/graphKit.hpp +++ b/hotspot/src/share/vm/opto/graphKit.hpp @@ -309,31 +309,31 @@ class GraphKit : public Phase { // Some convenient shortcuts for common nodes - Node* IfTrue(IfNode* iff) { return _gvn.transform(new (C) IfTrueNode(iff)); } - Node* IfFalse(IfNode* iff) { return _gvn.transform(new (C) IfFalseNode(iff)); } + Node* IfTrue(IfNode* iff) { return _gvn.transform(new IfTrueNode(iff)); } + Node* IfFalse(IfNode* iff) { return _gvn.transform(new IfFalseNode(iff)); } - Node* AddI(Node* l, Node* r) { return _gvn.transform(new (C) AddINode(l, r)); } - Node* SubI(Node* l, Node* r) { return _gvn.transform(new (C) SubINode(l, r)); } - Node* MulI(Node* l, Node* r) { return _gvn.transform(new (C) MulINode(l, r)); } - Node* DivI(Node* ctl, Node* l, Node* r) { return _gvn.transform(new (C) DivINode(ctl, l, r)); } + Node* AddI(Node* l, Node* r) { return _gvn.transform(new AddINode(l, r)); } + Node* SubI(Node* l, Node* r) { return _gvn.transform(new SubINode(l, r)); } + Node* MulI(Node* l, Node* r) { return _gvn.transform(new MulINode(l, r)); } + Node* DivI(Node* ctl, Node* l, Node* r) { return _gvn.transform(new DivINode(ctl, l, r)); } - Node* AndI(Node* l, Node* r) { return _gvn.transform(new (C) AndINode(l, r)); } - Node* OrI(Node* l, Node* r) { return _gvn.transform(new (C) OrINode(l, r)); } - Node* XorI(Node* l, Node* r) { return _gvn.transform(new (C) XorINode(l, r)); } + Node* AndI(Node* l, Node* r) { return _gvn.transform(new AndINode(l, r)); } + Node* OrI(Node* l, Node* r) { return _gvn.transform(new OrINode(l, r)); } + Node* XorI(Node* l, Node* r) { return _gvn.transform(new XorINode(l, r)); } - Node* MaxI(Node* l, Node* r) { return _gvn.transform(new (C) MaxINode(l, r)); } - Node* MinI(Node* l, Node* r) { return _gvn.transform(new (C) MinINode(l, r)); } + Node* MaxI(Node* l, Node* r) { return _gvn.transform(new MaxINode(l, r)); } + Node* MinI(Node* l, Node* r) { return _gvn.transform(new MinINode(l, r)); } - Node* LShiftI(Node* l, Node* r) { return _gvn.transform(new (C) LShiftINode(l, r)); } - Node* RShiftI(Node* l, Node* r) { return _gvn.transform(new (C) RShiftINode(l, r)); } - Node* URShiftI(Node* l, Node* r) { return _gvn.transform(new (C) URShiftINode(l, r)); } + Node* LShiftI(Node* l, Node* r) { return _gvn.transform(new LShiftINode(l, r)); } + Node* RShiftI(Node* l, Node* r) { return _gvn.transform(new RShiftINode(l, r)); } + Node* URShiftI(Node* l, Node* r) { return _gvn.transform(new URShiftINode(l, r)); } - Node* CmpI(Node* l, Node* r) { return _gvn.transform(new (C) CmpINode(l, r)); } - Node* CmpL(Node* l, Node* r) { return _gvn.transform(new (C) CmpLNode(l, r)); } - Node* CmpP(Node* l, Node* r) { return _gvn.transform(new (C) CmpPNode(l, r)); } - Node* Bool(Node* cmp, BoolTest::mask relop) { return _gvn.transform(new (C) BoolNode(cmp, relop)); } + Node* CmpI(Node* l, Node* r) { return _gvn.transform(new CmpINode(l, r)); } + Node* CmpL(Node* l, Node* r) { return _gvn.transform(new CmpLNode(l, r)); } + Node* CmpP(Node* l, Node* r) { return _gvn.transform(new CmpPNode(l, r)); } + Node* Bool(Node* cmp, BoolTest::mask relop) { return _gvn.transform(new BoolNode(cmp, relop)); } - Node* AddP(Node* b, Node* a, Node* o) { return _gvn.transform(new (C) AddPNode(b, a, o)); } + Node* AddP(Node* b, Node* a, Node* o) { return _gvn.transform(new AddPNode(b, a, o)); } // Convert between int and long, and size_t. // (See macros ConvI2X, etc., in type.hpp for ConvI2X, etc.) @@ -690,7 +690,7 @@ class GraphKit : public Phase { // Replace the call with the current state of the kit. Requires // that the call was generated with separate io_projs so that // exceptional control flow can be handled properly. - void replace_call(CallNode* call, Node* result); + void replace_call(CallNode* call, Node* result, bool do_replaced_nodes = false); // helper functions for statistics void increment_counter(address counter_addr); // increment a debug counter @@ -807,7 +807,7 @@ class GraphKit : public Phase { // merge in all memory slices from new_mem, along the given path void merge_memory(Node* new_mem, Node* region, int new_path); - void make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj); + void make_slow_call_ex(Node* call, ciInstanceKlass* ex_klass, bool separate_io_proj, bool deoptimize = false); // Helper functions to build synchronizations int next_monitor(); @@ -849,13 +849,16 @@ class GraphKit : public Phase { // implementation of object creation Node* set_output_for_allocation(AllocateNode* alloc, - const TypeOopPtr* oop_type); + const TypeOopPtr* oop_type, + bool deoptimize_on_exception=false); Node* get_layout_helper(Node* klass_node, jint& constant_value); Node* new_instance(Node* klass_node, Node* slow_test = NULL, - Node* *return_size_val = NULL); + Node* *return_size_val = NULL, + bool deoptimize_on_exception = false); Node* new_array(Node* klass_node, Node* count_val, int nargs, - Node* *return_size_val = NULL); + Node* *return_size_val = NULL, + bool deoptimize_on_exception = false); // java.lang.String helpers Node* load_String_offset(Node* ctrl, Node* str); @@ -867,7 +870,7 @@ class GraphKit : public Phase { // Handy for making control flow IfNode* create_and_map_if(Node* ctrl, Node* tst, float prob, float cnt) { - IfNode* iff = new (C) IfNode(ctrl, tst, prob, cnt);// New IfNode's + IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's _gvn.set_type(iff, iff->Value(&_gvn)); // Value may be known at parse-time // Place 'if' on worklist if it will be in graph if (!tst->is_Con()) record_for_igvn(iff); // Range-check and Null-check removal is later @@ -875,7 +878,7 @@ class GraphKit : public Phase { } IfNode* create_and_xform_if(Node* ctrl, Node* tst, float prob, float cnt) { - IfNode* iff = new (C) IfNode(ctrl, tst, prob, cnt);// New IfNode's + IfNode* iff = new IfNode(ctrl, tst, prob, cnt);// New IfNode's _gvn.transform(iff); // Value may be known at parse-time // Place 'if' on worklist if it will be in graph if (!tst->is_Con()) record_for_igvn(iff); // Range-check and Null-check removal is later diff --git a/hotspot/src/share/vm/opto/idealKit.cpp b/hotspot/src/share/vm/opto/idealKit.cpp index ee4c212d1ca..a0a9cbe62cc 100644 --- a/hotspot/src/share/vm/opto/idealKit.cpp +++ b/hotspot/src/share/vm/opto/idealKit.cpp @@ -86,7 +86,7 @@ void IdealKit::if_then(Node* left, BoolTest::mask relop, } // Delay gvn.tranform on if-nodes until construction is finished // to prevent a constant bool input from discarding a control output. - IfNode* iff = delay_transform(new (C) IfNode(ctrl(), bol, prob, cnt))->as_If(); + IfNode* iff = delay_transform(new IfNode(ctrl(), bol, prob, cnt))->as_If(); Node* then = IfTrue(iff); Node* elsen = IfFalse(iff); Node* else_cvstate = copy_cvstate(); @@ -205,7 +205,7 @@ Node* IdealKit::make_label(int goto_ct) { assert(_cvstate != NULL, "must declare variables before labels"); Node* lab = new_cvstate(); int sz = 1 + goto_ct + 1 /* fall thru */; - Node* reg = delay_transform(new (C) RegionNode(sz)); + Node* reg = delay_transform(new RegionNode(sz)); lab->init_req(TypeFunc::Control, reg); return lab; } @@ -312,7 +312,7 @@ Node* IdealKit::delay_transform(Node* n) { //-----------------------------new_cvstate----------------------------------- Node* IdealKit::new_cvstate() { uint sz = _var_ct + first_var; - return new (C) Node(sz); + return new Node(sz); } //-----------------------------copy_cvstate----------------------------------- @@ -397,7 +397,7 @@ Node* IdealKit::storeCM(Node* ctl, Node* adr, Node *val, Node* oop_store, int oo // Add required edge to oop_store, optimizer does not support precedence edges. // Convert required edge to precedence edge before allocation. - Node* st = new (C) StoreCMNode(ctl, mem, adr, adr_type, val, oop_store, oop_adr_idx); + Node* st = new StoreCMNode(ctl, mem, adr, adr_type, val, oop_store, oop_adr_idx); st = transform(st); set_memory(st, adr_idx); @@ -497,7 +497,7 @@ void IdealKit::make_leaf_call(const TypeFunc *slow_call_type, uint adr_idx = C->get_alias_index(adr_type); // Slow-path leaf call - CallNode *call = (CallNode*)new (C) CallLeafNode( slow_call_type, slow_call, leaf_name, adr_type); + CallNode *call = (CallNode*)new CallLeafNode( slow_call_type, slow_call, leaf_name, adr_type); // Set fixed predefined input arguments call->init_req( TypeFunc::Control, ctrl() ); @@ -518,10 +518,10 @@ void IdealKit::make_leaf_call(const TypeFunc *slow_call_type, // Slow leaf call has no side-effects, sets few values - set_ctrl(transform( new (C) ProjNode(call,TypeFunc::Control) )); + set_ctrl(transform( new ProjNode(call,TypeFunc::Control) )); // Make memory for the call - Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) ); + Node* mem = _gvn.transform( new ProjNode(call, TypeFunc::Memory) ); // Set the RawPtr memory state only. set_memory(mem, adr_idx); @@ -544,7 +544,7 @@ void IdealKit::make_leaf_call_no_fp(const TypeFunc *slow_call_type, uint adr_idx = C->get_alias_index(adr_type); // Slow-path leaf call - CallNode *call = (CallNode*)new (C) CallLeafNoFPNode( slow_call_type, slow_call, leaf_name, adr_type); + CallNode *call = (CallNode*)new CallLeafNoFPNode( slow_call_type, slow_call, leaf_name, adr_type); // Set fixed predefined input arguments call->init_req( TypeFunc::Control, ctrl() ); @@ -565,10 +565,10 @@ void IdealKit::make_leaf_call_no_fp(const TypeFunc *slow_call_type, // Slow leaf call has no side-effects, sets few values - set_ctrl(transform( new (C) ProjNode(call,TypeFunc::Control) )); + set_ctrl(transform( new ProjNode(call,TypeFunc::Control) )); // Make memory for the call - Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) ); + Node* mem = _gvn.transform( new ProjNode(call, TypeFunc::Memory) ); // Set the RawPtr memory state only. set_memory(mem, adr_idx); diff --git a/hotspot/src/share/vm/opto/idealKit.hpp b/hotspot/src/share/vm/opto/idealKit.hpp index f20d6bfee57..3828d30cc0b 100644 --- a/hotspot/src/share/vm/opto/idealKit.hpp +++ b/hotspot/src/share/vm/opto/idealKit.hpp @@ -173,43 +173,43 @@ class IdealKit: public StackObj { void goto_(Node* lab, bool bind = false); void declarations_done(); - Node* IfTrue(IfNode* iff) { return transform(new (C) IfTrueNode(iff)); } - Node* IfFalse(IfNode* iff) { return transform(new (C) IfFalseNode(iff)); } + Node* IfTrue(IfNode* iff) { return transform(new IfTrueNode(iff)); } + Node* IfFalse(IfNode* iff) { return transform(new IfFalseNode(iff)); } // Data Node* ConI(jint k) { return (Node*)gvn().intcon(k); } Node* makecon(const Type *t) const { return _gvn.makecon(t); } - Node* AddI(Node* l, Node* r) { return transform(new (C) AddINode(l, r)); } - Node* SubI(Node* l, Node* r) { return transform(new (C) SubINode(l, r)); } - Node* AndI(Node* l, Node* r) { return transform(new (C) AndINode(l, r)); } - Node* MaxI(Node* l, Node* r) { return transform(new (C) MaxINode(l, r)); } - Node* LShiftI(Node* l, Node* r) { return transform(new (C) LShiftINode(l, r)); } - Node* CmpI(Node* l, Node* r) { return transform(new (C) CmpINode(l, r)); } - Node* Bool(Node* cmp, BoolTest::mask relop) { return transform(new (C) BoolNode(cmp, relop)); } + Node* AddI(Node* l, Node* r) { return transform(new AddINode(l, r)); } + Node* SubI(Node* l, Node* r) { return transform(new SubINode(l, r)); } + Node* AndI(Node* l, Node* r) { return transform(new AndINode(l, r)); } + Node* MaxI(Node* l, Node* r) { return transform(new MaxINode(l, r)); } + Node* LShiftI(Node* l, Node* r) { return transform(new LShiftINode(l, r)); } + Node* CmpI(Node* l, Node* r) { return transform(new CmpINode(l, r)); } + Node* Bool(Node* cmp, BoolTest::mask relop) { return transform(new BoolNode(cmp, relop)); } void increment(IdealVariable& v, Node* j) { set(v, AddI(value(v), j)); } void decrement(IdealVariable& v, Node* j) { set(v, SubI(value(v), j)); } - Node* CmpL(Node* l, Node* r) { return transform(new (C) CmpLNode(l, r)); } + Node* CmpL(Node* l, Node* r) { return transform(new CmpLNode(l, r)); } // TLS - Node* thread() { return gvn().transform(new (C) ThreadLocalNode()); } + Node* thread() { return gvn().transform(new ThreadLocalNode()); } // Pointers // Raw address should be transformed regardless 'delay_transform' flag // to produce canonical form CastX2P(offset). - Node* AddP(Node *base, Node *ptr, Node *off) { return _gvn.transform(new (C) AddPNode(base, ptr, off)); } + Node* AddP(Node *base, Node *ptr, Node *off) { return _gvn.transform(new AddPNode(base, ptr, off)); } - Node* CmpP(Node* l, Node* r) { return transform(new (C) CmpPNode(l, r)); } + Node* CmpP(Node* l, Node* r) { return transform(new CmpPNode(l, r)); } #ifdef _LP64 - Node* XorX(Node* l, Node* r) { return transform(new (C) XorLNode(l, r)); } + Node* XorX(Node* l, Node* r) { return transform(new XorLNode(l, r)); } #else // _LP64 - Node* XorX(Node* l, Node* r) { return transform(new (C) XorINode(l, r)); } + Node* XorX(Node* l, Node* r) { return transform(new XorINode(l, r)); } #endif // _LP64 - Node* URShiftX(Node* l, Node* r) { return transform(new (C) URShiftXNode(l, r)); } + Node* URShiftX(Node* l, Node* r) { return transform(new URShiftXNode(l, r)); } Node* ConX(jint k) { return (Node*)gvn().MakeConX(k); } - Node* CastPX(Node* ctl, Node* p) { return transform(new (C) CastP2XNode(ctl, p)); } + Node* CastPX(Node* ctl, Node* p) { return transform(new CastP2XNode(ctl, p)); } // Memory operations diff --git a/hotspot/src/share/vm/opto/ifnode.cpp b/hotspot/src/share/vm/opto/ifnode.cpp index 587c3b8c864..96551a804d2 100644 --- a/hotspot/src/share/vm/opto/ifnode.cpp +++ b/hotspot/src/share/vm/opto/ifnode.cpp @@ -238,10 +238,10 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { Node* predicate_x = NULL; bool counted_loop = r->is_CountedLoop(); - Node *region_c = new (igvn->C) RegionNode(req_c + 1); + Node *region_c = new RegionNode(req_c + 1); Node *phi_c = con1; uint len = r->req(); - Node *region_x = new (igvn->C) RegionNode(len - req_c); + Node *region_x = new RegionNode(len - req_c); Node *phi_x = PhiNode::make_blank(region_x, phi); for (uint i = 1, i_c = 1, i_x = 1; i < len; i++) { if (phi->in(i) == con1) { @@ -272,7 +272,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { // Prevent the untimely death of phi_x. Currently he has no uses. He is // about to get one. If this only use goes away, then phi_x will look dead. // However, he will be picking up some more uses down below. - Node *hook = new (igvn->C) Node(4); + Node *hook = new Node(4); hook->init_req(0, phi_x); hook->init_req(1, phi_c); phi_x = phase->transform( phi_x ); @@ -284,30 +284,30 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { cmp_x->set_req(2,con2); cmp_x = phase->transform(cmp_x); // Make the bool - Node *b_c = phase->transform(new (igvn->C) BoolNode(cmp_c,b->_test._test)); - Node *b_x = phase->transform(new (igvn->C) BoolNode(cmp_x,b->_test._test)); + Node *b_c = phase->transform(new BoolNode(cmp_c,b->_test._test)); + Node *b_x = phase->transform(new BoolNode(cmp_x,b->_test._test)); // Make the IfNode - IfNode *iff_c = new (igvn->C) IfNode(region_c,b_c,iff->_prob,iff->_fcnt); + IfNode *iff_c = new IfNode(region_c,b_c,iff->_prob,iff->_fcnt); igvn->set_type_bottom(iff_c); igvn->_worklist.push(iff_c); hook->init_req(2, iff_c); - IfNode *iff_x = new (igvn->C) IfNode(region_x,b_x,iff->_prob, iff->_fcnt); + IfNode *iff_x = new IfNode(region_x,b_x,iff->_prob, iff->_fcnt); igvn->set_type_bottom(iff_x); igvn->_worklist.push(iff_x); hook->init_req(3, iff_x); // Make the true/false arms - Node *iff_c_t = phase->transform(new (igvn->C) IfTrueNode (iff_c)); - Node *iff_c_f = phase->transform(new (igvn->C) IfFalseNode(iff_c)); + Node *iff_c_t = phase->transform(new IfTrueNode (iff_c)); + Node *iff_c_f = phase->transform(new IfFalseNode(iff_c)); if (predicate_c != NULL) { assert(predicate_x == NULL, "only one predicate entry expected"); // Clone loop predicates to each path iff_c_t = igvn->clone_loop_predicates(predicate_c, iff_c_t, !counted_loop); iff_c_f = igvn->clone_loop_predicates(predicate_c, iff_c_f, !counted_loop); } - Node *iff_x_t = phase->transform(new (igvn->C) IfTrueNode (iff_x)); - Node *iff_x_f = phase->transform(new (igvn->C) IfFalseNode(iff_x)); + Node *iff_x_t = phase->transform(new IfTrueNode (iff_x)); + Node *iff_x_f = phase->transform(new IfFalseNode(iff_x)); if (predicate_x != NULL) { assert(predicate_c == NULL, "only one predicate entry expected"); // Clone loop predicates to each path @@ -316,14 +316,14 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { } // Merge the TRUE paths - Node *region_s = new (igvn->C) RegionNode(3); + Node *region_s = new RegionNode(3); igvn->_worklist.push(region_s); region_s->init_req(1, iff_c_t); region_s->init_req(2, iff_x_t); igvn->register_new_node_with_optimizer( region_s ); // Merge the FALSE paths - Node *region_f = new (igvn->C) RegionNode(3); + Node *region_f = new RegionNode(3); igvn->_worklist.push(region_f); region_f->init_req(1, iff_c_f); region_f->init_req(2, iff_x_f); @@ -438,7 +438,7 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { // Must return either the original node (now dead) or a new node // (Do not return a top here, since that would break the uniqueness of top.) - return new (igvn->C) ConINode(TypeInt::ZERO); + return new ConINode(TypeInt::ZERO); } //------------------------------is_range_check--------------------------------- @@ -541,16 +541,16 @@ static void adjust_check(Node* proj, Node* range, Node* index, // Compute a new check Node *new_add = gvn->intcon(off_lo); if( index ) { - new_add = off_lo ? gvn->transform(new (gvn->C) AddINode( index, new_add )) : index; + new_add = off_lo ? gvn->transform(new AddINode( index, new_add )) : index; } Node *new_cmp = (flip == 1) - ? new (gvn->C) CmpUNode( new_add, range ) - : new (gvn->C) CmpUNode( range, new_add ); + ? new CmpUNode( new_add, range ) + : new CmpUNode( range, new_add ); new_cmp = gvn->transform(new_cmp); // See if no need to adjust the existing check if( new_cmp == cmp ) return; // Else, adjust existing check - Node *new_bol = gvn->transform( new (gvn->C) BoolNode( new_cmp, bol->as_Bool()->_test._test ) ); + Node *new_bol = gvn->transform( new BoolNode( new_cmp, bol->as_Bool()->_test._test ) ); igvn->rehash_node_delayed( iff ); iff->set_req_X( 1, new_bol, igvn ); } @@ -728,9 +728,9 @@ Node* IfNode::fold_compares(PhaseGVN* phase) { if (failtype->_hi != max_jint && failtype->_lo != min_jint && bound > 1) { // Merge the two compares into a single unsigned compare by building (CmpU (n - lo) hi) BoolTest::mask cond = fail->as_Proj()->_con ? BoolTest::lt : BoolTest::ge; - Node* adjusted = phase->transform(new (phase->C) SubINode(n, phase->intcon(failtype->_lo))); - Node* newcmp = phase->transform(new (phase->C) CmpUNode(adjusted, phase->intcon(bound))); - Node* newbool = phase->transform(new (phase->C) BoolNode(newcmp, cond)); + Node* adjusted = phase->transform(new SubINode(n, phase->intcon(failtype->_lo))); + Node* newcmp = phase->transform(new CmpUNode(adjusted, phase->intcon(bound))); + Node* newbool = phase->transform(new BoolNode(newcmp, cond)); phase->is_IterGVN()->replace_input_of(dom_iff, 1, phase->intcon(ctrl->as_Proj()->_con)); phase->hash_delete(this); set_req(1, newbool); @@ -1003,7 +1003,7 @@ Node *IfNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Must return either the original node (now dead) or a new node // (Do not return a top here, since that would break the uniqueness of top.) - return new (phase->C) ConINode(TypeInt::ZERO); + return new ConINode(TypeInt::ZERO); } //------------------------------dominated_by----------------------------------- @@ -1099,7 +1099,7 @@ static IfNode* idealize_test(PhaseGVN* phase, IfNode* iff) { // Flip test to be canonical. Requires flipping the IfFalse/IfTrue and // cloning the IfNode. - Node* new_b = phase->transform( new (phase->C) BoolNode(b->in(1), bt.negate()) ); + Node* new_b = phase->transform( new BoolNode(b->in(1), bt.negate()) ); if( !new_b->is_Bool() ) return NULL; b = new_b->as_Bool(); @@ -1107,7 +1107,7 @@ static IfNode* idealize_test(PhaseGVN* phase, IfNode* iff) { assert( igvn, "Test is not canonical in parser?" ); // The IF node never really changes, but it needs to be cloned - iff = new (phase->C) IfNode( iff->in(0), b, 1.0-iff->_prob, iff->_fcnt); + iff = new IfNode( iff->in(0), b, 1.0-iff->_prob, iff->_fcnt); Node *prior = igvn->hash_find_insert(iff); if( prior ) { @@ -1120,8 +1120,8 @@ static IfNode* idealize_test(PhaseGVN* phase, IfNode* iff) { igvn->_worklist.push(iff); // Now handle projections. Cloning not required. - Node* new_if_f = (Node*)(new (phase->C) IfFalseNode( iff )); - Node* new_if_t = (Node*)(new (phase->C) IfTrueNode ( iff )); + Node* new_if_f = (Node*)(new IfFalseNode( iff )); + Node* new_if_t = (Node*)(new IfTrueNode ( iff )); igvn->register_new_node_with_optimizer(new_if_f); igvn->register_new_node_with_optimizer(new_if_t); diff --git a/hotspot/src/share/vm/opto/lcm.cpp b/hotspot/src/share/vm/opto/lcm.cpp index 8398bb3d254..10daf5694f9 100644 --- a/hotspot/src/share/vm/opto/lcm.cpp +++ b/hotspot/src/share/vm/opto/lcm.cpp @@ -419,7 +419,7 @@ void PhaseCFG::implicit_null_check(Block* block, Node *proj, Node *val, int allo Node *tmp2 = block->get_node(block->end_idx()+2); block->map_node(tmp2, block->end_idx()+1); block->map_node(tmp1, block->end_idx()+2); - Node *tmp = new (C) Node(C->top()); // Use not NULL input + Node *tmp = new Node(C->top()); // Use not NULL input tmp1->replace_by(tmp); tmp2->replace_by(tmp1); tmp->replace_by(tmp2); @@ -430,7 +430,7 @@ void PhaseCFG::implicit_null_check(Block* block, Node *proj, Node *val, int allo // Since schedule-local needs precise def-use info, we need to correct // it as well. Node *old_tst = proj->in(0); - MachNode *nul_chk = new (C) MachNullCheckNode(old_tst->in(0),best,bidx); + MachNode *nul_chk = new MachNullCheckNode(old_tst->in(0),best,bidx); block->map_node(nul_chk, block->end_idx()); map_node_to_block(nul_chk, block); // Redirect users of old_test to nul_chk @@ -671,7 +671,7 @@ uint PhaseCFG::sched_call(Block* block, uint node_cnt, Node_List& worklist, Grow // Set all registers killed and not already defined by the call. uint r_cnt = mcall->tf()->range()->cnt(); int op = mcall->ideal_Opcode(); - MachProjNode *proj = new (C) MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj ); + MachProjNode *proj = new MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj ); map_node_to_block(proj, block); block->insert_node(proj, node_cnt++); @@ -900,7 +900,7 @@ bool PhaseCFG::schedule_local(Block* block, GrowableArray& ready_cnt, Vecto regs.Insert(_matcher.c_frame_pointer()); regs.OR(n->out_RegMask()); - MachProjNode *proj = new (C) MachProjNode( n, 1, RegMask::Empty, MachProjNode::fat_proj ); + MachProjNode *proj = new MachProjNode( n, 1, RegMask::Empty, MachProjNode::fat_proj ); map_node_to_block(proj, block); block->insert_node(proj, phi_cnt++); diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 5cf1188435a..e0a09d27ff1 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -52,25 +52,28 @@ class LibraryIntrinsic : public InlineCallGenerator { public: private: bool _is_virtual; - bool _is_predicted; bool _does_virtual_dispatch; + int8_t _predicates_count; // Intrinsic is predicated by several conditions + int8_t _last_predicate; // Last generated predicate vmIntrinsics::ID _intrinsic_id; public: - LibraryIntrinsic(ciMethod* m, bool is_virtual, bool is_predicted, bool does_virtual_dispatch, vmIntrinsics::ID id) + LibraryIntrinsic(ciMethod* m, bool is_virtual, int predicates_count, bool does_virtual_dispatch, vmIntrinsics::ID id) : InlineCallGenerator(m), _is_virtual(is_virtual), - _is_predicted(is_predicted), _does_virtual_dispatch(does_virtual_dispatch), + _predicates_count((int8_t)predicates_count), + _last_predicate((int8_t)-1), _intrinsic_id(id) { } virtual bool is_intrinsic() const { return true; } virtual bool is_virtual() const { return _is_virtual; } - virtual bool is_predicted() const { return _is_predicted; } + virtual bool is_predicated() const { return _predicates_count > 0; } + virtual int predicates_count() const { return _predicates_count; } virtual bool does_virtual_dispatch() const { return _does_virtual_dispatch; } - virtual JVMState* generate(JVMState* jvms, Parse* parent_parser); - virtual Node* generate_predicate(JVMState* jvms); + virtual JVMState* generate(JVMState* jvms); + virtual Node* generate_predicate(JVMState* jvms, int predicate); vmIntrinsics::ID intrinsic_id() const { return _intrinsic_id; } }; @@ -113,8 +116,8 @@ class LibraryCallKit : public GraphKit { vmIntrinsics::ID intrinsic_id() const { return _intrinsic->intrinsic_id(); } ciMethod* callee() const { return _intrinsic->method(); } - bool try_to_inline(); - Node* try_to_predicate(); + bool try_to_inline(int predicate); + Node* try_to_predicate(int predicate); void push_result() { // Push the result onto the stack. @@ -313,6 +316,14 @@ class LibraryCallKit : public GraphKit { Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting); Node* get_key_start_from_aescrypt_object(Node* aescrypt_object); Node* get_original_key_start_from_aescrypt_object(Node* aescrypt_object); + bool inline_sha_implCompress(vmIntrinsics::ID id); + bool inline_digestBase_implCompressMB(int predicate); + bool inline_sha_implCompressMB(Node* digestBaseObj, ciInstanceKlass* instklass_SHA, + bool long_state, address stubAddr, const char *stubName, + Node* src_start, Node* ofs, Node* limit); + Node* get_state_from_sha_object(Node *sha_object); + Node* get_state_from_sha5_object(Node *sha_object); + Node* inline_digestBase_implCompressMB_predicate(int predicate); bool inline_encodeISOArray(); bool inline_updateCRC32(); bool inline_updateBytesCRC32(); @@ -373,7 +384,7 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { } } - bool is_predicted = false; + int predicates = 0; bool does_virtual_dispatch = false; switch (id) { @@ -513,7 +524,24 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: if (!UseAESIntrinsics) return NULL; // these two require the predicated logic - is_predicted = true; + predicates = 1; + break; + + case vmIntrinsics::_sha_implCompress: + if (!UseSHA1Intrinsics) return NULL; + break; + + case vmIntrinsics::_sha2_implCompress: + if (!UseSHA256Intrinsics) return NULL; + break; + + case vmIntrinsics::_sha5_implCompress: + if (!UseSHA512Intrinsics) return NULL; + break; + + case vmIntrinsics::_digestBase_implCompressMB: + if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) return NULL; + predicates = 3; break; case vmIntrinsics::_updateCRC32: @@ -582,7 +610,7 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { if (!InlineUnsafeOps) return NULL; } - return new LibraryIntrinsic(m, is_virtual, is_predicted, does_virtual_dispatch, (vmIntrinsics::ID) id); + return new LibraryIntrinsic(m, is_virtual, predicates, does_virtual_dispatch, (vmIntrinsics::ID) id); } //----------------------register_library_intrinsics----------------------- @@ -591,7 +619,7 @@ void Compile::register_library_intrinsics() { // Nothing to do here. } -JVMState* LibraryIntrinsic::generate(JVMState* jvms, Parse* parent_parser) { +JVMState* LibraryIntrinsic::generate(JVMState* jvms) { LibraryCallKit kit(jvms, this); Compile* C = kit.C; int nodes = C->unique(); @@ -606,7 +634,7 @@ JVMState* LibraryIntrinsic::generate(JVMState* jvms, Parse* parent_parser) { const int bci = kit.bci(); // Try to inline the intrinsic. - if (kit.try_to_inline()) { + if (kit.try_to_inline(_last_predicate)) { if (C->print_intrinsics() || C->print_inlining()) { C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)"); } @@ -641,12 +669,13 @@ JVMState* LibraryIntrinsic::generate(JVMState* jvms, Parse* parent_parser) { return NULL; } -Node* LibraryIntrinsic::generate_predicate(JVMState* jvms) { +Node* LibraryIntrinsic::generate_predicate(JVMState* jvms, int predicate) { LibraryCallKit kit(jvms, this); Compile* C = kit.C; int nodes = C->unique(); + _last_predicate = predicate; #ifndef PRODUCT - assert(is_predicted(), "sanity"); + assert(is_predicated() && predicate < predicates_count(), "sanity"); if ((C->print_intrinsics() || C->print_inlining()) && Verbose) { char buf[1000]; const char* str = vmIntrinsics::short_name_as_C_string(intrinsic_id(), buf, sizeof(buf)); @@ -656,10 +685,10 @@ Node* LibraryIntrinsic::generate_predicate(JVMState* jvms) { ciMethod* callee = kit.callee(); const int bci = kit.bci(); - Node* slow_ctl = kit.try_to_predicate(); + Node* slow_ctl = kit.try_to_predicate(predicate); if (!kit.failing()) { if (C->print_intrinsics() || C->print_inlining()) { - C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual)" : "(intrinsic)"); + C->print_inlining(callee, jvms->depth() - 1, bci, is_virtual() ? "(intrinsic, virtual, predicate)" : "(intrinsic, predicate)"); } C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_worked); if (C->log()) { @@ -688,7 +717,7 @@ Node* LibraryIntrinsic::generate_predicate(JVMState* jvms) { return NULL; } -bool LibraryCallKit::try_to_inline() { +bool LibraryCallKit::try_to_inline(int predicate) { // Handle symbolic names for otherwise undistinguished boolean switches: const bool is_store = true; const bool is_native_ptr = true; @@ -882,6 +911,14 @@ bool LibraryCallKit::try_to_inline() { case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: return inline_cipherBlockChaining_AESCrypt(intrinsic_id()); + case vmIntrinsics::_sha_implCompress: + case vmIntrinsics::_sha2_implCompress: + case vmIntrinsics::_sha5_implCompress: + return inline_sha_implCompress(intrinsic_id()); + + case vmIntrinsics::_digestBase_implCompressMB: + return inline_digestBase_implCompressMB(predicate); + case vmIntrinsics::_encodeISOArray: return inline_encodeISOArray(); @@ -905,7 +942,7 @@ bool LibraryCallKit::try_to_inline() { } } -Node* LibraryCallKit::try_to_predicate() { +Node* LibraryCallKit::try_to_predicate(int predicate) { if (!jvms()->has_method()) { // Root JVMState has a null method. assert(map()->memory()->Opcode() == Op_Parm, ""); @@ -919,6 +956,8 @@ Node* LibraryCallKit::try_to_predicate() { return inline_cipherBlockChaining_AESCrypt_predicate(false); case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: return inline_cipherBlockChaining_AESCrypt_predicate(true); + case vmIntrinsics::_digestBase_implCompressMB: + return inline_digestBase_implCompressMB_predicate(predicate); default: // If you get here, it may be that someone has added a new intrinsic @@ -969,7 +1008,7 @@ Node* LibraryCallKit::generate_guard(Node* test, RegionNode* region, float true_ IfNode* iff = create_and_map_if(control(), test, true_prob, COUNT_UNKNOWN); - Node* if_slow = _gvn.transform(new (C) IfTrueNode(iff)); + Node* if_slow = _gvn.transform(new IfTrueNode(iff)); if (if_slow == top()) { // The slow branch is never taken. No need to build this guard. return NULL; @@ -978,7 +1017,7 @@ Node* LibraryCallKit::generate_guard(Node* test, RegionNode* region, float true_ if (region != NULL) region->add_req(if_slow); - Node* if_fast = _gvn.transform(new (C) IfFalseNode(iff)); + Node* if_fast = _gvn.transform(new IfFalseNode(iff)); set_control(if_fast); return if_slow; @@ -997,12 +1036,12 @@ inline Node* LibraryCallKit::generate_negative_guard(Node* index, RegionNode* re return NULL; // already stopped if (_gvn.type(index)->higher_equal(TypeInt::POS)) // [0,maxint] return NULL; // index is already adequately typed - Node* cmp_lt = _gvn.transform(new (C) CmpINode(index, intcon(0))); - Node* bol_lt = _gvn.transform(new (C) BoolNode(cmp_lt, BoolTest::lt)); + Node* cmp_lt = _gvn.transform(new CmpINode(index, intcon(0))); + Node* bol_lt = _gvn.transform(new BoolNode(cmp_lt, BoolTest::lt)); Node* is_neg = generate_guard(bol_lt, region, PROB_MIN); if (is_neg != NULL && pos_index != NULL) { // Emulate effect of Parse::adjust_map_after_if. - Node* ccast = new (C) CastIINode(index, TypeInt::POS); + Node* ccast = new CastIINode(index, TypeInt::POS); ccast->set_req(0, control()); (*pos_index) = _gvn.transform(ccast); } @@ -1015,13 +1054,13 @@ inline Node* LibraryCallKit::generate_nonpositive_guard(Node* index, bool never_ return NULL; // already stopped if (_gvn.type(index)->higher_equal(TypeInt::POS1)) // [1,maxint] return NULL; // index is already adequately typed - Node* cmp_le = _gvn.transform(new (C) CmpINode(index, intcon(0))); + Node* cmp_le = _gvn.transform(new CmpINode(index, intcon(0))); BoolTest::mask le_or_eq = (never_negative ? BoolTest::eq : BoolTest::le); - Node* bol_le = _gvn.transform(new (C) BoolNode(cmp_le, le_or_eq)); + Node* bol_le = _gvn.transform(new BoolNode(cmp_le, le_or_eq)); Node* is_notp = generate_guard(bol_le, NULL, PROB_MIN); if (is_notp != NULL && pos_index != NULL) { // Emulate effect of Parse::adjust_map_after_if. - Node* ccast = new (C) CastIINode(index, TypeInt::POS1); + Node* ccast = new CastIINode(index, TypeInt::POS1); ccast->set_req(0, control()); (*pos_index) = _gvn.transform(ccast); } @@ -1053,9 +1092,9 @@ inline Node* LibraryCallKit::generate_limit_guard(Node* offset, return NULL; // common case of whole-array copy Node* last = subseq_length; if (!zero_offset) // last += offset - last = _gvn.transform(new (C) AddINode(last, offset)); - Node* cmp_lt = _gvn.transform(new (C) CmpUNode(array_length, last)); - Node* bol_lt = _gvn.transform(new (C) BoolNode(cmp_lt, BoolTest::lt)); + last = _gvn.transform(new AddINode(last, offset)); + Node* cmp_lt = _gvn.transform(new CmpUNode(array_length, last)); + Node* bol_lt = _gvn.transform(new BoolNode(cmp_lt, BoolTest::lt)); Node* is_over = generate_guard(bol_lt, region, PROB_MIN); return is_over; } @@ -1065,7 +1104,7 @@ inline Node* LibraryCallKit::generate_limit_guard(Node* offset, Node* LibraryCallKit::generate_current_thread(Node* &tls_output) { ciKlass* thread_klass = env()->Thread_klass(); const Type* thread_type = TypeOopPtr::make_from_klass(thread_klass)->cast_to_ptr_type(TypePtr::NotNull); - Node* thread = _gvn.transform(new (C) ThreadLocalNode()); + Node* thread = _gvn.transform(new ThreadLocalNode()); Node* p = basic_plus_adr(top()/*!oop*/, thread, in_bytes(JavaThread::threadObj_offset())); Node* threadObj = make_load(NULL, p, thread_type, T_OBJECT, MemNode::unordered); tls_output = thread; @@ -1100,18 +1139,18 @@ Node* LibraryCallKit::make_string_method_node(int opcode, Node* str1, Node* str2 // Get length of string 2 str2_len = load_String_length(no_ctrl, str2); - result = new (C) StrIndexOfNode(control(), memory(TypeAryPtr::CHARS), - str1_start, str1_len, str2_start, str2_len); + result = new StrIndexOfNode(control(), memory(TypeAryPtr::CHARS), + str1_start, str1_len, str2_start, str2_len); break; case Op_StrComp: // Get length of string 2 str2_len = load_String_length(no_ctrl, str2); - result = new (C) StrCompNode(control(), memory(TypeAryPtr::CHARS), - str1_start, str1_len, str2_start, str2_len); + result = new StrCompNode(control(), memory(TypeAryPtr::CHARS), + str1_start, str1_len, str2_start, str2_len); break; case Op_StrEquals: - result = new (C) StrEqualsNode(control(), memory(TypeAryPtr::CHARS), + result = new StrEqualsNode(control(), memory(TypeAryPtr::CHARS), str1_start, str2_start, str1_len); break; default: @@ -1133,16 +1172,16 @@ Node* LibraryCallKit::make_string_method_node(int opcode, Node* str1_start, Node Node* result = NULL; switch (opcode) { case Op_StrIndexOf: - result = new (C) StrIndexOfNode(control(), memory(TypeAryPtr::CHARS), - str1_start, cnt1, str2_start, cnt2); + result = new StrIndexOfNode(control(), memory(TypeAryPtr::CHARS), + str1_start, cnt1, str2_start, cnt2); break; case Op_StrComp: - result = new (C) StrCompNode(control(), memory(TypeAryPtr::CHARS), - str1_start, cnt1, str2_start, cnt2); + result = new StrCompNode(control(), memory(TypeAryPtr::CHARS), + str1_start, cnt1, str2_start, cnt2); break; case Op_StrEquals: - result = new (C) StrEqualsNode(control(), memory(TypeAryPtr::CHARS), - str1_start, str2_start, cnt1); + result = new StrEqualsNode(control(), memory(TypeAryPtr::CHARS), + str1_start, str2_start, cnt1); break; default: ShouldNotReachHere(); @@ -1178,12 +1217,12 @@ bool LibraryCallKit::inline_string_equals() { } // paths (plus control) merge - RegionNode* region = new (C) RegionNode(5); - Node* phi = new (C) PhiNode(region, TypeInt::BOOL); + RegionNode* region = new RegionNode(5); + Node* phi = new PhiNode(region, TypeInt::BOOL); // does source == target string? - Node* cmp = _gvn.transform(new (C) CmpPNode(receiver, argument)); - Node* bol = _gvn.transform(new (C) BoolNode(cmp, BoolTest::eq)); + Node* cmp = _gvn.transform(new CmpPNode(receiver, argument)); + Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq)); Node* if_eq = generate_slow_guard(bol, NULL); if (if_eq != NULL) { @@ -1197,8 +1236,8 @@ bool LibraryCallKit::inline_string_equals() { if (!stopped()) { Node* inst = gen_instanceof(argument, makecon(TypeKlassPtr::make(klass))); - Node* cmp = _gvn.transform(new (C) CmpINode(inst, intcon(1))); - Node* bol = _gvn.transform(new (C) BoolNode(cmp, BoolTest::ne)); + Node* cmp = _gvn.transform(new CmpINode(inst, intcon(1))); + Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne)); Node* inst_false = generate_guard(bol, NULL, PROB_MIN); //instanceOf == true, fallthrough @@ -1213,7 +1252,7 @@ bool LibraryCallKit::inline_string_equals() { const TypeOopPtr* string_type = TypeOopPtr::make_from_klass(klass); // Properly cast the argument to String - argument = _gvn.transform(new (C) CheckCastPPNode(control(), argument, string_type)); + argument = _gvn.transform(new CheckCastPPNode(control(), argument, string_type)); // This path is taken only when argument's type is String:NotNull. argument = cast_not_null(argument, false); @@ -1236,8 +1275,8 @@ bool LibraryCallKit::inline_string_equals() { Node* argument_cnt = load_String_length(no_ctrl, argument); // Check for receiver count != argument count - Node* cmp = _gvn.transform(new(C) CmpINode(receiver_cnt, argument_cnt)); - Node* bol = _gvn.transform(new(C) BoolNode(cmp, BoolTest::ne)); + Node* cmp = _gvn.transform(new CmpINode(receiver_cnt, argument_cnt)); + Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne)); Node* if_ne = generate_slow_guard(bol, NULL); if (if_ne != NULL) { phi->init_req(4, intcon(0)); @@ -1265,7 +1304,7 @@ bool LibraryCallKit::inline_string_equals() { bool LibraryCallKit::inline_array_equals() { Node* arg1 = argument(0); Node* arg2 = argument(1); - set_result(_gvn.transform(new (C) AryEqNode(control(), memory(TypeAryPtr::CHARS), arg1, arg2))); + set_result(_gvn.transform(new AryEqNode(control(), memory(TypeAryPtr::CHARS), arg1, arg2))); return true; } @@ -1434,8 +1473,8 @@ bool LibraryCallKit::inline_string_indexOf() { const TypeOopPtr* string_type = TypeOopPtr::make_from_klass(str_klass); // Make the merge point - RegionNode* result_rgn = new (C) RegionNode(4); - Node* result_phi = new (C) PhiNode(result_rgn, TypeInt::INT); + RegionNode* result_rgn = new RegionNode(4); + Node* result_phi = new PhiNode(result_rgn, TypeInt::INT); Node* no_ctrl = NULL; // Get start addr of source string @@ -1455,8 +1494,8 @@ bool LibraryCallKit::inline_string_indexOf() { Node* substr_cnt = load_String_length(no_ctrl, arg); // Check for substr count > string count - Node* cmp = _gvn.transform(new(C) CmpINode(substr_cnt, source_cnt)); - Node* bol = _gvn.transform(new(C) BoolNode(cmp, BoolTest::gt)); + Node* cmp = _gvn.transform(new CmpINode(substr_cnt, source_cnt)); + Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::gt)); Node* if_gt = generate_slow_guard(bol, NULL); if (if_gt != NULL) { result_phi->init_req(2, intcon(-1)); @@ -1465,8 +1504,8 @@ bool LibraryCallKit::inline_string_indexOf() { if (!stopped()) { // Check for substr count == 0 - cmp = _gvn.transform(new(C) CmpINode(substr_cnt, intcon(0))); - bol = _gvn.transform(new(C) BoolNode(cmp, BoolTest::eq)); + cmp = _gvn.transform(new CmpINode(substr_cnt, intcon(0))); + bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq)); Node* if_zero = generate_slow_guard(bol, NULL); if (if_zero != NULL) { result_phi->init_req(3, intcon(0)); @@ -1558,7 +1597,7 @@ bool LibraryCallKit::inline_string_indexOf() { // Round a double node if necessary. Node* LibraryCallKit::round_double_node(Node* n) { if (Matcher::strict_fp_requires_explicit_rounding && UseSSE <= 1) - n = _gvn.transform(new (C) RoundDoubleNode(0, n)); + n = _gvn.transform(new RoundDoubleNode(0, n)); return n; } @@ -1571,10 +1610,10 @@ bool LibraryCallKit::inline_math(vmIntrinsics::ID id) { Node* arg = round_double_node(argument(0)); Node* n; switch (id) { - case vmIntrinsics::_dabs: n = new (C) AbsDNode( arg); break; - case vmIntrinsics::_dsqrt: n = new (C) SqrtDNode(C, control(), arg); break; - case vmIntrinsics::_dlog: n = new (C) LogDNode(C, control(), arg); break; - case vmIntrinsics::_dlog10: n = new (C) Log10DNode(C, control(), arg); break; + case vmIntrinsics::_dabs: n = new AbsDNode( arg); break; + case vmIntrinsics::_dsqrt: n = new SqrtDNode(C, control(), arg); break; + case vmIntrinsics::_dlog: n = new LogDNode(C, control(), arg); break; + case vmIntrinsics::_dlog10: n = new Log10DNode(C, control(), arg); break; default: fatal_unexpected_iid(id); break; } set_result(_gvn.transform(n)); @@ -1589,9 +1628,9 @@ bool LibraryCallKit::inline_trig(vmIntrinsics::ID id) { Node* n = NULL; switch (id) { - case vmIntrinsics::_dsin: n = new (C) SinDNode(C, control(), arg); break; - case vmIntrinsics::_dcos: n = new (C) CosDNode(C, control(), arg); break; - case vmIntrinsics::_dtan: n = new (C) TanDNode(C, control(), arg); break; + case vmIntrinsics::_dsin: n = new SinDNode(C, control(), arg); break; + case vmIntrinsics::_dcos: n = new CosDNode(C, control(), arg); break; + case vmIntrinsics::_dtan: n = new TanDNode(C, control(), arg); break; default: fatal_unexpected_iid(id); break; } n = _gvn.transform(n); @@ -1632,17 +1671,17 @@ bool LibraryCallKit::inline_trig(vmIntrinsics::ID id) { // probably do the math inside the SIN encoding. // Make the merge point - RegionNode* r = new (C) RegionNode(3); - Node* phi = new (C) PhiNode(r, Type::DOUBLE); + RegionNode* r = new RegionNode(3); + Node* phi = new PhiNode(r, Type::DOUBLE); // Flatten arg so we need only 1 test - Node *abs = _gvn.transform(new (C) AbsDNode(arg)); + Node *abs = _gvn.transform(new AbsDNode(arg)); // Node for PI/4 constant Node *pi4 = makecon(TypeD::make(pi_4)); // Check PI/4 : abs(arg) - Node *cmp = _gvn.transform(new (C) CmpDNode(pi4,abs)); + Node *cmp = _gvn.transform(new CmpDNode(pi4,abs)); // Check: If PI/4 < abs(arg) then go slow - Node *bol = _gvn.transform(new (C) BoolNode( cmp, BoolTest::lt )); + Node *bol = _gvn.transform(new BoolNode( cmp, BoolTest::lt )); // Branch either way IfNode *iff = create_and_xform_if(control(),bol, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); set_control(opt_iff(r,iff)); @@ -1670,7 +1709,7 @@ bool LibraryCallKit::inline_trig(vmIntrinsics::ID id) { break; } assert(control()->in(0) == call, ""); - Node* slow_result = _gvn.transform(new (C) ProjNode(call, TypeFunc::Parms)); + Node* slow_result = _gvn.transform(new ProjNode(call, TypeFunc::Parms)); r->init_req(1, control()); phi->init_req(1, slow_result); @@ -1690,9 +1729,9 @@ Node* LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeF //result=(result.isNaN())? funcAddr():result; // Check: If isNaN() by checking result!=result? then either trap // or go to runtime - Node* cmpisnan = _gvn.transform(new (C) CmpDNode(result, result)); + Node* cmpisnan = _gvn.transform(new CmpDNode(result, result)); // Build the boolean node - Node* bolisnum = _gvn.transform(new (C) BoolNode(cmpisnan, BoolTest::eq)); + Node* bolisnum = _gvn.transform(new BoolNode(cmpisnan, BoolTest::eq)); if (!too_many_traps(Deoptimization::Reason_intrinsic)) { { BuildCutout unless(this, bolisnum, PROB_STATIC_FREQUENT); @@ -1707,12 +1746,12 @@ Node* LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeF // to the runtime to properly handle corner cases IfNode* iff = create_and_xform_if(control(), bolisnum, PROB_STATIC_FREQUENT, COUNT_UNKNOWN); - Node* if_slow = _gvn.transform(new (C) IfFalseNode(iff)); - Node* if_fast = _gvn.transform(new (C) IfTrueNode(iff)); + Node* if_slow = _gvn.transform(new IfFalseNode(iff)); + Node* if_fast = _gvn.transform(new IfTrueNode(iff)); if (!if_slow->is_top()) { - RegionNode* result_region = new (C) RegionNode(3); - PhiNode* result_val = new (C) PhiNode(result_region, Type::DOUBLE); + RegionNode* result_region = new RegionNode(3); + PhiNode* result_val = new PhiNode(result_region, Type::DOUBLE); result_region->init_req(1, if_fast); result_val->init_req(1, result); @@ -1723,9 +1762,9 @@ Node* LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeF Node* rt = make_runtime_call(RC_LEAF, call_type, funcAddr, funcName, no_memory_effects, x, top(), y, y ? top() : NULL); - Node* value = _gvn.transform(new (C) ProjNode(rt, TypeFunc::Parms+0)); + Node* value = _gvn.transform(new ProjNode(rt, TypeFunc::Parms+0)); #ifdef ASSERT - Node* value_top = _gvn.transform(new (C) ProjNode(rt, TypeFunc::Parms+1)); + Node* value_top = _gvn.transform(new ProjNode(rt, TypeFunc::Parms+1)); assert(value_top == top(), "second value must be top"); #endif @@ -1744,7 +1783,7 @@ Node* LibraryCallKit::finish_pow_exp(Node* result, Node* x, Node* y, const TypeF // really odd corner cases (+/- Infinity). Just uncommon-trap them. bool LibraryCallKit::inline_exp() { Node* arg = round_double_node(argument(0)); - Node* n = _gvn.transform(new (C) ExpDNode(C, control(), arg)); + Node* n = _gvn.transform(new ExpDNode(C, control(), arg)); n = finish_pow_exp(n, arg, NULL, OptoRuntime::Math_D_D_Type(), CAST_FROM_FN_PTR(address, SharedRuntime::dexp), "EXP"); set_result(n); @@ -1783,76 +1822,76 @@ bool LibraryCallKit::inline_pow() { Node* result = NULL; Node* const_two_node = makecon(TypeD::make(2.0)); - Node* cmp_node = _gvn.transform(new (C) CmpDNode(y, const_two_node)); - Node* bool_node = _gvn.transform(new (C) BoolNode(cmp_node, BoolTest::eq)); + Node* cmp_node = _gvn.transform(new CmpDNode(y, const_two_node)); + Node* bool_node = _gvn.transform(new BoolNode(cmp_node, BoolTest::eq)); IfNode* if_node = create_and_xform_if(control(), bool_node, PROB_STATIC_INFREQUENT, COUNT_UNKNOWN); - Node* if_true = _gvn.transform(new (C) IfTrueNode(if_node)); - Node* if_false = _gvn.transform(new (C) IfFalseNode(if_node)); + Node* if_true = _gvn.transform(new IfTrueNode(if_node)); + Node* if_false = _gvn.transform(new IfFalseNode(if_node)); - RegionNode* region_node = new (C) RegionNode(3); + RegionNode* region_node = new RegionNode(3); region_node->init_req(1, if_true); - Node* phi_node = new (C) PhiNode(region_node, Type::DOUBLE); + Node* phi_node = new PhiNode(region_node, Type::DOUBLE); // special case for x^y where y == 2, we can convert it to x * x - phi_node->init_req(1, _gvn.transform(new (C) MulDNode(x, x))); + phi_node->init_req(1, _gvn.transform(new MulDNode(x, x))); // set control to if_false since we will now process the false branch set_control(if_false); if (!too_many_traps(Deoptimization::Reason_intrinsic)) { // Short form: skip the fancy tests and just check for NaN result. - result = _gvn.transform(new (C) PowDNode(C, control(), x, y)); + result = _gvn.transform(new PowDNode(C, control(), x, y)); } else { // If this inlining ever returned NaN in the past, include all // checks + call to the runtime. // Set the merge point for If node with condition of (x <= 0.0) // There are four possible paths to region node and phi node - RegionNode *r = new (C) RegionNode(4); - Node *phi = new (C) PhiNode(r, Type::DOUBLE); + RegionNode *r = new RegionNode(4); + Node *phi = new PhiNode(r, Type::DOUBLE); // Build the first if node: if (x <= 0.0) // Node for 0 constant Node *zeronode = makecon(TypeD::ZERO); // Check x:0 - Node *cmp = _gvn.transform(new (C) CmpDNode(x, zeronode)); + Node *cmp = _gvn.transform(new CmpDNode(x, zeronode)); // Check: If (x<=0) then go complex path - Node *bol1 = _gvn.transform(new (C) BoolNode( cmp, BoolTest::le )); + Node *bol1 = _gvn.transform(new BoolNode( cmp, BoolTest::le )); // Branch either way IfNode *if1 = create_and_xform_if(control(),bol1, PROB_STATIC_INFREQUENT, COUNT_UNKNOWN); // Fast path taken; set region slot 3 - Node *fast_taken = _gvn.transform(new (C) IfFalseNode(if1)); + Node *fast_taken = _gvn.transform(new IfFalseNode(if1)); r->init_req(3,fast_taken); // Capture fast-control // Fast path not-taken, i.e. slow path - Node *complex_path = _gvn.transform(new (C) IfTrueNode(if1)); + Node *complex_path = _gvn.transform(new IfTrueNode(if1)); // Set fast path result - Node *fast_result = _gvn.transform(new (C) PowDNode(C, control(), x, y)); + Node *fast_result = _gvn.transform(new PowDNode(C, control(), x, y)); phi->init_req(3, fast_result); // Complex path // Build the second if node (if y is long) // Node for (long)y - Node *longy = _gvn.transform(new (C) ConvD2LNode(y)); + Node *longy = _gvn.transform(new ConvD2LNode(y)); // Node for (double)((long) y) - Node *doublelongy= _gvn.transform(new (C) ConvL2DNode(longy)); + Node *doublelongy= _gvn.transform(new ConvL2DNode(longy)); // Check (double)((long) y) : y - Node *cmplongy= _gvn.transform(new (C) CmpDNode(doublelongy, y)); + Node *cmplongy= _gvn.transform(new CmpDNode(doublelongy, y)); // Check if (y isn't long) then go to slow path - Node *bol2 = _gvn.transform(new (C) BoolNode( cmplongy, BoolTest::ne )); + Node *bol2 = _gvn.transform(new BoolNode( cmplongy, BoolTest::ne )); // Branch either way IfNode *if2 = create_and_xform_if(complex_path,bol2, PROB_STATIC_INFREQUENT, COUNT_UNKNOWN); - Node* ylong_path = _gvn.transform(new (C) IfFalseNode(if2)); + Node* ylong_path = _gvn.transform(new IfFalseNode(if2)); - Node *slow_path = _gvn.transform(new (C) IfTrueNode(if2)); + Node *slow_path = _gvn.transform(new IfTrueNode(if2)); // Calculate DPow(abs(x), y)*(1 & (long)y) // Node for constant 1 Node *conone = longcon(1); // 1& (long)y - Node *signnode= _gvn.transform(new (C) AndLNode(conone, longy)); + Node *signnode= _gvn.transform(new AndLNode(conone, longy)); // A huge number is always even. Detect a huge number by checking // if y + 1 == y and set integer to be tested for parity to 0. @@ -1860,18 +1899,18 @@ bool LibraryCallKit::inline_pow() { // (long)9.223372036854776E18 = max_jlong // (double)(long)9.223372036854776E18 = 9.223372036854776E18 // max_jlong is odd but 9.223372036854776E18 is even - Node* yplus1 = _gvn.transform(new (C) AddDNode(y, makecon(TypeD::make(1)))); - Node *cmpyplus1= _gvn.transform(new (C) CmpDNode(yplus1, y)); - Node *bolyplus1 = _gvn.transform(new (C) BoolNode( cmpyplus1, BoolTest::eq )); + Node* yplus1 = _gvn.transform(new AddDNode(y, makecon(TypeD::make(1)))); + Node *cmpyplus1= _gvn.transform(new CmpDNode(yplus1, y)); + Node *bolyplus1 = _gvn.transform(new BoolNode( cmpyplus1, BoolTest::eq )); Node* correctedsign = NULL; if (ConditionalMoveLimit != 0) { correctedsign = _gvn.transform( CMoveNode::make(C, NULL, bolyplus1, signnode, longcon(0), TypeLong::LONG)); } else { IfNode *ifyplus1 = create_and_xform_if(ylong_path,bolyplus1, PROB_FAIR, COUNT_UNKNOWN); - RegionNode *r = new (C) RegionNode(3); - Node *phi = new (C) PhiNode(r, TypeLong::LONG); - r->init_req(1, _gvn.transform(new (C) IfFalseNode(ifyplus1))); - r->init_req(2, _gvn.transform(new (C) IfTrueNode(ifyplus1))); + RegionNode *r = new RegionNode(3); + Node *phi = new PhiNode(r, TypeLong::LONG); + r->init_req(1, _gvn.transform(new IfFalseNode(ifyplus1))); + r->init_req(2, _gvn.transform(new IfTrueNode(ifyplus1))); phi->init_req(1, signnode); phi->init_req(2, longcon(0)); correctedsign = _gvn.transform(phi); @@ -1882,25 +1921,25 @@ bool LibraryCallKit::inline_pow() { // zero node Node *conzero = longcon(0); // Check (1&(long)y)==0? - Node *cmpeq1 = _gvn.transform(new (C) CmpLNode(correctedsign, conzero)); + Node *cmpeq1 = _gvn.transform(new CmpLNode(correctedsign, conzero)); // Check if (1&(long)y)!=0?, if so the result is negative - Node *bol3 = _gvn.transform(new (C) BoolNode( cmpeq1, BoolTest::ne )); + Node *bol3 = _gvn.transform(new BoolNode( cmpeq1, BoolTest::ne )); // abs(x) - Node *absx=_gvn.transform(new (C) AbsDNode(x)); + Node *absx=_gvn.transform(new AbsDNode(x)); // abs(x)^y - Node *absxpowy = _gvn.transform(new (C) PowDNode(C, control(), absx, y)); + Node *absxpowy = _gvn.transform(new PowDNode(C, control(), absx, y)); // -abs(x)^y - Node *negabsxpowy = _gvn.transform(new (C) NegDNode (absxpowy)); + Node *negabsxpowy = _gvn.transform(new NegDNode (absxpowy)); // (1&(long)y)==1?-DPow(abs(x), y):DPow(abs(x), y) Node *signresult = NULL; if (ConditionalMoveLimit != 0) { signresult = _gvn.transform( CMoveNode::make(C, NULL, bol3, absxpowy, negabsxpowy, Type::DOUBLE)); } else { IfNode *ifyeven = create_and_xform_if(ylong_path,bol3, PROB_FAIR, COUNT_UNKNOWN); - RegionNode *r = new (C) RegionNode(3); - Node *phi = new (C) PhiNode(r, Type::DOUBLE); - r->init_req(1, _gvn.transform(new (C) IfFalseNode(ifyeven))); - r->init_req(2, _gvn.transform(new (C) IfTrueNode(ifyeven))); + RegionNode *r = new RegionNode(3); + Node *phi = new PhiNode(r, Type::DOUBLE); + r->init_req(1, _gvn.transform(new IfFalseNode(ifyeven))); + r->init_req(2, _gvn.transform(new IfTrueNode(ifyeven))); phi->init_req(1, absxpowy); phi->init_req(2, negabsxpowy); signresult = _gvn.transform(phi); @@ -1949,9 +1988,9 @@ bool LibraryCallKit::runtime_math(const TypeFunc* call_type, address funcAddr, c Node* trig = make_runtime_call(RC_LEAF, call_type, funcAddr, funcName, no_memory_effects, a, top(), b, b ? top() : NULL); - Node* value = _gvn.transform(new (C) ProjNode(trig, TypeFunc::Parms+0)); + Node* value = _gvn.transform(new ProjNode(trig, TypeFunc::Parms+0)); #ifdef ASSERT - Node* value_top = _gvn.transform(new (C) ProjNode(trig, TypeFunc::Parms+1)); + Node* value_top = _gvn.transform(new ProjNode(trig, TypeFunc::Parms+1)); assert(value_top == top(), "second value must be top"); #endif @@ -2011,10 +2050,10 @@ bool LibraryCallKit::inline_min_max(vmIntrinsics::ID id) { } void LibraryCallKit::inline_math_mathExact(Node* math, Node *test) { - Node* bol = _gvn.transform( new (C) BoolNode(test, BoolTest::overflow) ); + Node* bol = _gvn.transform( new BoolNode(test, BoolTest::overflow) ); IfNode* check = create_and_map_if(control(), bol, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); - Node* fast_path = _gvn.transform( new (C) IfFalseNode(check)); - Node* slow_path = _gvn.transform( new (C) IfTrueNode(check) ); + Node* fast_path = _gvn.transform( new IfFalseNode(check)); + Node* slow_path = _gvn.transform( new IfTrueNode(check) ); { PreserveJVMState pjvms(this); @@ -2036,9 +2075,9 @@ template bool LibraryCallKit::inline_math_overflow(Node* arg1, Node* arg2) { typedef typename OverflowOp::MathOp MathOp; - MathOp* mathOp = new(C) MathOp(arg1, arg2); + MathOp* mathOp = new MathOp(arg1, arg2); Node* operation = _gvn.transform( mathOp ); - Node* ofcheck = _gvn.transform( new(C) OverflowOp(arg1, arg2) ); + Node* ofcheck = _gvn.transform( new OverflowOp(arg1, arg2) ); inline_math_mathExact(operation, ofcheck); return true; } @@ -2106,7 +2145,7 @@ LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) { int cmp_op = Op_CmpI; Node* xkey = xvalue; Node* ykey = yvalue; - Node* ideal_cmpxy = _gvn.transform(new(C) CmpINode(xkey, ykey)); + Node* ideal_cmpxy = _gvn.transform(new CmpINode(xkey, ykey)); if (ideal_cmpxy->is_Cmp()) { // E.g., if we have CmpI(length - offset, count), // it might idealize to CmpI(length, count + offset) @@ -2199,7 +2238,7 @@ LibraryCallKit::generate_min_max(vmIntrinsics::ID id, Node* x0, Node* y0) { default: if (cmpxy == NULL) cmpxy = ideal_cmpxy; - best_bol = _gvn.transform(new(C) BoolNode(cmpxy, BoolTest::lt)); + best_bol = _gvn.transform(new BoolNode(cmpxy, BoolTest::lt)); // and fall through: case BoolTest::lt: // x < y case BoolTest::le: // x <= y @@ -2259,7 +2298,7 @@ LibraryCallKit::classify_unsafe_addr(Node* &base, Node* &offset) { return Type::AnyPtr; } else if (base_type == TypePtr::NULL_PTR) { // Since this is a NULL+long form, we have to switch to a rawptr. - base = _gvn.transform(new (C) CastX2PNode(offset)); + base = _gvn.transform(new CastX2PNode(offset)); offset = MakeConX(0); return Type::RawPtr; } else if (base_type->base() == Type::RawPtr) { @@ -2312,16 +2351,16 @@ bool LibraryCallKit::inline_number_methods(vmIntrinsics::ID id) { Node* arg = argument(0); Node* n; switch (id) { - case vmIntrinsics::_numberOfLeadingZeros_i: n = new (C) CountLeadingZerosINode( arg); break; - case vmIntrinsics::_numberOfLeadingZeros_l: n = new (C) CountLeadingZerosLNode( arg); break; - case vmIntrinsics::_numberOfTrailingZeros_i: n = new (C) CountTrailingZerosINode(arg); break; - case vmIntrinsics::_numberOfTrailingZeros_l: n = new (C) CountTrailingZerosLNode(arg); break; - case vmIntrinsics::_bitCount_i: n = new (C) PopCountINode( arg); break; - case vmIntrinsics::_bitCount_l: n = new (C) PopCountLNode( arg); break; - case vmIntrinsics::_reverseBytes_c: n = new (C) ReverseBytesUSNode(0, arg); break; - case vmIntrinsics::_reverseBytes_s: n = new (C) ReverseBytesSNode( 0, arg); break; - case vmIntrinsics::_reverseBytes_i: n = new (C) ReverseBytesINode( 0, arg); break; - case vmIntrinsics::_reverseBytes_l: n = new (C) ReverseBytesLNode( 0, arg); break; + case vmIntrinsics::_numberOfLeadingZeros_i: n = new CountLeadingZerosINode( arg); break; + case vmIntrinsics::_numberOfLeadingZeros_l: n = new CountLeadingZerosLNode( arg); break; + case vmIntrinsics::_numberOfTrailingZeros_i: n = new CountTrailingZerosINode(arg); break; + case vmIntrinsics::_numberOfTrailingZeros_l: n = new CountTrailingZerosLNode(arg); break; + case vmIntrinsics::_bitCount_i: n = new PopCountINode( arg); break; + case vmIntrinsics::_bitCount_l: n = new PopCountLNode( arg); break; + case vmIntrinsics::_reverseBytes_c: n = new ReverseBytesUSNode(0, arg); break; + case vmIntrinsics::_reverseBytes_s: n = new ReverseBytesSNode( 0, arg); break; + case vmIntrinsics::_reverseBytes_i: n = new ReverseBytesINode( 0, arg); break; + case vmIntrinsics::_reverseBytes_l: n = new ReverseBytesLNode( 0, arg); break; default: fatal_unexpected_iid(id); break; } set_result(_gvn.transform(n)); @@ -2637,7 +2676,7 @@ bool LibraryCallKit::inline_unsafe_access(bool is_native_ptr, bool is_store, Bas break; case T_ADDRESS: // Cast to an int type. - p = _gvn.transform(new (C) CastP2XNode(NULL, p)); + p = _gvn.transform(new CastP2XNode(NULL, p)); p = ConvX2UL(p); break; default: @@ -2658,7 +2697,7 @@ bool LibraryCallKit::inline_unsafe_access(bool is_native_ptr, bool is_store, Bas case T_ADDRESS: // Repackage the long as a pointer. val = ConvL2X(val); - val = _gvn.transform(new (C) CastX2PNode(val)); + val = _gvn.transform(new CastX2PNode(val)); break; } @@ -2766,9 +2805,9 @@ bool LibraryCallKit::inline_unsafe_prefetch(bool is_native_ptr, bool is_store, b // Generate the read or write prefetch Node *prefetch; if (is_store) { - prefetch = new (C) PrefetchWriteNode(i_o(), adr); + prefetch = new PrefetchWriteNode(i_o(), adr); } else { - prefetch = new (C) PrefetchReadNode(i_o(), adr); + prefetch = new PrefetchReadNode(i_o(), adr); } prefetch->init_req(0, control()); set_i_o(_gvn.transform(prefetch)); @@ -2906,22 +2945,22 @@ bool LibraryCallKit::inline_unsafe_load_store(BasicType type, LoadStoreKind kind switch(type) { case T_INT: if (kind == LS_xadd) { - load_store = _gvn.transform(new (C) GetAndAddINode(control(), mem, adr, newval, adr_type)); + load_store = _gvn.transform(new GetAndAddINode(control(), mem, adr, newval, adr_type)); } else if (kind == LS_xchg) { - load_store = _gvn.transform(new (C) GetAndSetINode(control(), mem, adr, newval, adr_type)); + load_store = _gvn.transform(new GetAndSetINode(control(), mem, adr, newval, adr_type)); } else if (kind == LS_cmpxchg) { - load_store = _gvn.transform(new (C) CompareAndSwapINode(control(), mem, adr, newval, oldval)); + load_store = _gvn.transform(new CompareAndSwapINode(control(), mem, adr, newval, oldval)); } else { ShouldNotReachHere(); } break; case T_LONG: if (kind == LS_xadd) { - load_store = _gvn.transform(new (C) GetAndAddLNode(control(), mem, adr, newval, adr_type)); + load_store = _gvn.transform(new GetAndAddLNode(control(), mem, adr, newval, adr_type)); } else if (kind == LS_xchg) { - load_store = _gvn.transform(new (C) GetAndSetLNode(control(), mem, adr, newval, adr_type)); + load_store = _gvn.transform(new GetAndSetLNode(control(), mem, adr, newval, adr_type)); } else if (kind == LS_cmpxchg) { - load_store = _gvn.transform(new (C) CompareAndSwapLNode(control(), mem, adr, newval, oldval)); + load_store = _gvn.transform(new CompareAndSwapLNode(control(), mem, adr, newval, oldval)); } else { ShouldNotReachHere(); } @@ -2958,24 +2997,24 @@ bool LibraryCallKit::inline_unsafe_load_store(BasicType type, LoadStoreKind kind #ifdef _LP64 if (adr->bottom_type()->is_ptr_to_narrowoop()) { - Node *newval_enc = _gvn.transform(new (C) EncodePNode(newval, newval->bottom_type()->make_narrowoop())); + Node *newval_enc = _gvn.transform(new EncodePNode(newval, newval->bottom_type()->make_narrowoop())); if (kind == LS_xchg) { - load_store = _gvn.transform(new (C) GetAndSetNNode(control(), mem, adr, - newval_enc, adr_type, value_type->make_narrowoop())); + load_store = _gvn.transform(new GetAndSetNNode(control(), mem, adr, + newval_enc, adr_type, value_type->make_narrowoop())); } else { assert(kind == LS_cmpxchg, "wrong LoadStore operation"); - Node *oldval_enc = _gvn.transform(new (C) EncodePNode(oldval, oldval->bottom_type()->make_narrowoop())); - load_store = _gvn.transform(new (C) CompareAndSwapNNode(control(), mem, adr, + Node *oldval_enc = _gvn.transform(new EncodePNode(oldval, oldval->bottom_type()->make_narrowoop())); + load_store = _gvn.transform(new CompareAndSwapNNode(control(), mem, adr, newval_enc, oldval_enc)); } } else #endif { if (kind == LS_xchg) { - load_store = _gvn.transform(new (C) GetAndSetPNode(control(), mem, adr, newval, adr_type, value_type->is_oopptr())); + load_store = _gvn.transform(new GetAndSetPNode(control(), mem, adr, newval, adr_type, value_type->is_oopptr())); } else { assert(kind == LS_cmpxchg, "wrong LoadStore operation"); - load_store = _gvn.transform(new (C) CompareAndSwapPNode(control(), mem, adr, newval, oldval)); + load_store = _gvn.transform(new CompareAndSwapPNode(control(), mem, adr, newval, oldval)); } } post_barrier(control(), load_store, base, adr, alias_idx, newval, T_OBJECT, true); @@ -2988,13 +3027,13 @@ bool LibraryCallKit::inline_unsafe_load_store(BasicType type, LoadStoreKind kind // SCMemProjNodes represent the memory state of a LoadStore. Their // main role is to prevent LoadStore nodes from being optimized away // when their results aren't used. - Node* proj = _gvn.transform(new (C) SCMemProjNode(load_store)); + Node* proj = _gvn.transform(new SCMemProjNode(load_store)); set_memory(proj, alias_idx); if (type == T_OBJECT && kind == LS_xchg) { #ifdef _LP64 if (adr->bottom_type()->is_ptr_to_narrowoop()) { - load_store = _gvn.transform(new (C) DecodeNNode(load_store, load_store->get_ptr_type())); + load_store = _gvn.transform(new DecodeNNode(load_store, load_store->get_ptr_type())); } #endif if (can_move_pre_barrier()) { @@ -3136,7 +3175,7 @@ bool LibraryCallKit::inline_unsafe_allocate() { // can generate code to load it as unsigned byte. Node* inst = make_load(NULL, insp, TypeInt::UBYTE, T_BOOLEAN, MemNode::unordered); Node* bits = intcon(InstanceKlass::fully_initialized); - test = _gvn.transform(new (C) SubINode(inst, bits)); + test = _gvn.transform(new SubINode(inst, bits)); // The 'test' is non-zero if we need to take a slow path. } @@ -3160,9 +3199,9 @@ bool LibraryCallKit::inline_native_classID() { Node* insp = basic_plus_adr(kls, in_bytes(offset)); Node* tvalue = make_load(NULL, insp, TypeLong::LONG, T_LONG, MemNode::unordered); Node* bits = longcon(~0x03l); // ignore bit 0 & 1 - Node* andl = _gvn.transform(new (C) AndLNode(tvalue, bits)); + Node* andl = _gvn.transform(new AndLNode(tvalue, bits)); Node* clsused = longcon(0x01l); // set the class bit - Node* orl = _gvn.transform(new (C) OrLNode(tvalue, clsused)); + Node* orl = _gvn.transform(new OrLNode(tvalue, clsused)); const TypePtr *adr_type = _gvn.type(insp)->isa_ptr(); store_to_memory(control(), insp, orl, T_LONG, adr_type, MemNode::unordered); @@ -3198,9 +3237,9 @@ bool LibraryCallKit::inline_native_time_funcs(address funcAddr, const char* func const TypeFunc* tf = OptoRuntime::void_long_Type(); const TypePtr* no_memory_effects = NULL; Node* time = make_runtime_call(RC_LEAF, tf, funcAddr, funcName, no_memory_effects); - Node* value = _gvn.transform(new (C) ProjNode(time, TypeFunc::Parms+0)); + Node* value = _gvn.transform(new ProjNode(time, TypeFunc::Parms+0)); #ifdef ASSERT - Node* value_top = _gvn.transform(new (C) ProjNode(time, TypeFunc::Parms+1)); + Node* value_top = _gvn.transform(new ProjNode(time, TypeFunc::Parms+1)); assert(value_top == top(), "second value must be top"); #endif set_result(value); @@ -3241,18 +3280,18 @@ bool LibraryCallKit::inline_native_isInterrupted() { // out of the function. insert_mem_bar(Op_MemBarCPUOrder); - RegionNode* result_rgn = new (C) RegionNode(PATH_LIMIT); - PhiNode* result_val = new (C) PhiNode(result_rgn, TypeInt::BOOL); + RegionNode* result_rgn = new RegionNode(PATH_LIMIT); + PhiNode* result_val = new PhiNode(result_rgn, TypeInt::BOOL); - RegionNode* slow_region = new (C) RegionNode(1); + RegionNode* slow_region = new RegionNode(1); record_for_igvn(slow_region); // (a) Receiving thread must be the current thread. Node* rec_thr = argument(0); Node* tls_ptr = NULL; Node* cur_thr = generate_current_thread(tls_ptr); - Node* cmp_thr = _gvn.transform(new (C) CmpPNode(cur_thr, rec_thr)); - Node* bol_thr = _gvn.transform(new (C) BoolNode(cmp_thr, BoolTest::ne)); + Node* cmp_thr = _gvn.transform(new CmpPNode(cur_thr, rec_thr)); + Node* bol_thr = _gvn.transform(new BoolNode(cmp_thr, BoolTest::ne)); generate_slow_guard(bol_thr, slow_region); @@ -3263,33 +3302,33 @@ bool LibraryCallKit::inline_native_isInterrupted() { // Set the control input on the field _interrupted read to prevent it floating up. Node* int_bit = make_load(control(), p, TypeInt::BOOL, T_INT, MemNode::unordered); - Node* cmp_bit = _gvn.transform(new (C) CmpINode(int_bit, intcon(0))); - Node* bol_bit = _gvn.transform(new (C) BoolNode(cmp_bit, BoolTest::ne)); + Node* cmp_bit = _gvn.transform(new CmpINode(int_bit, intcon(0))); + Node* bol_bit = _gvn.transform(new BoolNode(cmp_bit, BoolTest::ne)); IfNode* iff_bit = create_and_map_if(control(), bol_bit, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); // First fast path: if (!TLS._interrupted) return false; - Node* false_bit = _gvn.transform(new (C) IfFalseNode(iff_bit)); + Node* false_bit = _gvn.transform(new IfFalseNode(iff_bit)); result_rgn->init_req(no_int_result_path, false_bit); result_val->init_req(no_int_result_path, intcon(0)); // drop through to next case - set_control( _gvn.transform(new (C) IfTrueNode(iff_bit))); + set_control( _gvn.transform(new IfTrueNode(iff_bit))); #ifndef TARGET_OS_FAMILY_windows // (c) Or, if interrupt bit is set and clear_int is false, use 2nd fast path. Node* clr_arg = argument(1); - Node* cmp_arg = _gvn.transform(new (C) CmpINode(clr_arg, intcon(0))); - Node* bol_arg = _gvn.transform(new (C) BoolNode(cmp_arg, BoolTest::ne)); + Node* cmp_arg = _gvn.transform(new CmpINode(clr_arg, intcon(0))); + Node* bol_arg = _gvn.transform(new BoolNode(cmp_arg, BoolTest::ne)); IfNode* iff_arg = create_and_map_if(control(), bol_arg, PROB_FAIR, COUNT_UNKNOWN); // Second fast path: ... else if (!clear_int) return true; - Node* false_arg = _gvn.transform(new (C) IfFalseNode(iff_arg)); + Node* false_arg = _gvn.transform(new IfFalseNode(iff_arg)); result_rgn->init_req(no_clear_result_path, false_arg); result_val->init_req(no_clear_result_path, intcon(1)); // drop through to next case - set_control( _gvn.transform(new (C) IfTrueNode(iff_arg))); + set_control( _gvn.transform(new IfTrueNode(iff_arg))); #else // To return true on Windows you must read the _interrupted field // and check the the event state i.e. take the slow path. @@ -3375,9 +3414,9 @@ Node* LibraryCallKit::generate_access_flags_guard(Node* kls, int modifier_mask, Node* mods = make_load(NULL, modp, TypeInt::INT, T_INT, MemNode::unordered); Node* mask = intcon(modifier_mask); Node* bits = intcon(modifier_bits); - Node* mbit = _gvn.transform(new (C) AndINode(mods, mask)); - Node* cmp = _gvn.transform(new (C) CmpINode(mbit, bits)); - Node* bol = _gvn.transform(new (C) BoolNode(cmp, BoolTest::ne)); + Node* mbit = _gvn.transform(new AndINode(mods, mask)); + Node* cmp = _gvn.transform(new CmpINode(mbit, bits)); + Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::ne)); return generate_fair_guard(bol, region); } Node* LibraryCallKit::generate_interface_guard(Node* kls, RegionNode* region) { @@ -3450,9 +3489,9 @@ bool LibraryCallKit::inline_native_Class_query(vmIntrinsics::ID id) { #endif // Null-check the mirror, and the mirror's klass ptr (in case it is a primitive). - RegionNode* region = new (C) RegionNode(PATH_LIMIT); + RegionNode* region = new RegionNode(PATH_LIMIT); record_for_igvn(region); - PhiNode* phi = new (C) PhiNode(region, return_type); + PhiNode* phi = new PhiNode(region, return_type); // The mirror will never be null of Reflection.getClassAccessFlags, however // it may be null for Class.isInstance or Class.getModifiers. Throw a NPE @@ -3594,8 +3633,8 @@ bool LibraryCallKit::inline_native_subtype_check() { PATH_LIMIT }; - RegionNode* region = new (C) RegionNode(PATH_LIMIT); - Node* phi = new (C) PhiNode(region, TypeInt::BOOL); + RegionNode* region = new RegionNode(PATH_LIMIT); + Node* phi = new PhiNode(region, TypeInt::BOOL); record_for_igvn(region); const TypePtr* adr_type = TypeRawPtr::BOTTOM; // memory type of loads @@ -3642,8 +3681,8 @@ bool LibraryCallKit::inline_native_subtype_check() { set_control(region->in(_prim_0_path)); // go back to first null check if (!stopped()) { // Since superc is primitive, make a guard for the superc==subc case. - Node* cmp_eq = _gvn.transform(new (C) CmpPNode(args[0], args[1])); - Node* bol_eq = _gvn.transform(new (C) BoolNode(cmp_eq, BoolTest::eq)); + Node* cmp_eq = _gvn.transform(new CmpPNode(args[0], args[1])); + Node* bol_eq = _gvn.transform(new BoolNode(cmp_eq, BoolTest::eq)); generate_guard(bol_eq, region, PROB_FAIR); if (region->req() == PATH_LIMIT+1) { // A guard was added. If the added guard is taken, superc==subc. @@ -3708,11 +3747,11 @@ Node* LibraryCallKit::generate_array_guard_common(Node* kls, RegionNode* region, ? ((jint)Klass::_lh_array_tag_type_value << Klass::_lh_array_tag_shift) : Klass::_lh_neutral_value); - Node* cmp = _gvn.transform(new(C) CmpINode(layout_val, intcon(nval))); + Node* cmp = _gvn.transform(new CmpINode(layout_val, intcon(nval))); BoolTest::mask btest = BoolTest::lt; // correct for testing is_[obj]array // invert the test if we are looking for a non-array if (not_array) btest = BoolTest(btest).negate(); - Node* bol = _gvn.transform(new(C) BoolNode(cmp, btest)); + Node* bol = _gvn.transform(new BoolNode(cmp, btest)); return generate_fair_guard(bol, region); } @@ -3728,12 +3767,10 @@ bool LibraryCallKit::inline_native_newArray() { if (stopped()) return true; enum { _normal_path = 1, _slow_path = 2, PATH_LIMIT }; - RegionNode* result_reg = new(C) RegionNode(PATH_LIMIT); - PhiNode* result_val = new(C) PhiNode(result_reg, - TypeInstPtr::NOTNULL); - PhiNode* result_io = new(C) PhiNode(result_reg, Type::ABIO); - PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, - TypePtr::BOTTOM); + RegionNode* result_reg = new RegionNode(PATH_LIMIT); + PhiNode* result_val = new PhiNode(result_reg, TypeInstPtr::NOTNULL); + PhiNode* result_io = new PhiNode(result_reg, Type::ABIO); + PhiNode* result_mem = new PhiNode(result_reg, Type::MEMORY, TypePtr::BOTTOM); bool never_see_null = !too_many_traps(Deoptimization::Reason_null_check); Node* klass_node = load_array_klass_from_mirror(mirror, never_see_null, @@ -3840,7 +3877,7 @@ bool LibraryCallKit::inline_array_copyOf(bool is_copyOfRange) { Node* klass_node = load_klass_from_mirror(array_type_mirror, false, NULL, 0); klass_node = null_check(klass_node); - RegionNode* bailout = new (C) RegionNode(1); + RegionNode* bailout = new RegionNode(1); record_for_igvn(bailout); // Despite the generic type of Arrays.copyOf, the mirror might be int, int[], etc. @@ -3850,7 +3887,7 @@ bool LibraryCallKit::inline_array_copyOf(bool is_copyOfRange) { // Improve the klass node's type from the new optimistic assumption: ciKlass* ak = ciArrayKlass::make(env()->Object_klass()); const Type* akls = TypeKlassPtr::make(TypePtr::NotNull, ak, 0/*offset*/); - Node* cast = new (C) CastPPNode(klass_node, akls); + Node* cast = new CastPPNode(klass_node, akls); cast->init_req(0, control()); klass_node = _gvn.transform(cast); } @@ -3861,7 +3898,7 @@ bool LibraryCallKit::inline_array_copyOf(bool is_copyOfRange) { Node* length = end; if (_gvn.type(start) != TypeInt::ZERO) { - length = _gvn.transform(new (C) SubINode(end, start)); + length = _gvn.transform(new SubINode(end, start)); } // Bail out if length is negative. @@ -3880,7 +3917,7 @@ bool LibraryCallKit::inline_array_copyOf(bool is_copyOfRange) { if (!stopped()) { // How many elements will we copy from the original? // The answer is MinI(orig_length - start, length). - Node* orig_tail = _gvn.transform(new (C) SubINode(orig_length, start)); + Node* orig_tail = _gvn.transform(new SubINode(orig_length, start)); Node* moved = generate_min_max(vmIntrinsics::_min, orig_tail, length); newcopy = new_array(klass_node, length, 0); // no argments to push @@ -3927,8 +3964,8 @@ Node* LibraryCallKit::generate_virtual_guard(Node* obj_klass, const TypePtr* native_call_addr = TypeMetadataPtr::make(method); Node* native_call = makecon(native_call_addr); - Node* chk_native = _gvn.transform(new(C) CmpPNode(target_call, native_call)); - Node* test_native = _gvn.transform(new(C) BoolNode(chk_native, BoolTest::ne)); + Node* chk_native = _gvn.transform(new CmpPNode(target_call, native_call)); + Node* test_native = _gvn.transform(new BoolNode(chk_native, BoolTest::ne)); return generate_slow_guard(test_native, slow_region); } @@ -3953,7 +3990,7 @@ LibraryCallKit::generate_method_call(vmIntrinsics::ID method_id, bool is_virtual CallJavaNode* slow_call; if (is_static) { assert(!is_virtual, ""); - slow_call = new(C) CallStaticJavaNode(C, tf, + slow_call = new CallStaticJavaNode(C, tf, SharedRuntime::get_resolve_static_call_stub(), method, bci()); } else if (is_virtual) { @@ -3969,12 +4006,12 @@ LibraryCallKit::generate_method_call(vmIntrinsics::ID method_id, bool is_virtual assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, err_msg_res("bad index %d", vtable_index)); } - slow_call = new(C) CallDynamicJavaNode(tf, + slow_call = new CallDynamicJavaNode(tf, SharedRuntime::get_resolve_virtual_call_stub(), method, vtable_index, bci()); } else { // neither virtual nor static: opt_virtual null_check_receiver(); - slow_call = new(C) CallStaticJavaNode(C, tf, + slow_call = new CallStaticJavaNode(C, tf, SharedRuntime::get_resolve_opt_virtual_call_stub(), method, bci()); slow_call->set_optimized_virtual(true); @@ -3985,20 +4022,21 @@ LibraryCallKit::generate_method_call(vmIntrinsics::ID method_id, bool is_virtual } -//------------------------------inline_native_hashcode-------------------- -// Build special case code for calls to hashCode on an object. +/** + * Build special case code for calls to hashCode on an object. This call may + * be virtual (invokevirtual) or bound (invokespecial). For each case we generate + * slightly different code. + */ bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) { assert(is_static == callee()->is_static(), "correct intrinsic selection"); assert(!(is_virtual && is_static), "either virtual, special, or static"); enum { _slow_path = 1, _fast_path, _null_path, PATH_LIMIT }; - RegionNode* result_reg = new(C) RegionNode(PATH_LIMIT); - PhiNode* result_val = new(C) PhiNode(result_reg, - TypeInt::INT); - PhiNode* result_io = new(C) PhiNode(result_reg, Type::ABIO); - PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, - TypePtr::BOTTOM); + RegionNode* result_reg = new RegionNode(PATH_LIMIT); + PhiNode* result_val = new PhiNode(result_reg, TypeInt::INT); + PhiNode* result_io = new PhiNode(result_reg, Type::ABIO); + PhiNode* result_mem = new PhiNode(result_reg, Type::MEMORY, TypePtr::BOTTOM); Node* obj = NULL; if (!is_static) { // Check for hashing null object @@ -4024,15 +4062,9 @@ bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) { return true; } - // After null check, get the object's klass. - Node* obj_klass = load_object_klass(obj); - - // This call may be virtual (invokevirtual) or bound (invokespecial). - // For each case we generate slightly different code. - // We only go to the fast case code if we pass a number of guards. The // paths which do not pass are accumulated in the slow_region. - RegionNode* slow_region = new (C) RegionNode(1); + RegionNode* slow_region = new RegionNode(1); record_for_igvn(slow_region); // If this is a virtual call, we generate a funny guard. We pull out @@ -4042,19 +4074,24 @@ bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) { // guard for non-virtual calls -- the caller is known to be the native // Object hashCode(). if (is_virtual) { + // After null check, get the object's klass. + Node* obj_klass = load_object_klass(obj); generate_virtual_guard(obj_klass, slow_region); } // Get the header out of the object, use LoadMarkNode when available Node* header_addr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes()); - Node* header = make_load(control(), header_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered); + // The control of the load must be NULL. Otherwise, the load can move before + // the null check after castPP removal. + Node* no_ctrl = NULL; + Node* header = make_load(no_ctrl, header_addr, TypeX_X, TypeX_X->basic_type(), MemNode::unordered); // Test the header to see if it is unlocked. Node *lock_mask = _gvn.MakeConX(markOopDesc::biased_lock_mask_in_place); - Node *lmasked_header = _gvn.transform(new (C) AndXNode(header, lock_mask)); + Node *lmasked_header = _gvn.transform(new AndXNode(header, lock_mask)); Node *unlocked_val = _gvn.MakeConX(markOopDesc::unlocked_value); - Node *chk_unlocked = _gvn.transform(new (C) CmpXNode( lmasked_header, unlocked_val)); - Node *test_unlocked = _gvn.transform(new (C) BoolNode( chk_unlocked, BoolTest::ne)); + Node *chk_unlocked = _gvn.transform(new CmpXNode( lmasked_header, unlocked_val)); + Node *test_unlocked = _gvn.transform(new BoolNode( chk_unlocked, BoolTest::ne)); generate_slow_guard(test_unlocked, slow_region); @@ -4064,17 +4101,17 @@ bool LibraryCallKit::inline_native_hashcode(bool is_virtual, bool is_static) { // vm: see markOop.hpp. Node *hash_mask = _gvn.intcon(markOopDesc::hash_mask); Node *hash_shift = _gvn.intcon(markOopDesc::hash_shift); - Node *hshifted_header= _gvn.transform(new (C) URShiftXNode(header, hash_shift)); + Node *hshifted_header= _gvn.transform(new URShiftXNode(header, hash_shift)); // This hack lets the hash bits live anywhere in the mark object now, as long // as the shift drops the relevant bits into the low 32 bits. Note that // Java spec says that HashCode is an int so there's no point in capturing // an 'X'-sized hashcode (32 in 32-bit build or 64 in 64-bit build). hshifted_header = ConvX2I(hshifted_header); - Node *hash_val = _gvn.transform(new (C) AndINode(hshifted_header, hash_mask)); + Node *hash_val = _gvn.transform(new AndINode(hshifted_header, hash_mask)); Node *no_hash_val = _gvn.intcon(markOopDesc::no_hash); - Node *chk_assigned = _gvn.transform(new (C) CmpINode( hash_val, no_hash_val)); - Node *test_assigned = _gvn.transform(new (C) BoolNode( chk_assigned, BoolTest::eq)); + Node *chk_assigned = _gvn.transform(new CmpINode( hash_val, no_hash_val)); + Node *test_assigned = _gvn.transform(new BoolNode( chk_assigned, BoolTest::eq)); generate_slow_guard(test_assigned, slow_region); @@ -4213,19 +4250,19 @@ bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { Node* result; switch (id) { - case vmIntrinsics::_floatToRawIntBits: result = new (C) MoveF2INode(arg); break; - case vmIntrinsics::_intBitsToFloat: result = new (C) MoveI2FNode(arg); break; - case vmIntrinsics::_doubleToRawLongBits: result = new (C) MoveD2LNode(arg); break; - case vmIntrinsics::_longBitsToDouble: result = new (C) MoveL2DNode(arg); break; + case vmIntrinsics::_floatToRawIntBits: result = new MoveF2INode(arg); break; + case vmIntrinsics::_intBitsToFloat: result = new MoveI2FNode(arg); break; + case vmIntrinsics::_doubleToRawLongBits: result = new MoveD2LNode(arg); break; + case vmIntrinsics::_longBitsToDouble: result = new MoveL2DNode(arg); break; case vmIntrinsics::_doubleToLongBits: { // two paths (plus control) merge in a wood - RegionNode *r = new (C) RegionNode(3); - Node *phi = new (C) PhiNode(r, TypeLong::LONG); + RegionNode *r = new RegionNode(3); + Node *phi = new PhiNode(r, TypeLong::LONG); - Node *cmpisnan = _gvn.transform(new (C) CmpDNode(arg, arg)); + Node *cmpisnan = _gvn.transform(new CmpDNode(arg, arg)); // Build the boolean node - Node *bolisnan = _gvn.transform(new (C) BoolNode(cmpisnan, BoolTest::ne)); + Node *bolisnan = _gvn.transform(new BoolNode(cmpisnan, BoolTest::ne)); // Branch either way. // NaN case is less traveled, which makes all the difference. @@ -4233,7 +4270,7 @@ bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { Node *opt_isnan = _gvn.transform(ifisnan); assert( opt_isnan->is_If(), "Expect an IfNode"); IfNode *opt_ifisnan = (IfNode*)opt_isnan; - Node *iftrue = _gvn.transform(new (C) IfTrueNode(opt_ifisnan)); + Node *iftrue = _gvn.transform(new IfTrueNode(opt_ifisnan)); set_control(iftrue); @@ -4243,10 +4280,10 @@ bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { r->init_req(1, iftrue); // Else fall through - Node *iffalse = _gvn.transform(new (C) IfFalseNode(opt_ifisnan)); + Node *iffalse = _gvn.transform(new IfFalseNode(opt_ifisnan)); set_control(iffalse); - phi->init_req(2, _gvn.transform(new (C) MoveD2LNode(arg))); + phi->init_req(2, _gvn.transform(new MoveD2LNode(arg))); r->init_req(2, iffalse); // Post merge @@ -4261,12 +4298,12 @@ bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { case vmIntrinsics::_floatToIntBits: { // two paths (plus control) merge in a wood - RegionNode *r = new (C) RegionNode(3); - Node *phi = new (C) PhiNode(r, TypeInt::INT); + RegionNode *r = new RegionNode(3); + Node *phi = new PhiNode(r, TypeInt::INT); - Node *cmpisnan = _gvn.transform(new (C) CmpFNode(arg, arg)); + Node *cmpisnan = _gvn.transform(new CmpFNode(arg, arg)); // Build the boolean node - Node *bolisnan = _gvn.transform(new (C) BoolNode(cmpisnan, BoolTest::ne)); + Node *bolisnan = _gvn.transform(new BoolNode(cmpisnan, BoolTest::ne)); // Branch either way. // NaN case is less traveled, which makes all the difference. @@ -4274,7 +4311,7 @@ bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { Node *opt_isnan = _gvn.transform(ifisnan); assert( opt_isnan->is_If(), "Expect an IfNode"); IfNode *opt_ifisnan = (IfNode*)opt_isnan; - Node *iftrue = _gvn.transform(new (C) IfTrueNode(opt_ifisnan)); + Node *iftrue = _gvn.transform(new IfTrueNode(opt_ifisnan)); set_control(iftrue); @@ -4284,10 +4321,10 @@ bool LibraryCallKit::inline_fp_conversions(vmIntrinsics::ID id) { r->init_req(1, iftrue); // Else fall through - Node *iffalse = _gvn.transform(new (C) IfFalseNode(opt_ifisnan)); + Node *iffalse = _gvn.transform(new IfFalseNode(opt_ifisnan)); set_control(iffalse); - phi->init_req(2, _gvn.transform(new (C) MoveF2INode(arg))); + phi->init_req(2, _gvn.transform(new MoveF2INode(arg))); r->init_req(2, iffalse); // Post merge @@ -4403,8 +4440,8 @@ void LibraryCallKit::copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, b // Compute the length also, if needed: Node* countx = size; - countx = _gvn.transform(new (C) SubXNode(countx, MakeConX(base_off))); - countx = _gvn.transform(new (C) URShiftXNode(countx, intcon(LogBytesPerLong) )); + countx = _gvn.transform(new SubXNode(countx, MakeConX(base_off))); + countx = _gvn.transform(new URShiftXNode(countx, intcon(LogBytesPerLong) )); const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM; bool disjoint_bases = true; @@ -4493,12 +4530,10 @@ bool LibraryCallKit::inline_native_clone(bool is_virtual) { _instance_path, // plain instance allocation, plus arrayof_long_arraycopy PATH_LIMIT }; - RegionNode* result_reg = new(C) RegionNode(PATH_LIMIT); - result_val = new(C) PhiNode(result_reg, - TypeInstPtr::NOTNULL); - PhiNode* result_i_o = new(C) PhiNode(result_reg, Type::ABIO); - PhiNode* result_mem = new(C) PhiNode(result_reg, Type::MEMORY, - TypePtr::BOTTOM); + RegionNode* result_reg = new RegionNode(PATH_LIMIT); + result_val = new PhiNode(result_reg, TypeInstPtr::NOTNULL); + PhiNode* result_i_o = new PhiNode(result_reg, Type::ABIO); + PhiNode* result_mem = new PhiNode(result_reg, Type::MEMORY, TypePtr::BOTTOM); record_for_igvn(result_reg); const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM; @@ -4554,7 +4589,7 @@ bool LibraryCallKit::inline_native_clone(bool is_virtual) { // We only go to the instance fast case code if we pass a number of guards. // The paths which do not pass are accumulated in the slow_region. - RegionNode* slow_region = new (C) RegionNode(1); + RegionNode* slow_region = new RegionNode(1); record_for_igvn(slow_region); if (!stopped()) { // It's an instance (we did array above). Make the slow-path tests. @@ -4583,7 +4618,10 @@ bool LibraryCallKit::inline_native_clone(bool is_virtual) { // It's an instance, and it passed the slow-path tests. PreserveJVMState pjvms(this); Node* obj_size = NULL; - Node* alloc_obj = new_instance(obj_klass, NULL, &obj_size); + // Need to deoptimize on exception from allocation since Object.clone intrinsic + // is reexecuted if deoptimization occurs and there could be problems when merging + // exception state between multiple Object.clone versions (reexecute=true vs reexecute=false). + Node* alloc_obj = new_instance(obj_klass, NULL, &obj_size, /*deoptimize_on_exception=*/true); copy_to_clone(obj, alloc_obj, obj_size, false, !use_ReduceInitialCardMarks()); @@ -4811,7 +4849,7 @@ bool LibraryCallKit::inline_arraycopy() { // (8) dest_offset + length must not exceed length of dest. // (9) each element of an oop array must be assignable - RegionNode* slow_region = new (C) RegionNode(1); + RegionNode* slow_region = new RegionNode(1); record_for_igvn(slow_region); // (3) operands must not be null @@ -4899,7 +4937,7 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type, RegionNode* slow_region) { if (slow_region == NULL) { - slow_region = new(C) RegionNode(1); + slow_region = new RegionNode(1); record_for_igvn(slow_region); } @@ -4947,9 +4985,9 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type, bcopy_path = 5, // copy primitive array by 64-bit blocks PATH_LIMIT = 6 }; - RegionNode* result_region = new(C) RegionNode(PATH_LIMIT); - PhiNode* result_i_o = new(C) PhiNode(result_region, Type::ABIO); - PhiNode* result_memory = new(C) PhiNode(result_region, Type::MEMORY, adr_type); + RegionNode* result_region = new RegionNode(PATH_LIMIT); + PhiNode* result_i_o = new PhiNode(result_region, Type::ABIO); + PhiNode* result_memory = new PhiNode(result_region, Type::MEMORY, adr_type); record_for_igvn(result_region); _gvn.set_type_bottom(result_i_o); _gvn.set_type_bottom(result_memory); @@ -5023,8 +5061,7 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type, // are dest_head = dest[0..off] and dest_tail = dest[off+len..dest.length]. Node* dest_size = alloc->in(AllocateNode::AllocSize); Node* dest_length = alloc->in(AllocateNode::ALength); - Node* dest_tail = _gvn.transform(new(C) AddINode(dest_offset, - copy_length)); + Node* dest_tail = _gvn.transform(new AddINode(dest_offset, copy_length)); // If there is a head section that needs zeroing, do it now. if (find_int_con(dest_offset, -1) != 0) { @@ -5040,8 +5077,8 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type, // the copy to a more hardware-friendly word size of 64 bits. Node* tail_ctl = NULL; if (!stopped() && !dest_tail->eqv_uncast(dest_length)) { - Node* cmp_lt = _gvn.transform(new(C) CmpINode(dest_tail, dest_length)); - Node* bol_lt = _gvn.transform(new(C) BoolNode(cmp_lt, BoolTest::lt)); + Node* cmp_lt = _gvn.transform(new CmpINode(dest_tail, dest_length)); + Node* bol_lt = _gvn.transform(new BoolNode(cmp_lt, BoolTest::lt)); tail_ctl = generate_slow_guard(bol_lt, NULL); assert(tail_ctl != NULL || !stopped(), "must be an outcome"); } @@ -5075,8 +5112,8 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type, dest_size); } else { // Make a local merge. - Node* done_ctl = new(C) RegionNode(3); - Node* done_mem = new(C) PhiNode(done_ctl, Type::MEMORY, adr_type); + Node* done_ctl = new RegionNode(3); + Node* done_mem = new PhiNode(done_ctl, Type::MEMORY, adr_type); done_ctl->init_req(1, notail_ctl); done_mem->init_req(1, memory(adr_type)); generate_clear_array(adr_type, dest, basic_elem_type, @@ -5171,21 +5208,21 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type, // Clean up after the checked call. // The returned value is either 0 or -1^K, // where K = number of partially transferred array elements. - Node* cmp = _gvn.transform(new(C) CmpINode(checked_value, intcon(0))); - Node* bol = _gvn.transform(new(C) BoolNode(cmp, BoolTest::eq)); + Node* cmp = _gvn.transform(new CmpINode(checked_value, intcon(0))); + Node* bol = _gvn.transform(new BoolNode(cmp, BoolTest::eq)); IfNode* iff = create_and_map_if(control(), bol, PROB_MAX, COUNT_UNKNOWN); // If it is 0, we are done, so transfer to the end. - Node* checks_done = _gvn.transform(new(C) IfTrueNode(iff)); + Node* checks_done = _gvn.transform(new IfTrueNode(iff)); result_region->init_req(checked_path, checks_done); result_i_o ->init_req(checked_path, checked_i_o); result_memory->init_req(checked_path, checked_mem); // If it is not zero, merge into the slow call. - set_control( _gvn.transform(new(C) IfFalseNode(iff) )); - RegionNode* slow_reg2 = new(C) RegionNode(3); - PhiNode* slow_i_o2 = new(C) PhiNode(slow_reg2, Type::ABIO); - PhiNode* slow_mem2 = new(C) PhiNode(slow_reg2, Type::MEMORY, adr_type); + set_control( _gvn.transform(new IfFalseNode(iff) )); + RegionNode* slow_reg2 = new RegionNode(3); + PhiNode* slow_i_o2 = new PhiNode(slow_reg2, Type::ABIO); + PhiNode* slow_mem2 = new PhiNode(slow_reg2, Type::MEMORY, adr_type); record_for_igvn(slow_reg2); slow_reg2 ->init_req(1, slow_control); slow_i_o2 ->init_req(1, slow_i_o); @@ -5205,16 +5242,16 @@ LibraryCallKit::generate_arraycopy(const TypePtr* adr_type, } else { // We must continue the copy exactly where it failed, or else // another thread might see the wrong number of writes to dest. - Node* checked_offset = _gvn.transform(new(C) XorINode(checked_value, intcon(-1))); - Node* slow_offset = new(C) PhiNode(slow_reg2, TypeInt::INT); + Node* checked_offset = _gvn.transform(new XorINode(checked_value, intcon(-1))); + Node* slow_offset = new PhiNode(slow_reg2, TypeInt::INT); slow_offset->init_req(1, intcon(0)); slow_offset->init_req(2, checked_offset); slow_offset = _gvn.transform(slow_offset); // Adjust the arguments by the conditionally incoming offset. - Node* src_off_plus = _gvn.transform(new(C) AddINode(src_offset, slow_offset)); - Node* dest_off_plus = _gvn.transform(new(C) AddINode(dest_offset, slow_offset)); - Node* length_minus = _gvn.transform(new(C) SubINode(copy_length, slow_offset)); + Node* src_off_plus = _gvn.transform(new AddINode(src_offset, slow_offset)); + Node* dest_off_plus = _gvn.transform(new AddINode(dest_offset, slow_offset)); + Node* length_minus = _gvn.transform(new SubINode(copy_length, slow_offset)); // Tweak the node variables to adjust the code produced below: src_offset = src_off_plus; @@ -5435,10 +5472,10 @@ LibraryCallKit::generate_clear_array(const TypePtr* adr_type, int end_round = (-1 << scale) & (BytesPerLong - 1); Node* end = ConvI2X(slice_len); if (scale != 0) - end = _gvn.transform(new(C) LShiftXNode(end, intcon(scale) )); + end = _gvn.transform(new LShiftXNode(end, intcon(scale) )); end_base += end_round; - end = _gvn.transform(new(C) AddXNode(end, MakeConX(end_base))); - end = _gvn.transform(new(C) AndXNode(end, MakeConX(~end_round))); + end = _gvn.transform(new AddXNode(end, MakeConX(end_base))); + end = _gvn.transform(new AndXNode(end, MakeConX(~end_round))); mem = ClearArrayNode::clear_memory(control(), mem, dest, start_con, end, &_gvn); } else if (start_con < 0 && dest_size != top()) { @@ -5447,8 +5484,8 @@ LibraryCallKit::generate_clear_array(const TypePtr* adr_type, Node* start = slice_idx; start = ConvI2X(start); if (scale != 0) - start = _gvn.transform(new(C) LShiftXNode( start, intcon(scale) )); - start = _gvn.transform(new(C) AddXNode(start, MakeConX(abase))); + start = _gvn.transform(new LShiftXNode( start, intcon(scale) )); + start = _gvn.transform(new AddXNode(start, MakeConX(abase))); if ((bump_bit | clear_low) != 0) { int to_clear = (bump_bit | clear_low); // Align up mod 8, then store a jint zero unconditionally @@ -5459,14 +5496,14 @@ LibraryCallKit::generate_clear_array(const TypePtr* adr_type, assert((abase & to_clear) == 0, "array base must be long-aligned"); } else { // Bump 'start' up to (or past) the next jint boundary: - start = _gvn.transform(new(C) AddXNode(start, MakeConX(bump_bit))); + start = _gvn.transform(new AddXNode(start, MakeConX(bump_bit))); assert((abase & clear_low) == 0, "array base must be int-aligned"); } // Round bumped 'start' down to jlong boundary in body of array. - start = _gvn.transform(new(C) AndXNode(start, MakeConX(~to_clear))); + start = _gvn.transform(new AndXNode(start, MakeConX(~to_clear))); if (bump_bit != 0) { // Store a zero to the immediately preceding jint: - Node* x1 = _gvn.transform(new(C) AddXNode(start, MakeConX(-bump_bit))); + Node* x1 = _gvn.transform(new AddXNode(start, MakeConX(-bump_bit))); Node* p1 = basic_plus_adr(dest, x1); mem = StoreNode::make(_gvn, control(), mem, p1, adr_type, intcon(0), T_INT, MemNode::unordered); mem = _gvn.transform(mem); @@ -5533,8 +5570,8 @@ LibraryCallKit::generate_block_arraycopy(const TypePtr* adr_type, Node* sptr = basic_plus_adr(src, src_off); Node* dptr = basic_plus_adr(dest, dest_off); Node* countx = dest_size; - countx = _gvn.transform(new (C) SubXNode(countx, MakeConX(dest_off))); - countx = _gvn.transform(new (C) URShiftXNode(countx, intcon(LogBytesPerLong))); + countx = _gvn.transform(new SubXNode(countx, MakeConX(dest_off))); + countx = _gvn.transform(new URShiftXNode(countx, intcon(LogBytesPerLong))); bool disjoint_bases = true; // since alloc != NULL generate_unchecked_arraycopy(adr_type, T_LONG, disjoint_bases, @@ -5584,7 +5621,7 @@ LibraryCallKit::generate_checkcast_arraycopy(const TypePtr* adr_type, // super_check_offset, for the desired klass. int sco_offset = in_bytes(Klass::super_check_offset_offset()); Node* p3 = basic_plus_adr(dest_elem_klass, sco_offset); - Node* n3 = new(C) LoadINode(NULL, memory(p3), p3, _gvn.type(p3)->is_ptr(), TypeInt::INT, MemNode::unordered); + Node* n3 = new LoadINode(NULL, memory(p3), p3, _gvn.type(p3)->is_ptr(), TypeInt::INT, MemNode::unordered); Node* check_offset = ConvI2X(_gvn.transform(n3)); Node* check_value = dest_elem_klass; @@ -5602,7 +5639,7 @@ LibraryCallKit::generate_checkcast_arraycopy(const TypePtr* adr_type, check_offset XTOP, check_value); - return _gvn.transform(new (C) ProjNode(call, TypeFunc::Parms)); + return _gvn.transform(new ProjNode(call, TypeFunc::Parms)); } @@ -5624,7 +5661,7 @@ LibraryCallKit::generate_generic_arraycopy(const TypePtr* adr_type, copyfunc_addr, "generic_arraycopy", adr_type, src, src_offset, dest, dest_offset, copy_length); - return _gvn.transform(new (C) ProjNode(call, TypeFunc::Parms)); + return _gvn.transform(new ProjNode(call, TypeFunc::Parms)); } // Helper function; generates the fast out-of-line call to an arraycopy stub. @@ -5691,9 +5728,9 @@ bool LibraryCallKit::inline_encodeISOArray() { // 'dst_start' points to dst array + scaled offset const TypeAryPtr* mtype = TypeAryPtr::BYTES; - Node* enc = new (C) EncodeISOArrayNode(control(), memory(mtype), src_start, dst_start, length); + Node* enc = new EncodeISOArrayNode(control(), memory(mtype), src_start, dst_start, length); enc = _gvn.transform(enc); - Node* res_mem = _gvn.transform(new (C) SCMemProjNode(enc)); + Node* res_mem = _gvn.transform(new SCMemProjNode(enc)); set_memory(res_mem, mtype); set_result(enc); return true; @@ -5718,18 +5755,18 @@ bool LibraryCallKit::inline_updateCRC32() { */ Node* M1 = intcon(-1); - crc = _gvn.transform(new (C) XorINode(crc, M1)); - Node* result = _gvn.transform(new (C) XorINode(crc, b)); - result = _gvn.transform(new (C) AndINode(result, intcon(0xFF))); + crc = _gvn.transform(new XorINode(crc, M1)); + Node* result = _gvn.transform(new XorINode(crc, b)); + result = _gvn.transform(new AndINode(result, intcon(0xFF))); Node* base = makecon(TypeRawPtr::make(StubRoutines::crc_table_addr())); - Node* offset = _gvn.transform(new (C) LShiftINode(result, intcon(0x2))); + Node* offset = _gvn.transform(new LShiftINode(result, intcon(0x2))); Node* adr = basic_plus_adr(top(), base, ConvI2X(offset)); result = make_load(control(), adr, TypeInt::INT, T_INT, MemNode::unordered); - crc = _gvn.transform(new (C) URShiftINode(crc, intcon(8))); - result = _gvn.transform(new (C) XorINode(crc, result)); - result = _gvn.transform(new (C) XorINode(result, M1)); + crc = _gvn.transform(new URShiftINode(crc, intcon(8))); + result = _gvn.transform(new XorINode(crc, result)); + result = _gvn.transform(new XorINode(result, M1)); set_result(result); return true; } @@ -5773,7 +5810,7 @@ bool LibraryCallKit::inline_updateBytesCRC32() { Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::updateBytesCRC32_Type(), stubAddr, stubName, TypePtr::BOTTOM, crc, src_start, length); - Node* result = _gvn.transform(new (C) ProjNode(call, TypeFunc::Parms)); + Node* result = _gvn.transform(new ProjNode(call, TypeFunc::Parms)); set_result(result); return true; } @@ -5792,7 +5829,7 @@ bool LibraryCallKit::inline_updateByteBufferCRC32() { Node* length = argument(4); // type: int src = ConvL2X(src); // adjust Java long to machine word - Node* base = _gvn.transform(new (C) CastX2PNode(src)); + Node* base = _gvn.transform(new CastX2PNode(src)); offset = ConvI2X(offset); // 'src_start' points to src array + scaled offset @@ -5805,7 +5842,7 @@ bool LibraryCallKit::inline_updateByteBufferCRC32() { Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::updateBytesCRC32_Type(), stubAddr, stubName, TypePtr::BOTTOM, crc, src_start, length); - Node* result = _gvn.transform(new (C) ProjNode(call, TypeFunc::Parms)); + Node* result = _gvn.transform(new ProjNode(call, TypeFunc::Parms)); set_result(result); return true; } @@ -5870,7 +5907,12 @@ Node * LibraryCallKit::load_field_from_object(Node * fromObj, const char * field BasicType bt = field->layout_type(); // Build the resultant type of the load - const Type *type = TypeOopPtr::make_from_klass(field_klass->as_klass()); + const Type *type; + if (bt == T_OBJECT) { + type = TypeOopPtr::make_from_klass(field_klass->as_klass()); + } else { + type = Type::get_const_basic_type(bt); + } // Build the load. Node* loadedField = make_load(NULL, adr, type, bt, adr_type, MemNode::unordered, is_vol); @@ -6000,12 +6042,12 @@ bool LibraryCallKit::inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id) { assert(tinst != NULL, "CBC obj is null"); assert(tinst->klass()->is_loaded(), "CBC obj is not loaded"); ciKlass* klass_AESCrypt = tinst->klass()->as_instance_klass()->find_klass(ciSymbol::make("com/sun/crypto/provider/AESCrypt")); - if (!klass_AESCrypt->is_loaded()) return false; + assert(klass_AESCrypt->is_loaded(), "predicate checks that this class is loaded"); ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass(); const TypeKlassPtr* aklass = TypeKlassPtr::make(instklass_AESCrypt); const TypeOopPtr* xtype = aklass->as_instance_type(); - Node* aescrypt_object = new(C) CheckCastPPNode(control(), embeddedCipherObj, xtype); + Node* aescrypt_object = new CheckCastPPNode(control(), embeddedCipherObj, xtype); aescrypt_object = _gvn.transform(aescrypt_object); // we need to get the start of the aescrypt_object's expanded key array @@ -6038,7 +6080,7 @@ bool LibraryCallKit::inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id) { } // return cipher length (int) - Node* retvalue = _gvn.transform(new (C) ProjNode(cbcCrypt, TypeFunc::Parms)); + Node* retvalue = _gvn.transform(new ProjNode(cbcCrypt, TypeFunc::Parms)); set_result(retvalue); return true; } @@ -6075,11 +6117,8 @@ Node * LibraryCallKit::get_original_key_start_from_aescrypt_object(Node *aescryp // note cipher==plain is more conservative than the original java code but that's OK // Node* LibraryCallKit::inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting) { - // First, check receiver for NULL since it is virtual method. + // The receiver was checked for NULL already. Node* objCBC = argument(0); - objCBC = null_check(objCBC); - - if (stopped()) return NULL; // Always NULL // Load embeddedCipher field of CipherBlockChaining object. Node* embeddedCipherObj = load_field_from_object(objCBC, "embeddedCipher", "Lcom/sun/crypto/provider/SymmetricCipher;", /*is_exact*/ false); @@ -6102,8 +6141,8 @@ Node* LibraryCallKit::inline_cipherBlockChaining_AESCrypt_predicate(bool decrypt ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass(); Node* instof = gen_instanceof(embeddedCipherObj, makecon(TypeKlassPtr::make(instklass_AESCrypt))); - Node* cmp_instof = _gvn.transform(new (C) CmpINode(instof, intcon(1))); - Node* bool_instof = _gvn.transform(new (C) BoolNode(cmp_instof, BoolTest::ne)); + Node* cmp_instof = _gvn.transform(new CmpINode(instof, intcon(1))); + Node* bool_instof = _gvn.transform(new BoolNode(cmp_instof, BoolTest::ne)); Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN); @@ -6114,15 +6153,270 @@ Node* LibraryCallKit::inline_cipherBlockChaining_AESCrypt_predicate(bool decrypt // for decryption, we need to add a further check to avoid // taking the intrinsic path when cipher and plain are the same // see the original java code for why. - RegionNode* region = new(C) RegionNode(3); + RegionNode* region = new RegionNode(3); region->init_req(1, instof_false); Node* src = argument(1); Node* dest = argument(4); - Node* cmp_src_dest = _gvn.transform(new (C) CmpPNode(src, dest)); - Node* bool_src_dest = _gvn.transform(new (C) BoolNode(cmp_src_dest, BoolTest::eq)); + Node* cmp_src_dest = _gvn.transform(new CmpPNode(src, dest)); + Node* bool_src_dest = _gvn.transform(new BoolNode(cmp_src_dest, BoolTest::eq)); Node* src_dest_conjoint = generate_guard(bool_src_dest, NULL, PROB_MIN); region->init_req(2, src_dest_conjoint); record_for_igvn(region); return _gvn.transform(region); } + +//------------------------------inline_sha_implCompress----------------------- +// +// Calculate SHA (i.e., SHA-1) for single-block byte[] array. +// void com.sun.security.provider.SHA.implCompress(byte[] buf, int ofs) +// +// Calculate SHA2 (i.e., SHA-244 or SHA-256) for single-block byte[] array. +// void com.sun.security.provider.SHA2.implCompress(byte[] buf, int ofs) +// +// Calculate SHA5 (i.e., SHA-384 or SHA-512) for single-block byte[] array. +// void com.sun.security.provider.SHA5.implCompress(byte[] buf, int ofs) +// +bool LibraryCallKit::inline_sha_implCompress(vmIntrinsics::ID id) { + assert(callee()->signature()->size() == 2, "sha_implCompress has 2 parameters"); + + Node* sha_obj = argument(0); + Node* src = argument(1); // type oop + Node* ofs = argument(2); // type int + + const Type* src_type = src->Value(&_gvn); + const TypeAryPtr* top_src = src_type->isa_aryptr(); + if (top_src == NULL || top_src->klass() == NULL) { + // failed array check + return false; + } + // Figure out the size and type of the elements we will be copying. + BasicType src_elem = src_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); + if (src_elem != T_BYTE) { + return false; + } + // 'src_start' points to src array + offset + Node* src_start = array_element_address(src, ofs, src_elem); + Node* state = NULL; + address stubAddr; + const char *stubName; + + switch(id) { + case vmIntrinsics::_sha_implCompress: + assert(UseSHA1Intrinsics, "need SHA1 instruction support"); + state = get_state_from_sha_object(sha_obj); + stubAddr = StubRoutines::sha1_implCompress(); + stubName = "sha1_implCompress"; + break; + case vmIntrinsics::_sha2_implCompress: + assert(UseSHA256Intrinsics, "need SHA256 instruction support"); + state = get_state_from_sha_object(sha_obj); + stubAddr = StubRoutines::sha256_implCompress(); + stubName = "sha256_implCompress"; + break; + case vmIntrinsics::_sha5_implCompress: + assert(UseSHA512Intrinsics, "need SHA512 instruction support"); + state = get_state_from_sha5_object(sha_obj); + stubAddr = StubRoutines::sha512_implCompress(); + stubName = "sha512_implCompress"; + break; + default: + fatal_unexpected_iid(id); + return false; + } + if (state == NULL) return false; + + // Call the stub. + Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::sha_implCompress_Type(), + stubAddr, stubName, TypePtr::BOTTOM, + src_start, state); + + return true; +} + +//------------------------------inline_digestBase_implCompressMB----------------------- +// +// Calculate SHA/SHA2/SHA5 for multi-block byte[] array. +// int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit) +// +bool LibraryCallKit::inline_digestBase_implCompressMB(int predicate) { + assert(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics, + "need SHA1/SHA256/SHA512 instruction support"); + assert((uint)predicate < 3, "sanity"); + assert(callee()->signature()->size() == 3, "digestBase_implCompressMB has 3 parameters"); + + Node* digestBase_obj = argument(0); // The receiver was checked for NULL already. + Node* src = argument(1); // byte[] array + Node* ofs = argument(2); // type int + Node* limit = argument(3); // type int + + const Type* src_type = src->Value(&_gvn); + const TypeAryPtr* top_src = src_type->isa_aryptr(); + if (top_src == NULL || top_src->klass() == NULL) { + // failed array check + return false; + } + // Figure out the size and type of the elements we will be copying. + BasicType src_elem = src_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); + if (src_elem != T_BYTE) { + return false; + } + // 'src_start' points to src array + offset + Node* src_start = array_element_address(src, ofs, src_elem); + + const char* klass_SHA_name = NULL; + const char* stub_name = NULL; + address stub_addr = NULL; + bool long_state = false; + + switch (predicate) { + case 0: + if (UseSHA1Intrinsics) { + klass_SHA_name = "sun/security/provider/SHA"; + stub_name = "sha1_implCompressMB"; + stub_addr = StubRoutines::sha1_implCompressMB(); + } + break; + case 1: + if (UseSHA256Intrinsics) { + klass_SHA_name = "sun/security/provider/SHA2"; + stub_name = "sha256_implCompressMB"; + stub_addr = StubRoutines::sha256_implCompressMB(); + } + break; + case 2: + if (UseSHA512Intrinsics) { + klass_SHA_name = "sun/security/provider/SHA5"; + stub_name = "sha512_implCompressMB"; + stub_addr = StubRoutines::sha512_implCompressMB(); + long_state = true; + } + break; + default: + fatal(err_msg_res("unknown SHA intrinsic predicate: %d", predicate)); + } + if (klass_SHA_name != NULL) { + // get DigestBase klass to lookup for SHA klass + const TypeInstPtr* tinst = _gvn.type(digestBase_obj)->isa_instptr(); + assert(tinst != NULL, "digestBase_obj is not instance???"); + assert(tinst->klass()->is_loaded(), "DigestBase is not loaded"); + + ciKlass* klass_SHA = tinst->klass()->as_instance_klass()->find_klass(ciSymbol::make(klass_SHA_name)); + assert(klass_SHA->is_loaded(), "predicate checks that this class is loaded"); + ciInstanceKlass* instklass_SHA = klass_SHA->as_instance_klass(); + return inline_sha_implCompressMB(digestBase_obj, instklass_SHA, long_state, stub_addr, stub_name, src_start, ofs, limit); + } + return false; +} +//------------------------------inline_sha_implCompressMB----------------------- +bool LibraryCallKit::inline_sha_implCompressMB(Node* digestBase_obj, ciInstanceKlass* instklass_SHA, + bool long_state, address stubAddr, const char *stubName, + Node* src_start, Node* ofs, Node* limit) { + const TypeKlassPtr* aklass = TypeKlassPtr::make(instklass_SHA); + const TypeOopPtr* xtype = aklass->as_instance_type(); + Node* sha_obj = new CheckCastPPNode(control(), digestBase_obj, xtype); + sha_obj = _gvn.transform(sha_obj); + + Node* state; + if (long_state) { + state = get_state_from_sha5_object(sha_obj); + } else { + state = get_state_from_sha_object(sha_obj); + } + if (state == NULL) return false; + + // Call the stub. + Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, + OptoRuntime::digestBase_implCompressMB_Type(), + stubAddr, stubName, TypePtr::BOTTOM, + src_start, state, ofs, limit); + // return ofs (int) + Node* result = _gvn.transform(new ProjNode(call, TypeFunc::Parms)); + set_result(result); + + return true; +} + +//------------------------------get_state_from_sha_object----------------------- +Node * LibraryCallKit::get_state_from_sha_object(Node *sha_object) { + Node* sha_state = load_field_from_object(sha_object, "state", "[I", /*is_exact*/ false); + assert (sha_state != NULL, "wrong version of sun.security.provider.SHA/SHA2"); + if (sha_state == NULL) return (Node *) NULL; + + // now have the array, need to get the start address of the state array + Node* state = array_element_address(sha_state, intcon(0), T_INT); + return state; +} + +//------------------------------get_state_from_sha5_object----------------------- +Node * LibraryCallKit::get_state_from_sha5_object(Node *sha_object) { + Node* sha_state = load_field_from_object(sha_object, "state", "[J", /*is_exact*/ false); + assert (sha_state != NULL, "wrong version of sun.security.provider.SHA5"); + if (sha_state == NULL) return (Node *) NULL; + + // now have the array, need to get the start address of the state array + Node* state = array_element_address(sha_state, intcon(0), T_LONG); + return state; +} + +//----------------------------inline_digestBase_implCompressMB_predicate---------------------------- +// Return node representing slow path of predicate check. +// the pseudo code we want to emulate with this predicate is: +// if (digestBaseObj instanceof SHA/SHA2/SHA5) do_intrinsic, else do_javapath +// +Node* LibraryCallKit::inline_digestBase_implCompressMB_predicate(int predicate) { + assert(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics, + "need SHA1/SHA256/SHA512 instruction support"); + assert((uint)predicate < 3, "sanity"); + + // The receiver was checked for NULL already. + Node* digestBaseObj = argument(0); + + // get DigestBase klass for instanceOf check + const TypeInstPtr* tinst = _gvn.type(digestBaseObj)->isa_instptr(); + assert(tinst != NULL, "digestBaseObj is null"); + assert(tinst->klass()->is_loaded(), "DigestBase is not loaded"); + + const char* klass_SHA_name = NULL; + switch (predicate) { + case 0: + if (UseSHA1Intrinsics) { + // we want to do an instanceof comparison against the SHA class + klass_SHA_name = "sun/security/provider/SHA"; + } + break; + case 1: + if (UseSHA256Intrinsics) { + // we want to do an instanceof comparison against the SHA2 class + klass_SHA_name = "sun/security/provider/SHA2"; + } + break; + case 2: + if (UseSHA512Intrinsics) { + // we want to do an instanceof comparison against the SHA5 class + klass_SHA_name = "sun/security/provider/SHA5"; + } + break; + default: + fatal(err_msg_res("unknown SHA intrinsic predicate: %d", predicate)); + } + + ciKlass* klass_SHA = NULL; + if (klass_SHA_name != NULL) { + klass_SHA = tinst->klass()->as_instance_klass()->find_klass(ciSymbol::make(klass_SHA_name)); + } + if ((klass_SHA == NULL) || !klass_SHA->is_loaded()) { + // if none of SHA/SHA2/SHA5 is loaded, we never take the intrinsic fast path + Node* ctrl = control(); + set_control(top()); // no intrinsic path + return ctrl; + } + ciInstanceKlass* instklass_SHA = klass_SHA->as_instance_klass(); + + Node* instofSHA = gen_instanceof(digestBaseObj, makecon(TypeKlassPtr::make(instklass_SHA))); + Node* cmp_instof = _gvn.transform(new CmpINode(instofSHA, intcon(1))); + Node* bool_instof = _gvn.transform(new BoolNode(cmp_instof, BoolTest::ne)); + Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN); + + return instof_false; // even if it is NULL +} diff --git a/hotspot/src/share/vm/opto/loopPredicate.cpp b/hotspot/src/share/vm/opto/loopPredicate.cpp index aeb3ffad0d5..4f2ddd3d068 100644 --- a/hotspot/src/share/vm/opto/loopPredicate.cpp +++ b/hotspot/src/share/vm/opto/loopPredicate.cpp @@ -104,7 +104,7 @@ ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj, Node* assert(rgn->is_Call(), "must be call uct"); CallNode* call = rgn->as_Call(); IdealLoopTree* loop = get_loop(call); - rgn = new (C) RegionNode(1); + rgn = new RegionNode(1); rgn->add_req(uncommon_proj); register_control(rgn, loop, uncommon_proj); _igvn.hash_delete(call); @@ -130,8 +130,8 @@ ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj, Node* IfNode *new_iff = iff->clone()->as_If(); new_iff->set_req(0, entry); register_control(new_iff, lp, entry); - Node *if_cont = new (C) IfTrueNode(new_iff); - Node *if_uct = new (C) IfFalseNode(new_iff); + Node *if_cont = new IfTrueNode(new_iff); + Node *if_uct = new IfFalseNode(new_iff); if (cont_proj->is_IfFalse()) { // Swap Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp; @@ -191,7 +191,7 @@ ProjNode* PhaseIterGVN::create_new_if_for_predicate(ProjNode* cont_proj, Node* n if (!rgn->is_Region()) { // create a region to guard the call assert(rgn->is_Call(), "must be call uct"); CallNode* call = rgn->as_Call(); - rgn = new (C) RegionNode(1); + rgn = new RegionNode(1); register_new_node_with_optimizer(rgn); rgn->add_req(uncommon_proj); hash_delete(call); @@ -208,8 +208,8 @@ ProjNode* PhaseIterGVN::create_new_if_for_predicate(ProjNode* cont_proj, Node* n new_iff->set_req(0, new_entry); register_new_node_with_optimizer(new_iff); - Node *if_cont = new (C) IfTrueNode(new_iff); - Node *if_uct = new (C) IfFalseNode(new_iff); + Node *if_cont = new IfTrueNode(new_iff); + Node *if_uct = new IfFalseNode(new_iff); if (cont_proj->is_IfFalse()) { // Swap Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp; @@ -254,10 +254,10 @@ ProjNode* PhaseIdealLoop::clone_predicate(ProjNode* predicate_proj, Node* new_en // Match original condition since predicate's projections could be swapped. assert(predicate_proj->in(0)->in(1)->in(1)->Opcode()==Op_Opaque1, "must be"); - Node* opq = new (igvn->C) Opaque1Node(igvn->C, predicate_proj->in(0)->in(1)->in(1)->in(1)); + Node* opq = new Opaque1Node(igvn->C, predicate_proj->in(0)->in(1)->in(1)->in(1)); igvn->C->add_predicate_opaq(opq); - Node* bol = new (igvn->C) Conv2BNode(opq); + Node* bol = new Conv2BNode(opq); if (loop_phase != NULL) { loop_phase->register_new_node(opq, ctrl); loop_phase->register_new_node(bol, ctrl); @@ -605,11 +605,11 @@ BoolNode* PhaseIdealLoop::rc_predicate(IdealLoopTree *loop, Node* ctrl, // Calculate exact limit here. // Note, counted loop's test is '<' or '>'. limit = exact_limit(loop); - max_idx_expr = new (C) SubINode(limit, stride); + max_idx_expr = new SubINode(limit, stride); register_new_node(max_idx_expr, ctrl); if (TraceLoopPredicate) predString->print("(limit - stride) "); } else { - max_idx_expr = new (C) SubINode(limit, stride); + max_idx_expr = new SubINode(limit, stride); register_new_node(max_idx_expr, ctrl); if (TraceLoopPredicate) predString->print("(limit - stride) "); } @@ -619,22 +619,22 @@ BoolNode* PhaseIdealLoop::rc_predicate(IdealLoopTree *loop, Node* ctrl, if (scale != 1) { ConNode* con_scale = _igvn.intcon(scale); - max_idx_expr = new (C) MulINode(max_idx_expr, con_scale); + max_idx_expr = new MulINode(max_idx_expr, con_scale); register_new_node(max_idx_expr, ctrl); if (TraceLoopPredicate) predString->print("* %d ", scale); } if (offset && (!offset->is_Con() || offset->get_int() != 0)){ - max_idx_expr = new (C) AddINode(max_idx_expr, offset); + max_idx_expr = new AddINode(max_idx_expr, offset); register_new_node(max_idx_expr, ctrl); if (TraceLoopPredicate) if (offset->is_Con()) predString->print("+ %d ", offset->get_int()); else predString->print("+ offset "); } - CmpUNode* cmp = new (C) CmpUNode(max_idx_expr, range); + CmpUNode* cmp = new CmpUNode(max_idx_expr, range); register_new_node(cmp, ctrl); - BoolNode* bol = new (C) BoolNode(cmp, BoolTest::lt); + BoolNode* bol = new BoolNode(cmp, BoolTest::lt); register_new_node(bol, ctrl); if (TraceLoopPredicate) { @@ -750,7 +750,7 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) { // Negate test if necessary bool negated = false; if (proj->_con != predicate_proj->_con) { - new_predicate_bol = new (C) BoolNode(new_predicate_bol->in(1), new_predicate_bol->_test.negate()); + new_predicate_bol = new BoolNode(new_predicate_bol->in(1), new_predicate_bol->_test.negate()); register_new_node(new_predicate_bol, ctrl); negated = true; } diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp index 0893981abac..73ec0617370 100644 --- a/hotspot/src/share/vm/opto/loopTransform.cpp +++ b/hotspot/src/share/vm/opto/loopTransform.cpp @@ -227,24 +227,24 @@ Node* IdealLoopTree::reassociate_add_sub(Node* n1, PhaseIdealLoop *phase) { if (neg_inv1) { Node *zero = phase->_igvn.intcon(0); phase->set_ctrl(zero, phase->C->root()); - n_inv1 = new (phase->C) SubINode(zero, inv1); + n_inv1 = new SubINode(zero, inv1); phase->register_new_node(n_inv1, inv1_c); } else { n_inv1 = inv1; } Node* inv; if (neg_inv2) { - inv = new (phase->C) SubINode(n_inv1, inv2); + inv = new SubINode(n_inv1, inv2); } else { - inv = new (phase->C) AddINode(n_inv1, inv2); + inv = new AddINode(n_inv1, inv2); } phase->register_new_node(inv, phase->get_early_ctrl(inv)); Node* addx; if (neg_x) { - addx = new (phase->C) SubINode(inv, x); + addx = new SubINode(inv, x); } else { - addx = new (phase->C) AddINode(x, inv); + addx = new AddINode(x, inv); } phase->register_new_node(addx, phase->get_ctrl(x)); phase->_igvn.replace_node(n1, addx); @@ -953,7 +953,7 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ post_end->_prob = PROB_FAIR; // Build the main-loop normal exit. - IfFalseNode *new_main_exit = new (C) IfFalseNode(main_end); + IfFalseNode *new_main_exit = new IfFalseNode(main_end); _igvn.register_new_node_with_optimizer( new_main_exit ); set_idom(new_main_exit, main_end, dd_main_exit ); set_loop(new_main_exit, loop->_parent); @@ -963,15 +963,15 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ // (the main-loop trip-counter exit value) because we will be changing // the exit value (via unrolling) so we cannot constant-fold away the zero // trip guard until all unrolling is done. - Node *zer_opaq = new (C) Opaque1Node(C, incr); - Node *zer_cmp = new (C) CmpINode( zer_opaq, limit ); - Node *zer_bol = new (C) BoolNode( zer_cmp, b_test ); + Node *zer_opaq = new Opaque1Node(C, incr); + Node *zer_cmp = new CmpINode( zer_opaq, limit ); + Node *zer_bol = new BoolNode( zer_cmp, b_test ); register_new_node( zer_opaq, new_main_exit ); register_new_node( zer_cmp , new_main_exit ); register_new_node( zer_bol , new_main_exit ); // Build the IfNode - IfNode *zer_iff = new (C) IfNode( new_main_exit, zer_bol, PROB_FAIR, COUNT_UNKNOWN ); + IfNode *zer_iff = new IfNode( new_main_exit, zer_bol, PROB_FAIR, COUNT_UNKNOWN ); _igvn.register_new_node_with_optimizer( zer_iff ); set_idom(zer_iff, new_main_exit, dd_main_exit); set_loop(zer_iff, loop->_parent); @@ -981,7 +981,7 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ set_idom(main_exit, zer_iff, dd_main_exit); set_idom(main_exit->unique_out(), zer_iff, dd_main_exit); // Make the true-path, must enter the post loop - Node *zer_taken = new (C) IfTrueNode( zer_iff ); + Node *zer_taken = new IfTrueNode( zer_iff ); _igvn.register_new_node_with_optimizer( zer_taken ); set_idom(zer_taken, zer_iff, dd_main_exit); set_loop(zer_taken, loop->_parent); @@ -1029,7 +1029,7 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ // Find the pre-loop normal exit. Node* pre_exit = pre_end->proj_out(false); assert( pre_exit->Opcode() == Op_IfFalse, "" ); - IfFalseNode *new_pre_exit = new (C) IfFalseNode(pre_end); + IfFalseNode *new_pre_exit = new IfFalseNode(pre_end); _igvn.register_new_node_with_optimizer( new_pre_exit ); set_idom(new_pre_exit, pre_end, dd_main_head); set_loop(new_pre_exit, loop->_parent); @@ -1038,15 +1038,15 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ // pre-loop, the main-loop may not execute at all. Later in life this // zero-trip guard will become the minimum-trip guard when we unroll // the main-loop. - Node *min_opaq = new (C) Opaque1Node(C, limit); - Node *min_cmp = new (C) CmpINode( pre_incr, min_opaq ); - Node *min_bol = new (C) BoolNode( min_cmp, b_test ); + Node *min_opaq = new Opaque1Node(C, limit); + Node *min_cmp = new CmpINode( pre_incr, min_opaq ); + Node *min_bol = new BoolNode( min_cmp, b_test ); register_new_node( min_opaq, new_pre_exit ); register_new_node( min_cmp , new_pre_exit ); register_new_node( min_bol , new_pre_exit ); // Build the IfNode (assume the main-loop is executed always). - IfNode *min_iff = new (C) IfNode( new_pre_exit, min_bol, PROB_ALWAYS, COUNT_UNKNOWN ); + IfNode *min_iff = new IfNode( new_pre_exit, min_bol, PROB_ALWAYS, COUNT_UNKNOWN ); _igvn.register_new_node_with_optimizer( min_iff ); set_idom(min_iff, new_pre_exit, dd_main_head); set_loop(min_iff, loop->_parent); @@ -1057,7 +1057,7 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ set_idom(pre_exit, min_iff, dd_main_head); set_idom(pre_exit->unique_out(), min_iff, dd_main_head); // Make the true-path, must enter the main loop - Node *min_taken = new (C) IfTrueNode( min_iff ); + Node *min_taken = new IfTrueNode( min_iff ); _igvn.register_new_node_with_optimizer( min_taken ); set_idom(min_taken, min_iff, dd_main_head); set_loop(min_taken, loop->_parent); @@ -1087,11 +1087,11 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ // RCE and alignment may change this later. Node *cmp_end = pre_end->cmp_node(); assert( cmp_end->in(2) == limit, "" ); - Node *pre_limit = new (C) AddINode( init, stride ); + Node *pre_limit = new AddINode( init, stride ); // Save the original loop limit in this Opaque1 node for // use by range check elimination. - Node *pre_opaq = new (C) Opaque1Node(C, pre_limit, limit); + Node *pre_opaq = new Opaque1Node(C, pre_limit, limit); register_new_node( pre_limit, pre_head->in(0) ); register_new_node( pre_opaq , pre_head->in(0) ); @@ -1116,19 +1116,19 @@ void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_ BoolTest::mask new_test = (main_end->stride_con() > 0) ? BoolTest::lt : BoolTest::gt; // Modify pre loop end condition Node* pre_bol = pre_end->in(CountedLoopEndNode::TestValue)->as_Bool(); - BoolNode* new_bol0 = new (C) BoolNode(pre_bol->in(1), new_test); + BoolNode* new_bol0 = new BoolNode(pre_bol->in(1), new_test); register_new_node( new_bol0, pre_head->in(0) ); _igvn.hash_delete(pre_end); pre_end->set_req(CountedLoopEndNode::TestValue, new_bol0); // Modify main loop guard condition assert(min_iff->in(CountedLoopEndNode::TestValue) == min_bol, "guard okay"); - BoolNode* new_bol1 = new (C) BoolNode(min_bol->in(1), new_test); + BoolNode* new_bol1 = new BoolNode(min_bol->in(1), new_test); register_new_node( new_bol1, new_pre_exit ); _igvn.hash_delete(min_iff); min_iff->set_req(CountedLoopEndNode::TestValue, new_bol1); // Modify main loop end condition BoolNode* main_bol = main_end->in(CountedLoopEndNode::TestValue)->as_Bool(); - BoolNode* new_bol2 = new (C) BoolNode(main_bol->in(1), new_test); + BoolNode* new_bol2 = new BoolNode(main_bol->in(1), new_test); register_new_node( new_bol2, main_end->in(CountedLoopEndNode::TestControl) ); _igvn.hash_delete(main_end); main_end->set_req(CountedLoopEndNode::TestValue, new_bol2); @@ -1279,13 +1279,13 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad // zero trip guard limit will be different from loop limit. assert(has_ctrl(opaq), "should have it"); Node* opaq_ctrl = get_ctrl(opaq); - limit = new (C) Opaque2Node( C, limit ); + limit = new Opaque2Node( C, limit ); register_new_node( limit, opaq_ctrl ); } if (stride_con > 0 && ((limit_type->_lo - stride_con) < limit_type->_lo) || stride_con < 0 && ((limit_type->_hi - stride_con) > limit_type->_hi)) { // No underflow. - new_limit = new (C) SubINode(limit, stride); + new_limit = new SubINode(limit, stride); } else { // (limit - stride) may underflow. // Clamp the adjustment value with MININT or MAXINT: @@ -1315,18 +1315,18 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad old_limit = bol->in(1)->in(1); // Adjust previous adjusted limit. adj_limit = limit->in(CMoveNode::IfFalse); - adj_limit = new (C) SubINode(adj_limit, stride); + adj_limit = new SubINode(adj_limit, stride); } else { old_limit = limit; - adj_limit = new (C) SubINode(limit, stride); + adj_limit = new SubINode(limit, stride); } assert(old_limit != NULL && adj_limit != NULL, ""); register_new_node( adj_limit, ctrl ); // adjust amount - Node* adj_cmp = new (C) CmpINode(old_limit, adj_limit); + Node* adj_cmp = new CmpINode(old_limit, adj_limit); register_new_node( adj_cmp, ctrl ); - Node* adj_bool = new (C) BoolNode(adj_cmp, bt); + Node* adj_bool = new BoolNode(adj_cmp, bt); register_new_node( adj_bool, ctrl ); - new_limit = new (C) CMoveINode(adj_bool, adj_limit, adj_max, TypeInt::INT); + new_limit = new CMoveINode(adj_bool, adj_limit, adj_max, TypeInt::INT); } register_new_node(new_limit, ctrl); } @@ -1388,24 +1388,24 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad // CountedLoop this is exact (stride divides limit-init exactly). // We are going to double the loop body, so we want to knock off any // odd iteration: (trip_cnt & ~1). Then back compute a new limit. - Node *span = new (C) SubINode( limit, init ); + Node *span = new SubINode( limit, init ); register_new_node( span, ctrl ); - Node *trip = new (C) DivINode( 0, span, stride ); + Node *trip = new DivINode( 0, span, stride ); register_new_node( trip, ctrl ); Node *mtwo = _igvn.intcon(-2); set_ctrl(mtwo, C->root()); - Node *rond = new (C) AndINode( trip, mtwo ); + Node *rond = new AndINode( trip, mtwo ); register_new_node( rond, ctrl ); - Node *spn2 = new (C) MulINode( rond, stride ); + Node *spn2 = new MulINode( rond, stride ); register_new_node( spn2, ctrl ); - new_limit = new (C) AddINode( spn2, init ); + new_limit = new AddINode( spn2, init ); register_new_node( new_limit, ctrl ); // Hammer in the new limit Node *ctrl2 = loop_end->in(0); - Node *cmp2 = new (C) CmpINode( loop_head->incr(), new_limit ); + Node *cmp2 = new CmpINode( loop_head->incr(), new_limit ); register_new_node( cmp2, ctrl2 ); - Node *bol2 = new (C) BoolNode( cmp2, loop_end->test_trip() ); + Node *bol2 = new BoolNode( cmp2, loop_end->test_trip() ); register_new_node( bol2, ctrl2 ); _igvn.hash_delete(loop_end); loop_end->set_req(CountedLoopEndNode::TestValue, bol2); @@ -1511,15 +1511,15 @@ bool IdealLoopTree::dominates_backedge(Node* ctrl) { // Helper function for add_constraint(). Node* PhaseIdealLoop::adjust_limit(int stride_con, Node * scale, Node *offset, Node *rc_limit, Node *loop_limit, Node *pre_ctrl) { // Compute "I :: (limit-offset)/scale" - Node *con = new (C) SubINode(rc_limit, offset); + Node *con = new SubINode(rc_limit, offset); register_new_node(con, pre_ctrl); - Node *X = new (C) DivINode(0, con, scale); + Node *X = new DivINode(0, con, scale); register_new_node(X, pre_ctrl); // Adjust loop limit loop_limit = (stride_con > 0) - ? (Node*)(new (C) MinINode(loop_limit, X)) - : (Node*)(new (C) MaxINode(loop_limit, X)); + ? (Node*)(new MinINode(loop_limit, X)) + : (Node*)(new MaxINode(loop_limit, X)); register_new_node(loop_limit, pre_ctrl); return loop_limit; } @@ -1580,9 +1580,9 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset // to avoid problem with scale == -1 (min_int/(-1) == min_int). Node* shift = _igvn.intcon(31); set_ctrl(shift, C->root()); - Node* sign = new (C) RShiftINode(offset, shift); + Node* sign = new RShiftINode(offset, shift); register_new_node(sign, pre_ctrl); - offset = new (C) AndINode(offset, sign); + offset = new AndINode(offset, sign); register_new_node(offset, pre_ctrl); } else { assert(low_limit->get_int() == 0, "wrong low limit for range check"); @@ -1615,7 +1615,7 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset Node *one = _igvn.intcon(1); set_ctrl(one, C->root()); - Node *plus_one = new (C) AddINode(offset, one); + Node *plus_one = new AddINode(offset, one); register_new_node( plus_one, pre_ctrl ); // Pass (-stride) to indicate pre_loop_cond = NOT(main_loop_cond); *pre_limit = adjust_limit((-stride_con), scale, plus_one, upper_limit, *pre_limit, pre_ctrl); @@ -1633,9 +1633,9 @@ void PhaseIdealLoop::add_constraint( int stride_con, int scale_con, Node *offset // to avoid problem with scale == -1 (min_int/(-1) == min_int). Node* shift = _igvn.intcon(31); set_ctrl(shift, C->root()); - Node* sign = new (C) RShiftINode(plus_one, shift); + Node* sign = new RShiftINode(plus_one, shift); register_new_node(sign, pre_ctrl); - plus_one = new (C) AndINode(plus_one, sign); + plus_one = new AndINode(plus_one, sign); register_new_node(plus_one, pre_ctrl); } else { assert(low_limit->get_int() == 0, "wrong low limit for range check"); @@ -1718,7 +1718,7 @@ bool PhaseIdealLoop::is_scaled_iv_plus_offset(Node* exp, Node* iv, int* p_scale, p_offset != NULL ? &offset2 : NULL, depth+1)) { if (p_offset != NULL) { Node *ctrl_off2 = get_ctrl(offset2); - Node* offset = new (C) AddINode(offset2, exp->in(2)); + Node* offset = new AddINode(offset2, exp->in(2)); register_new_node(offset, ctrl_off2); *p_offset = offset; } @@ -1731,7 +1731,7 @@ bool PhaseIdealLoop::is_scaled_iv_plus_offset(Node* exp, Node* iv, int* p_scale, Node *zero = _igvn.intcon(0); set_ctrl(zero, C->root()); Node *ctrl_off = get_ctrl(exp->in(2)); - Node* offset = new (C) SubINode(zero, exp->in(2)); + Node* offset = new SubINode(zero, exp->in(2)); register_new_node(offset, ctrl_off); *p_offset = offset; } @@ -1934,15 +1934,15 @@ void PhaseIdealLoop::do_range_check( IdealLoopTree *loop, Node_List &old_new ) { case BoolTest::ge: // Convert (I*scale+offset) >= Limit to (I*(-scale)+(-offset)) <= -Limit scale_con = -scale_con; - offset = new (C) SubINode( zero, offset ); + offset = new SubINode( zero, offset ); register_new_node( offset, pre_ctrl ); - limit = new (C) SubINode( zero, limit ); + limit = new SubINode( zero, limit ); register_new_node( limit, pre_ctrl ); // Fall into LE case case BoolTest::le: if (b_test._test != BoolTest::gt) { // Convert X <= Y to X < Y+1 - limit = new (C) AddINode( limit, one ); + limit = new AddINode( limit, one ); register_new_node( limit, pre_ctrl ); } // Fall into LT case @@ -1993,8 +1993,8 @@ void PhaseIdealLoop::do_range_check( IdealLoopTree *loop, Node_List &old_new ) { // Update loop limits if (conditional_rc) { - pre_limit = (stride_con > 0) ? (Node*)new (C) MinINode(pre_limit, orig_limit) - : (Node*)new (C) MaxINode(pre_limit, orig_limit); + pre_limit = (stride_con > 0) ? (Node*)new MinINode(pre_limit, orig_limit) + : (Node*)new MaxINode(pre_limit, orig_limit); register_new_node(pre_limit, pre_ctrl); } _igvn.hash_delete(pre_opaq); @@ -2009,16 +2009,16 @@ void PhaseIdealLoop::do_range_check( IdealLoopTree *loop, Node_List &old_new ) { Node *ctrl = get_ctrl(main_limit); Node *stride = cl->stride(); Node *init = cl->init_trip(); - Node *span = new (C) SubINode(main_limit,init); + Node *span = new SubINode(main_limit,init); register_new_node(span,ctrl); Node *rndup = _igvn.intcon(stride_con + ((stride_con>0)?-1:1)); - Node *add = new (C) AddINode(span,rndup); + Node *add = new AddINode(span,rndup); register_new_node(add,ctrl); - Node *div = new (C) DivINode(0,add,stride); + Node *div = new DivINode(0,add,stride); register_new_node(div,ctrl); - Node *mul = new (C) MulINode(div,stride); + Node *mul = new MulINode(div,stride); register_new_node(mul,ctrl); - Node *newlim = new (C) AddINode(mul,init); + Node *newlim = new AddINode(mul,init); register_new_node(newlim,ctrl); main_limit = newlim; } @@ -2189,7 +2189,7 @@ bool IdealLoopTree::policy_do_remove_empty_loop( PhaseIdealLoop *phase ) { } // Note: the final value after increment should not overflow since // counted loop has limit check predicate. - Node *final = new (phase->C) SubINode( exact_limit, cl->stride() ); + Node *final = new SubINode( exact_limit, cl->stride() ); phase->register_new_node(final,cl->in(LoopNode::EntryControl)); phase->_igvn.replace_node(phi,final); phase->C->set_major_progress(); @@ -2676,20 +2676,20 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) { // Build an expression for the beginning of the copy region Node* index = head->init_trip(); #ifdef _LP64 - index = new (C) ConvI2LNode(index); + index = new ConvI2LNode(index); _igvn.register_new_node_with_optimizer(index); #endif if (shift != NULL) { // byte arrays don't require a shift but others do. - index = new (C) LShiftXNode(index, shift->in(2)); + index = new LShiftXNode(index, shift->in(2)); _igvn.register_new_node_with_optimizer(index); } - index = new (C) AddPNode(base, base, index); + index = new AddPNode(base, base, index); _igvn.register_new_node_with_optimizer(index); - Node* from = new (C) AddPNode(base, index, offset); + Node* from = new AddPNode(base, index, offset); _igvn.register_new_node_with_optimizer(from); // Compute the number of elements to copy - Node* len = new (C) SubINode(head->limit(), head->init_trip()); + Node* len = new SubINode(head->limit(), head->init_trip()); _igvn.register_new_node_with_optimizer(len); BasicType t = store->as_Mem()->memory_type(); @@ -2706,17 +2706,17 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) { // Convert float/double to int/long for fill routines if (t == T_FLOAT) { - store_value = new (C) MoveF2INode(store_value); + store_value = new MoveF2INode(store_value); _igvn.register_new_node_with_optimizer(store_value); } else if (t == T_DOUBLE) { - store_value = new (C) MoveD2LNode(store_value); + store_value = new MoveD2LNode(store_value); _igvn.register_new_node_with_optimizer(store_value); } if (CCallingConventionRequiresIntsAsLongs && // See StubRoutines::select_fill_function for types. FLOAT has been converted to INT. (t == T_FLOAT || t == T_INT || is_subword_type(t))) { - store_value = new (C) ConvI2LNode(store_value); + store_value = new ConvI2LNode(store_value); _igvn.register_new_node_with_optimizer(store_value); } @@ -2724,8 +2724,8 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) { Node* result_ctrl; Node* result_mem; const TypeFunc* call_type = OptoRuntime::array_fill_Type(); - CallLeafNode *call = new (C) CallLeafNoFPNode(call_type, fill, - fill_name, TypeAryPtr::get_array_body_type(t)); + CallLeafNode *call = new CallLeafNoFPNode(call_type, fill, + fill_name, TypeAryPtr::get_array_body_type(t)); uint cnt = 0; call->init_req(TypeFunc::Parms + cnt++, from); call->init_req(TypeFunc::Parms + cnt++, store_value); @@ -2733,7 +2733,7 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) { call->init_req(TypeFunc::Parms + cnt++, C->top()); } #ifdef _LP64 - len = new (C) ConvI2LNode(len); + len = new ConvI2LNode(len); _igvn.register_new_node_with_optimizer(len); #endif call->init_req(TypeFunc::Parms + cnt++, len); @@ -2746,9 +2746,9 @@ bool PhaseIdealLoop::intrinsify_fill(IdealLoopTree* lpt) { call->init_req(TypeFunc::ReturnAdr, C->start()->proj_out(TypeFunc::ReturnAdr)); call->init_req(TypeFunc::FramePtr, C->start()->proj_out(TypeFunc::FramePtr)); _igvn.register_new_node_with_optimizer(call); - result_ctrl = new (C) ProjNode(call,TypeFunc::Control); + result_ctrl = new ProjNode(call,TypeFunc::Control); _igvn.register_new_node_with_optimizer(result_ctrl); - result_mem = new (C) ProjNode(call,TypeFunc::Memory); + result_mem = new ProjNode(call,TypeFunc::Memory); _igvn.register_new_node_with_optimizer(result_mem); /* Disable following optimization until proper fix (add missing checks). diff --git a/hotspot/src/share/vm/opto/loopUnswitch.cpp b/hotspot/src/share/vm/opto/loopUnswitch.cpp index 06e17664efe..43f2008f2aa 100644 --- a/hotspot/src/share/vm/opto/loopUnswitch.cpp +++ b/hotspot/src/share/vm/opto/loopUnswitch.cpp @@ -225,15 +225,15 @@ ProjNode* PhaseIdealLoop::create_slow_version_of_loop(IdealLoopTree *loop, Node *cont = _igvn.intcon(1); set_ctrl(cont, C->root()); - Node* opq = new (C) Opaque1Node(C, cont); + Node* opq = new Opaque1Node(C, cont); register_node(opq, outer_loop, entry, dom_depth(entry)); - Node *bol = new (C) Conv2BNode(opq); + Node *bol = new Conv2BNode(opq); register_node(bol, outer_loop, entry, dom_depth(entry)); - IfNode* iff = new (C) IfNode(entry, bol, PROB_MAX, COUNT_UNKNOWN); + IfNode* iff = new IfNode(entry, bol, PROB_MAX, COUNT_UNKNOWN); register_node(iff, outer_loop, entry, dom_depth(entry)); - ProjNode* iffast = new (C) IfTrueNode(iff); + ProjNode* iffast = new IfTrueNode(iff); register_node(iffast, outer_loop, iff, dom_depth(iff)); - ProjNode* ifslow = new (C) IfFalseNode(iff); + ProjNode* ifslow = new IfFalseNode(iff); register_node(ifslow, outer_loop, iff, dom_depth(iff)); // Clone the loop body. The clone becomes the fast loop. The diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp index f11583a25b2..5ee44d084bd 100644 --- a/hotspot/src/share/vm/opto/loopnode.cpp +++ b/hotspot/src/share/vm/opto/loopnode.cpp @@ -443,7 +443,7 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { assert(x->Opcode() == Op_Loop, "regular loops only"); C->print_method(PHASE_BEFORE_CLOOPS, 3); - Node *hook = new (C) Node(6); + Node *hook = new Node(6); if (LoopLimitCheck) { @@ -506,11 +506,11 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { Node* bol; if (stride_con > 0) { - cmp_limit = new (C) CmpINode(limit, _igvn.intcon(max_jint - stride_m)); - bol = new (C) BoolNode(cmp_limit, BoolTest::le); + cmp_limit = new CmpINode(limit, _igvn.intcon(max_jint - stride_m)); + bol = new BoolNode(cmp_limit, BoolTest::le); } else { - cmp_limit = new (C) CmpINode(limit, _igvn.intcon(min_jint - stride_m)); - bol = new (C) BoolNode(cmp_limit, BoolTest::ge); + cmp_limit = new CmpINode(limit, _igvn.intcon(min_jint - stride_m)); + bol = new BoolNode(cmp_limit, BoolTest::ge); } cmp_limit = _igvn.register_new_node_with_optimizer(cmp_limit); bol = _igvn.register_new_node_with_optimizer(bol); @@ -547,7 +547,7 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { // is converted to // i = init; do {} while(++i < limit+1); // - limit = gvn->transform(new (C) AddINode(limit, stride)); + limit = gvn->transform(new AddINode(limit, stride)); } // Now we need to canonicalize loop condition. @@ -566,7 +566,7 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { // we can convert 'i <= limit' to 'i < limit+1' since stride != 0. // Node* one = (stride_con > 0) ? gvn->intcon( 1) : gvn->intcon(-1); - limit = gvn->transform(new (C) AddINode(limit, one)); + limit = gvn->transform(new AddINode(limit, one)); if (bt == BoolTest::le) bt = BoolTest::lt; else if (bt == BoolTest::ge) @@ -582,7 +582,7 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { // can directly point to the phi; in this case adjust the compare so that // it points to the incr by adjusting the limit. if (cmp->in(1) == phi || cmp->in(2) == phi) - limit = gvn->transform(new (C) AddINode(limit,stride)); + limit = gvn->transform(new AddINode(limit,stride)); // trip-count for +-tive stride should be: (limit - init_trip + stride - 1)/stride. // Final value for iterator should be: trip_count * stride + init_trip. @@ -595,16 +595,16 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { ShouldNotReachHere(); case BoolTest::ne: // Ahh, the case we desire if (stride_con == 1) - trip_count = gvn->transform(new (C) SubINode(limit,init_trip)); + trip_count = gvn->transform(new SubINode(limit,init_trip)); else if (stride_con == -1) - trip_count = gvn->transform(new (C) SubINode(init_trip,limit)); + trip_count = gvn->transform(new SubINode(init_trip,limit)); else ShouldNotReachHere(); set_subtree_ctrl(trip_count); //_loop.map(trip_count->_idx,loop(limit)); break; case BoolTest::le: // Maybe convert to '<' case - limit = gvn->transform(new (C) AddINode(limit,one_p)); + limit = gvn->transform(new AddINode(limit,one_p)); set_subtree_ctrl( limit ); hook->init_req(4, limit); @@ -615,26 +615,26 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { case BoolTest::lt: { // Maybe convert to '!=' case if (stride_con < 0) // Count down loop rolls through MAXINT ShouldNotReachHere(); - Node *range = gvn->transform(new (C) SubINode(limit,init_trip)); + Node *range = gvn->transform(new SubINode(limit,init_trip)); set_subtree_ctrl( range ); hook->init_req(0, range); - Node *bias = gvn->transform(new (C) AddINode(range,stride)); + Node *bias = gvn->transform(new AddINode(range,stride)); set_subtree_ctrl( bias ); hook->init_req(1, bias); - Node *bias1 = gvn->transform(new (C) AddINode(bias,one_m)); + Node *bias1 = gvn->transform(new AddINode(bias,one_m)); set_subtree_ctrl( bias1 ); hook->init_req(2, bias1); - trip_count = gvn->transform(new (C) DivINode(0,bias1,stride)); + trip_count = gvn->transform(new DivINode(0,bias1,stride)); set_subtree_ctrl( trip_count ); hook->init_req(3, trip_count); break; } case BoolTest::ge: // Maybe convert to '>' case - limit = gvn->transform(new (C) AddINode(limit,one_m)); + limit = gvn->transform(new AddINode(limit,one_m)); set_subtree_ctrl( limit ); hook->init_req(4 ,limit); @@ -645,30 +645,30 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { case BoolTest::gt: { // Maybe convert to '!=' case if (stride_con > 0) // count up loop rolls through MININT ShouldNotReachHere(); - Node *range = gvn->transform(new (C) SubINode(limit,init_trip)); + Node *range = gvn->transform(new SubINode(limit,init_trip)); set_subtree_ctrl( range ); hook->init_req(0, range); - Node *bias = gvn->transform(new (C) AddINode(range,stride)); + Node *bias = gvn->transform(new AddINode(range,stride)); set_subtree_ctrl( bias ); hook->init_req(1, bias); - Node *bias1 = gvn->transform(new (C) AddINode(bias,one_p)); + Node *bias1 = gvn->transform(new AddINode(bias,one_p)); set_subtree_ctrl( bias1 ); hook->init_req(2, bias1); - trip_count = gvn->transform(new (C) DivINode(0,bias1,stride)); + trip_count = gvn->transform(new DivINode(0,bias1,stride)); set_subtree_ctrl( trip_count ); hook->init_req(3, trip_count); break; } } // switch( bt ) - Node *span = gvn->transform(new (C) MulINode(trip_count,stride)); + Node *span = gvn->transform(new MulINode(trip_count,stride)); set_subtree_ctrl( span ); hook->init_req(5, span); - limit = gvn->transform(new (C) AddINode(span,init_trip)); + limit = gvn->transform(new AddINode(span,init_trip)); set_subtree_ctrl( limit ); } // LoopLimitCheck @@ -717,7 +717,7 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { set_ctrl(test, iff->in(0)); // Replace the old IfNode with a new LoopEndNode - Node *lex = _igvn.register_new_node_with_optimizer(new (C) CountedLoopEndNode( iff->in(0), test, cl_prob, iff->as_If()->_fcnt )); + Node *lex = _igvn.register_new_node_with_optimizer(new CountedLoopEndNode( iff->in(0), test, cl_prob, iff->as_If()->_fcnt )); IfNode *le = lex->as_If(); uint dd = dom_depth(iff); set_idom(le, le->in(0), dd); // Update dominance for loop exit @@ -728,8 +728,8 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { // Need to swap loop-exit and loop-back control? if (iftrue_op == Op_IfFalse) { - Node *ift2=_igvn.register_new_node_with_optimizer(new (C) IfTrueNode (le)); - Node *iff2=_igvn.register_new_node_with_optimizer(new (C) IfFalseNode(le)); + Node *ift2=_igvn.register_new_node_with_optimizer(new IfTrueNode (le)); + Node *iff2=_igvn.register_new_node_with_optimizer(new IfFalseNode(le)); loop->_tail = back_control = ift2; set_loop(ift2, loop); @@ -755,7 +755,7 @@ bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) { lazy_replace( iff, le ); // fix 'get_ctrl' // Now setup a new CountedLoopNode to replace the existing LoopNode - CountedLoopNode *l = new (C) CountedLoopNode(init_control, back_control); + CountedLoopNode *l = new CountedLoopNode(init_control, back_control); l->set_unswitch_count(x->as_Loop()->unswitch_count()); // Preserve // The following assert is approximately true, and defines the intention // of can_be_counted_loop. It fails, however, because phase->type @@ -829,7 +829,7 @@ Node* PhaseIdealLoop::exact_limit( IdealLoopTree *loop ) { limit = _igvn.intcon(final_int); } else { // Create new LoopLimit node to get exact limit (final iv value). - limit = new (C) LoopLimitNode(C, cl->init_trip(), cl->limit(), cl->stride()); + limit = new LoopLimitNode(C, cl->init_trip(), cl->limit(), cl->stride()); register_new_node(limit, cl->in(LoopNode::EntryControl)); } assert(limit != NULL, "sanity"); @@ -946,11 +946,11 @@ Node *LoopLimitNode::Ideal(PhaseGVN *phase, bool can_reshape) { if (range <= max) { // Convert to integer expression if it is not overflow. Node* stride_m = phase->intcon(stride_con - (stride_con > 0 ? 1 : -1)); - Node *range = phase->transform(new (phase->C) SubINode(in(Limit), in(Init))); - Node *bias = phase->transform(new (phase->C) AddINode(range, stride_m)); - Node *trip = phase->transform(new (phase->C) DivINode(0, bias, in(Stride))); - Node *span = phase->transform(new (phase->C) MulINode(trip, in(Stride))); - return new (phase->C) AddINode(span, in(Init)); // exact limit + Node *range = phase->transform(new SubINode(in(Limit), in(Init))); + Node *bias = phase->transform(new AddINode(range, stride_m)); + Node *trip = phase->transform(new DivINode(0, bias, in(Stride))); + Node *span = phase->transform(new MulINode(trip, in(Stride))); + return new AddINode(span, in(Init)); // exact limit } if (is_power_of_2(stride_p) || // divisor is 2^n @@ -958,13 +958,13 @@ Node *LoopLimitNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Convert to long expression to avoid integer overflow // and let igvn optimizer convert this division. // - Node* init = phase->transform( new (phase->C) ConvI2LNode(in(Init))); - Node* limit = phase->transform( new (phase->C) ConvI2LNode(in(Limit))); + Node* init = phase->transform( new ConvI2LNode(in(Init))); + Node* limit = phase->transform( new ConvI2LNode(in(Limit))); Node* stride = phase->longcon(stride_con); Node* stride_m = phase->longcon(stride_con - (stride_con > 0 ? 1 : -1)); - Node *range = phase->transform(new (phase->C) SubLNode(limit, init)); - Node *bias = phase->transform(new (phase->C) AddLNode(range, stride_m)); + Node *range = phase->transform(new SubLNode(limit, init)); + Node *bias = phase->transform(new AddLNode(range, stride_m)); Node *span; if (stride_con > 0 && is_power_of_2(stride_p)) { // bias >= 0 if stride >0, so if stride is 2^n we can use &(-stride) @@ -975,14 +975,14 @@ Node *LoopLimitNode::Ideal(PhaseGVN *phase, bool can_reshape) { // only RCE predicate where exact limit is used and the predicate // will simply fail forcing recompilation. Node* neg_stride = phase->longcon(-stride_con); - span = phase->transform(new (phase->C) AndLNode(bias, neg_stride)); + span = phase->transform(new AndLNode(bias, neg_stride)); } else { - Node *trip = phase->transform(new (phase->C) DivLNode(0, bias, stride)); - span = phase->transform(new (phase->C) MulLNode(trip, stride)); + Node *trip = phase->transform(new DivLNode(0, bias, stride)); + span = phase->transform(new MulLNode(trip, stride)); } // Convert back to int - Node *span_int = phase->transform(new (phase->C) ConvL2INode(span)); - return new (phase->C) AddINode(span_int, in(Init)); // exact limit + Node *span_int = phase->transform(new ConvL2INode(span)); + return new AddINode(span_int, in(Init)); // exact limit } return NULL; // No progress @@ -1188,7 +1188,7 @@ void IdealLoopTree::split_fall_in( PhaseIdealLoop *phase, int fall_in_cnt ) { uint i; // Make a new RegionNode to be the landing pad. - Node *landing_pad = new (phase->C) RegionNode( fall_in_cnt+1 ); + Node *landing_pad = new RegionNode( fall_in_cnt+1 ); phase->set_loop(landing_pad,_parent); // Gather all the fall-in control paths into the landing pad uint icnt = fall_in_cnt; @@ -1274,7 +1274,7 @@ void IdealLoopTree::split_outer_loop( PhaseIdealLoop *phase ) { // Make a LoopNode for the outermost loop. Node *ctl = _head->in(LoopNode::EntryControl); - Node *outer = new (phase->C) LoopNode( ctl, _head->in(outer_idx) ); + Node *outer = new LoopNode( ctl, _head->in(outer_idx) ); outer = igvn.register_new_node_with_optimizer(outer, _head); phase->set_created_loop_node(); @@ -1388,7 +1388,7 @@ void IdealLoopTree::merge_many_backedges( PhaseIdealLoop *phase ) { Node *hot_tail = NULL; // Make a Region for the merge point - Node *r = new (phase->C) RegionNode(1); + Node *r = new RegionNode(1); for( i = 2; i < _head->req(); i++ ) { if( i != hot_idx ) r->add_req( _head->in(i) ); @@ -1407,7 +1407,7 @@ void IdealLoopTree::merge_many_backedges( PhaseIdealLoop *phase ) { PhiNode* n = out->as_Phi(); igvn.hash_delete(n); // Delete from hash before hacking edges Node *hot_phi = NULL; - Node *phi = new (phase->C) PhiNode(r, n->type(), n->adr_type()); + Node *phi = new PhiNode(r, n->type(), n->adr_type()); // Check all inputs for the ones to peel out uint j = 1; for( uint i = 2; i < n->req(); i++ ) { @@ -1529,7 +1529,7 @@ bool IdealLoopTree::beautify_loops( PhaseIdealLoop *phase ) { } else if (!_head->is_Loop() && !_irreducible) { // Make a new LoopNode to replace the old loop head - Node *l = new (phase->C) LoopNode( _head->in(1), _head->in(2) ); + Node *l = new LoopNode( _head->in(1), _head->in(2) ); l = igvn.register_new_node_with_optimizer(l, _head); phase->set_created_loop_node(); // Go ahead and replace _head @@ -1771,16 +1771,16 @@ void PhaseIdealLoop::replace_parallel_iv(IdealLoopTree *loop) { // It is scaled by the 'ratio_con'. Node* ratio = _igvn.intcon(ratio_con); set_ctrl(ratio, C->root()); - Node* ratio_init = new (C) MulINode(init, ratio); + Node* ratio_init = new MulINode(init, ratio); _igvn.register_new_node_with_optimizer(ratio_init, init); set_early_ctrl(ratio_init); - Node* diff = new (C) SubINode(init2, ratio_init); + Node* diff = new SubINode(init2, ratio_init); _igvn.register_new_node_with_optimizer(diff, init2); set_early_ctrl(diff); - Node* ratio_idx = new (C) MulINode(phi, ratio); + Node* ratio_idx = new MulINode(phi, ratio); _igvn.register_new_node_with_optimizer(ratio_idx, phi); set_ctrl(ratio_idx, cl); - Node* add = new (C) AddINode(ratio_idx, diff); + Node* add = new AddINode(ratio_idx, diff); _igvn.register_new_node_with_optimizer(add); set_ctrl(add, cl); _igvn.replace_node( phi2, add ); @@ -2888,10 +2888,10 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) { if (!_verify_only) { // Insert the NeverBranch between 'm' and it's control user. - NeverBranchNode *iff = new (C) NeverBranchNode( m ); + NeverBranchNode *iff = new NeverBranchNode( m ); _igvn.register_new_node_with_optimizer(iff); set_loop(iff, l); - Node *if_t = new (C) CProjNode( iff, 0 ); + Node *if_t = new CProjNode( iff, 0 ); _igvn.register_new_node_with_optimizer(if_t); set_loop(if_t, l); @@ -2907,16 +2907,16 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) { cfg->set_req( k, if_t ); // Now point to NeverBranch // Now create the never-taken loop exit - Node *if_f = new (C) CProjNode( iff, 1 ); + Node *if_f = new CProjNode( iff, 1 ); _igvn.register_new_node_with_optimizer(if_f); set_loop(if_f, l); // Find frame ptr for Halt. Relies on the optimizer // V-N'ing. Easier and quicker than searching through // the program structure. - Node *frame = new (C) ParmNode( C->start(), TypeFunc::FramePtr ); + Node *frame = new ParmNode( C->start(), TypeFunc::FramePtr ); _igvn.register_new_node_with_optimizer(frame); // Halt & Catch Fire - Node *halt = new (C) HaltNode( if_f, frame ); + Node *halt = new HaltNode( if_f, frame ); _igvn.register_new_node_with_optimizer(halt); set_loop(halt, l); C->root()->add_req(halt); diff --git a/hotspot/src/share/vm/opto/loopopts.cpp b/hotspot/src/share/vm/opto/loopopts.cpp index 67a6d703cc0..e25a6b0762e 100644 --- a/hotspot/src/share/vm/opto/loopopts.cpp +++ b/hotspot/src/share/vm/opto/loopopts.cpp @@ -56,7 +56,7 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) { int iid = t_oop->instance_id(); int index = C->get_alias_index(t_oop); int offset = t_oop->offset(); - phi = new (C) PhiNode(region, type, NULL, iid, index, offset); + phi = new PhiNode(region, type, NULL, iid, index, offset); } else { phi = PhiNode::make_blank(region, n); } @@ -363,9 +363,9 @@ Node *PhaseIdealLoop::remix_address_expressions( Node *n ) { _igvn.type( add->in(1) ) != TypeInt::ZERO ) { Node *zero = _igvn.intcon(0); set_ctrl(zero, C->root()); - Node *neg = new (C) SubINode( _igvn.intcon(0), add->in(2) ); + Node *neg = new SubINode( _igvn.intcon(0), add->in(2) ); register_new_node( neg, get_ctrl(add->in(2) ) ); - add = new (C) AddINode( add->in(1), neg ); + add = new AddINode( add->in(1), neg ); register_new_node( add, add_ctrl ); } if( add->Opcode() != Op_AddI ) return NULL; @@ -391,14 +391,14 @@ Node *PhaseIdealLoop::remix_address_expressions( Node *n ) { return NULL; // No invariant part of the add? // Yes! Reshape address expression! - Node *inv_scale = new (C) LShiftINode( add_invar, scale ); + Node *inv_scale = new LShiftINode( add_invar, scale ); Node *inv_scale_ctrl = dom_depth(add_invar_ctrl) > dom_depth(scale_ctrl) ? add_invar_ctrl : scale_ctrl; register_new_node( inv_scale, inv_scale_ctrl ); - Node *var_scale = new (C) LShiftINode( add_var, scale ); + Node *var_scale = new LShiftINode( add_var, scale ); register_new_node( var_scale, n_ctrl ); - Node *var_add = new (C) AddINode( var_scale, inv_scale ); + Node *var_add = new AddINode( var_scale, inv_scale ); register_new_node( var_add, n_ctrl ); _igvn.replace_node( n, var_add ); return var_add; @@ -430,10 +430,10 @@ Node *PhaseIdealLoop::remix_address_expressions( Node *n ) { IdealLoopTree *n23_loop = get_loop( n23_ctrl ); if( n22loop != n_loop && n22loop->is_member(n_loop) && n23_loop == n_loop ) { - Node *add1 = new (C) AddPNode( n->in(1), n->in(2)->in(2), n->in(3) ); + Node *add1 = new AddPNode( n->in(1), n->in(2)->in(2), n->in(3) ); // Stuff new AddP in the loop preheader register_new_node( add1, n_loop->_head->in(LoopNode::EntryControl) ); - Node *add2 = new (C) AddPNode( n->in(1), add1, n->in(2)->in(3) ); + Node *add2 = new AddPNode( n->in(1), add1, n->in(2)->in(3) ); register_new_node( add2, n_ctrl ); _igvn.replace_node( n, add2 ); return add2; @@ -451,10 +451,10 @@ Node *PhaseIdealLoop::remix_address_expressions( Node *n ) { Node *tmp = V; V = I; I = tmp; } if( !is_member(n_loop,get_ctrl(I)) ) { - Node *add1 = new (C) AddPNode( n->in(1), n->in(2), I ); + Node *add1 = new AddPNode( n->in(1), n->in(2), I ); // Stuff new AddP in the loop preheader register_new_node( add1, n_loop->_head->in(LoopNode::EntryControl) ); - Node *add2 = new (C) AddPNode( n->in(1), add1, V ); + Node *add2 = new AddPNode( n->in(1), add1, V ); register_new_node( add2, n_ctrl ); _igvn.replace_node( n, add2 ); return add2; @@ -1104,8 +1104,8 @@ BoolNode *PhaseIdealLoop::clone_iff( PhiNode *phi, IdealLoopTree *loop ) { Node *sample_cmp = sample_bool->in(1); // Make Phis to merge the Cmp's inputs. - PhiNode *phi1 = new (C) PhiNode( phi->in(0), Type::TOP ); - PhiNode *phi2 = new (C) PhiNode( phi->in(0), Type::TOP ); + PhiNode *phi1 = new PhiNode( phi->in(0), Type::TOP ); + PhiNode *phi2 = new PhiNode( phi->in(0), Type::TOP ); for( i = 1; i < phi->req(); i++ ) { Node *n1 = phi->in(i)->in(1)->in(1); Node *n2 = phi->in(i)->in(1)->in(2); @@ -1172,8 +1172,8 @@ CmpNode *PhaseIdealLoop::clone_bool( PhiNode *phi, IdealLoopTree *loop ) { Node *sample_cmp = phi->in(1); // Make Phis to merge the Cmp's inputs. - PhiNode *phi1 = new (C) PhiNode( phi->in(0), Type::TOP ); - PhiNode *phi2 = new (C) PhiNode( phi->in(0), Type::TOP ); + PhiNode *phi1 = new PhiNode( phi->in(0), Type::TOP ); + PhiNode *phi2 = new PhiNode( phi->in(0), Type::TOP ); for( uint j = 1; j < phi->req(); j++ ) { Node *cmp_top = phi->in(j); // Inputs are all Cmp or TOP Node *n1, *n2; @@ -1337,7 +1337,7 @@ void PhaseIdealLoop::clone_loop( IdealLoopTree *loop, Node_List &old_new, int dd // We need a Region to merge the exit from the peeled body and the // exit from the old loop body. - RegionNode *r = new (C) RegionNode(3); + RegionNode *r = new RegionNode(3); // Map the old use to the new merge point old_new.map( use->_idx, r ); uint dd_r = MIN2(dom_depth(newuse),dom_depth(use)); @@ -1403,7 +1403,8 @@ void PhaseIdealLoop::clone_loop( IdealLoopTree *loop, Node_List &old_new, int dd // loop. Happens if people set a loop-exit flag; then test the flag // in the loop to break the loop, then test is again outside of the // loop to determine which way the loop exited. - if( use->is_If() || use->is_CMove() ) { + // Loop predicate If node connects to Bool node through Opaque1 node. + if (use->is_If() || use->is_CMove() || C->is_predicate_opaq(use)) { // Since this code is highly unlikely, we lazily build the worklist // of such Nodes to go split. if( !split_if_set ) @@ -1684,13 +1685,13 @@ ProjNode* PhaseIdealLoop::insert_if_before_proj(Node* left, bool Signed, BoolTes ProjNode* proj2 = proj_clone(proj, iff); register_node(proj2, loop, iff, ddepth); - Node* cmp = Signed ? (Node*) new (C)CmpINode(left, right) : (Node*) new (C)CmpUNode(left, right); + Node* cmp = Signed ? (Node*) new CmpINode(left, right) : (Node*) new CmpUNode(left, right); register_node(cmp, loop, proj2, ddepth); - BoolNode* bol = new (C)BoolNode(cmp, relop); + BoolNode* bol = new BoolNode(cmp, relop); register_node(bol, loop, proj2, ddepth); - IfNode* new_if = new (C)IfNode(proj2, bol, iff->_prob, iff->_fcnt); + IfNode* new_if = new IfNode(proj2, bol, iff->_prob, iff->_fcnt); register_node(new_if, loop, proj2, ddepth); proj->set_req(0, new_if); // reattach @@ -1742,11 +1743,11 @@ RegionNode* PhaseIdealLoop::insert_region_before_proj(ProjNode* proj) { ProjNode* proj2 = proj_clone(proj, iff); register_node(proj2, loop, iff, ddepth); - RegionNode* reg = new (C)RegionNode(2); + RegionNode* reg = new RegionNode(2); reg->set_req(1, proj2); register_node(reg, loop, iff, ddepth); - IfNode* dum_if = new (C)IfNode(reg, short_circuit_if(NULL, proj), iff->_prob, iff->_fcnt); + IfNode* dum_if = new IfNode(reg, short_circuit_if(NULL, proj), iff->_prob, iff->_fcnt); register_node(dum_if, loop, reg, ddepth); proj->set_req(0, dum_if); // reattach @@ -2569,7 +2570,7 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) { // Create new loop head for new phis and to hang // the nodes being moved (sinked) from the peel region. - LoopNode* new_head = new (C) LoopNode(last_peel, last_peel); + LoopNode* new_head = new LoopNode(last_peel, last_peel); new_head->set_unswitch_count(head->unswitch_count()); // Preserve _igvn.register_new_node_with_optimizer(new_head); assert(first_not_peeled->in(0) == last_peel, "last_peel <- first_not_peeled"); @@ -2769,12 +2770,12 @@ void PhaseIdealLoop::reorg_offsets(IdealLoopTree *loop) { if (dom_lca(exit, u_ctrl) != exit) continue; // Hit! Refactor use to use the post-incremented tripcounter. // Compute a post-increment tripcounter. - Node *opaq = new (C) Opaque2Node( C, cle->incr() ); - register_new_node( opaq, u_ctrl ); + Node *opaq = new Opaque2Node( C, cle->incr() ); + register_new_node(opaq, exit); Node *neg_stride = _igvn.intcon(-cle->stride_con()); set_ctrl(neg_stride, C->root()); - Node *post = new (C) AddINode( opaq, neg_stride); - register_new_node( post, u_ctrl ); + Node *post = new AddINode( opaq, neg_stride); + register_new_node(post, exit); _igvn.rehash_node_delayed(use); for (uint j = 1; j < use->req(); j++) { if (use->in(j) == phi) diff --git a/hotspot/src/share/vm/opto/machnode.hpp b/hotspot/src/share/vm/opto/machnode.hpp index 8d42093ac31..1e2f22e9ef7 100644 --- a/hotspot/src/share/vm/opto/machnode.hpp +++ b/hotspot/src/share/vm/opto/machnode.hpp @@ -60,7 +60,10 @@ class State; class MachOper : public ResourceObj { public: // Allocate right next to the MachNodes in the same arena - void *operator new( size_t x, Compile* C ) throw() { return C->node_arena()->Amalloc_D(x); } + void *operator new(size_t x) throw() { + Compile* C = Compile::current(); + return C->node_arena()->Amalloc_D(x); + } // Opcode virtual uint opcode() const = 0; diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp index afaa4e858d4..5b1f4397642 100644 --- a/hotspot/src/share/vm/opto/macro.cpp +++ b/hotspot/src/share/vm/opto/macro.cpp @@ -108,20 +108,20 @@ void PhaseMacroExpand::copy_call_debug_info(CallNode *oldcall, CallNode * newcal Node* PhaseMacroExpand::opt_bits_test(Node* ctrl, Node* region, int edge, Node* word, int mask, int bits, bool return_fast_path) { Node* cmp; if (mask != 0) { - Node* and_node = transform_later(new (C) AndXNode(word, MakeConX(mask))); - cmp = transform_later(new (C) CmpXNode(and_node, MakeConX(bits))); + Node* and_node = transform_later(new AndXNode(word, MakeConX(mask))); + cmp = transform_later(new CmpXNode(and_node, MakeConX(bits))); } else { cmp = word; } - Node* bol = transform_later(new (C) BoolNode(cmp, BoolTest::ne)); - IfNode* iff = new (C) IfNode( ctrl, bol, PROB_MIN, COUNT_UNKNOWN ); + Node* bol = transform_later(new BoolNode(cmp, BoolTest::ne)); + IfNode* iff = new IfNode( ctrl, bol, PROB_MIN, COUNT_UNKNOWN ); transform_later(iff); // Fast path taken. - Node *fast_taken = transform_later( new (C) IfFalseNode(iff) ); + Node *fast_taken = transform_later(new IfFalseNode(iff)); // Fast path not-taken, i.e. slow path - Node *slow_taken = transform_later( new (C) IfTrueNode(iff) ); + Node *slow_taken = transform_later(new IfTrueNode(iff)); if (return_fast_path) { region->init_req(edge, slow_taken); // Capture slow-control @@ -147,8 +147,8 @@ CallNode* PhaseMacroExpand::make_slow_call(CallNode *oldcall, const TypeFunc* sl // Slow-path call CallNode *call = leaf_name - ? (CallNode*)new (C) CallLeafNode ( slow_call_type, slow_call, leaf_name, TypeRawPtr::BOTTOM ) - : (CallNode*)new (C) CallStaticJavaNode( slow_call_type, slow_call, OptoRuntime::stub_name(slow_call), oldcall->jvms()->bci(), TypeRawPtr::BOTTOM ); + ? (CallNode*)new CallLeafNode ( slow_call_type, slow_call, leaf_name, TypeRawPtr::BOTTOM ) + : (CallNode*)new CallStaticJavaNode( slow_call_type, slow_call, OptoRuntime::stub_name(slow_call), oldcall->jvms()->bci(), TypeRawPtr::BOTTOM ); // Slow path call has no side-effects, uses few values copy_predefined_input_for_runtime_call(slow_path, oldcall, call ); @@ -423,7 +423,7 @@ Node *PhaseMacroExpand::value_from_mem_phi(Node *mem, BasicType ft, const Type * GrowableArray values(length, length, NULL, false); // create a new Phi for the value - PhiNode *phi = new (C) PhiNode(mem->in(0), phi_type, NULL, instance_id, alias_idx, offset); + PhiNode *phi = new PhiNode(mem->in(0), phi_type, NULL, instance_id, alias_idx, offset); transform_later(phi); value_phis->push(phi, mem->_idx); @@ -735,7 +735,7 @@ bool PhaseMacroExpand::scalar_replacement(AllocateNode *alloc, GrowableArray req() - sfpt->jvms()->scloff()); - SafePointScalarObjectNode* sobj = new (C) SafePointScalarObjectNode(res_type, + SafePointScalarObjectNode* sobj = new SafePointScalarObjectNode(res_type, #ifdef ASSERT alloc, #endif @@ -843,7 +843,7 @@ bool PhaseMacroExpand::scalar_replacement(AllocateNode *alloc, GrowableArray is_EncodeP()) { field_val = field_val->in(1); } else { - field_val = transform_later(new (C) DecodeNNode(field_val, field_val->get_ptr_type())); + field_val = transform_later(new DecodeNNode(field_val, field_val->get_ptr_type())); } } sfpt->add_req(field_val); @@ -1069,7 +1069,7 @@ bool PhaseMacroExpand::eliminate_boxing_node(CallStaticJavaNode *boxing) { //---------------------------set_eden_pointers------------------------- void PhaseMacroExpand::set_eden_pointers(Node* &eden_top_adr, Node* &eden_end_adr) { if (UseTLAB) { // Private allocation: load from TLS - Node* thread = transform_later(new (C) ThreadLocalNode()); + Node* thread = transform_later(new ThreadLocalNode()); int tlab_top_offset = in_bytes(JavaThread::tlab_top_offset()); int tlab_end_offset = in_bytes(JavaThread::tlab_end_offset()); eden_top_adr = basic_plus_adr(top()/*not oop*/, thread, tlab_top_offset); @@ -1205,18 +1205,18 @@ void PhaseMacroExpand::expand_allocate_common( assert (initial_slow_test == NULL || !always_slow, "arguments must be consistent"); // generate the initial test if necessary if (initial_slow_test != NULL ) { - slow_region = new (C) RegionNode(3); + slow_region = new RegionNode(3); // Now make the initial failure test. Usually a too-big test but // might be a TRUE for finalizers or a fancy class check for // newInstance0. - IfNode *toobig_iff = new (C) IfNode(ctrl, initial_slow_test, PROB_MIN, COUNT_UNKNOWN); + IfNode *toobig_iff = new IfNode(ctrl, initial_slow_test, PROB_MIN, COUNT_UNKNOWN); transform_later(toobig_iff); // Plug the failing-too-big test into the slow-path region - Node *toobig_true = new (C) IfTrueNode( toobig_iff ); + Node *toobig_true = new IfTrueNode( toobig_iff ); transform_later(toobig_true); slow_region ->init_req( too_big_or_final_path, toobig_true ); - toobig_false = new (C) IfFalseNode( toobig_iff ); + toobig_false = new IfFalseNode( toobig_iff ); transform_later(toobig_false); } else { // No initial test, just fall into next case toobig_false = ctrl; @@ -1249,10 +1249,10 @@ void PhaseMacroExpand::expand_allocate_common( Node *eden_end = make_load(ctrl, mem, eden_end_adr, 0, TypeRawPtr::BOTTOM, T_ADDRESS); // allocate the Region and Phi nodes for the result - result_region = new (C) RegionNode(3); - result_phi_rawmem = new (C) PhiNode(result_region, Type::MEMORY, TypeRawPtr::BOTTOM); - result_phi_rawoop = new (C) PhiNode(result_region, TypeRawPtr::BOTTOM); - result_phi_i_o = new (C) PhiNode(result_region, Type::ABIO); // I/O is used for Prefetch + result_region = new RegionNode(3); + result_phi_rawmem = new PhiNode(result_region, Type::MEMORY, TypeRawPtr::BOTTOM); + result_phi_rawoop = new PhiNode(result_region, TypeRawPtr::BOTTOM); + result_phi_i_o = new PhiNode(result_region, Type::ABIO); // I/O is used for Prefetch // We need a Region for the loop-back contended case. enum { fall_in_path = 1, contended_loopback_path = 2 }; @@ -1262,8 +1262,8 @@ void PhaseMacroExpand::expand_allocate_common( contended_region = toobig_false; contended_phi_rawmem = mem; } else { - contended_region = new (C) RegionNode(3); - contended_phi_rawmem = new (C) PhiNode(contended_region, Type::MEMORY, TypeRawPtr::BOTTOM); + contended_region = new RegionNode(3); + contended_phi_rawmem = new PhiNode(contended_region, Type::MEMORY, TypeRawPtr::BOTTOM); // Now handle the passing-too-big test. We fall into the contended // loop-back merge point. contended_region ->init_req(fall_in_path, toobig_false); @@ -1275,23 +1275,23 @@ void PhaseMacroExpand::expand_allocate_common( // Load(-locked) the heap top. // See note above concerning the control input when using a TLAB Node *old_eden_top = UseTLAB - ? new (C) LoadPNode (ctrl, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM, MemNode::unordered) - : new (C) LoadPLockedNode(contended_region, contended_phi_rawmem, eden_top_adr, MemNode::acquire); + ? new LoadPNode (ctrl, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM, MemNode::unordered) + : new LoadPLockedNode(contended_region, contended_phi_rawmem, eden_top_adr, MemNode::acquire); transform_later(old_eden_top); // Add to heap top to get a new heap top - Node *new_eden_top = new (C) AddPNode(top(), old_eden_top, size_in_bytes); + Node *new_eden_top = new AddPNode(top(), old_eden_top, size_in_bytes); transform_later(new_eden_top); // Check for needing a GC; compare against heap end - Node *needgc_cmp = new (C) CmpPNode(new_eden_top, eden_end); + Node *needgc_cmp = new CmpPNode(new_eden_top, eden_end); transform_later(needgc_cmp); - Node *needgc_bol = new (C) BoolNode(needgc_cmp, BoolTest::ge); + Node *needgc_bol = new BoolNode(needgc_cmp, BoolTest::ge); transform_later(needgc_bol); - IfNode *needgc_iff = new (C) IfNode(contended_region, needgc_bol, PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN); + IfNode *needgc_iff = new IfNode(contended_region, needgc_bol, PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN); transform_later(needgc_iff); // Plug the failing-heap-space-need-gc test into the slow-path region - Node *needgc_true = new (C) IfTrueNode(needgc_iff); + Node *needgc_true = new IfTrueNode(needgc_iff); transform_later(needgc_true); if (initial_slow_test) { slow_region->init_req(need_gc_path, needgc_true); @@ -1302,7 +1302,7 @@ void PhaseMacroExpand::expand_allocate_common( slow_region = needgc_true; } // No need for a GC. Setup for the Store-Conditional - Node *needgc_false = new (C) IfFalseNode(needgc_iff); + Node *needgc_false = new IfFalseNode(needgc_iff); transform_later(needgc_false); // Grab regular I/O before optional prefetch may change it. @@ -1322,37 +1322,37 @@ void PhaseMacroExpand::expand_allocate_common( // memory state. if (UseTLAB) { Node* store_eden_top = - new (C) StorePNode(needgc_false, contended_phi_rawmem, eden_top_adr, + new StorePNode(needgc_false, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, new_eden_top, MemNode::unordered); transform_later(store_eden_top); fast_oop_ctrl = needgc_false; // No contention, so this is the fast path fast_oop_rawmem = store_eden_top; } else { Node* store_eden_top = - new (C) StorePConditionalNode(needgc_false, contended_phi_rawmem, eden_top_adr, + new StorePConditionalNode(needgc_false, contended_phi_rawmem, eden_top_adr, new_eden_top, fast_oop/*old_eden_top*/); transform_later(store_eden_top); - Node *contention_check = new (C) BoolNode(store_eden_top, BoolTest::ne); + Node *contention_check = new BoolNode(store_eden_top, BoolTest::ne); transform_later(contention_check); - store_eden_top = new (C) SCMemProjNode(store_eden_top); + store_eden_top = new SCMemProjNode(store_eden_top); transform_later(store_eden_top); // If not using TLABs, check to see if there was contention. - IfNode *contention_iff = new (C) IfNode (needgc_false, contention_check, PROB_MIN, COUNT_UNKNOWN); + IfNode *contention_iff = new IfNode (needgc_false, contention_check, PROB_MIN, COUNT_UNKNOWN); transform_later(contention_iff); - Node *contention_true = new (C) IfTrueNode(contention_iff); + Node *contention_true = new IfTrueNode(contention_iff); transform_later(contention_true); // If contention, loopback and try again. contended_region->init_req(contended_loopback_path, contention_true); contended_phi_rawmem->init_req(contended_loopback_path, store_eden_top); // Fast-path succeeded with no contention! - Node *contention_false = new (C) IfFalseNode(contention_iff); + Node *contention_false = new IfFalseNode(contention_iff); transform_later(contention_false); fast_oop_ctrl = contention_false; // Bump total allocated bytes for this thread - Node* thread = new (C) ThreadLocalNode(); + Node* thread = new ThreadLocalNode(); transform_later(thread); Node* alloc_bytes_adr = basic_plus_adr(top()/*not oop*/, thread, in_bytes(JavaThread::allocated_bytes_offset())); @@ -1361,10 +1361,10 @@ void PhaseMacroExpand::expand_allocate_common( #ifdef _LP64 Node* alloc_size = size_in_bytes; #else - Node* alloc_size = new (C) ConvI2LNode(size_in_bytes); + Node* alloc_size = new ConvI2LNode(size_in_bytes); transform_later(alloc_size); #endif - Node* new_alloc_bytes = new (C) AddLNode(alloc_bytes, alloc_size); + Node* new_alloc_bytes = new AddLNode(alloc_bytes, alloc_size); transform_later(new_alloc_bytes); fast_oop_rawmem = make_store(fast_oop_ctrl, store_eden_top, alloc_bytes_adr, 0, new_alloc_bytes, T_LONG); @@ -1391,9 +1391,9 @@ void PhaseMacroExpand::expand_allocate_common( mb->init_req(TypeFunc::Memory, fast_oop_rawmem); mb->init_req(TypeFunc::Control, fast_oop_ctrl); - fast_oop_ctrl = new (C) ProjNode(mb,TypeFunc::Control); + fast_oop_ctrl = new ProjNode(mb,TypeFunc::Control); transform_later(fast_oop_ctrl); - fast_oop_rawmem = new (C) ProjNode(mb,TypeFunc::Memory); + fast_oop_rawmem = new ProjNode(mb,TypeFunc::Memory); transform_later(fast_oop_rawmem); } else { // Add the MemBarStoreStore after the InitializeNode so that @@ -1407,9 +1407,9 @@ void PhaseMacroExpand::expand_allocate_common( MemBarNode* mb = MemBarNode::make(C, Op_MemBarStoreStore, Compile::AliasIdxBot); transform_later(mb); - Node* ctrl = new (C) ProjNode(init,TypeFunc::Control); + Node* ctrl = new ProjNode(init,TypeFunc::Control); transform_later(ctrl); - Node* mem = new (C) ProjNode(init,TypeFunc::Memory); + Node* mem = new ProjNode(init,TypeFunc::Memory); transform_later(mem); // The MemBarStoreStore depends on control and memory coming @@ -1417,9 +1417,9 @@ void PhaseMacroExpand::expand_allocate_common( mb->init_req(TypeFunc::Memory, mem); mb->init_req(TypeFunc::Control, ctrl); - ctrl = new (C) ProjNode(mb,TypeFunc::Control); + ctrl = new ProjNode(mb,TypeFunc::Control); transform_later(ctrl); - mem = new (C) ProjNode(mb,TypeFunc::Memory); + mem = new ProjNode(mb,TypeFunc::Memory); transform_later(mem); // All nodes that depended on the InitializeNode for control @@ -1433,13 +1433,13 @@ void PhaseMacroExpand::expand_allocate_common( if (C->env()->dtrace_extended_probes()) { // Slow-path call int size = TypeFunc::Parms + 2; - CallLeafNode *call = new (C) CallLeafNode(OptoRuntime::dtrace_object_alloc_Type(), - CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc_base), - "dtrace_object_alloc", - TypeRawPtr::BOTTOM); + CallLeafNode *call = new CallLeafNode(OptoRuntime::dtrace_object_alloc_Type(), + CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc_base), + "dtrace_object_alloc", + TypeRawPtr::BOTTOM); // Get base of thread-local storage area - Node* thread = new (C) ThreadLocalNode(); + Node* thread = new ThreadLocalNode(); transform_later(thread); call->init_req(TypeFunc::Parms+0, thread); @@ -1450,9 +1450,9 @@ void PhaseMacroExpand::expand_allocate_common( call->init_req(TypeFunc::ReturnAdr, alloc->in(TypeFunc::ReturnAdr)); call->init_req(TypeFunc::FramePtr, alloc->in(TypeFunc::FramePtr)); transform_later(call); - fast_oop_ctrl = new (C) ProjNode(call,TypeFunc::Control); + fast_oop_ctrl = new ProjNode(call,TypeFunc::Control); transform_later(fast_oop_ctrl); - fast_oop_rawmem = new (C) ProjNode(call,TypeFunc::Memory); + fast_oop_rawmem = new ProjNode(call,TypeFunc::Memory); transform_later(fast_oop_rawmem); } @@ -1467,7 +1467,7 @@ void PhaseMacroExpand::expand_allocate_common( } // Generate slow-path call - CallNode *call = new (C) CallStaticJavaNode(slow_call_type, slow_call_address, + CallNode *call = new CallStaticJavaNode(slow_call_type, slow_call_address, OptoRuntime::stub_name(slow_call_address), alloc->jvms()->bci(), TypePtr::BOTTOM); @@ -1524,7 +1524,7 @@ void PhaseMacroExpand::expand_allocate_common( // _memproj_catchall so we end up with a call that has only 1 memory projection. if (_memproj_catchall != NULL ) { if (_memproj_fallthrough == NULL) { - _memproj_fallthrough = new (C) ProjNode(call, TypeFunc::Memory); + _memproj_fallthrough = new ProjNode(call, TypeFunc::Memory); transform_later(_memproj_fallthrough); } for (DUIterator_Fast imax, i = _memproj_catchall->fast_outs(imax); i < imax; i++) { @@ -1556,7 +1556,7 @@ void PhaseMacroExpand::expand_allocate_common( // _ioproj_catchall so we end up with a call that has only 1 i_o projection. if (_ioproj_catchall != NULL ) { if (_ioproj_fallthrough == NULL) { - _ioproj_fallthrough = new (C) ProjNode(call, TypeFunc::I_O); + _ioproj_fallthrough = new ProjNode(call, TypeFunc::I_O); transform_later(_ioproj_fallthrough); } for (DUIterator_Fast imax, i = _ioproj_catchall->fast_outs(imax); i < imax; i++) { @@ -1690,47 +1690,47 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, // As an allocation hits the watermark, we will prefetch starting // at a "distance" away from watermark. - Node *pf_region = new (C) RegionNode(3); - Node *pf_phi_rawmem = new (C) PhiNode( pf_region, Type::MEMORY, + Node *pf_region = new RegionNode(3); + Node *pf_phi_rawmem = new PhiNode( pf_region, Type::MEMORY, TypeRawPtr::BOTTOM ); // I/O is used for Prefetch - Node *pf_phi_abio = new (C) PhiNode( pf_region, Type::ABIO ); + Node *pf_phi_abio = new PhiNode( pf_region, Type::ABIO ); - Node *thread = new (C) ThreadLocalNode(); + Node *thread = new ThreadLocalNode(); transform_later(thread); - Node *eden_pf_adr = new (C) AddPNode( top()/*not oop*/, thread, + Node *eden_pf_adr = new AddPNode( top()/*not oop*/, thread, _igvn.MakeConX(in_bytes(JavaThread::tlab_pf_top_offset())) ); transform_later(eden_pf_adr); - Node *old_pf_wm = new (C) LoadPNode(needgc_false, + Node *old_pf_wm = new LoadPNode(needgc_false, contended_phi_rawmem, eden_pf_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM, MemNode::unordered); transform_later(old_pf_wm); // check against new_eden_top - Node *need_pf_cmp = new (C) CmpPNode( new_eden_top, old_pf_wm ); + Node *need_pf_cmp = new CmpPNode( new_eden_top, old_pf_wm ); transform_later(need_pf_cmp); - Node *need_pf_bol = new (C) BoolNode( need_pf_cmp, BoolTest::ge ); + Node *need_pf_bol = new BoolNode( need_pf_cmp, BoolTest::ge ); transform_later(need_pf_bol); - IfNode *need_pf_iff = new (C) IfNode( needgc_false, need_pf_bol, + IfNode *need_pf_iff = new IfNode( needgc_false, need_pf_bol, PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN ); transform_later(need_pf_iff); // true node, add prefetchdistance - Node *need_pf_true = new (C) IfTrueNode( need_pf_iff ); + Node *need_pf_true = new IfTrueNode( need_pf_iff ); transform_later(need_pf_true); - Node *need_pf_false = new (C) IfFalseNode( need_pf_iff ); + Node *need_pf_false = new IfFalseNode( need_pf_iff ); transform_later(need_pf_false); - Node *new_pf_wmt = new (C) AddPNode( top(), old_pf_wm, + Node *new_pf_wmt = new AddPNode( top(), old_pf_wm, _igvn.MakeConX(AllocatePrefetchDistance) ); transform_later(new_pf_wmt ); new_pf_wmt->set_req(0, need_pf_true); - Node *store_new_wmt = new (C) StorePNode(need_pf_true, + Node *store_new_wmt = new StorePNode(need_pf_true, contended_phi_rawmem, eden_pf_adr, TypeRawPtr::BOTTOM, new_pf_wmt, MemNode::unordered); @@ -1746,10 +1746,10 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, uint distance = 0; for ( uint i = 0; i < lines; i++ ) { - prefetch_adr = new (C) AddPNode( old_pf_wm, new_pf_wmt, + prefetch_adr = new AddPNode( old_pf_wm, new_pf_wmt, _igvn.MakeConX(distance) ); transform_later(prefetch_adr); - prefetch = new (C) PrefetchAllocationNode( i_o, prefetch_adr ); + prefetch = new PrefetchAllocationNode( i_o, prefetch_adr ); transform_later(prefetch); distance += step_size; i_o = prefetch; @@ -1772,8 +1772,8 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, } else if( UseTLAB && AllocatePrefetchStyle == 3 ) { // Insert a prefetch for each allocation. // This code is used for Sparc with BIS. - Node *pf_region = new (C) RegionNode(3); - Node *pf_phi_rawmem = new (C) PhiNode( pf_region, Type::MEMORY, + Node *pf_region = new RegionNode(3); + Node *pf_phi_rawmem = new PhiNode( pf_region, Type::MEMORY, TypeRawPtr::BOTTOM ); // Generate several prefetch instructions. @@ -1782,29 +1782,29 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, uint distance = AllocatePrefetchDistance; // Next cache address. - Node *cache_adr = new (C) AddPNode(old_eden_top, old_eden_top, + Node *cache_adr = new AddPNode(old_eden_top, old_eden_top, _igvn.MakeConX(distance)); transform_later(cache_adr); - cache_adr = new (C) CastP2XNode(needgc_false, cache_adr); + cache_adr = new CastP2XNode(needgc_false, cache_adr); transform_later(cache_adr); Node* mask = _igvn.MakeConX(~(intptr_t)(step_size-1)); - cache_adr = new (C) AndXNode(cache_adr, mask); + cache_adr = new AndXNode(cache_adr, mask); transform_later(cache_adr); - cache_adr = new (C) CastX2PNode(cache_adr); + cache_adr = new CastX2PNode(cache_adr); transform_later(cache_adr); // Prefetch - Node *prefetch = new (C) PrefetchAllocationNode( contended_phi_rawmem, cache_adr ); + Node *prefetch = new PrefetchAllocationNode( contended_phi_rawmem, cache_adr ); prefetch->set_req(0, needgc_false); transform_later(prefetch); contended_phi_rawmem = prefetch; Node *prefetch_adr; distance = step_size; for ( uint i = 1; i < lines; i++ ) { - prefetch_adr = new (C) AddPNode( cache_adr, cache_adr, + prefetch_adr = new AddPNode( cache_adr, cache_adr, _igvn.MakeConX(distance) ); transform_later(prefetch_adr); - prefetch = new (C) PrefetchAllocationNode( contended_phi_rawmem, prefetch_adr ); + prefetch = new PrefetchAllocationNode( contended_phi_rawmem, prefetch_adr ); transform_later(prefetch); distance += step_size; contended_phi_rawmem = prefetch; @@ -1818,10 +1818,10 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, uint step_size = AllocatePrefetchStepSize; uint distance = AllocatePrefetchDistance; for ( uint i = 0; i < lines; i++ ) { - prefetch_adr = new (C) AddPNode( old_eden_top, new_eden_top, + prefetch_adr = new AddPNode( old_eden_top, new_eden_top, _igvn.MakeConX(distance) ); transform_later(prefetch_adr); - prefetch = new (C) PrefetchAllocationNode( i_o, prefetch_adr ); + prefetch = new PrefetchAllocationNode( i_o, prefetch_adr ); // Do not let it float too high, since if eden_top == eden_end, // both might be null. if( i == 0 ) { // Set control for first prefetch, next follows it @@ -2170,12 +2170,12 @@ void PhaseMacroExpand::expand_lock_node(LockNode *lock) { * } */ - region = new (C) RegionNode(5); + region = new RegionNode(5); // create a Phi for the memory state - mem_phi = new (C) PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM); + mem_phi = new PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM); - Node* fast_lock_region = new (C) RegionNode(3); - Node* fast_lock_mem_phi = new (C) PhiNode( fast_lock_region, Type::MEMORY, TypeRawPtr::BOTTOM); + Node* fast_lock_region = new RegionNode(3); + Node* fast_lock_mem_phi = new PhiNode( fast_lock_region, Type::MEMORY, TypeRawPtr::BOTTOM); // First, check mark word for the biased lock pattern. Node* mark_node = make_load(ctrl, mem, obj, oopDesc::mark_offset_in_bytes(), TypeX_X, TypeX_X->basic_type()); @@ -2205,10 +2205,10 @@ void PhaseMacroExpand::expand_lock_node(LockNode *lock) { } Node *proto_node = make_load(ctrl, mem, klass_node, in_bytes(Klass::prototype_header_offset()), TypeX_X, TypeX_X->basic_type()); - Node* thread = transform_later(new (C) ThreadLocalNode()); - Node* cast_thread = transform_later(new (C) CastP2XNode(ctrl, thread)); - Node* o_node = transform_later(new (C) OrXNode(cast_thread, proto_node)); - Node* x_node = transform_later(new (C) XorXNode(o_node, mark_node)); + Node* thread = transform_later(new ThreadLocalNode()); + Node* cast_thread = transform_later(new CastP2XNode(ctrl, thread)); + Node* o_node = transform_later(new OrXNode(cast_thread, proto_node)); + Node* x_node = transform_later(new XorXNode(o_node, mark_node)); // Get slow path - mark word does NOT match the value. Node* not_biased_ctrl = opt_bits_test(ctrl, region, 3, x_node, @@ -2231,17 +2231,17 @@ void PhaseMacroExpand::expand_lock_node(LockNode *lock) { // We are going to try to reset the mark of this object to the prototype // value and fall through to the CAS-based locking scheme. Node* adr = basic_plus_adr(obj, oopDesc::mark_offset_in_bytes()); - Node* cas = new (C) StoreXConditionalNode(not_biased_ctrl, mem, adr, - proto_node, mark_node); + Node* cas = new StoreXConditionalNode(not_biased_ctrl, mem, adr, + proto_node, mark_node); transform_later(cas); - Node* proj = transform_later( new (C) SCMemProjNode(cas)); + Node* proj = transform_later(new SCMemProjNode(cas)); fast_lock_mem_phi->init_req(2, proj); // Second, check epoch bits. - Node* rebiased_region = new (C) RegionNode(3); - Node* old_phi = new (C) PhiNode( rebiased_region, TypeX_X); - Node* new_phi = new (C) PhiNode( rebiased_region, TypeX_X); + Node* rebiased_region = new RegionNode(3); + Node* old_phi = new PhiNode( rebiased_region, TypeX_X); + Node* new_phi = new PhiNode( rebiased_region, TypeX_X); // Get slow path - mark word does NOT match epoch bits. Node* epoch_ctrl = opt_bits_test(ctrl, rebiased_region, 1, x_node, @@ -2258,9 +2258,9 @@ void PhaseMacroExpand::expand_lock_node(LockNode *lock) { Node* cmask = MakeConX(markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place); - Node* old = transform_later(new (C) AndXNode(mark_node, cmask)); - cast_thread = transform_later(new (C) CastP2XNode(ctrl, thread)); - Node* new_mark = transform_later(new (C) OrXNode(cast_thread, old)); + Node* old = transform_later(new AndXNode(mark_node, cmask)); + cast_thread = transform_later(new CastP2XNode(ctrl, thread)); + Node* new_mark = transform_later(new OrXNode(cast_thread, old)); old_phi->init_req(1, old); new_phi->init_req(1, new_mark); @@ -2270,10 +2270,9 @@ void PhaseMacroExpand::expand_lock_node(LockNode *lock) { // Try to acquire the bias of the object using an atomic operation. // If this fails we will go in to the runtime to revoke the object's bias. - cas = new (C) StoreXConditionalNode(rebiased_region, mem, adr, - new_phi, old_phi); + cas = new StoreXConditionalNode(rebiased_region, mem, adr, new_phi, old_phi); transform_later(cas); - proj = transform_later( new (C) SCMemProjNode(cas)); + proj = transform_later(new SCMemProjNode(cas)); // Get slow path - Failed to CAS. not_biased_ctrl = opt_bits_test(rebiased_region, region, 4, cas, 0, 0); @@ -2281,8 +2280,8 @@ void PhaseMacroExpand::expand_lock_node(LockNode *lock) { // region->in(4) is set to fast path - the object is rebiased to the current thread. // Failed to CAS. - slow_path = new (C) RegionNode(3); - Node *slow_mem = new (C) PhiNode( slow_path, Type::MEMORY, TypeRawPtr::BOTTOM); + slow_path = new RegionNode(3); + Node *slow_mem = new PhiNode( slow_path, Type::MEMORY, TypeRawPtr::BOTTOM); slow_path->init_req(1, not_biased_ctrl); // Capture slow-control slow_mem->init_req(1, proj); @@ -2306,9 +2305,9 @@ void PhaseMacroExpand::expand_lock_node(LockNode *lock) { lock->set_req(TypeFunc::Memory, slow_mem); } else { - region = new (C) RegionNode(3); + region = new RegionNode(3); // create a Phi for the memory state - mem_phi = new (C) PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM); + mem_phi = new PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM); // Optimize test; set region slot 2 slow_path = opt_bits_test(ctrl, region, 2, flock, 0, 0); @@ -2339,7 +2338,7 @@ void PhaseMacroExpand::expand_lock_node(LockNode *lock) { transform_later(region); _igvn.replace_node(_fallthroughproj, region); - Node *memproj = transform_later( new(C) ProjNode(call, TypeFunc::Memory) ); + Node *memproj = transform_later(new ProjNode(call, TypeFunc::Memory)); mem_phi->init_req(1, memproj ); transform_later(mem_phi); _igvn.replace_node(_memproj_fallthrough, mem_phi); @@ -2364,9 +2363,9 @@ void PhaseMacroExpand::expand_unlock_node(UnlockNode *unlock) { if (UseOptoBiasInlining) { // Check for biased locking unlock case, which is a no-op. // See the full description in MacroAssembler::biased_locking_exit(). - region = new (C) RegionNode(4); + region = new RegionNode(4); // create a Phi for the memory state - mem_phi = new (C) PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM); + mem_phi = new PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM); mem_phi->init_req(3, mem); Node* mark_node = make_load(ctrl, mem, obj, oopDesc::mark_offset_in_bytes(), TypeX_X, TypeX_X->basic_type()); @@ -2374,12 +2373,12 @@ void PhaseMacroExpand::expand_unlock_node(UnlockNode *unlock) { markOopDesc::biased_lock_mask_in_place, markOopDesc::biased_lock_pattern); } else { - region = new (C) RegionNode(3); + region = new RegionNode(3); // create a Phi for the memory state - mem_phi = new (C) PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM); + mem_phi = new PhiNode( region, Type::MEMORY, TypeRawPtr::BOTTOM); } - FastUnlockNode *funlock = new (C) FastUnlockNode( ctrl, obj, box ); + FastUnlockNode *funlock = new FastUnlockNode( ctrl, obj, box ); funlock = transform_later( funlock )->as_FastUnlock(); // Optimize test; set region slot 2 Node *slow_path = opt_bits_test(ctrl, region, 2, funlock, 0, 0); @@ -2404,7 +2403,7 @@ void PhaseMacroExpand::expand_unlock_node(UnlockNode *unlock) { transform_later(region); _igvn.replace_node(_fallthroughproj, region); - Node *memproj = transform_later( new(C) ProjNode(call, TypeFunc::Memory) ); + Node *memproj = transform_later(new ProjNode(call, TypeFunc::Memory) ); mem_phi->init_req(1, memproj ); mem_phi->init_req(2, mem); transform_later(mem_phi); diff --git a/hotspot/src/share/vm/opto/macro.hpp b/hotspot/src/share/vm/opto/macro.hpp index 0efe988ab17..5cefbb1c063 100644 --- a/hotspot/src/share/vm/opto/macro.hpp +++ b/hotspot/src/share/vm/opto/macro.hpp @@ -52,7 +52,7 @@ private: return basic_plus_adr(base, base, offset); } Node* basic_plus_adr(Node* base, Node* ptr, Node* offset) { - Node* adr = new (C) AddPNode(base, ptr, offset); + Node* adr = new AddPNode(base, ptr, offset); return transform_later(adr); } Node* transform_later(Node* n) { diff --git a/hotspot/src/share/vm/opto/matcher.cpp b/hotspot/src/share/vm/opto/matcher.cpp index 7cdf630e1dc..2b2f11f9b4e 100644 --- a/hotspot/src/share/vm/opto/matcher.cpp +++ b/hotspot/src/share/vm/opto/matcher.cpp @@ -751,7 +751,7 @@ void Matcher::Fixup_Save_On_Entry( ) { tail_call_rms[tail_call_edge_cnt].Insert(OptoReg::Name(i+1)); tail_jump_rms[tail_jump_edge_cnt].Insert(OptoReg::Name(i+1)); halt_rms [ halt_edge_cnt].Insert(OptoReg::Name(i+1)); - mproj = new (C) MachProjNode( start, proj_cnt, ret_rms[ret_edge_cnt], Op_RegD ); + mproj = new MachProjNode( start, proj_cnt, ret_rms[ret_edge_cnt], Op_RegD ); proj_cnt += 2; // Skip 2 for doubles } else if( (i&1) == 1 && // Else check for high half of double @@ -777,7 +777,7 @@ void Matcher::Fixup_Save_On_Entry( ) { tail_call_rms[tail_call_edge_cnt].Insert(OptoReg::Name(i+1)); tail_jump_rms[tail_jump_edge_cnt].Insert(OptoReg::Name(i+1)); halt_rms [ halt_edge_cnt].Insert(OptoReg::Name(i+1)); - mproj = new (C) MachProjNode( start, proj_cnt, ret_rms[ret_edge_cnt], Op_RegL ); + mproj = new MachProjNode( start, proj_cnt, ret_rms[ret_edge_cnt], Op_RegL ); proj_cnt += 2; // Skip 2 for longs } else if( (i&1) == 1 && // Else check for high half of long @@ -792,7 +792,7 @@ void Matcher::Fixup_Save_On_Entry( ) { mproj = C->top(); } else { // Make a projection for it off the Start - mproj = new (C) MachProjNode( start, proj_cnt++, ret_rms[ret_edge_cnt], _register_save_type[i] ); + mproj = new MachProjNode( start, proj_cnt++, ret_rms[ret_edge_cnt], _register_save_type[i] ); } ret_edge_cnt ++; @@ -845,13 +845,13 @@ void Matcher::init_spill_mask( Node *ret ) { // Compute generic short-offset Loads #ifdef _LP64 - MachNode *spillCP = match_tree(new (C) LoadNNode(NULL,mem,fp,atp,TypeInstPtr::BOTTOM,MemNode::unordered)); + MachNode *spillCP = match_tree(new LoadNNode(NULL,mem,fp,atp,TypeInstPtr::BOTTOM,MemNode::unordered)); #endif - MachNode *spillI = match_tree(new (C) LoadINode(NULL,mem,fp,atp,TypeInt::INT,MemNode::unordered)); - MachNode *spillL = match_tree(new (C) LoadLNode(NULL,mem,fp,atp,TypeLong::LONG,MemNode::unordered,false)); - MachNode *spillF = match_tree(new (C) LoadFNode(NULL,mem,fp,atp,Type::FLOAT,MemNode::unordered)); - MachNode *spillD = match_tree(new (C) LoadDNode(NULL,mem,fp,atp,Type::DOUBLE,MemNode::unordered)); - MachNode *spillP = match_tree(new (C) LoadPNode(NULL,mem,fp,atp,TypeInstPtr::BOTTOM,MemNode::unordered)); + MachNode *spillI = match_tree(new LoadINode(NULL,mem,fp,atp,TypeInt::INT,MemNode::unordered)); + MachNode *spillL = match_tree(new LoadLNode(NULL,mem,fp,atp,TypeLong::LONG,MemNode::unordered,false)); + MachNode *spillF = match_tree(new LoadFNode(NULL,mem,fp,atp,Type::FLOAT,MemNode::unordered)); + MachNode *spillD = match_tree(new LoadDNode(NULL,mem,fp,atp,Type::DOUBLE,MemNode::unordered)); + MachNode *spillP = match_tree(new LoadPNode(NULL,mem,fp,atp,TypeInstPtr::BOTTOM,MemNode::unordered)); assert(spillI != NULL && spillL != NULL && spillF != NULL && spillD != NULL && spillP != NULL, ""); // Get the ADLC notion of the right regmask, for each basic type. @@ -867,19 +867,19 @@ void Matcher::init_spill_mask( Node *ret ) { // Vector regmasks. if (Matcher::vector_size_supported(T_BYTE,4)) { TypeVect::VECTS = TypeVect::make(T_BYTE, 4); - MachNode *spillVectS = match_tree(new (C) LoadVectorNode(NULL,mem,fp,atp,TypeVect::VECTS)); + MachNode *spillVectS = match_tree(new LoadVectorNode(NULL,mem,fp,atp,TypeVect::VECTS)); idealreg2regmask[Op_VecS] = &spillVectS->out_RegMask(); } if (Matcher::vector_size_supported(T_FLOAT,2)) { - MachNode *spillVectD = match_tree(new (C) LoadVectorNode(NULL,mem,fp,atp,TypeVect::VECTD)); + MachNode *spillVectD = match_tree(new LoadVectorNode(NULL,mem,fp,atp,TypeVect::VECTD)); idealreg2regmask[Op_VecD] = &spillVectD->out_RegMask(); } if (Matcher::vector_size_supported(T_FLOAT,4)) { - MachNode *spillVectX = match_tree(new (C) LoadVectorNode(NULL,mem,fp,atp,TypeVect::VECTX)); + MachNode *spillVectX = match_tree(new LoadVectorNode(NULL,mem,fp,atp,TypeVect::VECTX)); idealreg2regmask[Op_VecX] = &spillVectX->out_RegMask(); } if (Matcher::vector_size_supported(T_FLOAT,8)) { - MachNode *spillVectY = match_tree(new (C) LoadVectorNode(NULL,mem,fp,atp,TypeVect::VECTY)); + MachNode *spillVectY = match_tree(new LoadVectorNode(NULL,mem,fp,atp,TypeVect::VECTY)); idealreg2regmask[Op_VecY] = &spillVectY->out_RegMask(); } } @@ -1319,7 +1319,7 @@ MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) { // is excluded on the max-per-method basis, debug info cannot land in // this killed area. uint r_cnt = mcall->tf()->range()->cnt(); - MachProjNode *proj = new (C) MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj ); + MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj ); if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) { C->record_method_not_compilable_all_tiers("unsupported outgoing calling sequence"); } else { @@ -2274,7 +2274,7 @@ void Matcher::find_shared( Node *n ) { case Op_CompareAndSwapN: { // Convert trinary to binary-tree Node *newval = n->in(MemNode::ValueIn ); Node *oldval = n->in(LoadStoreConditionalNode::ExpectedIn); - Node *pair = new (C) BinaryNode( oldval, newval ); + Node *pair = new BinaryNode( oldval, newval ); n->set_req(MemNode::ValueIn,pair); n->del_req(LoadStoreConditionalNode::ExpectedIn); break; @@ -2289,22 +2289,22 @@ void Matcher::find_shared( Node *n ) { // we could move this code up next to the graph reshaping for IfNodes // or vice-versa, but I do not want to debug this for Ladybird. // 10/2/2000 CNC. - Node *pair1 = new (C) BinaryNode(n->in(1),n->in(1)->in(1)); + Node *pair1 = new BinaryNode(n->in(1),n->in(1)->in(1)); n->set_req(1,pair1); - Node *pair2 = new (C) BinaryNode(n->in(2),n->in(3)); + Node *pair2 = new BinaryNode(n->in(2),n->in(3)); n->set_req(2,pair2); n->del_req(3); break; } case Op_LoopLimit: { - Node *pair1 = new (C) BinaryNode(n->in(1),n->in(2)); + Node *pair1 = new BinaryNode(n->in(1),n->in(2)); n->set_req(1,pair1); n->set_req(2,n->in(3)); n->del_req(3); break; } case Op_StrEquals: { - Node *pair1 = new (C) BinaryNode(n->in(2),n->in(3)); + Node *pair1 = new BinaryNode(n->in(2),n->in(3)); n->set_req(2,pair1); n->set_req(3,n->in(4)); n->del_req(4); @@ -2312,9 +2312,9 @@ void Matcher::find_shared( Node *n ) { } case Op_StrComp: case Op_StrIndexOf: { - Node *pair1 = new (C) BinaryNode(n->in(2),n->in(3)); + Node *pair1 = new BinaryNode(n->in(2),n->in(3)); n->set_req(2,pair1); - Node *pair2 = new (C) BinaryNode(n->in(4),n->in(5)); + Node *pair2 = new BinaryNode(n->in(4),n->in(5)); n->set_req(3,pair2); n->del_req(5); n->del_req(4); @@ -2322,7 +2322,7 @@ void Matcher::find_shared( Node *n ) { } case Op_EncodeISOArray: { // Restructure into a binary tree for Matching. - Node* pair = new (C) BinaryNode(n->in(3), n->in(4)); + Node* pair = new BinaryNode(n->in(3), n->in(4)); n->set_req(3, pair); n->del_req(4); break; diff --git a/hotspot/src/share/vm/opto/memnode.cpp b/hotspot/src/share/vm/opto/memnode.cpp index 1d908c5b577..1c4d2bd773e 100644 --- a/hotspot/src/share/vm/opto/memnode.cpp +++ b/hotspot/src/share/vm/opto/memnode.cpp @@ -908,25 +908,25 @@ Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypeP rt->isa_oopptr() || is_immutable_value(adr), "raw memory operations should have control edge"); switch (bt) { - case T_BOOLEAN: return new (C) LoadUBNode(ctl, mem, adr, adr_type, rt->is_int(), mo); - case T_BYTE: return new (C) LoadBNode (ctl, mem, adr, adr_type, rt->is_int(), mo); - case T_INT: return new (C) LoadINode (ctl, mem, adr, adr_type, rt->is_int(), mo); - case T_CHAR: return new (C) LoadUSNode(ctl, mem, adr, adr_type, rt->is_int(), mo); - case T_SHORT: return new (C) LoadSNode (ctl, mem, adr, adr_type, rt->is_int(), mo); - case T_LONG: return new (C) LoadLNode (ctl, mem, adr, adr_type, rt->is_long(), mo); - case T_FLOAT: return new (C) LoadFNode (ctl, mem, adr, adr_type, rt, mo); - case T_DOUBLE: return new (C) LoadDNode (ctl, mem, adr, adr_type, rt, mo); - case T_ADDRESS: return new (C) LoadPNode (ctl, mem, adr, adr_type, rt->is_ptr(), mo); + case T_BOOLEAN: return new LoadUBNode(ctl, mem, adr, adr_type, rt->is_int(), mo); + case T_BYTE: return new LoadBNode (ctl, mem, adr, adr_type, rt->is_int(), mo); + case T_INT: return new LoadINode (ctl, mem, adr, adr_type, rt->is_int(), mo); + case T_CHAR: return new LoadUSNode(ctl, mem, adr, adr_type, rt->is_int(), mo); + case T_SHORT: return new LoadSNode (ctl, mem, adr, adr_type, rt->is_int(), mo); + case T_LONG: return new LoadLNode (ctl, mem, adr, adr_type, rt->is_long(), mo); + case T_FLOAT: return new LoadFNode (ctl, mem, adr, adr_type, rt, mo); + case T_DOUBLE: return new LoadDNode (ctl, mem, adr, adr_type, rt, mo); + case T_ADDRESS: return new LoadPNode (ctl, mem, adr, adr_type, rt->is_ptr(), mo); case T_OBJECT: #ifdef _LP64 if (adr->bottom_type()->is_ptr_to_narrowoop()) { - Node* load = gvn.transform(new (C) LoadNNode(ctl, mem, adr, adr_type, rt->make_narrowoop(), mo)); - return new (C) DecodeNNode(load, load->bottom_type()->make_ptr()); + Node* load = gvn.transform(new LoadNNode(ctl, mem, adr, adr_type, rt->make_narrowoop(), mo)); + return new DecodeNNode(load, load->bottom_type()->make_ptr()); } else #endif { assert(!adr->bottom_type()->is_ptr_to_narrowoop() && !adr->bottom_type()->is_ptr_to_narrowklass(), "should have got back a narrow oop"); - return new (C) LoadPNode(ctl, mem, adr, adr_type, rt->is_oopptr(), mo); + return new LoadPNode(ctl, mem, adr, adr_type, rt->is_oopptr(), mo); } } ShouldNotReachHere(); @@ -935,12 +935,12 @@ Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypeP LoadLNode* LoadLNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo) { bool require_atomic = true; - return new (C) LoadLNode(ctl, mem, adr, adr_type, rt->is_long(), mo, require_atomic); + return new LoadLNode(ctl, mem, adr, adr_type, rt->is_long(), mo, require_atomic); } LoadDNode* LoadDNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, const Type* rt, MemOrd mo) { bool require_atomic = true; - return new (C) LoadDNode(ctl, mem, adr, adr_type, rt, mo, require_atomic); + return new LoadDNode(ctl, mem, adr, adr_type, rt, mo, require_atomic); } @@ -1228,33 +1228,33 @@ Node* LoadNode::eliminate_autobox(PhaseGVN* phase) { // Add up all the offsets making of the address of the load Node* result = elements[0]; for (int i = 1; i < count; i++) { - result = phase->transform(new (phase->C) AddXNode(result, elements[i])); + result = phase->transform(new AddXNode(result, elements[i])); } // Remove the constant offset from the address and then - result = phase->transform(new (phase->C) AddXNode(result, phase->MakeConX(-(int)offset))); + result = phase->transform(new AddXNode(result, phase->MakeConX(-(int)offset))); // remove the scaling of the offset to recover the original index. if (result->Opcode() == Op_LShiftX && result->in(2) == phase->intcon(shift)) { // Peel the shift off directly but wrap it in a dummy node // since Ideal can't return existing nodes - result = new (phase->C) RShiftXNode(result->in(1), phase->intcon(0)); + result = new RShiftXNode(result->in(1), phase->intcon(0)); } else if (result->is_Add() && result->in(2)->is_Con() && result->in(1)->Opcode() == Op_LShiftX && result->in(1)->in(2) == phase->intcon(shift)) { // We can't do general optimization: ((X<> Z ==> X + (Y>>Z) // but for boxing cache access we know that X<C) RShiftXNode(result->in(2), phase->intcon(shift)); - result = new (phase->C) AddXNode(result->in(1)->in(1), phase->transform(add_con)); + Node* add_con = new RShiftXNode(result->in(2), phase->intcon(shift)); + result = new AddXNode(result->in(1)->in(1), phase->transform(add_con)); } else { - result = new (phase->C) RShiftXNode(result, phase->intcon(shift)); + result = new RShiftXNode(result, phase->intcon(shift)); } #ifdef _LP64 if (bt != T_LONG) { - result = new (phase->C) ConvL2INode(phase->transform(result)); + result = new ConvL2INode(phase->transform(result)); } #else if (bt == T_LONG) { - result = new (phase->C) ConvI2LNode(phase->transform(result)); + result = new ConvI2LNode(phase->transform(result)); } #endif return result; @@ -1385,7 +1385,7 @@ Node *LoadNode::split_through_phi(PhaseGVN *phase) { this_iid = base->_idx; } PhaseIterGVN* igvn = phase->is_IterGVN(); - Node* phi = new (C) PhiNode(region, this_type, NULL, this_iid, this_index, this_offset); + Node* phi = new PhiNode(region, this_type, NULL, this_iid, this_index, this_offset); for (uint i = 1; i < region->req(); i++) { Node* x; Node* the_clone = NULL; @@ -1408,7 +1408,7 @@ Node *LoadNode::split_through_phi(PhaseGVN *phase) { } if (base_is_phi && (base->in(0) == region)) { Node* base_x = base->in(i); // Clone address for loads from boxed objects. - Node* adr_x = phase->transform(new (C) AddPNode(base_x,base_x,address->in(AddPNode::Offset))); + Node* adr_x = phase->transform(new AddPNode(base_x,base_x,address->in(AddPNode::Offset))); x->set_req(Address, adr_x); } } @@ -1897,8 +1897,8 @@ Node *LoadBNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node* mem = in(MemNode::Memory); Node* value = can_see_stored_value(mem,phase); if( value && !phase->type(value)->higher_equal( _type ) ) { - Node *result = phase->transform( new (phase->C) LShiftINode(value, phase->intcon(24)) ); - return new (phase->C) RShiftINode(result, phase->intcon(24)); + Node *result = phase->transform( new LShiftINode(value, phase->intcon(24)) ); + return new RShiftINode(result, phase->intcon(24)); } // Identity call will handle the case where truncation is not needed. return LoadNode::Ideal(phase, can_reshape); @@ -1929,7 +1929,7 @@ Node* LoadUBNode::Ideal(PhaseGVN* phase, bool can_reshape) { Node* mem = in(MemNode::Memory); Node* value = can_see_stored_value(mem, phase); if (value && !phase->type(value)->higher_equal(_type)) - return new (phase->C) AndINode(value, phase->intcon(0xFF)); + return new AndINode(value, phase->intcon(0xFF)); // Identity call will handle the case where truncation is not needed. return LoadNode::Ideal(phase, can_reshape); } @@ -1959,7 +1959,7 @@ Node *LoadUSNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node* mem = in(MemNode::Memory); Node* value = can_see_stored_value(mem,phase); if( value && !phase->type(value)->higher_equal( _type ) ) - return new (phase->C) AndINode(value,phase->intcon(0xFFFF)); + return new AndINode(value,phase->intcon(0xFFFF)); // Identity call will handle the case where truncation is not needed. return LoadNode::Ideal(phase, can_reshape); } @@ -1989,8 +1989,8 @@ Node *LoadSNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node* mem = in(MemNode::Memory); Node* value = can_see_stored_value(mem,phase); if( value && !phase->type(value)->higher_equal( _type ) ) { - Node *result = phase->transform( new (phase->C) LShiftINode(value, phase->intcon(16)) ); - return new (phase->C) RShiftINode(result, phase->intcon(16)); + Node *result = phase->transform( new LShiftINode(value, phase->intcon(16)) ); + return new RShiftINode(result, phase->intcon(16)); } // Identity call will handle the case where truncation is not needed. return LoadNode::Ideal(phase, can_reshape); @@ -2022,12 +2022,12 @@ Node *LoadKlassNode::make( PhaseGVN& gvn, Node *mem, Node *adr, const TypePtr* a #ifdef _LP64 if (adr_type->is_ptr_to_narrowklass()) { assert(UseCompressedClassPointers, "no compressed klasses"); - Node* load_klass = gvn.transform(new (C) LoadNKlassNode(ctl, mem, adr, at, tk->make_narrowklass(), MemNode::unordered)); - return new (C) DecodeNKlassNode(load_klass, load_klass->bottom_type()->make_ptr()); + Node* load_klass = gvn.transform(new LoadNKlassNode(ctl, mem, adr, at, tk->make_narrowklass(), MemNode::unordered)); + return new DecodeNKlassNode(load_klass, load_klass->bottom_type()->make_ptr()); } #endif assert(!adr_type->is_ptr_to_narrowklass() && !adr_type->is_ptr_to_narrowoop(), "should have got back a narrow oop"); - return new (C) LoadKlassNode(ctl, mem, adr, at, tk, MemNode::unordered); + return new LoadKlassNode(ctl, mem, adr, at, tk, MemNode::unordered); } //------------------------------Value------------------------------------------ @@ -2255,7 +2255,7 @@ Node* LoadNKlassNode::Identity( PhaseTransform *phase ) { if( t->isa_narrowklass()) return x; assert (!t->isa_narrowoop(), "no narrow oop here"); - return phase->transform(new (phase->C) EncodePKlassNode(x, t->make_narrowklass())); + return phase->transform(new EncodePKlassNode(x, t->make_narrowklass())); } //------------------------------Value----------------------------------------- @@ -2350,29 +2350,29 @@ StoreNode* StoreNode::make(PhaseGVN& gvn, Node* ctl, Node* mem, Node* adr, const switch (bt) { case T_BOOLEAN: - case T_BYTE: return new (C) StoreBNode(ctl, mem, adr, adr_type, val, mo); - case T_INT: return new (C) StoreINode(ctl, mem, adr, adr_type, val, mo); + case T_BYTE: return new StoreBNode(ctl, mem, adr, adr_type, val, mo); + case T_INT: return new StoreINode(ctl, mem, adr, adr_type, val, mo); case T_CHAR: - case T_SHORT: return new (C) StoreCNode(ctl, mem, adr, adr_type, val, mo); - case T_LONG: return new (C) StoreLNode(ctl, mem, adr, adr_type, val, mo); - case T_FLOAT: return new (C) StoreFNode(ctl, mem, adr, adr_type, val, mo); - case T_DOUBLE: return new (C) StoreDNode(ctl, mem, adr, adr_type, val, mo); + case T_SHORT: return new StoreCNode(ctl, mem, adr, adr_type, val, mo); + case T_LONG: return new StoreLNode(ctl, mem, adr, adr_type, val, mo); + case T_FLOAT: return new StoreFNode(ctl, mem, adr, adr_type, val, mo); + case T_DOUBLE: return new StoreDNode(ctl, mem, adr, adr_type, val, mo); case T_METADATA: case T_ADDRESS: case T_OBJECT: #ifdef _LP64 if (adr->bottom_type()->is_ptr_to_narrowoop()) { - val = gvn.transform(new (C) EncodePNode(val, val->bottom_type()->make_narrowoop())); - return new (C) StoreNNode(ctl, mem, adr, adr_type, val, mo); + val = gvn.transform(new EncodePNode(val, val->bottom_type()->make_narrowoop())); + return new StoreNNode(ctl, mem, adr, adr_type, val, mo); } else if (adr->bottom_type()->is_ptr_to_narrowklass() || (UseCompressedClassPointers && val->bottom_type()->isa_klassptr() && adr->bottom_type()->isa_rawptr())) { - val = gvn.transform(new (C) EncodePKlassNode(val, val->bottom_type()->make_narrowklass())); - return new (C) StoreNKlassNode(ctl, mem, adr, adr_type, val, mo); + val = gvn.transform(new EncodePKlassNode(val, val->bottom_type()->make_narrowklass())); + return new StoreNKlassNode(ctl, mem, adr, adr_type, val, mo); } #endif { - return new (C) StorePNode(ctl, mem, adr, adr_type, val, mo); + return new StorePNode(ctl, mem, adr, adr_type, val, mo); } } ShouldNotReachHere(); @@ -2381,12 +2381,12 @@ StoreNode* StoreNode::make(PhaseGVN& gvn, Node* ctl, Node* mem, Node* adr, const StoreLNode* StoreLNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, MemOrd mo) { bool require_atomic = true; - return new (C) StoreLNode(ctl, mem, adr, adr_type, val, mo, require_atomic); + return new StoreLNode(ctl, mem, adr, adr_type, val, mo, require_atomic); } StoreDNode* StoreDNode::make_atomic(Compile *C, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, MemOrd mo) { bool require_atomic = true; - return new (C) StoreDNode(ctl, mem, adr, adr_type, val, mo, require_atomic); + return new StoreDNode(ctl, mem, adr, adr_type, val, mo, require_atomic); } @@ -2779,12 +2779,12 @@ Node *ClearArrayNode::Ideal(PhaseGVN *phase, bool can_reshape){ Node *zero = phase->makecon(TypeLong::ZERO); Node *off = phase->MakeConX(BytesPerLong); - mem = new (phase->C) StoreLNode(in(0),mem,adr,atp,zero,MemNode::unordered,false); + mem = new StoreLNode(in(0),mem,adr,atp,zero,MemNode::unordered,false); count--; while( count-- ) { mem = phase->transform(mem); - adr = phase->transform(new (phase->C) AddPNode(base,adr,off)); - mem = new (phase->C) StoreLNode(in(0),mem,adr,atp,zero,MemNode::unordered,false); + adr = phase->transform(new AddPNode(base,adr,off)); + mem = new StoreLNode(in(0),mem,adr,atp,zero,MemNode::unordered,false); } return mem; } @@ -2825,7 +2825,7 @@ Node* ClearArrayNode::clear_memory(Node* ctl, Node* mem, Node* dest, int unit = BytesPerLong; if ((offset % unit) != 0) { - Node* adr = new (C) AddPNode(dest, dest, phase->MakeConX(offset)); + Node* adr = new AddPNode(dest, dest, phase->MakeConX(offset)); adr = phase->transform(adr); const TypePtr* atp = TypeRawPtr::BOTTOM; mem = StoreNode::make(*phase, ctl, mem, adr, atp, phase->zerocon(T_INT), T_INT, MemNode::unordered); @@ -2855,14 +2855,14 @@ Node* ClearArrayNode::clear_memory(Node* ctl, Node* mem, Node* dest, // Scale to the unit required by the CPU: if (!Matcher::init_array_count_is_in_bytes) { Node* shift = phase->intcon(exact_log2(unit)); - zbase = phase->transform( new(C) URShiftXNode(zbase, shift) ); - zend = phase->transform( new(C) URShiftXNode(zend, shift) ); + zbase = phase->transform(new URShiftXNode(zbase, shift) ); + zend = phase->transform(new URShiftXNode(zend, shift) ); } // Bulk clear double-words - Node* zsize = phase->transform( new(C) SubXNode(zend, zbase) ); - Node* adr = phase->transform( new(C) AddPNode(dest, dest, start_offset) ); - mem = new (C) ClearArrayNode(ctl, mem, zsize, adr); + Node* zsize = phase->transform(new SubXNode(zend, zbase) ); + Node* adr = phase->transform(new AddPNode(dest, dest, start_offset) ); + mem = new ClearArrayNode(ctl, mem, zsize, adr); return phase->transform(mem); } @@ -2886,7 +2886,7 @@ Node* ClearArrayNode::clear_memory(Node* ctl, Node* mem, Node* dest, start_offset, phase->MakeConX(done_offset), phase); } if (done_offset < end_offset) { // emit the final 32-bit store - Node* adr = new (C) AddPNode(dest, dest, phase->MakeConX(done_offset)); + Node* adr = new AddPNode(dest, dest, phase->MakeConX(done_offset)); adr = phase->transform(adr); const TypePtr* atp = TypeRawPtr::BOTTOM; mem = StoreNode::make(*phase, ctl, mem, adr, atp, phase->zerocon(T_INT), T_INT, MemNode::unordered); @@ -2920,16 +2920,16 @@ uint MemBarNode::cmp( const Node &n ) const { //------------------------------make------------------------------------------- MemBarNode* MemBarNode::make(Compile* C, int opcode, int atp, Node* pn) { switch (opcode) { - case Op_MemBarAcquire: return new(C) MemBarAcquireNode(C, atp, pn); - case Op_LoadFence: return new(C) LoadFenceNode(C, atp, pn); - case Op_MemBarRelease: return new(C) MemBarReleaseNode(C, atp, pn); - case Op_StoreFence: return new(C) StoreFenceNode(C, atp, pn); - case Op_MemBarAcquireLock: return new(C) MemBarAcquireLockNode(C, atp, pn); - case Op_MemBarReleaseLock: return new(C) MemBarReleaseLockNode(C, atp, pn); - case Op_MemBarVolatile: return new(C) MemBarVolatileNode(C, atp, pn); - case Op_MemBarCPUOrder: return new(C) MemBarCPUOrderNode(C, atp, pn); - case Op_Initialize: return new(C) InitializeNode(C, atp, pn); - case Op_MemBarStoreStore: return new(C) MemBarStoreStoreNode(C, atp, pn); + case Op_MemBarAcquire: return new MemBarAcquireNode(C, atp, pn); + case Op_LoadFence: return new LoadFenceNode(C, atp, pn); + case Op_MemBarRelease: return new MemBarReleaseNode(C, atp, pn); + case Op_StoreFence: return new StoreFenceNode(C, atp, pn); + case Op_MemBarAcquireLock: return new MemBarAcquireLockNode(C, atp, pn); + case Op_MemBarReleaseLock: return new MemBarReleaseLockNode(C, atp, pn); + case Op_MemBarVolatile: return new MemBarVolatileNode(C, atp, pn); + case Op_MemBarCPUOrder: return new MemBarCPUOrderNode(C, atp, pn); + case Op_Initialize: return new InitializeNode(C, atp, pn); + case Op_MemBarStoreStore: return new MemBarStoreStoreNode(C, atp, pn); default: ShouldNotReachHere(); return NULL; } } @@ -2992,7 +2992,7 @@ Node *MemBarNode::Ideal(PhaseGVN *phase, bool can_reshape) { igvn->replace_node(proj_out(TypeFunc::Control), in(TypeFunc::Control)); // Must return either the original node (now dead) or a new node // (Do not return a top here, since that would break the uniqueness of top.) - return new (phase->C) ConINode(TypeInt::ZERO); + return new ConINode(TypeInt::ZERO); } } return NULL; @@ -3012,7 +3012,7 @@ Node *MemBarNode::match( const ProjNode *proj, const Matcher *m ) { switch (proj->_con) { case TypeFunc::Control: case TypeFunc::Memory: - return new (m->C) MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj); + return new MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj); } ShouldNotReachHere(); return NULL; @@ -3438,7 +3438,7 @@ Node* InitializeNode::make_raw_address(intptr_t offset, Node* addr = in(RawAddress); if (offset != 0) { Compile* C = phase->C; - addr = phase->transform( new (C) AddPNode(C->top(), addr, + addr = phase->transform( new AddPNode(C->top(), addr, phase->MakeConX(offset)) ); } return addr; @@ -4127,7 +4127,7 @@ MergeMemNode::MergeMemNode(Node *new_base) : Node(1+Compile::AliasIdxRaw) { // Make a new, untransformed MergeMem with the same base as 'mem'. // If mem is itself a MergeMem, populate the result with the same edges. MergeMemNode* MergeMemNode::make(Compile* C, Node* mem) { - return new(C) MergeMemNode(mem); + return new MergeMemNode(mem); } //------------------------------cmp-------------------------------------------- diff --git a/hotspot/src/share/vm/opto/movenode.cpp b/hotspot/src/share/vm/opto/movenode.cpp index bf2a83712c1..b7e32deb2e4 100644 --- a/hotspot/src/share/vm/opto/movenode.cpp +++ b/hotspot/src/share/vm/opto/movenode.cpp @@ -160,13 +160,13 @@ const Type *CMoveNode::Value( PhaseTransform *phase ) const { // from the inputs we do not need to specify it here. CMoveNode *CMoveNode::make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t ) { switch( t->basic_type() ) { - case T_INT: return new (C) CMoveINode( bol, left, right, t->is_int() ); - case T_FLOAT: return new (C) CMoveFNode( bol, left, right, t ); - case T_DOUBLE: return new (C) CMoveDNode( bol, left, right, t ); - case T_LONG: return new (C) CMoveLNode( bol, left, right, t->is_long() ); - case T_OBJECT: return new (C) CMovePNode( c, bol, left, right, t->is_oopptr() ); - case T_ADDRESS: return new (C) CMovePNode( c, bol, left, right, t->is_ptr() ); - case T_NARROWOOP: return new (C) CMoveNNode( c, bol, left, right, t ); + case T_INT: return new CMoveINode( bol, left, right, t->is_int() ); + case T_FLOAT: return new CMoveFNode( bol, left, right, t ); + case T_DOUBLE: return new CMoveDNode( bol, left, right, t ); + case T_LONG: return new CMoveLNode( bol, left, right, t->is_long() ); + case T_OBJECT: return new CMovePNode( c, bol, left, right, t->is_oopptr() ); + case T_ADDRESS: return new CMovePNode( c, bol, left, right, t->is_ptr() ); + case T_NARROWOOP: return new CMoveNNode( c, bol, left, right, t ); default: ShouldNotReachHere(); return NULL; @@ -233,9 +233,9 @@ Node *CMoveINode::Ideal(PhaseGVN *phase, bool can_reshape) { #ifndef PRODUCT if( PrintOpto ) tty->print_cr("CMOV to I2B"); #endif - Node *n = new (phase->C) Conv2BNode( cmp->in(1) ); + Node *n = new Conv2BNode( cmp->in(1) ); if( flip ) - n = new (phase->C) XorINode( phase->transform(n), phase->intcon(1) ); + n = new XorINode( phase->transform(n), phase->intcon(1) ); return n; } @@ -289,9 +289,9 @@ Node *CMoveFNode::Ideal(PhaseGVN *phase, bool can_reshape) { sub->in(2) != X || phase->type(sub->in(1)) != TypeF::ZERO ) return NULL; - Node *abs = new (phase->C) AbsFNode( X ); + Node *abs = new AbsFNode( X ); if( flip ) - abs = new (phase->C) SubFNode(sub->in(1), phase->transform(abs)); + abs = new SubFNode(sub->in(1), phase->transform(abs)); return abs; } @@ -345,9 +345,9 @@ Node *CMoveDNode::Ideal(PhaseGVN *phase, bool can_reshape) { sub->in(2) != X || phase->type(sub->in(1)) != TypeD::ZERO ) return NULL; - Node *abs = new (phase->C) AbsDNode( X ); + Node *abs = new AbsDNode( X ); if( flip ) - abs = new (phase->C) SubDNode(sub->in(1), phase->transform(abs)); + abs = new SubDNode(sub->in(1), phase->transform(abs)); return abs; } diff --git a/hotspot/src/share/vm/opto/mulnode.cpp b/hotspot/src/share/vm/opto/mulnode.cpp index 056d8c5043a..1406f8364a6 100644 --- a/hotspot/src/share/vm/opto/mulnode.cpp +++ b/hotspot/src/share/vm/opto/mulnode.cpp @@ -199,22 +199,22 @@ Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *res = NULL; jint bit1 = con & -con; // Extract low bit if( bit1 == con ) { // Found a power of 2? - res = new (phase->C) LShiftINode( in(1), phase->intcon(log2_intptr(bit1)) ); + res = new LShiftINode( in(1), phase->intcon(log2_intptr(bit1)) ); } else { // Check for constant with 2 bits set jint bit2 = con-bit1; bit2 = bit2 & -bit2; // Extract 2nd bit if( bit2 + bit1 == con ) { // Found all bits in con? - Node *n1 = phase->transform( new (phase->C) LShiftINode( in(1), phase->intcon(log2_intptr(bit1)) ) ); - Node *n2 = phase->transform( new (phase->C) LShiftINode( in(1), phase->intcon(log2_intptr(bit2)) ) ); - res = new (phase->C) AddINode( n2, n1 ); + Node *n1 = phase->transform( new LShiftINode( in(1), phase->intcon(log2_intptr(bit1)) ) ); + Node *n2 = phase->transform( new LShiftINode( in(1), phase->intcon(log2_intptr(bit2)) ) ); + res = new AddINode( n2, n1 ); } else if (is_power_of_2(con+1)) { // Sleezy: power-of-2 -1. Next time be generic. jint temp = (jint) (con + 1); - Node *n1 = phase->transform( new (phase->C) LShiftINode( in(1), phase->intcon(log2_intptr(temp)) ) ); - res = new (phase->C) SubINode( n1, in(1) ); + Node *n1 = phase->transform( new LShiftINode( in(1), phase->intcon(log2_intptr(temp)) ) ); + res = new SubINode( n1, in(1) ); } else { return MulNode::Ideal(phase, can_reshape); } @@ -222,7 +222,7 @@ Node *MulINode::Ideal(PhaseGVN *phase, bool can_reshape) { if( sign_flip ) { // Need to negate result? res = phase->transform(res);// Transform, before making the zero con - res = new (phase->C) SubINode(phase->intcon(0),res); + res = new SubINode(phase->intcon(0),res); } return res; // Return final result @@ -295,22 +295,22 @@ Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *res = NULL; jlong bit1 = con & -con; // Extract low bit if( bit1 == con ) { // Found a power of 2? - res = new (phase->C) LShiftLNode( in(1), phase->intcon(log2_long(bit1)) ); + res = new LShiftLNode( in(1), phase->intcon(log2_long(bit1)) ); } else { // Check for constant with 2 bits set jlong bit2 = con-bit1; bit2 = bit2 & -bit2; // Extract 2nd bit if( bit2 + bit1 == con ) { // Found all bits in con? - Node *n1 = phase->transform( new (phase->C) LShiftLNode( in(1), phase->intcon(log2_long(bit1)) ) ); - Node *n2 = phase->transform( new (phase->C) LShiftLNode( in(1), phase->intcon(log2_long(bit2)) ) ); - res = new (phase->C) AddLNode( n2, n1 ); + Node *n1 = phase->transform( new LShiftLNode( in(1), phase->intcon(log2_long(bit1)) ) ); + Node *n2 = phase->transform( new LShiftLNode( in(1), phase->intcon(log2_long(bit2)) ) ); + res = new AddLNode( n2, n1 ); } else if (is_power_of_2_long(con+1)) { // Sleezy: power-of-2 -1. Next time be generic. jlong temp = (jlong) (con + 1); - Node *n1 = phase->transform( new (phase->C) LShiftLNode( in(1), phase->intcon(log2_long(temp)) ) ); - res = new (phase->C) SubLNode( n1, in(1) ); + Node *n1 = phase->transform( new LShiftLNode( in(1), phase->intcon(log2_long(temp)) ) ); + res = new SubLNode( n1, in(1) ); } else { return MulNode::Ideal(phase, can_reshape); } @@ -318,7 +318,7 @@ Node *MulLNode::Ideal(PhaseGVN *phase, bool can_reshape) { if( sign_flip ) { // Need to negate result? res = phase->transform(res);// Transform, before making the zero con - res = new (phase->C) SubLNode(phase->longcon(0),res); + res = new SubLNode(phase->longcon(0),res); } return res; // Return final result @@ -477,31 +477,31 @@ Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) { // Masking bits off of a Character? Hi bits are already zero. if( lop == Op_LoadUS && (mask & 0xFFFF0000) ) // Can we make a smaller mask? - return new (phase->C) AndINode(load,phase->intcon(mask&0xFFFF)); + return new AndINode(load,phase->intcon(mask&0xFFFF)); // Masking bits off of a Short? Loading a Character does some masking if (can_reshape && load->outcnt() == 1 && load->unique_out() == this) { if (lop == Op_LoadS && (mask & 0xFFFF0000) == 0 ) { - Node *ldus = new (phase->C) LoadUSNode(load->in(MemNode::Control), - load->in(MemNode::Memory), - load->in(MemNode::Address), - load->adr_type(), - TypeInt::CHAR, MemNode::unordered); + Node *ldus = new LoadUSNode(load->in(MemNode::Control), + load->in(MemNode::Memory), + load->in(MemNode::Address), + load->adr_type(), + TypeInt::CHAR, MemNode::unordered); ldus = phase->transform(ldus); - return new (phase->C) AndINode(ldus, phase->intcon(mask & 0xFFFF)); + return new AndINode(ldus, phase->intcon(mask & 0xFFFF)); } // Masking sign bits off of a Byte? Do an unsigned byte load plus // an and. if (lop == Op_LoadB && (mask & 0xFFFFFF00) == 0) { - Node* ldub = new (phase->C) LoadUBNode(load->in(MemNode::Control), - load->in(MemNode::Memory), - load->in(MemNode::Address), - load->adr_type(), - TypeInt::UBYTE, MemNode::unordered); + Node* ldub = new LoadUBNode(load->in(MemNode::Control), + load->in(MemNode::Memory), + load->in(MemNode::Address), + load->adr_type(), + TypeInt::UBYTE, MemNode::unordered); ldub = phase->transform(ldub); - return new (phase->C) AndINode(ldub, phase->intcon(mask)); + return new AndINode(ldub, phase->intcon(mask)); } } @@ -516,8 +516,8 @@ Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) { // bits survive. NO sign-extension bits survive the maskings. if( (sign_bits_mask & mask) == 0 ) { // Use zero-fill shift instead - Node *zshift = phase->transform(new (phase->C) URShiftINode(load->in(1),load->in(2))); - return new (phase->C) AndINode( zshift, in(2) ); + Node *zshift = phase->transform(new URShiftINode(load->in(1),load->in(2))); + return new AndINode( zshift, in(2) ); } } } @@ -527,7 +527,7 @@ Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) { // plus 1) and the mask is of the low order bit. Skip the negate. if( lop == Op_SubI && mask == 1 && load->in(1) && phase->type(load->in(1)) == TypeInt::ZERO ) - return new (phase->C) AndINode( load->in(2), in(2) ); + return new AndINode( load->in(2), in(2) ); return MulNode::Ideal(phase, can_reshape); } @@ -611,9 +611,9 @@ Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) { // value. This check includes UI2L masks (0x00000000FFFFFFFF) which // would be optimized away later in Identity. if (op == Op_ConvI2L && (mask & CONST64(0xFFFFFFFF80000000)) == 0) { - Node* andi = new (phase->C) AndINode(in1->in(1), phase->intcon(mask)); + Node* andi = new AndINode(in1->in(1), phase->intcon(mask)); andi = phase->transform(andi); - return new (phase->C) ConvI2LNode(andi); + return new ConvI2LNode(andi); } // Masking off sign bits? Dont make them! @@ -627,8 +627,8 @@ Node *AndLNode::Ideal(PhaseGVN *phase, bool can_reshape) { // bits survive. NO sign-extension bits survive the maskings. if( (sign_bits_mask & mask) == 0 ) { // Use zero-fill shift instead - Node *zshift = phase->transform(new (phase->C) URShiftLNode(in1->in(1), in1->in(2))); - return new (phase->C) AndLNode(zshift, in(2)); + Node *zshift = phase->transform(new URShiftLNode(in1->in(1), in1->in(2))); + return new AndLNode(zshift, in(2)); } } } @@ -666,9 +666,9 @@ Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { // and 'i2b' patterns which typically fold into 'StoreC/StoreB'. if( con < 16 ) { // Compute X << con0 - Node *lsh = phase->transform( new (phase->C) LShiftINode( add1->in(1), in(2) ) ); + Node *lsh = phase->transform( new LShiftINode( add1->in(1), in(2) ) ); // Compute X<C) AddINode( lsh, phase->intcon(t12->get_con() << con)); + return new AddINode( lsh, phase->intcon(t12->get_con() << con)); } } } @@ -677,7 +677,7 @@ Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { if( (add1_op == Op_RShiftI || add1_op == Op_URShiftI ) && add1->in(2) == in(2) ) // Convert to "(x & -(1<C) AndINode(add1->in(1),phase->intcon( -(1<in(1),phase->intcon( -(1<>c0) & Y)<in(2) == in(2) ) { // Convert to "(x & (Y<transform( new (phase->C) LShiftINode( add1->in(2), in(2) ) ); - return new (phase->C) AndINode( add2->in(1), y_sh ); + Node *y_sh = phase->transform( new LShiftINode( add1->in(2), in(2) ) ); + return new AndINode( add2->in(1), y_sh ); } } @@ -696,7 +696,7 @@ Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { const jint bits_mask = right_n_bits(BitsPerJavaInteger-con); if( add1_op == Op_AndI && phase->type(add1->in(2)) == TypeInt::make( bits_mask ) ) - return new (phase->C) LShiftINode( add1->in(1), in(2) ); + return new LShiftINode( add1->in(1), in(2) ); return NULL; } @@ -776,9 +776,9 @@ Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { const TypeLong *t12 = phase->type(add1->in(2))->isa_long(); if( t12 && t12->is_con() ){ // Left input is an add of a con? // Compute X << con0 - Node *lsh = phase->transform( new (phase->C) LShiftLNode( add1->in(1), in(2) ) ); + Node *lsh = phase->transform( new LShiftLNode( add1->in(1), in(2) ) ); // Compute X<C) AddLNode( lsh, phase->longcon(t12->get_con() << con)); + return new AddLNode( lsh, phase->longcon(t12->get_con() << con)); } } @@ -786,7 +786,7 @@ Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { if( (add1_op == Op_RShiftL || add1_op == Op_URShiftL ) && add1->in(2) == in(2) ) // Convert to "(x & -(1<C) AndLNode(add1->in(1),phase->longcon( -(CONST64(1)<in(1),phase->longcon( -(CONST64(1)<>c0) & Y)<in(2) == in(2) ) { // Convert to "(x & (Y<transform( new (phase->C) LShiftLNode( add1->in(2), in(2) ) ); - return new (phase->C) AndLNode( add2->in(1), y_sh ); + Node *y_sh = phase->transform( new LShiftLNode( add1->in(2), in(2) ) ); + return new AndLNode( add2->in(1), y_sh ); } } @@ -805,7 +805,7 @@ Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { const jlong bits_mask = ((jlong)CONST64(1) << (jlong)(BitsPerJavaLong - con)) - CONST64(1); if( add1_op == Op_AndL && phase->type(add1->in(2)) == TypeLong::make( bits_mask ) ) - return new (phase->C) LShiftLNode( add1->in(1), in(2) ); + return new LShiftLNode( add1->in(1), in(2) ); return NULL; } @@ -907,8 +907,8 @@ Node *RShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *x = mask->in(1); jint maskbits = t3->get_con(); // Convert to "(x >> shift) & (mask >> shift)" - Node *shr_nomask = phase->transform( new (phase->C) RShiftINode(mask->in(1), in(2)) ); - return new (phase->C) AndINode(shr_nomask, phase->intcon( maskbits >> shift)); + Node *shr_nomask = phase->transform( new RShiftINode(mask->in(1), in(2)) ); + return new AndINode(shr_nomask, phase->intcon( maskbits >> shift)); } // Check for "(short[i] <<16)>>16" which simply sign-extends @@ -933,11 +933,11 @@ Node *RShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { ld->Opcode() == Op_LoadUS && ld->outcnt() == 1 && ld->unique_out() == shl) // Replace zero-extension-load with sign-extension-load - return new (phase->C) LoadSNode( ld->in(MemNode::Control), - ld->in(MemNode::Memory), - ld->in(MemNode::Address), - ld->adr_type(), TypeInt::SHORT, - MemNode::unordered); + return new LoadSNode( ld->in(MemNode::Control), + ld->in(MemNode::Memory), + ld->in(MemNode::Address), + ld->adr_type(), TypeInt::SHORT, + MemNode::unordered); } // Check for "(byte[i] <<24)>>24" which simply sign-extends @@ -1119,7 +1119,7 @@ Node *URShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { const int con2 = t12->get_con() & 31; // Shift count is always masked const int con3 = con+con2; if( con3 < 32 ) // Only merge shifts if total is < 32 - return new (phase->C) URShiftINode( in(1)->in(1), phase->intcon(con3) ); + return new URShiftINode( in(1)->in(1), phase->intcon(con3) ); } } @@ -1132,9 +1132,9 @@ Node *URShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *lshl = add->in(1); if( lshl->Opcode() == Op_LShiftI && phase->type(lshl->in(2)) == t2 ) { - Node *y_z = phase->transform( new (phase->C) URShiftINode(add->in(2),in(2)) ); - Node *sum = phase->transform( new (phase->C) AddINode( lshl->in(1), y_z ) ); - return new (phase->C) AndINode( sum, phase->intcon(mask) ); + Node *y_z = phase->transform( new URShiftINode(add->in(2),in(2)) ); + Node *sum = phase->transform( new AddINode( lshl->in(1), y_z ) ); + return new AndINode( sum, phase->intcon(mask) ); } } @@ -1147,8 +1147,8 @@ Node *URShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { if( t3 && t3->is_con() ) { // Right input is a constant jint mask2 = t3->get_con(); mask2 >>= con; // *signed* shift downward (high-order zeroes do not help) - Node *newshr = phase->transform( new (phase->C) URShiftINode(andi->in(1), in(2)) ); - return new (phase->C) AndINode(newshr, phase->intcon(mask2)); + Node *newshr = phase->transform( new URShiftINode(andi->in(1), in(2)) ); + return new AndINode(newshr, phase->intcon(mask2)); // The negative values are easier to materialize than positive ones. // A typical case from address arithmetic is ((x & ~15) >> 4). // It's better to change that to ((x >> 4) & ~0) versus @@ -1160,7 +1160,7 @@ Node *URShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *shl = in(1); if( in1_op == Op_LShiftI && phase->type(shl->in(2)) == t2 ) - return new (phase->C) AndINode( shl->in(1), phase->intcon(mask) ); + return new AndINode( shl->in(1), phase->intcon(mask) ); return NULL; } @@ -1265,9 +1265,9 @@ Node *URShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *lshl = add->in(1); if( lshl->Opcode() == Op_LShiftL && phase->type(lshl->in(2)) == t2 ) { - Node *y_z = phase->transform( new (phase->C) URShiftLNode(add->in(2),in(2)) ); - Node *sum = phase->transform( new (phase->C) AddLNode( lshl->in(1), y_z ) ); - return new (phase->C) AndLNode( sum, phase->longcon(mask) ); + Node *y_z = phase->transform( new URShiftLNode(add->in(2),in(2)) ); + Node *sum = phase->transform( new AddLNode( lshl->in(1), y_z ) ); + return new AndLNode( sum, phase->longcon(mask) ); } } @@ -1280,8 +1280,8 @@ Node *URShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { if( t3 && t3->is_con() ) { // Right input is a constant jlong mask2 = t3->get_con(); mask2 >>= con; // *signed* shift downward (high-order zeroes do not help) - Node *newshr = phase->transform( new (phase->C) URShiftLNode(andi->in(1), in(2)) ); - return new (phase->C) AndLNode(newshr, phase->longcon(mask2)); + Node *newshr = phase->transform( new URShiftLNode(andi->in(1), in(2)) ); + return new AndLNode(newshr, phase->longcon(mask2)); } } @@ -1289,7 +1289,7 @@ Node *URShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *shl = in(1); if( shl->Opcode() == Op_LShiftL && phase->type(shl->in(2)) == t2 ) - return new (phase->C) AndLNode( shl->in(1), phase->longcon(mask) ); + return new AndLNode( shl->in(1), phase->longcon(mask) ); return NULL; } diff --git a/hotspot/src/share/vm/opto/node.cpp b/hotspot/src/share/vm/opto/node.cpp index cec7f0d517b..f48e87c0c33 100644 --- a/hotspot/src/share/vm/opto/node.cpp +++ b/hotspot/src/share/vm/opto/node.cpp @@ -274,23 +274,6 @@ void DUIterator_Last::verify_step(uint num_edges) { // The value NULL is reserved for the top node only. #define NO_OUT_ARRAY ((Node**)-1) -// This funny expression handshakes with Node::operator new -// to pull Compile::current out of the new node's _out field, -// and then calls a subroutine which manages most field -// initializations. The only one which is tricky is the -// _idx field, which is const, and so must be initialized -// by a return value, not an assignment. -// -// (Aren't you thankful that Java finals don't require so many tricks?) -#define IDX_INIT(req) this->Init((req), (Compile*) this->_out) -#ifdef _MSC_VER // the IDX_INIT hack falls foul of warning C4355 -#pragma warning( disable:4355 ) // 'this' : used in base member initializer list -#endif -#ifdef __clang__ -#pragma clang diagnostic push -#pragma GCC diagnostic ignored "-Wuninitialized" -#endif - // Out-of-line code from node constructors. // Executed only when extra debug info. is being passed around. static void init_node_notes(Compile* C, int idx, Node_Notes* nn) { @@ -298,8 +281,8 @@ static void init_node_notes(Compile* C, int idx, Node_Notes* nn) { } // Shared initialization code. -inline int Node::Init(int req, Compile* C) { - assert(Compile::current() == C, "must use operator new(Compile*)"); +inline int Node::Init(int req) { + Compile* C = Compile::current(); int idx = C->next_unique(); // Allocate memory for the necessary number of edges. @@ -328,7 +311,7 @@ inline int Node::Init(int req, Compile* C) { //------------------------------Node------------------------------------------- // Create a Node, with a given number of required edges. Node::Node(uint req) - : _idx(IDX_INIT(req)) + : _idx(Init(req)) { assert( req < (uint)(MaxNodeLimit - NodeLimitFudgeFactor), "Input limit exceeded" ); debug_only( verify_construction() ); @@ -347,7 +330,7 @@ Node::Node(uint req) //------------------------------Node------------------------------------------- Node::Node(Node *n0) - : _idx(IDX_INIT(1)) + : _idx(Init(1)) { debug_only( verify_construction() ); NOT_PRODUCT(nodes_created++); @@ -359,7 +342,7 @@ Node::Node(Node *n0) //------------------------------Node------------------------------------------- Node::Node(Node *n0, Node *n1) - : _idx(IDX_INIT(2)) + : _idx(Init(2)) { debug_only( verify_construction() ); NOT_PRODUCT(nodes_created++); @@ -373,7 +356,7 @@ Node::Node(Node *n0, Node *n1) //------------------------------Node------------------------------------------- Node::Node(Node *n0, Node *n1, Node *n2) - : _idx(IDX_INIT(3)) + : _idx(Init(3)) { debug_only( verify_construction() ); NOT_PRODUCT(nodes_created++); @@ -389,7 +372,7 @@ Node::Node(Node *n0, Node *n1, Node *n2) //------------------------------Node------------------------------------------- Node::Node(Node *n0, Node *n1, Node *n2, Node *n3) - : _idx(IDX_INIT(4)) + : _idx(Init(4)) { debug_only( verify_construction() ); NOT_PRODUCT(nodes_created++); @@ -407,7 +390,7 @@ Node::Node(Node *n0, Node *n1, Node *n2, Node *n3) //------------------------------Node------------------------------------------- Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4) - : _idx(IDX_INIT(5)) + : _idx(Init(5)) { debug_only( verify_construction() ); NOT_PRODUCT(nodes_created++); @@ -428,7 +411,7 @@ Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4) //------------------------------Node------------------------------------------- Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4, Node *n5) - : _idx(IDX_INIT(6)) + : _idx(Init(6)) { debug_only( verify_construction() ); NOT_PRODUCT(nodes_created++); @@ -451,7 +434,7 @@ Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, //------------------------------Node------------------------------------------- Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, Node *n4, Node *n5, Node *n6) - : _idx(IDX_INIT(7)) + : _idx(Init(7)) { debug_only( verify_construction() ); NOT_PRODUCT(nodes_created++); @@ -473,10 +456,6 @@ Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, _in[6] = n6; if (n6 != NULL) n6->add_out((Node *)this); } -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - //------------------------------clone------------------------------------------ // Clone a Node. @@ -535,6 +514,9 @@ Node *Node::clone() const { if (n->is_Call()) { n->as_Call()->clone_jvms(C); } + if (n->is_SafePoint()) { + n->as_SafePoint()->clone_replaced_nodes(); + } return n; // Return the clone } @@ -630,6 +612,9 @@ void Node::destruct() { if (is_expensive()) { compile->remove_expensive_node(this); } + if (is_SafePoint()) { + as_SafePoint()->delete_replaced_nodes(); + } #ifdef ASSERT // We will not actually delete the storage, but we'll make the node unusable. *(address*)this = badAddress; // smash the C++ vtbl, probably @@ -1066,15 +1051,15 @@ const Type *Node::Value( PhaseTransform * ) const { // set_req(2, phase->intcon(7)); // return this; // Example: reshape "X*4" into "X<<2" -// return new (C) LShiftINode(in(1), phase->intcon(2)); +// return new LShiftINode(in(1), phase->intcon(2)); // // You must call 'phase->transform(X)' on any new Nodes X you make, except // for the returned root node. Example: reshape "X*31" with "(X<<5)-X". -// Node *shift=phase->transform(new(C)LShiftINode(in(1),phase->intcon(5))); -// return new (C) AddINode(shift, in(1)); +// Node *shift=phase->transform(new LShiftINode(in(1),phase->intcon(5))); +// return new AddINode(shift, in(1)); // // When making a Node for a constant use 'phase->makecon' or 'phase->intcon'. -// These forms are faster than 'phase->transform(new (C) ConNode())' and Do +// These forms are faster than 'phase->transform(new ConNode())' and Do // The Right Thing with def-use info. // // You cannot bury the 'this' Node inside of a graph reshape. If the reshaped diff --git a/hotspot/src/share/vm/opto/node.hpp b/hotspot/src/share/vm/opto/node.hpp index 67db16f154b..5bb9c6873d7 100644 --- a/hotspot/src/share/vm/opto/node.hpp +++ b/hotspot/src/share/vm/opto/node.hpp @@ -208,14 +208,12 @@ public: // field is a local cache of a value defined in some "program fragment" for // which these Nodes are just a part of. - // New Operator that takes a Compile pointer, this will eventually - // be the "new" New operator. - inline void* operator new( size_t x, Compile* C) throw() { + inline void* operator new(size_t x) throw() { + Compile* C = Compile::current(); Node* n = (Node*)C->node_arena()->Amalloc_D(x); #ifdef ASSERT n->_in = (Node**)n; // magic cookie for assertion check #endif - n->_out = (Node**)C; return (void*)n; } @@ -259,7 +257,7 @@ private: // Puts initial values in all Node fields except _idx. // Returns the initial value for _idx, which cannot // be initialized by assignment. - inline int Init(int req, Compile* C); + inline int Init(int req); //----------------- input edge handling protected: diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp index d47912f208c..be29ce452f8 100644 --- a/hotspot/src/share/vm/opto/output.cpp +++ b/hotspot/src/share/vm/opto/output.cpp @@ -67,7 +67,7 @@ void Compile::Output() { const StartNode *start = entry->head()->as_Start(); // Replace StartNode with prolog - MachPrologNode *prolog = new (this) MachPrologNode(); + MachPrologNode *prolog = new MachPrologNode(); entry->map_node(prolog, 0); _cfg->map_node_to_block(prolog, entry); _cfg->unmap_node_from_block(start); // start is no longer in any block @@ -77,12 +77,12 @@ void Compile::Output() { if( is_osr_compilation() ) { if( PoisonOSREntry ) { // TODO: Should use a ShouldNotReachHereNode... - _cfg->insert( broot, 0, new (this) MachBreakpointNode() ); + _cfg->insert( broot, 0, new MachBreakpointNode() ); } } else { if( _method && !_method->flags().is_static() ) { // Insert unvalidated entry point - _cfg->insert( broot, 0, new (this) MachUEPNode() ); + _cfg->insert( broot, 0, new MachUEPNode() ); } } @@ -98,7 +98,7 @@ void Compile::Output() { ) { // checking for _method means that OptoBreakpoint does not apply to // runtime stubs or frame converters - _cfg->insert( entry, 1, new (this) MachBreakpointNode() ); + _cfg->insert( entry, 1, new MachBreakpointNode() ); } // Insert epilogs before every return @@ -107,7 +107,7 @@ void Compile::Output() { if (!block->is_connector() && block->non_connector_successor(0) == _cfg->get_root_block()) { // Found a program exit point? Node* m = block->end(); if (m->is_Mach() && m->as_Mach()->ideal_Opcode() != Op_Halt) { - MachEpilogNode* epilog = new (this) MachEpilogNode(m->as_Mach()->ideal_Opcode() == Op_Return); + MachEpilogNode* epilog = new MachEpilogNode(m->as_Mach()->ideal_Opcode() == Op_Return); block->add_inst(epilog); _cfg->map_node_to_block(epilog, block); } @@ -268,7 +268,7 @@ void Compile::Insert_zap_nodes() { Node* Compile::call_zap_node(MachSafePointNode* node_to_check, int block_no) { const TypeFunc *tf = OptoRuntime::zap_dead_locals_Type(); CallStaticJavaNode* ideal_node = - new (this) CallStaticJavaNode( tf, + new CallStaticJavaNode( tf, OptoRuntime::zap_dead_locals_stub(_method->flags().is_native()), "call zap dead locals stub", 0, TypePtr::BOTTOM); // We need to copy the OopMap from the site we're zapping at. @@ -368,7 +368,7 @@ void Compile::shorten_branches(uint* blk_starts, int& code_size, int& reloc_size // Step one, perform a pessimistic sizing pass. uint last_call_adr = max_juint; uint last_avoid_back_to_back_adr = max_juint; - uint nop_size = (new (this) MachNopNode())->size(_regalloc); + uint nop_size = (new MachNopNode())->size(_regalloc); for (uint i = 0; i < nblocks; i++) { // For all blocks Block* block = _cfg->get_block(i); @@ -1201,7 +1201,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { uint *call_returns = NEW_RESOURCE_ARRAY(uint, nblocks+1); uint return_offset = 0; - int nop_size = (new (this) MachNopNode())->size(_regalloc); + int nop_size = (new MachNopNode())->size(_regalloc); int previous_offset = 0; int current_offset = 0; @@ -1327,7 +1327,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { if(padding > 0) { assert((padding % nop_size) == 0, "padding is not a multiple of NOP size"); int nops_cnt = padding / nop_size; - MachNode *nop = new (this) MachNopNode(nops_cnt); + MachNode *nop = new MachNopNode(nops_cnt); block->insert_node(nop, j++); last_inst++; _cfg->map_node_to_block(nop, block); @@ -1413,7 +1413,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { assert((br_size - new_size) >= (int)nop_size, "short_branch size should be smaller"); // Insert padding between avoid_back_to_back branches. if (needs_padding && replacement->avoid_back_to_back(MachNode::AVOID_BEFORE)) { - MachNode *nop = new (this) MachNopNode(); + MachNode *nop = new MachNopNode(); block->insert_node(nop, j++); _cfg->map_node_to_block(nop, block); last_inst++; @@ -1573,7 +1573,7 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { Block *nb = _cfg->get_block(i + 1); int padding = nb->alignment_padding(current_offset); if( padding > 0 ) { - MachNode *nop = new (this) MachNopNode(padding / nop_size); + MachNode *nop = new MachNopNode(padding / nop_size); block->insert_node(nop, block->number_of_nodes()); _cfg->map_node_to_block(nop, block); nop->emit(*cb, _regalloc); @@ -1786,7 +1786,7 @@ Scheduling::Scheduling(Arena *arena, Compile &compile) #endif { // Create a MachNopNode - _nop = new (&compile) MachNopNode(); + _nop = new MachNopNode(); // Now that the nops are in the array, save the count // (but allow entries for the nops) @@ -2688,7 +2688,7 @@ void Scheduling::anti_do_def( Block *b, Node *def, OptoReg::Name def_reg, int is if ( _pinch_free_list.size() > 0) { pinch = _pinch_free_list.pop(); } else { - pinch = new (_cfg->C) Node(1); // Pinch point to-be + pinch = new Node(1); // Pinch point to-be } if (pinch->_idx >= _regalloc->node_regs_max_index()) { _cfg->C->record_method_not_compilable("too many D-U pinch points"); diff --git a/hotspot/src/share/vm/opto/parse.hpp b/hotspot/src/share/vm/opto/parse.hpp index e810c9d4d58..fe941c07298 100644 --- a/hotspot/src/share/vm/opto/parse.hpp +++ b/hotspot/src/share/vm/opto/parse.hpp @@ -359,12 +359,13 @@ class Parse : public GraphKit { int _est_switch_depth; // Debugging SwitchRanges. #endif - // parser for the caller of the method of this object - Parse* const _parent; + bool _first_return; // true if return is the first to be parsed + bool _replaced_nodes_for_exceptions; // needs processing of replaced nodes in exception paths? + uint _new_idx; // any node with _idx above were new during this parsing. Used to trim the replaced nodes list. public: // Constructor - Parse(JVMState* caller, ciMethod* parse_method, float expected_uses, Parse* parent); + Parse(JVMState* caller, ciMethod* parse_method, float expected_uses); virtual Parse* is_Parse() const { return (Parse*)this; } @@ -425,8 +426,6 @@ 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(); diff --git a/hotspot/src/share/vm/opto/parse1.cpp b/hotspot/src/share/vm/opto/parse1.cpp index 6fea7130786..a758f72acdc 100644 --- a/hotspot/src/share/vm/opto/parse1.cpp +++ b/hotspot/src/share/vm/opto/parse1.cpp @@ -109,10 +109,10 @@ Node *Parse::fetch_interpreter_state(int index, // doubles on Sparc. Intel can handle them just fine directly. Node *l; switch (bt) { // Signature is flattened - case T_INT: l = new (C) LoadINode(ctl, mem, adr, TypeRawPtr::BOTTOM, TypeInt::INT, MemNode::unordered); break; - case T_FLOAT: l = new (C) LoadFNode(ctl, mem, adr, TypeRawPtr::BOTTOM, Type::FLOAT, MemNode::unordered); break; - case T_ADDRESS: l = new (C) LoadPNode(ctl, mem, adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM, MemNode::unordered); break; - case T_OBJECT: l = new (C) LoadPNode(ctl, mem, adr, TypeRawPtr::BOTTOM, TypeInstPtr::BOTTOM, MemNode::unordered); break; + case T_INT: l = new LoadINode(ctl, mem, adr, TypeRawPtr::BOTTOM, TypeInt::INT, MemNode::unordered); break; + case T_FLOAT: l = new LoadFNode(ctl, mem, adr, TypeRawPtr::BOTTOM, Type::FLOAT, MemNode::unordered); break; + case T_ADDRESS: l = new LoadPNode(ctl, mem, adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM, MemNode::unordered); break; + case T_OBJECT: l = new LoadPNode(ctl, mem, adr, TypeRawPtr::BOTTOM, TypeInstPtr::BOTTOM, MemNode::unordered); break; case T_LONG: case T_DOUBLE: { // Since arguments are in reverse order, the argument address 'adr' @@ -120,12 +120,12 @@ Node *Parse::fetch_interpreter_state(int index, adr = basic_plus_adr(local_addrs_base, local_addrs, -(index+1)*wordSize); if (Matcher::misaligned_doubles_ok) { l = (bt == T_DOUBLE) - ? (Node*)new (C) LoadDNode(ctl, mem, adr, TypeRawPtr::BOTTOM, Type::DOUBLE, MemNode::unordered) - : (Node*)new (C) LoadLNode(ctl, mem, adr, TypeRawPtr::BOTTOM, TypeLong::LONG, MemNode::unordered); + ? (Node*)new LoadDNode(ctl, mem, adr, TypeRawPtr::BOTTOM, Type::DOUBLE, MemNode::unordered) + : (Node*)new LoadLNode(ctl, mem, adr, TypeRawPtr::BOTTOM, TypeLong::LONG, MemNode::unordered); } else { l = (bt == T_DOUBLE) - ? (Node*)new (C) LoadD_unalignedNode(ctl, mem, adr, TypeRawPtr::BOTTOM, MemNode::unordered) - : (Node*)new (C) LoadL_unalignedNode(ctl, mem, adr, TypeRawPtr::BOTTOM, MemNode::unordered); + ? (Node*)new LoadD_unalignedNode(ctl, mem, adr, TypeRawPtr::BOTTOM, MemNode::unordered) + : (Node*)new LoadL_unalignedNode(ctl, mem, adr, TypeRawPtr::BOTTOM, MemNode::unordered); } break; } @@ -149,11 +149,11 @@ Node* Parse::check_interpreter_type(Node* l, const Type* type, if (type == TypePtr::NULL_PTR || (tp != NULL && !tp->klass()->is_loaded())) { // Value must be null, not a real oop. - Node* chk = _gvn.transform( new (C) CmpPNode(l, null()) ); - Node* tst = _gvn.transform( new (C) BoolNode(chk, BoolTest::eq) ); + Node* chk = _gvn.transform( new CmpPNode(l, null()) ); + Node* tst = _gvn.transform( new BoolNode(chk, BoolTest::eq) ); IfNode* iff = create_and_map_if(control(), tst, PROB_MAX, COUNT_UNKNOWN); - set_control(_gvn.transform( new (C) IfTrueNode(iff) )); - Node* bad_type = _gvn.transform( new (C) IfFalseNode(iff) ); + set_control(_gvn.transform( new IfTrueNode(iff) )); + Node* bad_type = _gvn.transform( new IfFalseNode(iff) ); bad_type_exit->control()->add_req(bad_type); l = null(); } @@ -220,7 +220,7 @@ void Parse::load_interpreter_state(Node* osr_buf) { Node *monitors_addr = basic_plus_adr(osr_buf, osr_buf, (max_locals+mcnt*2-1)*wordSize); for (index = 0; index < mcnt; index++) { // Make a BoxLockNode for the monitor. - Node *box = _gvn.transform(new (C) BoxLockNode(next_monitor())); + Node *box = _gvn.transform(new BoxLockNode(next_monitor())); // Displaced headers and locked objects are interleaved in the @@ -235,7 +235,7 @@ void Parse::load_interpreter_state(Node* osr_buf) { // Build a bogus FastLockNode (no code will be generated) and push the // monitor into our debug info. - const FastLockNode *flock = _gvn.transform(new (C) FastLockNode( 0, lock_object, box ))->as_FastLock(); + const FastLockNode *flock = _gvn.transform(new FastLockNode( 0, lock_object, box ))->as_FastLock(); map()->push_monitor(flock); // If the lock is our method synchronization lock, tuck it away in @@ -325,7 +325,7 @@ void Parse::load_interpreter_state(Node* osr_buf) { // Now that the interpreter state is loaded, make sure it will match // at execution time what the compiler is expecting now: SafePointNode* bad_type_exit = clone_map(); - bad_type_exit->set_control(new (C) RegionNode(1)); + bad_type_exit->set_control(new RegionNode(1)); assert(osr_block->flow()->jsrs()->size() == 0, "should be no jsrs live at osr point"); for (index = 0; index < max_locals; index++) { @@ -383,8 +383,8 @@ void Parse::load_interpreter_state(Node* osr_buf) { //------------------------------Parse------------------------------------------ // Main parser constructor. -Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses, Parse* parent) - : _exits(caller), _parent(parent) +Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses) + : _exits(caller) { // Init some variables _caller = caller; @@ -399,6 +399,9 @@ Parse::Parse(JVMState* caller, ciMethod* parse_method, float expected_uses, Pars _entry_bci = InvocationEntryBci; _tf = NULL; _block = NULL; + _first_return = true; + _replaced_nodes_for_exceptions = false; + _new_idx = C->unique(); debug_only(_block_count = -1); debug_only(_blocks = (Block*)-1); #ifndef PRODUCT @@ -661,7 +664,7 @@ void Parse::do_all_blocks() { add_predicate(); // Add new region for back branches. int edges = block->pred_count() - block->preds_parsed() + 1; // +1 for original region - RegionNode *r = new (C) RegionNode(edges+1); + RegionNode *r = new RegionNode(edges+1); _gvn.set_type(r, Type::CONTROL); record_for_igvn(r); r->init_req(edges, control()); @@ -728,14 +731,14 @@ void Parse::build_exits() { _exits.clean_stack(_exits.sp()); _exits.sync_jvms(); - RegionNode* region = new (C) RegionNode(1); + RegionNode* region = new RegionNode(1); record_for_igvn(region); gvn().set_type_bottom(region); _exits.set_control(region); // Note: iophi and memphi are not transformed until do_exits. - Node* iophi = new (C) PhiNode(region, Type::ABIO); - Node* memphi = new (C) PhiNode(region, Type::MEMORY, TypePtr::BOTTOM); + Node* iophi = new PhiNode(region, Type::ABIO); + Node* memphi = new PhiNode(region, Type::MEMORY, TypePtr::BOTTOM); gvn().set_type_bottom(iophi); gvn().set_type_bottom(memphi); _exits.set_i_o(iophi); @@ -752,7 +755,7 @@ void Parse::build_exits() { ret_type = TypeOopPtr::BOTTOM; } int ret_size = type2size[ret_type->basic_type()]; - Node* ret_phi = new (C) PhiNode(region, ret_type); + Node* ret_phi = new PhiNode(region, ret_type); gvn().set_type_bottom(ret_phi); _exits.ensure_stack(ret_size); assert((int)(tf()->range()->cnt() - TypeFunc::Parms) == ret_size, "good tf range"); @@ -770,7 +773,7 @@ JVMState* Compile::build_start_state(StartNode* start, const TypeFunc* tf) { int arg_size = tf->domain()->cnt(); int max_size = MAX2(arg_size, (int)tf->range()->cnt()); JVMState* jvms = new (this) JVMState(max_size - TypeFunc::Parms); - SafePointNode* map = new (this) SafePointNode(max_size, NULL); + SafePointNode* map = new SafePointNode(max_size, NULL); record_for_igvn(map); assert(arg_size == TypeFunc::Parms + (is_osr_compilation() ? 1 : method()->arg_size()), "correct arg_size"); Node_Notes* old_nn = default_node_notes(); @@ -784,7 +787,7 @@ JVMState* Compile::build_start_state(StartNode* start, const TypeFunc* tf) { } uint i; for (i = 0; i < (uint)arg_size; i++) { - Node* parm = initial_gvn()->transform(new (this) ParmNode(start, i)); + Node* parm = initial_gvn()->transform(new ParmNode(start, i)); map->init_req(i, parm); // Record all these guys for later GVN. record_for_igvn(parm); @@ -815,7 +818,7 @@ Node_Notes* Parse::make_node_notes(Node_Notes* caller_nn) { //--------------------------return_values-------------------------------------- void Compile::return_values(JVMState* jvms) { GraphKit kit(jvms); - Node* ret = new (this) ReturnNode(TypeFunc::Parms, + Node* ret = new ReturnNode(TypeFunc::Parms, kit.control(), kit.i_o(), kit.reset_memory(), @@ -843,7 +846,7 @@ void Compile::rethrow_exceptions(JVMState* jvms) { // Load my combined exception state into the kit, with all phis transformed: SafePointNode* ex_map = kit.combine_and_pop_all_exception_states(); Node* ex_oop = kit.use_exception_state(ex_map); - RethrowNode* exit = new (this) RethrowNode(kit.control(), + RethrowNode* exit = new RethrowNode(kit.control(), kit.i_o(), kit.reset_memory(), kit.frameptr(), kit.returnadr(), // like a return but with exception input @@ -901,6 +904,10 @@ void Parse::throw_to_exit(SafePointNode* ex_map) { for (uint i = 0; i < TypeFunc::Parms; i++) { caller.map()->set_req(i, ex_map->in(i)); } + if (ex_map->has_replaced_nodes()) { + _replaced_nodes_for_exceptions = true; + } + caller.map()->transfer_replaced_nodes_from(ex_map, _new_idx); // ...and the exception: Node* ex_oop = saved_ex_oop(ex_map); SafePointNode* caller_ex_map = caller.make_exception_state(ex_oop); @@ -991,7 +998,7 @@ void Parse::do_exits() { bool do_synch = method()->is_synchronized() && GenerateSynchronizationCode; // record exit from a method if compiled while Dtrace is turned on. - if (do_synch || C->env()->dtrace_method_probes()) { + if (do_synch || C->env()->dtrace_method_probes() || _replaced_nodes_for_exceptions) { // First move the exception list out of _exits: GraphKit kit(_exits.transfer_exceptions_into_jvms()); SafePointNode* normal_map = kit.map(); // keep this guy safe @@ -1016,6 +1023,9 @@ void Parse::do_exits() { if (C->env()->dtrace_method_probes()) { kit.make_dtrace_method_exit(method()); } + if (_replaced_nodes_for_exceptions) { + kit.map()->apply_replaced_nodes(); + } // Done with exception-path processing. ex_map = kit.make_exception_state(ex_oop); assert(ex_jvms->same_calls_as(ex_map->jvms()), "sanity"); @@ -1035,6 +1045,7 @@ void Parse::do_exits() { _exits.add_exception_state(ex_map); } } + _exits.map()->apply_replaced_nodes(); } //-----------------------------create_entry_map------------------------------- @@ -1049,6 +1060,9 @@ SafePointNode* Parse::create_entry_map() { return NULL; } + // clear current replaced nodes that are of no use from here on (map was cloned in build_exits). + _caller->map()->delete_replaced_nodes(); + // If this is an inlined method, we may have to do a receiver null check. if (_caller->has_method() && is_normal_parse() && !method()->is_static()) { GraphKit kit(_caller); @@ -1065,13 +1079,15 @@ SafePointNode* Parse::create_entry_map() { // Create an initial safepoint to hold JVM state during parsing JVMState* jvms = new (C) JVMState(method(), _caller->has_method() ? _caller : NULL); - set_map(new (C) SafePointNode(len, jvms)); + set_map(new SafePointNode(len, jvms)); jvms->set_map(map()); record_for_igvn(map()); assert(jvms->endoff() == len, "correct jvms sizing"); SafePointNode* inmap = _caller->map(); assert(inmap != NULL, "must have inmap"); + // In case of null check on receiver above + map()->transfer_replaced_nodes_from(inmap, _new_idx); uint i; @@ -1578,7 +1594,7 @@ void Parse::merge_common(Parse::Block* target, int pnum) { // later lazily. int edges = target->pred_count(); if (edges < pnum) edges = pnum; // might be a new path! - RegionNode *r = new (C) RegionNode(edges+1); + RegionNode *r = new RegionNode(edges+1); gvn().set_type(r, Type::CONTROL); record_for_igvn(r); // zap all inputs to NULL for debugging (done in Node(uint) constructor) @@ -1701,6 +1717,8 @@ void Parse::merge_common(Parse::Block* target, int pnum) { set_control(r->nonnull_req()); } + map()->merge_replaced_nodes_with(newin); + // newin has been subsumed into the lazy merge, and is now dead. set_block(save_block); @@ -1973,19 +1991,19 @@ void Parse::call_register_finalizer() { Node* access_flags_addr = basic_plus_adr(klass, klass, in_bytes(Klass::access_flags_offset())); Node* access_flags = make_load(NULL, access_flags_addr, TypeInt::INT, T_INT, MemNode::unordered); - Node* mask = _gvn.transform(new (C) AndINode(access_flags, intcon(JVM_ACC_HAS_FINALIZER))); - Node* check = _gvn.transform(new (C) CmpINode(mask, intcon(0))); - Node* test = _gvn.transform(new (C) BoolNode(check, BoolTest::ne)); + Node* mask = _gvn.transform(new AndINode(access_flags, intcon(JVM_ACC_HAS_FINALIZER))); + Node* check = _gvn.transform(new CmpINode(mask, intcon(0))); + Node* test = _gvn.transform(new BoolNode(check, BoolTest::ne)); IfNode* iff = create_and_map_if(control(), test, PROB_MAX, COUNT_UNKNOWN); - RegionNode* result_rgn = new (C) RegionNode(3); + RegionNode* result_rgn = new RegionNode(3); record_for_igvn(result_rgn); - Node *skip_register = _gvn.transform(new (C) IfFalseNode(iff)); + Node *skip_register = _gvn.transform(new IfFalseNode(iff)); result_rgn->init_req(1, skip_register); - Node *needs_register = _gvn.transform(new (C) IfTrueNode(iff)); + Node *needs_register = _gvn.transform(new IfTrueNode(iff)); set_control(needs_register); if (stopped()) { // There is no slow path. @@ -2039,9 +2057,9 @@ void Parse::rtm_deopt() { // or with ProfileRTM (cmp->in(2)) otherwise so that // the check will fold. Node* profile_state = makecon(TypeInt::make(ProfileRTM)); - Node* opq = _gvn.transform( new (C) Opaque3Node(C, rtm_state, Opaque3Node::RTM_OPT) ); - Node* chk = _gvn.transform( new (C) CmpINode(opq, profile_state) ); - Node* tst = _gvn.transform( new (C) BoolNode(chk, BoolTest::eq) ); + Node* opq = _gvn.transform( new Opaque3Node(C, rtm_state, Opaque3Node::RTM_OPT) ); + Node* chk = _gvn.transform( new CmpINode(opq, profile_state) ); + Node* tst = _gvn.transform( new BoolNode(chk, BoolTest::eq) ); // Branch to failure if state was changed { BuildCutout unless(this, tst, PROB_ALWAYS); uncommon_trap(Deoptimization::Reason_rtm_state_change, @@ -2066,10 +2084,10 @@ void Parse::decrement_age() { Node* mc_adr = makecon(adr_type); Node* cnt_adr = basic_plus_adr(mc_adr, mc_adr, in_bytes(MethodCounters::nmethod_age_offset())); Node* cnt = make_load(control(), cnt_adr, TypeInt::INT, T_INT, adr_type, MemNode::unordered); - Node* decr = _gvn.transform(new (C) SubINode(cnt, makecon(TypeInt::ONE))); + Node* decr = _gvn.transform(new SubINode(cnt, makecon(TypeInt::ONE))); store_to_memory(control(), cnt_adr, decr, T_INT, adr_type, MemNode::unordered); - Node *chk = _gvn.transform(new (C) CmpINode(decr, makecon(TypeInt::ZERO))); - Node* tst = _gvn.transform(new (C) BoolNode(chk, BoolTest::gt)); + Node *chk = _gvn.transform(new CmpINode(decr, makecon(TypeInt::ZERO))); + Node* tst = _gvn.transform(new BoolNode(chk, BoolTest::gt)); { BuildCutout unless(this, tst, PROB_ALWAYS); uncommon_trap(Deoptimization::Reason_tenured, Deoptimization::Action_make_not_entrant); @@ -2124,12 +2142,19 @@ void Parse::return_current(Node* value) { // sharpen the type eagerly; this eases certain assert checking if (tp->higher_equal(TypeInstPtr::NOTNULL)) tr = tr->join_speculative(TypeInstPtr::NOTNULL)->is_instptr(); - value = _gvn.transform(new (C) CheckCastPPNode(0,value,tr)); + value = _gvn.transform(new CheckCastPPNode(0,value,tr)); } } phi->add_req(value); } + if (_first_return) { + _exits.map()->transfer_replaced_nodes_from(map(), _new_idx); + _first_return = false; + } else { + _exits.map()->merge_replaced_nodes_with(map()); + } + stop_and_kill_map(); // This CFG path dies here } @@ -2159,7 +2184,7 @@ void Parse::add_safepoint() { kill_dead_locals(); // Clone the JVM State - SafePointNode *sfpnt = new (C) SafePointNode(parms, NULL); + SafePointNode *sfpnt = new SafePointNode(parms, NULL); // Capture memory state BEFORE a SafePoint. Since we can block at a // SafePoint we need our GC state to be safe; i.e. we need all our current diff --git a/hotspot/src/share/vm/opto/parse2.cpp b/hotspot/src/share/vm/opto/parse2.cpp index 1f085a0223b..15826863ee5 100644 --- a/hotspot/src/share/vm/opto/parse2.cpp +++ b/hotspot/src/share/vm/opto/parse2.cpp @@ -130,9 +130,9 @@ Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) { Node* len = load_array_length(ary); // Test length vs index (standard trick using unsigned compare) - Node* chk = _gvn.transform( new (C) CmpUNode(idx, len) ); + Node* chk = _gvn.transform( new CmpUNode(idx, len) ); BoolTest::mask btest = BoolTest::lt; - tst = _gvn.transform( new (C) BoolNode(chk, btest) ); + tst = _gvn.transform( new BoolNode(chk, btest) ); } // Branch to failure if out of bounds { BuildCutout unless(this, tst, PROB_MAX); @@ -168,15 +168,15 @@ Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) { // returns IfNode IfNode* Parse::jump_if_fork_int(Node* a, Node* b, BoolTest::mask mask) { - Node *cmp = _gvn.transform( new (C) CmpINode( a, b)); // two cases: shiftcount > 32 and shiftcount <= 32 - Node *tst = _gvn.transform( new (C) BoolNode( cmp, mask)); + Node *cmp = _gvn.transform( new CmpINode( a, b)); // two cases: shiftcount > 32 and shiftcount <= 32 + Node *tst = _gvn.transform( new BoolNode( cmp, mask)); IfNode *iff = create_and_map_if( control(), tst, ((mask == BoolTest::eq) ? PROB_STATIC_INFREQUENT : PROB_FAIR), COUNT_UNKNOWN ); return iff; } // return Region node Node* Parse::jump_if_join(Node* iffalse, Node* iftrue) { - Node *region = new (C) RegionNode(3); // 2 results + Node *region = new RegionNode(3); // 2 results record_for_igvn(region); region->init_req(1, iffalse); region->init_req(2, iftrue ); @@ -191,28 +191,28 @@ Node* Parse::jump_if_join(Node* iffalse, Node* iftrue) { void Parse::jump_if_true_fork(IfNode *iff, int dest_bci_if_true, int prof_table_index) { // True branch, use existing map info { PreserveJVMState pjvms(this); - Node *iftrue = _gvn.transform( new (C) IfTrueNode (iff) ); + Node *iftrue = _gvn.transform( new IfTrueNode (iff) ); set_control( iftrue ); profile_switch_case(prof_table_index); merge_new_path(dest_bci_if_true); } // False branch - Node *iffalse = _gvn.transform( new (C) IfFalseNode(iff) ); + Node *iffalse = _gvn.transform( new IfFalseNode(iff) ); set_control( iffalse ); } void Parse::jump_if_false_fork(IfNode *iff, int dest_bci_if_true, int prof_table_index) { // True branch, use existing map info { PreserveJVMState pjvms(this); - Node *iffalse = _gvn.transform( new (C) IfFalseNode (iff) ); + Node *iffalse = _gvn.transform( new IfFalseNode (iff) ); set_control( iffalse ); profile_switch_case(prof_table_index); merge_new_path(dest_bci_if_true); } // False branch - Node *iftrue = _gvn.transform( new (C) IfTrueNode(iff) ); + Node *iftrue = _gvn.transform( new IfTrueNode(iff) ); set_control( iftrue ); } @@ -440,14 +440,14 @@ bool Parse::create_jump_tables(Node* key_val, SwitchRange* lo, SwitchRange* hi) // Normalize table lookups to zero int lowval = lo->lo(); - key_val = _gvn.transform( new (C) SubINode(key_val, _gvn.intcon(lowval)) ); + key_val = _gvn.transform( new SubINode(key_val, _gvn.intcon(lowval)) ); // Generate a guard to protect against input keyvals that aren't // in the switch domain. if (needs_guard) { Node* size = _gvn.intcon(num_cases); - Node* cmp = _gvn.transform( new (C) CmpUNode(key_val, size) ); - Node* tst = _gvn.transform( new (C) BoolNode(cmp, BoolTest::ge) ); + Node* cmp = _gvn.transform( new CmpUNode(key_val, size) ); + Node* tst = _gvn.transform( new BoolNode(cmp, BoolTest::ge) ); IfNode* iff = create_and_map_if( control(), tst, PROB_FAIR, COUNT_UNKNOWN); jump_if_true_fork(iff, default_dest, NullTableIndex); } @@ -460,21 +460,21 @@ bool Parse::create_jump_tables(Node* key_val, SwitchRange* lo, SwitchRange* hi) // Clean the 32-bit int into a real 64-bit offset. // Otherwise, the jint value 0 might turn into an offset of 0x0800000000. const TypeLong* lkeytype = TypeLong::make(CONST64(0), num_cases-1, Type::WidenMin); - key_val = _gvn.transform( new (C) ConvI2LNode(key_val, lkeytype) ); + key_val = _gvn.transform( new ConvI2LNode(key_val, lkeytype) ); #endif // Shift the value by wordsize so we have an index into the table, rather // than a switch value Node *shiftWord = _gvn.MakeConX(wordSize); - key_val = _gvn.transform( new (C) MulXNode( key_val, shiftWord)); + key_val = _gvn.transform( new MulXNode( key_val, shiftWord)); // Create the JumpNode - Node* jtn = _gvn.transform( new (C) JumpNode(control(), key_val, num_cases) ); + Node* jtn = _gvn.transform( new JumpNode(control(), key_val, num_cases) ); // These are the switch destinations hanging off the jumpnode int i = 0; for (SwitchRange* r = lo; r <= hi; r++) { for (int64_t j = r->lo(); j <= r->hi(); j++, i++) { - Node* input = _gvn.transform(new (C) JumpProjNode(jtn, i, r->dest(), (int)(j - lowval))); + Node* input = _gvn.transform(new JumpProjNode(jtn, i, r->dest(), (int)(j - lowval))); { PreserveJVMState pjvms(this); set_control(input); @@ -575,8 +575,8 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, // two comparisons of same values--should enable 1 test for 2 branches // Use BoolTest::le instead of BoolTest::gt IfNode *iff_le = jump_if_fork_int(key_val, test_val, BoolTest::le); - Node *iftrue = _gvn.transform( new (C) IfTrueNode(iff_le) ); - Node *iffalse = _gvn.transform( new (C) IfFalseNode(iff_le) ); + Node *iftrue = _gvn.transform( new IfTrueNode(iff_le) ); + Node *iffalse = _gvn.transform( new IfFalseNode(iff_le) ); { PreserveJVMState pjvms(this); set_control(iffalse); jump_switch_ranges(key_val, mid+1, hi, switch_depth+1); @@ -592,8 +592,8 @@ void Parse::jump_switch_ranges(Node* key_val, SwitchRange *lo, SwitchRange *hi, if (mid == hi) { jump_if_true_fork(iff_ge, mid->dest(), mid->table_index()); } else { - Node *iftrue = _gvn.transform( new (C) IfTrueNode(iff_ge) ); - Node *iffalse = _gvn.transform( new (C) IfFalseNode(iff_ge) ); + Node *iftrue = _gvn.transform( new IfTrueNode(iff_ge) ); + Node *iffalse = _gvn.transform( new IfFalseNode(iff_ge) ); { PreserveJVMState pjvms(this); set_control(iftrue); jump_switch_ranges(key_val, mid, hi, switch_depth+1); @@ -648,7 +648,7 @@ void Parse::modf() { CAST_FROM_FN_PTR(address, SharedRuntime::frem), "frem", NULL, //no memory effects f1, f2); - Node* res = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0)); + Node* res = _gvn.transform(new ProjNode(c, TypeFunc::Parms + 0)); push(res); } @@ -660,10 +660,10 @@ void Parse::modd() { CAST_FROM_FN_PTR(address, SharedRuntime::drem), "drem", NULL, //no memory effects d1, top(), d2, top()); - Node* res_d = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0)); + Node* res_d = _gvn.transform(new ProjNode(c, TypeFunc::Parms + 0)); #ifdef ASSERT - Node* res_top = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 1)); + Node* res_top = _gvn.transform(new ProjNode(c, TypeFunc::Parms + 1)); assert(res_top == top(), "second value must be top"); #endif @@ -677,7 +677,7 @@ void Parse::l2f() { CAST_FROM_FN_PTR(address, SharedRuntime::l2f), "l2f", NULL, //no memory effects f1, f2); - Node* res = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms + 0)); + Node* res = _gvn.transform(new ProjNode(c, TypeFunc::Parms + 0)); push(res); } @@ -704,17 +704,17 @@ void Parse::do_irem() { // Sigh, must handle negative dividends Node *zero = _gvn.intcon(0); IfNode *ifff = jump_if_fork_int(a, zero, BoolTest::lt); - Node *iff = _gvn.transform( new (C) IfFalseNode(ifff) ); - Node *ift = _gvn.transform( new (C) IfTrueNode (ifff) ); + Node *iff = _gvn.transform( new IfFalseNode(ifff) ); + Node *ift = _gvn.transform( new IfTrueNode (ifff) ); Node *reg = jump_if_join(ift, iff); Node *phi = PhiNode::make(reg, NULL, TypeInt::INT); // Negative path; negate/and/negate - Node *neg = _gvn.transform( new (C) SubINode(zero, a) ); - Node *andn= _gvn.transform( new (C) AndINode(neg, mask) ); - Node *negn= _gvn.transform( new (C) SubINode(zero, andn) ); + Node *neg = _gvn.transform( new SubINode(zero, a) ); + Node *andn= _gvn.transform( new AndINode(neg, mask) ); + Node *negn= _gvn.transform( new SubINode(zero, andn) ); phi->init_req(1, negn); // Fast positive case - Node *andx = _gvn.transform( new (C) AndINode(a, mask) ); + Node *andx = _gvn.transform( new AndINode(a, mask) ); phi->init_req(2, andx); // Push the merge push( _gvn.transform(phi) ); @@ -723,7 +723,7 @@ void Parse::do_irem() { } } // Default case - push( _gvn.transform( new (C) ModINode(control(),a,b) ) ); + push( _gvn.transform( new ModINode(control(),a,b) ) ); } // Handle jsr and jsr_w bytecode @@ -897,53 +897,12 @@ bool Parse::seems_never_taken(float prob) { // if a path is never taken, its controlling comparison is // already acting in a stable fashion. If the comparison // seems stable, we will put an expensive uncommon trap -// on the untaken path. To be conservative, and to allow -// partially executed counted loops to be compiled fully, -// we will plant uncommon traps only after pointer comparisons. +// on the untaken path. bool Parse::seems_stable_comparison(BoolTest::mask btest, Node* cmp) { - for (int depth = 4; depth > 0; depth--) { - // The following switch can find CmpP here over half the time for - // dynamic language code rich with type tests. - // Code using counted loops or array manipulations (typical - // of benchmarks) will have many (>80%) CmpI instructions. - switch (cmp->Opcode()) { - case Op_CmpP: - // A never-taken null check looks like CmpP/BoolTest::eq. - // These certainly should be closed off as uncommon traps. - if (btest == BoolTest::eq) - return true; - // A never-failed type check looks like CmpP/BoolTest::ne. - // Let's put traps on those, too, so that we don't have to compile - // unused paths with indeterminate dynamic type information. - if (ProfileDynamicTypes) - return true; - return false; - - case Op_CmpI: - // A small minority (< 10%) of CmpP are masked as CmpI, - // as if by boolean conversion ((p == q? 1: 0) != 0). - // Detect that here, even if it hasn't optimized away yet. - // Specifically, this covers the 'instanceof' operator. - if (btest == BoolTest::ne || btest == BoolTest::eq) { - if (_gvn.type(cmp->in(2))->singleton() && - cmp->in(1)->is_Phi()) { - PhiNode* phi = cmp->in(1)->as_Phi(); - int true_path = phi->is_diamond_phi(); - if (true_path > 0 && - _gvn.type(phi->in(1))->singleton() && - _gvn.type(phi->in(2))->singleton()) { - // phi->region->if_proj->ifnode->bool->cmp - BoolNode* bol = phi->in(0)->in(1)->in(0)->in(1)->as_Bool(); - btest = bol->_test._test; - cmp = bol->in(1); - continue; - } - } - } - return false; - } + if (C->too_many_traps(method(), bci(), Deoptimization::Reason_unstable_if)) { + return false; } - return false; + return true; } //-------------------------------repush_if_args-------------------------------- @@ -1000,7 +959,7 @@ void Parse::do_ifnull(BoolTest::mask btest, Node *c) { explicit_null_checks_inserted++; // Generate real control flow - Node *tst = _gvn.transform( new (C) BoolNode( c, btest ) ); + Node *tst = _gvn.transform( new BoolNode( c, btest ) ); // Sanity check the probability value assert(prob > 0.0f,"Bad probability in Parser"); @@ -1009,7 +968,7 @@ void Parse::do_ifnull(BoolTest::mask btest, Node *c) { assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser"); // True branch { PreserveJVMState pjvms(this); - Node* iftrue = _gvn.transform( new (C) IfTrueNode (iff) ); + Node* iftrue = _gvn.transform( new IfTrueNode (iff) ); set_control(iftrue); if (stopped()) { // Path is dead? @@ -1029,7 +988,7 @@ void Parse::do_ifnull(BoolTest::mask btest, Node *c) { } // False branch - Node* iffalse = _gvn.transform( new (C) IfFalseNode(iff) ); + Node* iffalse = _gvn.transform( new IfFalseNode(iff) ); set_control(iffalse); if (stopped()) { // Path is dead? @@ -1092,7 +1051,7 @@ void Parse::do_if(BoolTest::mask btest, Node* c) { } assert(btest != BoolTest::eq, "!= is the only canonical exact test"); - Node* tst0 = new (C) BoolNode(c, btest); + Node* tst0 = new BoolNode(c, btest); Node* tst = _gvn.transform(tst0); BoolTest::mask taken_btest = BoolTest::illegal; BoolTest::mask untaken_btest = BoolTest::illegal; @@ -1123,8 +1082,8 @@ void Parse::do_if(BoolTest::mask btest, Node* c) { float true_prob = (taken_if_true ? prob : untaken_prob); IfNode* iff = create_and_map_if(control(), tst, true_prob, cnt); assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser"); - Node* taken_branch = new (C) IfTrueNode(iff); - Node* untaken_branch = new (C) IfFalseNode(iff); + Node* taken_branch = new IfTrueNode(iff); + Node* untaken_branch = new IfFalseNode(iff); if (!taken_if_true) { // Finish conversion to canonical form Node* tmp = taken_branch; taken_branch = untaken_branch; @@ -1182,32 +1141,8 @@ void Parse::adjust_map_after_if(BoolTest::mask btest, Node* c, float prob, bool is_fallthrough = (path == successor_for_bci(iter().next_bci())); if (seems_never_taken(prob) && seems_stable_comparison(btest, c)) { - // If this might possibly turn into an implicit null check, - // and the null has never yet been seen, we need to generate - // an uncommon trap, so as to recompile instead of suffering - // with very slow branches. (We'll get the slow branches if - // the program ever changes phase and starts seeing nulls here.) - // - // We do not inspect for a null constant, since a node may - // optimize to 'null' later on. - // - // Null checks, and other tests which expect inequality, - // show btest == BoolTest::eq along the non-taken branch. - // On the other hand, type tests, must-be-null tests, - // and other tests which expect pointer equality, - // show btest == BoolTest::ne along the non-taken branch. - // We prune both types of branches if they look unused. repush_if_args(); - // We need to mark this branch as taken so that if we recompile we will - // see that it is possible. In the tiered system the interpreter doesn't - // do profiling and by the time we get to the lower tier from the interpreter - // the path may be cold again. Make sure it doesn't look untaken - if (is_fallthrough) { - profile_not_taken_branch(!ProfileInterpreter); - } else { - profile_taken_branch(iter().get_dest(), !ProfileInterpreter); - } - uncommon_trap(Deoptimization::Reason_unreached, + uncommon_trap(Deoptimization::Reason_unstable_if, Deoptimization::Action_reinterpret, NULL, (is_fallthrough ? "taken always" : "taken never")); @@ -1288,7 +1223,7 @@ void Parse::sharpen_type_after_if(BoolTest::mask btest, JVMState* jvms = this->jvms(); if (obj_in_map >= 0 && (jvms->is_loc(obj_in_map) || jvms->is_stk(obj_in_map))) { - TypeNode* ccast = new (C) CheckCastPPNode(control(), obj, tboth); + TypeNode* ccast = new CheckCastPPNode(control(), obj, tboth); const Type* tcc = ccast->as_Type()->type(); assert(tcc != obj_type && tcc->higher_equal(obj_type), "must improve"); // Delay transform() call to allow recovery of pre-cast value @@ -1323,10 +1258,10 @@ void Parse::sharpen_type_after_if(BoolTest::mask btest, const Type* tboth = tcon->join_speculative(tval); if (tboth == tval) break; // Nothing to gain. if (tcon->isa_int()) { - ccast = new (C) CastIINode(val, tboth); + ccast = new CastIINode(val, tboth); } else if (tcon == TypePtr::NULL_PTR) { // Cast to null, but keep the pointer identity temporarily live. - ccast = new (C) CastPPNode(val, tboth); + ccast = new CastPPNode(val, tboth); } else { const TypeF* tf = tcon->isa_float_constant(); const TypeD* td = tcon->isa_double_constant(); @@ -1792,59 +1727,59 @@ void Parse::do_one_bytecode() { if (stopped()) return; b = pop(); a = pop(); - push( _gvn.transform( new (C) DivINode(control(),a,b) ) ); + push( _gvn.transform( new DivINode(control(),a,b) ) ); break; case Bytecodes::_imul: b = pop(); a = pop(); - push( _gvn.transform( new (C) MulINode(a,b) ) ); + push( _gvn.transform( new MulINode(a,b) ) ); break; case Bytecodes::_iadd: b = pop(); a = pop(); - push( _gvn.transform( new (C) AddINode(a,b) ) ); + push( _gvn.transform( new AddINode(a,b) ) ); break; case Bytecodes::_ineg: a = pop(); - push( _gvn.transform( new (C) SubINode(_gvn.intcon(0),a)) ); + push( _gvn.transform( new SubINode(_gvn.intcon(0),a)) ); break; case Bytecodes::_isub: b = pop(); a = pop(); - push( _gvn.transform( new (C) SubINode(a,b) ) ); + push( _gvn.transform( new SubINode(a,b) ) ); break; case Bytecodes::_iand: b = pop(); a = pop(); - push( _gvn.transform( new (C) AndINode(a,b) ) ); + push( _gvn.transform( new AndINode(a,b) ) ); break; case Bytecodes::_ior: b = pop(); a = pop(); - push( _gvn.transform( new (C) OrINode(a,b) ) ); + push( _gvn.transform( new OrINode(a,b) ) ); break; case Bytecodes::_ixor: b = pop(); a = pop(); - push( _gvn.transform( new (C) XorINode(a,b) ) ); + push( _gvn.transform( new XorINode(a,b) ) ); break; case Bytecodes::_ishl: b = pop(); a = pop(); - push( _gvn.transform( new (C) LShiftINode(a,b) ) ); + push( _gvn.transform( new LShiftINode(a,b) ) ); break; case Bytecodes::_ishr: b = pop(); a = pop(); - push( _gvn.transform( new (C) RShiftINode(a,b) ) ); + push( _gvn.transform( new RShiftINode(a,b) ) ); break; case Bytecodes::_iushr: b = pop(); a = pop(); - push( _gvn.transform( new (C) URShiftINode(a,b) ) ); + push( _gvn.transform( new URShiftINode(a,b) ) ); break; case Bytecodes::_fneg: a = pop(); - b = _gvn.transform(new (C) NegFNode (a)); + b = _gvn.transform(new NegFNode (a)); push(b); break; case Bytecodes::_fsub: b = pop(); a = pop(); - c = _gvn.transform( new (C) SubFNode(a,b) ); + c = _gvn.transform( new SubFNode(a,b) ); d = precision_rounding(c); push( d ); break; @@ -1852,7 +1787,7 @@ void Parse::do_one_bytecode() { case Bytecodes::_fadd: b = pop(); a = pop(); - c = _gvn.transform( new (C) AddFNode(a,b) ); + c = _gvn.transform( new AddFNode(a,b) ); d = precision_rounding(c); push( d ); break; @@ -1860,7 +1795,7 @@ void Parse::do_one_bytecode() { case Bytecodes::_fmul: b = pop(); a = pop(); - c = _gvn.transform( new (C) MulFNode(a,b) ); + c = _gvn.transform( new MulFNode(a,b) ); d = precision_rounding(c); push( d ); break; @@ -1868,7 +1803,7 @@ void Parse::do_one_bytecode() { case Bytecodes::_fdiv: b = pop(); a = pop(); - c = _gvn.transform( new (C) DivFNode(0,a,b) ); + c = _gvn.transform( new DivFNode(0,a,b) ); d = precision_rounding(c); push( d ); break; @@ -1878,7 +1813,7 @@ void Parse::do_one_bytecode() { // Generate a ModF node. b = pop(); a = pop(); - c = _gvn.transform( new (C) ModFNode(0,a,b) ); + c = _gvn.transform( new ModFNode(0,a,b) ); d = precision_rounding(c); push( d ); } @@ -1891,7 +1826,7 @@ void Parse::do_one_bytecode() { case Bytecodes::_fcmpl: b = pop(); a = pop(); - c = _gvn.transform( new (C) CmpF3Node( a, b)); + c = _gvn.transform( new CmpF3Node( a, b)); push(c); break; case Bytecodes::_fcmpg: @@ -1903,40 +1838,40 @@ void Parse::do_one_bytecode() { // as well by using CmpF3 which implements unordered-lesser instead of // unordered-greater semantics. Finally, commute the result bits. Result // is same as using a CmpF3Greater except we did it with CmpF3 alone. - c = _gvn.transform( new (C) CmpF3Node( b, a)); - c = _gvn.transform( new (C) SubINode(_gvn.intcon(0),c) ); + c = _gvn.transform( new CmpF3Node( b, a)); + c = _gvn.transform( new SubINode(_gvn.intcon(0),c) ); push(c); break; case Bytecodes::_f2i: a = pop(); - push(_gvn.transform(new (C) ConvF2INode(a))); + push(_gvn.transform(new ConvF2INode(a))); break; case Bytecodes::_d2i: a = pop_pair(); - b = _gvn.transform(new (C) ConvD2INode(a)); + b = _gvn.transform(new ConvD2INode(a)); push( b ); break; case Bytecodes::_f2d: a = pop(); - b = _gvn.transform( new (C) ConvF2DNode(a)); + b = _gvn.transform( new ConvF2DNode(a)); push_pair( b ); break; case Bytecodes::_d2f: a = pop_pair(); - b = _gvn.transform( new (C) ConvD2FNode(a)); + b = _gvn.transform( new ConvD2FNode(a)); // This breaks _227_mtrt (speed & correctness) and _222_mpegaudio (speed) - //b = _gvn.transform(new (C) RoundFloatNode(0, b) ); + //b = _gvn.transform(new RoundFloatNode(0, b) ); push( b ); break; case Bytecodes::_l2f: if (Matcher::convL2FSupported()) { a = pop_pair(); - b = _gvn.transform( new (C) ConvL2FNode(a)); + b = _gvn.transform( new ConvL2FNode(a)); // For i486.ad, FILD doesn't restrict precision to 24 or 53 bits. // Rather than storing the result into an FP register then pushing // out to memory to round, the machine instruction that implements @@ -1951,7 +1886,7 @@ void Parse::do_one_bytecode() { case Bytecodes::_l2d: a = pop_pair(); - b = _gvn.transform( new (C) ConvL2DNode(a)); + b = _gvn.transform( new ConvL2DNode(a)); // For i486.ad, rounding is always necessary (see _l2f above). // c = dprecision_rounding(b); c = _gvn.transform(b); @@ -1960,20 +1895,20 @@ void Parse::do_one_bytecode() { case Bytecodes::_f2l: a = pop(); - b = _gvn.transform( new (C) ConvF2LNode(a)); + b = _gvn.transform( new ConvF2LNode(a)); push_pair(b); break; case Bytecodes::_d2l: a = pop_pair(); - b = _gvn.transform( new (C) ConvD2LNode(a)); + b = _gvn.transform( new ConvD2LNode(a)); push_pair(b); break; case Bytecodes::_dsub: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) SubDNode(a,b) ); + c = _gvn.transform( new SubDNode(a,b) ); d = dprecision_rounding(c); push_pair( d ); break; @@ -1981,7 +1916,7 @@ void Parse::do_one_bytecode() { case Bytecodes::_dadd: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) AddDNode(a,b) ); + c = _gvn.transform( new AddDNode(a,b) ); d = dprecision_rounding(c); push_pair( d ); break; @@ -1989,7 +1924,7 @@ void Parse::do_one_bytecode() { case Bytecodes::_dmul: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) MulDNode(a,b) ); + c = _gvn.transform( new MulDNode(a,b) ); d = dprecision_rounding(c); push_pair( d ); break; @@ -1997,14 +1932,14 @@ void Parse::do_one_bytecode() { case Bytecodes::_ddiv: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) DivDNode(0,a,b) ); + c = _gvn.transform( new DivDNode(0,a,b) ); d = dprecision_rounding(c); push_pair( d ); break; case Bytecodes::_dneg: a = pop_pair(); - b = _gvn.transform(new (C) NegDNode (a)); + b = _gvn.transform(new NegDNode (a)); push_pair(b); break; @@ -2015,7 +1950,7 @@ void Parse::do_one_bytecode() { a = pop_pair(); // a % b - c = _gvn.transform( new (C) ModDNode(0,a,b) ); + c = _gvn.transform( new ModDNode(0,a,b) ); d = dprecision_rounding(c); push_pair( d ); } @@ -2028,7 +1963,7 @@ void Parse::do_one_bytecode() { case Bytecodes::_dcmpl: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) CmpD3Node( a, b)); + c = _gvn.transform( new CmpD3Node( a, b)); push(c); break; @@ -2041,8 +1976,8 @@ void Parse::do_one_bytecode() { // unordered-lesser instead of unordered-greater semantics. // Finally, negate the result bits. Result is same as using a // CmpD3Greater except we did it with CmpD3 alone. - c = _gvn.transform( new (C) CmpD3Node( b, a)); - c = _gvn.transform( new (C) SubINode(_gvn.intcon(0),c) ); + c = _gvn.transform( new CmpD3Node( b, a)); + c = _gvn.transform( new SubINode(_gvn.intcon(0),c) ); push(c); break; @@ -2051,44 +1986,44 @@ void Parse::do_one_bytecode() { case Bytecodes::_land: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) AndLNode(a,b) ); + c = _gvn.transform( new AndLNode(a,b) ); push_pair(c); break; case Bytecodes::_lor: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) OrLNode(a,b) ); + c = _gvn.transform( new OrLNode(a,b) ); push_pair(c); break; case Bytecodes::_lxor: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) XorLNode(a,b) ); + c = _gvn.transform( new XorLNode(a,b) ); push_pair(c); break; case Bytecodes::_lshl: b = pop(); // the shift count a = pop_pair(); // value to be shifted - c = _gvn.transform( new (C) LShiftLNode(a,b) ); + c = _gvn.transform( new LShiftLNode(a,b) ); push_pair(c); break; case Bytecodes::_lshr: b = pop(); // the shift count a = pop_pair(); // value to be shifted - c = _gvn.transform( new (C) RShiftLNode(a,b) ); + c = _gvn.transform( new RShiftLNode(a,b) ); push_pair(c); break; case Bytecodes::_lushr: b = pop(); // the shift count a = pop_pair(); // value to be shifted - c = _gvn.transform( new (C) URShiftLNode(a,b) ); + c = _gvn.transform( new URShiftLNode(a,b) ); push_pair(c); break; case Bytecodes::_lmul: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) MulLNode(a,b) ); + c = _gvn.transform( new MulLNode(a,b) ); push_pair(c); break; @@ -2100,7 +2035,7 @@ void Parse::do_one_bytecode() { if (stopped()) return; b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) ModLNode(control(),a,b) ); + c = _gvn.transform( new ModLNode(control(),a,b) ); push_pair(c); break; @@ -2112,20 +2047,20 @@ void Parse::do_one_bytecode() { if (stopped()) return; b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) DivLNode(control(),a,b) ); + c = _gvn.transform( new DivLNode(control(),a,b) ); push_pair(c); break; case Bytecodes::_ladd: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) AddLNode(a,b) ); + c = _gvn.transform( new AddLNode(a,b) ); push_pair(c); break; case Bytecodes::_lsub: b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) SubLNode(a,b) ); + c = _gvn.transform( new SubLNode(a,b) ); push_pair(c); break; case Bytecodes::_lcmp: @@ -2156,58 +2091,58 @@ void Parse::do_one_bytecode() { } b = pop_pair(); a = pop_pair(); - c = _gvn.transform( new (C) CmpL3Node( a, b )); + c = _gvn.transform( new CmpL3Node( a, b )); push(c); break; case Bytecodes::_lneg: a = pop_pair(); - b = _gvn.transform( new (C) SubLNode(longcon(0),a)); + b = _gvn.transform( new SubLNode(longcon(0),a)); push_pair(b); break; case Bytecodes::_l2i: a = pop_pair(); - push( _gvn.transform( new (C) ConvL2INode(a))); + push( _gvn.transform( new ConvL2INode(a))); break; case Bytecodes::_i2l: a = pop(); - b = _gvn.transform( new (C) ConvI2LNode(a)); + b = _gvn.transform( new ConvI2LNode(a)); push_pair(b); break; case Bytecodes::_i2b: // Sign extend a = pop(); - a = _gvn.transform( new (C) LShiftINode(a,_gvn.intcon(24)) ); - a = _gvn.transform( new (C) RShiftINode(a,_gvn.intcon(24)) ); + a = _gvn.transform( new LShiftINode(a,_gvn.intcon(24)) ); + a = _gvn.transform( new RShiftINode(a,_gvn.intcon(24)) ); push( a ); break; case Bytecodes::_i2s: a = pop(); - a = _gvn.transform( new (C) LShiftINode(a,_gvn.intcon(16)) ); - a = _gvn.transform( new (C) RShiftINode(a,_gvn.intcon(16)) ); + a = _gvn.transform( new LShiftINode(a,_gvn.intcon(16)) ); + a = _gvn.transform( new RShiftINode(a,_gvn.intcon(16)) ); push( a ); break; case Bytecodes::_i2c: a = pop(); - push( _gvn.transform( new (C) AndINode(a,_gvn.intcon(0xFFFF)) ) ); + push( _gvn.transform( new AndINode(a,_gvn.intcon(0xFFFF)) ) ); break; case Bytecodes::_i2f: a = pop(); - b = _gvn.transform( new (C) ConvI2FNode(a) ) ; + b = _gvn.transform( new ConvI2FNode(a) ) ; c = precision_rounding(b); push (b); break; case Bytecodes::_i2d: a = pop(); - b = _gvn.transform( new (C) ConvI2DNode(a)); + b = _gvn.transform( new ConvI2DNode(a)); push_pair(b); break; case Bytecodes::_iinc: // Increment local i = iter().get_index(); // Get local index - set_local( i, _gvn.transform( new (C) AddINode( _gvn.intcon(iter().get_iinc_con()), local(i) ) ) ); + set_local( i, _gvn.transform( new AddINode( _gvn.intcon(iter().get_iinc_con()), local(i) ) ) ); break; // Exit points of synchronized methods must have an unlock node @@ -2287,7 +2222,7 @@ void Parse::do_one_bytecode() { assert(null_ctl->is_top(), "no null control here"); dec_sp(1); } - c = _gvn.transform( new (C) CmpPNode(b, a) ); + c = _gvn.transform( new CmpPNode(b, a) ); do_ifnull(btest, c); break; @@ -2298,7 +2233,7 @@ void Parse::do_one_bytecode() { maybe_add_safepoint(iter().get_dest()); a = pop(); b = pop(); - c = _gvn.transform( new (C) CmpPNode(b, a) ); + c = _gvn.transform( new CmpPNode(b, a) ); c = optimize_cmp_with_klass(c); do_if(btest, c); break; @@ -2314,7 +2249,7 @@ void Parse::do_one_bytecode() { maybe_add_safepoint(iter().get_dest()); a = _gvn.intcon(0); b = pop(); - c = _gvn.transform( new (C) CmpINode(b, a) ); + c = _gvn.transform( new CmpINode(b, a) ); do_if(btest, c); break; @@ -2329,7 +2264,7 @@ void Parse::do_one_bytecode() { maybe_add_safepoint(iter().get_dest()); a = pop(); b = pop(); - c = _gvn.transform( new (C) CmpINode( b, a ) ); + c = _gvn.transform( new CmpINode( b, a ) ); do_if(btest, c); break; diff --git a/hotspot/src/share/vm/opto/parse3.cpp b/hotspot/src/share/vm/opto/parse3.cpp index b76eec74073..0f07506774e 100644 --- a/hotspot/src/share/vm/opto/parse3.cpp +++ b/hotspot/src/share/vm/opto/parse3.cpp @@ -552,7 +552,7 @@ void Parse::do_multianewarray() { } make_slow_call_ex(c, env()->Throwable_klass(), false); - Node* res = _gvn.transform(new (C) ProjNode(c, TypeFunc::Parms)); + Node* res = _gvn.transform(new ProjNode(c, TypeFunc::Parms)); const Type* type = TypeOopPtr::make_from_klass_raw(array_klass); @@ -566,7 +566,7 @@ void Parse::do_multianewarray() { // We cannot sharpen the nested sub-arrays, since the top level is mutable. - Node* cast = _gvn.transform( new (C) CheckCastPPNode(control(), res, type) ); + Node* cast = _gvn.transform( new CheckCastPPNode(control(), res, type) ); push(cast); // Possible improvements: diff --git a/hotspot/src/share/vm/opto/parseHelper.cpp b/hotspot/src/share/vm/opto/parseHelper.cpp index 729a038d873..45d627d2500 100644 --- a/hotspot/src/share/vm/opto/parseHelper.cpp +++ b/hotspot/src/share/vm/opto/parseHelper.cpp @@ -43,7 +43,7 @@ void GraphKit::make_dtrace_method_entry_exit(ciMethod* method, bool is_entry) { const char *call_name = is_entry ? "dtrace_method_entry" : "dtrace_method_exit"; // Get base of thread-local storage area - Node* thread = _gvn.transform( new (C) ThreadLocalNode() ); + Node* thread = _gvn.transform( new ThreadLocalNode() ); // Get method const TypePtr* method_type = TypeMetadataPtr::make(method); @@ -175,8 +175,8 @@ void Parse::array_store_check() { // Make a constant out of the inexact array klass const TypeKlassPtr *extak = tak->cast_to_exactness(true)->is_klassptr(); Node* con = makecon(extak); - Node* cmp = _gvn.transform(new (C) CmpPNode( array_klass, con )); - Node* bol = _gvn.transform(new (C) BoolNode( cmp, BoolTest::eq )); + Node* cmp = _gvn.transform(new CmpPNode( array_klass, con )); + Node* bol = _gvn.transform(new BoolNode( cmp, BoolTest::eq )); Node* ctrl= control(); { BuildCutout unless(this, bol, PROB_MAX); uncommon_trap(Deoptimization::Reason_array_check, @@ -215,8 +215,8 @@ void Parse::emit_guard_for_new(ciInstanceKlass* klass) { // if (klass->_init_thread != current_thread || // klass->_init_state != being_initialized) // uncommon_trap - Node* cur_thread = _gvn.transform( new (C) ThreadLocalNode() ); - Node* merge = new (C) RegionNode(3); + Node* cur_thread = _gvn.transform( new ThreadLocalNode() ); + Node* merge = new RegionNode(3); _gvn.set_type(merge, Type::CONTROL); Node* kls = makecon(TypeKlassPtr::make(klass)); @@ -327,9 +327,9 @@ void Parse::test_counter_against_threshold(Node* cnt, int limit) { // Test invocation count vs threshold Node *threshold = makecon(TypeInt::make(limit)); - Node *chk = _gvn.transform( new (C) CmpUNode( cnt, threshold) ); + Node *chk = _gvn.transform( new CmpUNode( cnt, threshold) ); BoolTest::mask btest = BoolTest::lt; - Node *tst = _gvn.transform( new (C) BoolNode( chk, btest) ); + Node *tst = _gvn.transform( new BoolNode( chk, btest) ); // Branch to failure if threshold exceeded { BuildCutout unless(this, tst, PROB_ALWAYS); uncommon_trap(Deoptimization::Reason_age, @@ -359,7 +359,7 @@ void Parse::increment_and_test_invocation_counter(int limit) { test_counter_against_threshold(cnt, limit); // Add one to the counter and store - Node* incr = _gvn.transform(new (C) AddINode(cnt, _gvn.intcon(1))); + Node* incr = _gvn.transform(new AddINode(cnt, _gvn.intcon(1))); store_to_memory(ctrl, adr_iic_node, incr, T_INT, adr_type, MemNode::unordered); } @@ -380,8 +380,8 @@ Node* Parse::method_data_addressing(ciMethodData* md, ciProfileData* data, ByteS if (stride != 0) { Node* str = _gvn.MakeConX(stride); - Node* scale = _gvn.transform( new (C) MulXNode( idx, str ) ); - ptr = _gvn.transform( new (C) AddPNode( mdo, ptr, scale ) ); + Node* scale = _gvn.transform( new MulXNode( idx, str ) ); + ptr = _gvn.transform( new AddPNode( mdo, ptr, scale ) ); } return ptr; @@ -393,7 +393,7 @@ void Parse::increment_md_counter_at(ciMethodData* md, ciProfileData* data, ByteS const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr(); Node* cnt = make_load(NULL, adr_node, TypeInt::INT, T_INT, adr_type, MemNode::unordered); - Node* incr = _gvn.transform(new (C) AddINode(cnt, _gvn.intcon(DataLayout::counter_increment))); + Node* incr = _gvn.transform(new AddINode(cnt, _gvn.intcon(DataLayout::counter_increment))); store_to_memory(NULL, adr_node, incr, T_INT, adr_type, MemNode::unordered); } @@ -413,7 +413,7 @@ void Parse::set_md_flag_at(ciMethodData* md, ciProfileData* data, int flag_const const TypePtr* adr_type = _gvn.type(adr_node)->is_ptr(); Node* flags = make_load(NULL, adr_node, TypeInt::BYTE, T_BYTE, adr_type, MemNode::unordered); - Node* incr = _gvn.transform(new (C) OrINode(flags, _gvn.intcon(flag_constant))); + Node* incr = _gvn.transform(new OrINode(flags, _gvn.intcon(flag_constant))); store_to_memory(NULL, adr_node, incr, T_BYTE, adr_type, MemNode::unordered); } diff --git a/hotspot/src/share/vm/opto/phaseX.cpp b/hotspot/src/share/vm/opto/phaseX.cpp index 4635342e678..5b2771e83ef 100644 --- a/hotspot/src/share/vm/opto/phaseX.cpp +++ b/hotspot/src/share/vm/opto/phaseX.cpp @@ -47,7 +47,7 @@ NodeHash::NodeHash(uint est_max_size) : _total_insert_probes(0), _total_inserts(0), _insert_probes(0), _grows(0) { // _sentinel must be in the current node space - _sentinel = new (Compile::current()) ProjNode(NULL, TypeFunc::Control); + _sentinel = new ProjNode(NULL, TypeFunc::Control); memset(_table,0,sizeof(Node*)*_max); } @@ -62,7 +62,7 @@ NodeHash::NodeHash(Arena *arena, uint est_max_size) : _total_insert_probes(0), _total_inserts(0), _insert_probes(0), _grows(0) { // _sentinel must be in the current node space - _sentinel = new (Compile::current()) ProjNode(NULL, TypeFunc::Control); + _sentinel = new ProjNode(NULL, TypeFunc::Control); memset(_table,0,sizeof(Node*)*_max); } @@ -1309,7 +1309,7 @@ void PhaseIterGVN::subsume_node( Node *old, Node *nn ) { } // Smash all inputs to 'old', isolating him completely - Node *temp = new (C) Node(1); + Node *temp = new Node(1); temp->init_req(0,nn); // Add a use to nn to prevent him from dying remove_dead_node( old ); temp->del_req(0); // Yank bogus edge diff --git a/hotspot/src/share/vm/opto/reg_split.cpp b/hotspot/src/share/vm/opto/reg_split.cpp index 7ec346bc6a9..7c47b4c0065 100644 --- a/hotspot/src/share/vm/opto/reg_split.cpp +++ b/hotspot/src/share/vm/opto/reg_split.cpp @@ -93,7 +93,7 @@ Node *PhaseChaitin::get_spillcopy_wide(MachSpillCopyNode::SpillType spill_type, // Here we assume a trip through memory is required. w_i_mask = &C->FIRST_STACK_mask(); } - return new (C) MachSpillCopyNode(spill_type, def, *w_i_mask, *w_o_mask ); + return new MachSpillCopyNode(spill_type, def, *w_i_mask, *w_o_mask ); } //------------------------------insert_proj------------------------------------ @@ -663,7 +663,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { // create a new phi node and insert it into the block // type is taken from left over pointer to a predecessor assert(n3,"No non-NULL reaching DEF for a Phi"); - phi = new (C) PhiNode(b->head(), n3->bottom_type()); + phi = new PhiNode(b->head(), n3->bottom_type()); // initialize the Reaches entry for this LRG Reachblock[slidx] = phi; @@ -1075,7 +1075,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { // First Split-UP to move value into Register uint def_ideal = def->ideal_reg(); const RegMask* tmp_rm = Matcher::idealreg2regmask[def_ideal]; - Node *spill = new (C) MachSpillCopyNode(MachSpillCopyNode::MemToReg, def, dmask, *tmp_rm); + Node *spill = new MachSpillCopyNode(MachSpillCopyNode::MemToReg, def, dmask, *tmp_rm); insert_proj( b, insidx, spill, maxlrg ); // Then Split-DOWN as if previous Split was DEF maxlrg = split_USE(MachSpillCopyNode::RegToMem, spill,b,n,inpidx,maxlrg,false,false, splits,slidx); @@ -1229,7 +1229,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { if (C->check_node_count(NodeLimitFudgeFactor, out_of_nodes)) { // Check when generating nodes return 0; } - Node *spill = new (C) MachSpillCopyNode(MachSpillCopyNode::MemToReg, use,use_rm,def_rm); + Node *spill = new MachSpillCopyNode(MachSpillCopyNode::MemToReg, use,use_rm,def_rm); n->set_req(copyidx,spill); n->as_MachSpillCopy()->set_in_RegMask(def_rm); // Put the spill just before the copy diff --git a/hotspot/src/share/vm/opto/replacednodes.cpp b/hotspot/src/share/vm/opto/replacednodes.cpp new file mode 100644 index 00000000000..bf647e96481 --- /dev/null +++ b/hotspot/src/share/vm/opto/replacednodes.cpp @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "opto/cfgnode.hpp" +#include "opto/phaseX.hpp" +#include "opto/replacednodes.hpp" + +void ReplacedNodes::allocate_if_necessary() { + if (_replaced_nodes == NULL) { + _replaced_nodes = new GrowableArray(); + } +} + +bool ReplacedNodes::is_empty() const { + return _replaced_nodes == NULL || _replaced_nodes->length() == 0; +} + +bool ReplacedNodes::has_node(const ReplacedNode& r) const { + return _replaced_nodes->find(r) != -1; +} + +bool ReplacedNodes::has_target_node(Node* n) const { + for (int i = 0; i < _replaced_nodes->length(); i++) { + if (_replaced_nodes->at(i).improved() == n) { + return true; + } + } + return false; +} + +// Record replaced node if not seen before +void ReplacedNodes::record(Node* initial, Node* improved) { + allocate_if_necessary(); + ReplacedNode r(initial, improved); + if (!has_node(r)) { + _replaced_nodes->push(r); + } +} + +// Copy replaced nodes from one map to another. idx is used to +// identify nodes that are too new to be of interest in the target +// node list. +void ReplacedNodes::transfer_from(const ReplacedNodes& other, uint idx) { + if (other.is_empty()) { + return; + } + allocate_if_necessary(); + for (int i = 0; i < other._replaced_nodes->length(); i++) { + ReplacedNode replaced = other._replaced_nodes->at(i); + // Only transfer the nodes that can actually be useful + if (!has_node(replaced) && (replaced.initial()->_idx < idx || has_target_node(replaced.initial()))) { + _replaced_nodes->push(replaced); + } + } +} + +void ReplacedNodes::clone() { + if (_replaced_nodes != NULL) { + GrowableArray* replaced_nodes_clone = new GrowableArray(); + replaced_nodes_clone->appendAll(_replaced_nodes); + _replaced_nodes = replaced_nodes_clone; + } +} + +void ReplacedNodes::reset() { + if (_replaced_nodes != NULL) { + _replaced_nodes->clear(); + } +} + +// Perfom node replacement (used when returning to caller) +void ReplacedNodes::apply(Node* n) { + if (is_empty()) { + return; + } + for (int i = 0; i < _replaced_nodes->length(); i++) { + ReplacedNode replaced = _replaced_nodes->at(i); + n->replace_edge(replaced.initial(), replaced.improved()); + } +} + +static void enqueue_use(Node* n, Node* use, Unique_Node_List& work) { + if (use->is_Phi()) { + Node* r = use->in(0); + assert(r->is_Region(), "Phi should have Region"); + for (uint i = 1; i < use->req(); i++) { + if (use->in(i) == n) { + work.push(r->in(i)); + } + } + } else { + work.push(use); + } +} + +// Perfom node replacement following late inlining +void ReplacedNodes::apply(Compile* C, Node* ctl) { + // ctl is the control on exit of the method that was late inlined + if (is_empty()) { + return; + } + for (int i = 0; i < _replaced_nodes->length(); i++) { + ReplacedNode replaced = _replaced_nodes->at(i); + Node* initial = replaced.initial(); + Node* improved = replaced.improved(); + assert (ctl != NULL && !ctl->is_top(), "replaced node should have actual control"); + + ResourceMark rm; + Unique_Node_List work; + // Go over all the uses of the node that is considered for replacement... + for (DUIterator j = initial->outs(); initial->has_out(j); j++) { + Node* use = initial->out(j); + + if (use == improved || use->outcnt() == 0) { + continue; + } + work.clear(); + enqueue_use(initial, use, work); + bool replace = true; + // Check that this use is dominated by ctl. Go ahead with the + // replacement if it is. + while (work.size() != 0 && replace) { + Node* n = work.pop(); + if (use->outcnt() == 0) { + continue; + } + if (n->is_CFG() || (n->in(0) != NULL && !n->in(0)->is_top())) { + int depth = 0; + Node *m = n; + if (!n->is_CFG()) { + n = n->in(0); + } + assert(n->is_CFG(), "should be CFG now"); + while(n != ctl) { + n = IfNode::up_one_dom(n); + depth++; + // limit search depth + if (depth >= 100 || n == NULL) { + replace = false; + break; + } + } + } else { + for (DUIterator k = n->outs(); n->has_out(k); k++) { + enqueue_use(n, n->out(k), work); + } + } + } + if (replace) { + bool is_in_table = C->initial_gvn()->hash_delete(use); + int replaced = use->replace_edge(initial, improved); + if (is_in_table) { + C->initial_gvn()->hash_find_insert(use); + } + C->record_for_igvn(use); + + assert(replaced > 0, "inconsistent"); + --j; + } + } + } +} + +void ReplacedNodes::dump(outputStream *st) const { + if (!is_empty()) { + tty->print("replaced nodes: "); + for (int i = 0; i < _replaced_nodes->length(); i++) { + tty->print("%d->%d", _replaced_nodes->at(i).initial()->_idx, _replaced_nodes->at(i).improved()->_idx); + if (i < _replaced_nodes->length()-1) { + tty->print(","); + } + } + } +} + +// Merge 2 list of replaced node at a point where control flow paths merge +void ReplacedNodes::merge_with(const ReplacedNodes& other) { + if (is_empty()) { + return; + } + if (other.is_empty()) { + reset(); + return; + } + int shift = 0; + int len = _replaced_nodes->length(); + for (int i = 0; i < len; i++) { + if (!other.has_node(_replaced_nodes->at(i))) { + shift++; + } else if (shift > 0) { + _replaced_nodes->at_put(i-shift, _replaced_nodes->at(i)); + } + } + if (shift > 0) { + _replaced_nodes->trunc_to(len - shift); + } +} diff --git a/hotspot/src/share/vm/opto/replacednodes.hpp b/hotspot/src/share/vm/opto/replacednodes.hpp new file mode 100644 index 00000000000..0f68fe986d5 --- /dev/null +++ b/hotspot/src/share/vm/opto/replacednodes.hpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_OPTO_REPLACEDNODES_HPP +#define SHARE_VM_OPTO_REPLACEDNODES_HPP + +#include "opto/connode.hpp" + +// During parsing, when a node is "improved", +// GraphKit::replace_in_map() is called to update the current map so +// that the improved node is used from that point +// on. GraphKit::replace_in_map() doesn't operate on the callers maps +// and so some optimization opportunities may be lost. The +// ReplacedNodes class addresses that problem. +// +// A ReplacedNodes object is a list of pair of nodes. Every +// SafePointNode carries a ReplacedNodes object. Every time +// GraphKit::replace_in_map() is called, a new pair of nodes is pushed +// on the list of replaced nodes. When control flow paths merge, their +// replaced nodes are also merged. When parsing exits a method to +// return to a caller, the replaced nodes on the exit path are used to +// update the caller's map. +class ReplacedNodes VALUE_OBJ_CLASS_SPEC { + private: + class ReplacedNode VALUE_OBJ_CLASS_SPEC { + private: + Node* _initial; + Node* _improved; + public: + ReplacedNode() : _initial(NULL), _improved(NULL) {} + ReplacedNode(Node* initial, Node* improved) : _initial(initial), _improved(improved) {} + Node* initial() const { return _initial; } + Node* improved() const { return _improved; } + + bool operator==(const ReplacedNode& other) { + return _initial == other._initial && _improved == other._improved; + } + }; + GrowableArray* _replaced_nodes; + + void allocate_if_necessary(); + bool has_node(const ReplacedNode& r) const; + bool has_target_node(Node* n) const; + + public: + ReplacedNodes() + : _replaced_nodes(NULL) {} + + void clone(); + void record(Node* initial, Node* improved); + void transfer_from(const ReplacedNodes& other, uint idx); + void reset(); + void apply(Node* n); + void merge_with(const ReplacedNodes& other); + bool is_empty() const; + void dump(outputStream *st) const; + void apply(Compile* C, Node* ctl); +}; + +#endif // SHARE_VM_OPTO_REPLACEDNODES_HPP diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp index 1beaac7fd38..632a03f2304 100644 --- a/hotspot/src/share/vm/opto/runtime.cpp +++ b/hotspot/src/share/vm/opto/runtime.cpp @@ -896,6 +896,50 @@ const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() { return TypeFunc::make(domain, range); } +/* + * void implCompress(byte[] buf, int ofs) + */ +const TypeFunc* OptoRuntime::sha_implCompress_Type() { + // create input type (domain) + int num_args = 2; + int argcnt = num_args; + const Type** fields = TypeTuple::fields(argcnt); + int argp = TypeFunc::Parms; + fields[argp++] = TypePtr::NOTNULL; // buf + fields[argp++] = TypePtr::NOTNULL; // state + assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); + const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); + + // no result type needed + fields = TypeTuple::fields(1); + fields[TypeFunc::Parms+0] = NULL; // void + const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields); + return TypeFunc::make(domain, range); +} + +/* + * int implCompressMultiBlock(byte[] b, int ofs, int limit) + */ +const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type() { + // create input type (domain) + int num_args = 4; + int argcnt = num_args; + const Type** fields = TypeTuple::fields(argcnt); + int argp = TypeFunc::Parms; + fields[argp++] = TypePtr::NOTNULL; // buf + fields[argp++] = TypePtr::NOTNULL; // state + fields[argp++] = TypeInt::INT; // ofs + fields[argp++] = TypeInt::INT; // limit + assert(argp == TypeFunc::Parms+argcnt, "correct decoding"); + const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields); + + // returning ofs (int) + fields = TypeTuple::fields(1); + fields[TypeFunc::Parms+0] = TypeInt::INT; // ofs + const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields); + return TypeFunc::make(domain, range); +} + //------------- Interpreter state access for on stack replacement const TypeFunc* OptoRuntime::osr_end_Type() { // create input type (domain) diff --git a/hotspot/src/share/vm/opto/runtime.hpp b/hotspot/src/share/vm/opto/runtime.hpp index 9f2a26cecb7..b8ad0105dfc 100644 --- a/hotspot/src/share/vm/opto/runtime.hpp +++ b/hotspot/src/share/vm/opto/runtime.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -300,6 +300,9 @@ private: static const TypeFunc* aescrypt_block_Type(); static const TypeFunc* cipherBlockChaining_aescrypt_Type(); + static const TypeFunc* sha_implCompress_Type(); + static const TypeFunc* digestBase_implCompressMB_Type(); + static const TypeFunc* updateBytesCRC32_Type(); // leaf on stack replacement interpreter accessor types diff --git a/hotspot/src/share/vm/opto/split_if.cpp b/hotspot/src/share/vm/opto/split_if.cpp index 9b99313f2ac..40a762b03a3 100644 --- a/hotspot/src/share/vm/opto/split_if.cpp +++ b/hotspot/src/share/vm/opto/split_if.cpp @@ -35,7 +35,7 @@ Node *PhaseIdealLoop::split_thru_region( Node *n, Node *region ) { uint wins = 0; assert( n->is_CFG(), "" ); assert( region->is_Region(), "" ); - Node *r = new (C) RegionNode( region->req() ); + Node *r = new RegionNode( region->req() ); IdealLoopTree *loop = get_loop( n ); for( uint i = 1; i < region->req(); i++ ) { Node *x = n->clone(); diff --git a/hotspot/src/share/vm/opto/stringopts.cpp b/hotspot/src/share/vm/opto/stringopts.cpp index b00bb881faa..fcca4684833 100644 --- a/hotspot/src/share/vm/opto/stringopts.cpp +++ b/hotspot/src/share/vm/opto/stringopts.cpp @@ -70,7 +70,7 @@ class StringConcat : public ResourceObj { _multiple(false), _string_alloc(NULL), _stringopts(stringopts) { - _arguments = new (_stringopts->C) Node(1); + _arguments = new Node(1); _arguments->del_req(0); } @@ -228,8 +228,8 @@ class StringConcat : public ResourceObj { const TypeFunc* call_type = OptoRuntime::uncommon_trap_Type(); const TypePtr* no_memory_effects = NULL; Compile* C = _stringopts->C; - CallStaticJavaNode* call = new (C) CallStaticJavaNode(call_type, call_addr, "uncommon_trap", - jvms->bci(), no_memory_effects); + CallStaticJavaNode* call = new CallStaticJavaNode(call_type, call_addr, "uncommon_trap", + jvms->bci(), no_memory_effects); for (int e = 0; e < TypeFunc::Parms; e++) { call->init_req(e, uct->in(e)); } @@ -1127,9 +1127,9 @@ Node* PhaseStringOpts::fetch_static_field(GraphKit& kit, ciField* field) { } Node* PhaseStringOpts::int_stringSize(GraphKit& kit, Node* arg) { - RegionNode *final_merge = new (C) RegionNode(3); + RegionNode *final_merge = new RegionNode(3); kit.gvn().set_type(final_merge, Type::CONTROL); - Node* final_size = new (C) PhiNode(final_merge, TypeInt::INT); + Node* final_size = new PhiNode(final_merge, TypeInt::INT); kit.gvn().set_type(final_size, TypeInt::INT); IfNode* iff = kit.create_and_map_if(kit.control(), @@ -1146,11 +1146,11 @@ Node* PhaseStringOpts::int_stringSize(GraphKit& kit, Node* arg) { } else { // int size = (i < 0) ? stringSize(-i) + 1 : stringSize(i); - RegionNode *r = new (C) RegionNode(3); + RegionNode *r = new RegionNode(3); kit.gvn().set_type(r, Type::CONTROL); - Node *phi = new (C) PhiNode(r, TypeInt::INT); + Node *phi = new PhiNode(r, TypeInt::INT); kit.gvn().set_type(phi, TypeInt::INT); - Node *size = new (C) PhiNode(r, TypeInt::INT); + Node *size = new PhiNode(r, TypeInt::INT); kit.gvn().set_type(size, TypeInt::INT); Node* chk = __ CmpI(arg, __ intcon(0)); Node* p = __ Bool(chk, BoolTest::lt); @@ -1175,11 +1175,11 @@ Node* PhaseStringOpts::int_stringSize(GraphKit& kit, Node* arg) { // Add loop predicate first. kit.add_predicate(); - RegionNode *loop = new (C) RegionNode(3); + RegionNode *loop = new RegionNode(3); loop->init_req(1, kit.control()); kit.gvn().set_type(loop, Type::CONTROL); - Node *index = new (C) PhiNode(loop, TypeInt::INT); + Node *index = new PhiNode(loop, TypeInt::INT); index->init_req(1, __ intcon(0)); kit.gvn().set_type(index, TypeInt::INT); kit.set_control(loop); @@ -1212,7 +1212,7 @@ Node* PhaseStringOpts::int_stringSize(GraphKit& kit, Node* arg) { } void PhaseStringOpts::int_getChars(GraphKit& kit, Node* arg, Node* char_array, Node* start, Node* end) { - RegionNode *final_merge = new (C) RegionNode(4); + RegionNode *final_merge = new RegionNode(4); kit.gvn().set_type(final_merge, Type::CONTROL); Node *final_mem = PhiNode::make(final_merge, kit.memory(char_adr_idx), Type::MEMORY, TypeAryPtr::CHARS); kit.gvn().set_type(final_mem, Type::MEMORY); @@ -1262,11 +1262,11 @@ void PhaseStringOpts::int_getChars(GraphKit& kit, Node* arg, Node* char_array, N __ Bool(__ CmpI(arg, __ intcon(0)), BoolTest::lt), PROB_FAIR, COUNT_UNKNOWN); - RegionNode *merge = new (C) RegionNode(3); + RegionNode *merge = new RegionNode(3); kit.gvn().set_type(merge, Type::CONTROL); - i = new (C) PhiNode(merge, TypeInt::INT); + i = new PhiNode(merge, TypeInt::INT); kit.gvn().set_type(i, TypeInt::INT); - sign = new (C) PhiNode(merge, TypeInt::INT); + sign = new PhiNode(merge, TypeInt::INT); kit.gvn().set_type(sign, TypeInt::INT); merge->init_req(1, __ IfTrue(iff)); @@ -1295,10 +1295,10 @@ void PhaseStringOpts::int_getChars(GraphKit& kit, Node* arg, Node* char_array, N // Add loop predicate first. kit.add_predicate(); - RegionNode *head = new (C) RegionNode(3); + RegionNode *head = new RegionNode(3); head->init_req(1, kit.control()); kit.gvn().set_type(head, Type::CONTROL); - Node *i_phi = new (C) PhiNode(head, TypeInt::INT); + Node *i_phi = new PhiNode(head, TypeInt::INT); i_phi->init_req(1, i); kit.gvn().set_type(i_phi, TypeInt::INT); charPos = PhiNode::make(head, charPos); @@ -1420,7 +1420,7 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) { // as a shim for the insertion of the new code. JVMState* jvms = sc->begin()->jvms()->clone_shallow(C); uint size = sc->begin()->req(); - SafePointNode* map = new (C) SafePointNode(size, jvms); + SafePointNode* map = new SafePointNode(size, jvms); // copy the control and memory state from the final call into our // new starting state. This allows any preceeding tests to feed @@ -1465,12 +1465,12 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) { // Create a region for the overflow checks to merge into. int args = MAX2(sc->num_arguments(), 1); - RegionNode* overflow = new (C) RegionNode(args); + RegionNode* overflow = new RegionNode(args); kit.gvn().set_type(overflow, Type::CONTROL); // Create a hook node to hold onto the individual sizes since they // are need for the copying phase. - Node* string_sizes = new (C) Node(args); + Node* string_sizes = new Node(args); Node* length = __ intcon(0); for (int argi = 0; argi < sc->num_arguments(); argi++) { @@ -1514,9 +1514,9 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) { } else if (!type->higher_equal(TypeInstPtr::NOTNULL)) { // s = s != null ? s : "null"; // length = length + (s.count - s.offset); - RegionNode *r = new (C) RegionNode(3); + RegionNode *r = new RegionNode(3); kit.gvn().set_type(r, Type::CONTROL); - Node *phi = new (C) PhiNode(r, type); + Node *phi = new PhiNode(r, type); kit.gvn().set_type(phi, phi->bottom_type()); Node* p = __ Bool(__ CmpP(arg, kit.null()), BoolTest::ne); IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_MIN, COUNT_UNKNOWN); diff --git a/hotspot/src/share/vm/opto/subnode.cpp b/hotspot/src/share/vm/opto/subnode.cpp index ae41bee47ae..e5f24b6ca6c 100644 --- a/hotspot/src/share/vm/opto/subnode.cpp +++ b/hotspot/src/share/vm/opto/subnode.cpp @@ -159,7 +159,7 @@ Node *SubINode::Ideal(PhaseGVN *phase, bool can_reshape){ if( t2->base() == Type::Int ){ // Might be bottom or top... const TypeInt *i = t2->is_int(); if( i->is_con() ) - return new (phase->C) AddINode(in1, phase->intcon(-i->get_con())); + return new AddINode(in1, phase->intcon(-i->get_con())); } // Convert "(x+c0) - y" into (x-y) + c0" @@ -168,8 +168,8 @@ Node *SubINode::Ideal(PhaseGVN *phase, bool can_reshape){ if( op1 == Op_AddI && ok_to_convert(in1, in2) ) { const Type *tadd = phase->type( in1->in(2) ); if( tadd->singleton() && tadd != Type::TOP ) { - Node *sub2 = phase->transform( new (phase->C) SubINode( in1->in(1), in2 )); - return new (phase->C) AddINode( sub2, in1->in(2) ); + Node *sub2 = phase->transform( new SubINode( in1->in(1), in2 )); + return new AddINode( sub2, in1->in(2) ); } } @@ -181,9 +181,9 @@ Node *SubINode::Ideal(PhaseGVN *phase, bool can_reshape){ Node* in22 = in2->in(2); const TypeInt* tcon = phase->type(in22)->isa_int(); if (tcon != NULL && tcon->is_con()) { - Node* sub2 = phase->transform( new (phase->C) SubINode(in1, in21) ); + Node* sub2 = phase->transform( new SubINode(in1, in21) ); Node* neg_c0 = phase->intcon(- tcon->get_con()); - return new (phase->C) AddINode(sub2, neg_c0); + return new AddINode(sub2, neg_c0); } } @@ -201,47 +201,47 @@ Node *SubINode::Ideal(PhaseGVN *phase, bool can_reshape){ // Convert "x - (x+y)" into "-y" if( op2 == Op_AddI && phase->eqv( in1, in2->in(1) ) ) - return new (phase->C) SubINode( phase->intcon(0),in2->in(2)); + return new SubINode( phase->intcon(0),in2->in(2)); // Convert "(x-y) - x" into "-y" if( op1 == Op_SubI && phase->eqv( in1->in(1), in2 ) ) - return new (phase->C) SubINode( phase->intcon(0),in1->in(2)); + return new SubINode( phase->intcon(0),in1->in(2)); // Convert "x - (y+x)" into "-y" if( op2 == Op_AddI && phase->eqv( in1, in2->in(2) ) ) - return new (phase->C) SubINode( phase->intcon(0),in2->in(1)); + return new SubINode( phase->intcon(0),in2->in(1)); // Convert "0 - (x-y)" into "y-x" if( t1 == TypeInt::ZERO && op2 == Op_SubI ) - return new (phase->C) SubINode( in2->in(2), in2->in(1) ); + return new SubINode( in2->in(2), in2->in(1) ); // Convert "0 - (x+con)" into "-con-x" jint con; if( t1 == TypeInt::ZERO && op2 == Op_AddI && (con = in2->in(2)->find_int_con(0)) != 0 ) - return new (phase->C) SubINode( phase->intcon(-con), in2->in(1) ); + return new SubINode( phase->intcon(-con), in2->in(1) ); // Convert "(X+A) - (X+B)" into "A - B" if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(1) ) - return new (phase->C) SubINode( in1->in(2), in2->in(2) ); + return new SubINode( in1->in(2), in2->in(2) ); // Convert "(A+X) - (B+X)" into "A - B" if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(2) ) - return new (phase->C) SubINode( in1->in(1), in2->in(1) ); + return new SubINode( in1->in(1), in2->in(1) ); // Convert "(A+X) - (X+B)" into "A - B" if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(1) ) - return new (phase->C) SubINode( in1->in(1), in2->in(2) ); + return new SubINode( in1->in(1), in2->in(2) ); // Convert "(X+A) - (B+X)" into "A - B" if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(2) ) - return new (phase->C) SubINode( in1->in(2), in2->in(1) ); + return new SubINode( in1->in(2), in2->in(1) ); // Convert "A-(B-C)" into (A+C)-B", since add is commutative and generally // nicer to optimize than subtract. if( op2 == Op_SubI && in2->outcnt() == 1) { - Node *add1 = phase->transform( new (phase->C) AddINode( in1, in2->in(2) ) ); - return new (phase->C) SubINode( add1, in2->in(1) ); + Node *add1 = phase->transform( new AddINode( in1, in2->in(2) ) ); + return new SubINode( add1, in2->in(1) ); } return NULL; @@ -288,7 +288,7 @@ Node *SubLNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Convert "x-c0" into "x+ -c0". if( i && // Might be bottom or top... i->is_con() ) - return new (phase->C) AddLNode(in1, phase->longcon(-i->get_con())); + return new AddLNode(in1, phase->longcon(-i->get_con())); // Convert "(x+c0) - y" into (x-y) + c0" // Do not collapse (x+c0)-y if "+" is a loop increment or @@ -297,8 +297,8 @@ Node *SubLNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *in11 = in1->in(1); const Type *tadd = phase->type( in1->in(2) ); if( tadd->singleton() && tadd != Type::TOP ) { - Node *sub2 = phase->transform( new (phase->C) SubLNode( in11, in2 )); - return new (phase->C) AddLNode( sub2, in1->in(2) ); + Node *sub2 = phase->transform( new SubLNode( in11, in2 )); + return new AddLNode( sub2, in1->in(2) ); } } @@ -309,9 +309,9 @@ Node *SubLNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node* in22 = in2->in(2); const TypeLong* tcon = phase->type(in22)->isa_long(); if (tcon != NULL && tcon->is_con()) { - Node* sub2 = phase->transform( new (phase->C) SubLNode(in1, in21) ); + Node* sub2 = phase->transform( new SubLNode(in1, in21) ); Node* neg_c0 = phase->longcon(- tcon->get_con()); - return new (phase->C) AddLNode(sub2, neg_c0); + return new AddLNode(sub2, neg_c0); } } @@ -329,28 +329,28 @@ Node *SubLNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Convert "x - (x+y)" into "-y" if( op2 == Op_AddL && phase->eqv( in1, in2->in(1) ) ) - return new (phase->C) SubLNode( phase->makecon(TypeLong::ZERO), in2->in(2)); + return new SubLNode( phase->makecon(TypeLong::ZERO), in2->in(2)); // Convert "x - (y+x)" into "-y" if( op2 == Op_AddL && phase->eqv( in1, in2->in(2) ) ) - return new (phase->C) SubLNode( phase->makecon(TypeLong::ZERO),in2->in(1)); + return new SubLNode( phase->makecon(TypeLong::ZERO),in2->in(1)); // Convert "0 - (x-y)" into "y-x" if( phase->type( in1 ) == TypeLong::ZERO && op2 == Op_SubL ) - return new (phase->C) SubLNode( in2->in(2), in2->in(1) ); + return new SubLNode( in2->in(2), in2->in(1) ); // Convert "(X+A) - (X+B)" into "A - B" if( op1 == Op_AddL && op2 == Op_AddL && in1->in(1) == in2->in(1) ) - return new (phase->C) SubLNode( in1->in(2), in2->in(2) ); + return new SubLNode( in1->in(2), in2->in(2) ); // Convert "(A+X) - (B+X)" into "A - B" if( op1 == Op_AddL && op2 == Op_AddL && in1->in(2) == in2->in(2) ) - return new (phase->C) SubLNode( in1->in(1), in2->in(1) ); + return new SubLNode( in1->in(1), in2->in(1) ); // Convert "A-(B-C)" into (A+C)-B" if( op2 == Op_SubL && in2->outcnt() == 1) { - Node *add1 = phase->transform( new (phase->C) AddLNode( in1, in2->in(2) ) ); - return new (phase->C) SubLNode( add1, in2->in(1) ); + Node *add1 = phase->transform( new AddLNode( in1, in2->in(2) ) ); + return new SubLNode( add1, in2->in(1) ); } return NULL; @@ -417,7 +417,7 @@ Node *SubFNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Convert "x - (x+y)" into "-y" if( in(2)->is_Add() && phase->eqv(in(1),in(2)->in(1) ) ) - return new (phase->C) SubFNode( phase->makecon(TypeF::ZERO),in(2)->in(2)); + return new SubFNode( phase->makecon(TypeF::ZERO),in(2)->in(2)); } // Cannot replace 0.0-X with -X because a 'fsub' bytecode computes @@ -460,7 +460,7 @@ Node *SubDNode::Ideal(PhaseGVN *phase, bool can_reshape){ // Convert "x - (x+y)" into "-y" if( in(2)->is_Add() && phase->eqv(in(1),in(2)->in(1) ) ) - return new (phase->C) SubDNode( phase->makecon(TypeD::ZERO),in(2)->in(2)); + return new SubDNode( phase->makecon(TypeD::ZERO),in(2)->in(2)); } // Cannot replace 0.0-X with -X because a 'dsub' bytecode computes @@ -666,11 +666,11 @@ Node *CmpINode::Ideal( PhaseGVN *phase, bool can_reshape ) { if (phase->type(in(2))->higher_equal(TypeInt::ZERO)) { switch (in(1)->Opcode()) { case Op_CmpL3: // Collapse a CmpL3/CmpI into a CmpL - return new (phase->C) CmpLNode(in(1)->in(1),in(1)->in(2)); + return new CmpLNode(in(1)->in(1),in(1)->in(2)); case Op_CmpF3: // Collapse a CmpF3/CmpI into a CmpF - return new (phase->C) CmpFNode(in(1)->in(1),in(1)->in(2)); + return new CmpFNode(in(1)->in(1),in(1)->in(2)); case Op_CmpD3: // Collapse a CmpD3/CmpI into a CmpD - return new (phase->C) CmpDNode(in(1)->in(1),in(1)->in(2)); + return new CmpDNode(in(1)->in(1),in(1)->in(2)); //case Op_SubI: // If (x - y) cannot overflow, then ((x - y) 0) // can be turned into (x y). @@ -1109,8 +1109,8 @@ Node *CmpDNode::Ideal(PhaseGVN *phase, bool can_reshape){ new_in2 = tmp; } CmpFNode *new_cmp = (Opcode() == Op_CmpD3) - ? new (phase->C) CmpF3Node( new_in1, new_in2 ) - : new (phase->C) CmpFNode ( new_in1, new_in2 ) ; + ? new CmpF3Node( new_in1, new_in2 ) + : new CmpFNode ( new_in1, new_in2 ) ; return new_cmp; // Changed to CmpFNode } // Testing value required the precision of a double @@ -1182,9 +1182,9 @@ Node* BoolNode::make_predicate(Node* test_value, PhaseGVN* phase) { // Else fall through. The CMove gets in the way of the test. // It should be the case that make_predicate(bol->as_int_value()) == bol. } - Node* cmp = new (C) CmpINode(test_value, phase->intcon(0)); + Node* cmp = new CmpINode(test_value, phase->intcon(0)); cmp = phase->transform(cmp); - Node* bol = new (C) BoolNode(cmp, BoolTest::ne); + Node* bol = new BoolNode(cmp, BoolTest::ne); return phase->transform(bol); } @@ -1200,7 +1200,7 @@ Node* BoolNode::as_int_value(PhaseGVN* phase) { //----------------------------------negate------------------------------------- BoolNode* BoolNode::negate(PhaseGVN* phase) { Compile* C = phase->C; - return new (C) BoolNode(in(1), _test.negate()); + return new BoolNode(in(1), _test.negate()); } @@ -1238,7 +1238,7 @@ Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) { // Swap inputs to the clone cmp->swap_edges(1, 2); cmp = phase->transform( cmp ); - return new (phase->C) BoolNode( cmp, _test.commute() ); + return new BoolNode( cmp, _test.commute() ); } // Change "bool eq/ne (cmp (xor X 1) 0)" into "bool ne/eq (cmp X 0)". @@ -1255,8 +1255,8 @@ Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) { phase->type( j_xor->in(2) ) == TypeInt::ONE && (_test._test == BoolTest::eq || _test._test == BoolTest::ne) ) { - Node *ncmp = phase->transform(new (phase->C) CmpINode(j_xor->in(1),cmp2)); - return new (phase->C) BoolNode( ncmp, _test.negate() ); + Node *ncmp = phase->transform(new CmpINode(j_xor->in(1),cmp2)); + return new BoolNode( ncmp, _test.negate() ); } // Change "bool eq/ne (cmp (Conv2B X) 0)" into "bool eq/ne (cmp X 0)". @@ -1267,10 +1267,10 @@ Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) { (_test._test == BoolTest::eq || _test._test == BoolTest::ne) ) { Node *ncmp = phase->transform(phase->type(c2b->in(1))->isa_int() - ? (Node*)new (phase->C) CmpINode(c2b->in(1),cmp2) - : (Node*)new (phase->C) CmpPNode(c2b->in(1),phase->makecon(TypePtr::NULL_PTR)) + ? (Node*)new CmpINode(c2b->in(1),cmp2) + : (Node*)new CmpPNode(c2b->in(1),phase->makecon(TypePtr::NULL_PTR)) ); - return new (phase->C) BoolNode( ncmp, _test._test ); + return new BoolNode( ncmp, _test._test ); } // Comparing a SubI against a zero is equal to comparing the SubI @@ -1280,8 +1280,8 @@ Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) { (cop == Op_CmpI) && (cmp1->Opcode() == Op_SubI) && ( cmp2_type == TypeInt::ZERO ) ) { - Node *ncmp = phase->transform( new (phase->C) CmpINode(cmp1->in(1),cmp1->in(2))); - return new (phase->C) BoolNode( ncmp, _test._test ); + Node *ncmp = phase->transform( new CmpINode(cmp1->in(1),cmp1->in(2))); + return new BoolNode( ncmp, _test._test ); } // Change (-A vs 0) into (A vs 0) by commuting the test. Disallow in the @@ -1292,8 +1292,8 @@ Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) { cmp2_type == TypeInt::ZERO && phase->type( cmp1->in(1) ) == TypeInt::ZERO && phase->type( cmp1->in(2) )->higher_equal(TypeInt::SYMINT) ) { - Node *ncmp = phase->transform( new (phase->C) CmpINode(cmp1->in(2),cmp2)); - return new (phase->C) BoolNode( ncmp, _test.commute() ); + Node *ncmp = phase->transform( new CmpINode(cmp1->in(2),cmp2)); + return new BoolNode( ncmp, _test.commute() ); } // The transformation below is not valid for either signed or unsigned diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp index 49a0dae9ece..72fabf9cc22 100644 --- a/hotspot/src/share/vm/opto/superword.cpp +++ b/hotspot/src/share/vm/opto/superword.cpp @@ -1456,7 +1456,7 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) { if (t == NULL || t->_lo < 0 || t->_hi > (int)mask) { cnt = ConNode::make(C, TypeInt::make(mask)); _igvn.register_new_node_with_optimizer(cnt); - cnt = new (C) AndINode(opd, cnt); + cnt = new AndINode(opd, cnt); _igvn.register_new_node_with_optimizer(cnt); _phase->set_ctrl(cnt, _phase->get_ctrl(opd)); } @@ -2067,42 +2067,42 @@ void SuperWord::align_initial_loop_index(MemNode* align_to_ref) { if (align_to_ref_p.invar() != NULL) { // incorporate any extra invariant piece producing (offset +/- invar) >>> log2(elt) Node* log2_elt = _igvn.intcon(exact_log2(elt_size)); - Node* aref = new (_phase->C) URShiftINode(align_to_ref_p.invar(), log2_elt); + Node* aref = new URShiftINode(align_to_ref_p.invar(), log2_elt); _igvn.register_new_node_with_optimizer(aref); _phase->set_ctrl(aref, pre_ctrl); if (align_to_ref_p.negate_invar()) { - e = new (_phase->C) SubINode(e, aref); + e = new SubINode(e, aref); } else { - e = new (_phase->C) AddINode(e, aref); + e = new AddINode(e, aref); } _igvn.register_new_node_with_optimizer(e); _phase->set_ctrl(e, pre_ctrl); } if (vw > ObjectAlignmentInBytes) { // incorporate base e +/- base && Mask >>> log2(elt) - Node* xbase = new(_phase->C) CastP2XNode(NULL, align_to_ref_p.base()); + Node* xbase = new CastP2XNode(NULL, align_to_ref_p.base()); _igvn.register_new_node_with_optimizer(xbase); #ifdef _LP64 - xbase = new (_phase->C) ConvL2INode(xbase); + xbase = new ConvL2INode(xbase); _igvn.register_new_node_with_optimizer(xbase); #endif Node* mask = _igvn.intcon(vw-1); - Node* masked_xbase = new (_phase->C) AndINode(xbase, mask); + Node* masked_xbase = new AndINode(xbase, mask); _igvn.register_new_node_with_optimizer(masked_xbase); Node* log2_elt = _igvn.intcon(exact_log2(elt_size)); - Node* bref = new (_phase->C) URShiftINode(masked_xbase, log2_elt); + Node* bref = new URShiftINode(masked_xbase, log2_elt); _igvn.register_new_node_with_optimizer(bref); _phase->set_ctrl(bref, pre_ctrl); - e = new (_phase->C) AddINode(e, bref); + e = new AddINode(e, bref); _igvn.register_new_node_with_optimizer(e); _phase->set_ctrl(e, pre_ctrl); } // compute e +/- lim0 if (scale < 0) { - e = new (_phase->C) SubINode(e, lim0); + e = new SubINode(e, lim0); } else { - e = new (_phase->C) AddINode(e, lim0); + e = new AddINode(e, lim0); } _igvn.register_new_node_with_optimizer(e); _phase->set_ctrl(e, pre_ctrl); @@ -2110,13 +2110,13 @@ void SuperWord::align_initial_loop_index(MemNode* align_to_ref) { if (stride * scale > 0) { // compute V - (e +/- lim0) Node* va = _igvn.intcon(v_align); - e = new (_phase->C) SubINode(va, e); + e = new SubINode(va, e); _igvn.register_new_node_with_optimizer(e); _phase->set_ctrl(e, pre_ctrl); } // compute N = (exp) % V Node* va_msk = _igvn.intcon(v_align - 1); - Node* N = new (_phase->C) AndINode(e, va_msk); + Node* N = new AndINode(e, va_msk); _igvn.register_new_node_with_optimizer(N); _phase->set_ctrl(N, pre_ctrl); @@ -2124,15 +2124,15 @@ void SuperWord::align_initial_loop_index(MemNode* align_to_ref) { // lim = lim0 + N Node* lim; if (stride < 0) { - lim = new (_phase->C) SubINode(lim0, N); + lim = new SubINode(lim0, N); } else { - lim = new (_phase->C) AddINode(lim0, N); + lim = new AddINode(lim0, N); } _igvn.register_new_node_with_optimizer(lim); _phase->set_ctrl(lim, pre_ctrl); Node* constrained = - (stride > 0) ? (Node*) new (_phase->C) MinINode(lim, orig_limit) - : (Node*) new (_phase->C) MaxINode(lim, orig_limit); + (stride > 0) ? (Node*) new MinINode(lim, orig_limit) + : (Node*) new MaxINode(lim, orig_limit); _igvn.register_new_node_with_optimizer(constrained); _phase->set_ctrl(constrained, pre_ctrl); _igvn.hash_delete(pre_opaq); diff --git a/hotspot/src/share/vm/opto/vectornode.cpp b/hotspot/src/share/vm/opto/vectornode.cpp index 9660d4ed818..21b51e5b524 100644 --- a/hotspot/src/share/vm/opto/vectornode.cpp +++ b/hotspot/src/share/vm/opto/vectornode.cpp @@ -252,46 +252,46 @@ VectorNode* VectorNode::make(Compile* C, int opc, Node* n1, Node* n2, uint vlen, guarantee(vopc > 0, err_msg_res("Vector for '%s' is not implemented", NodeClassNames[opc])); switch (vopc) { - case Op_AddVB: return new (C) AddVBNode(n1, n2, vt); - case Op_AddVS: return new (C) AddVSNode(n1, n2, vt); - case Op_AddVI: return new (C) AddVINode(n1, n2, vt); - case Op_AddVL: return new (C) AddVLNode(n1, n2, vt); - case Op_AddVF: return new (C) AddVFNode(n1, n2, vt); - case Op_AddVD: return new (C) AddVDNode(n1, n2, vt); + case Op_AddVB: return new AddVBNode(n1, n2, vt); + case Op_AddVS: return new AddVSNode(n1, n2, vt); + case Op_AddVI: return new AddVINode(n1, n2, vt); + case Op_AddVL: return new AddVLNode(n1, n2, vt); + case Op_AddVF: return new AddVFNode(n1, n2, vt); + case Op_AddVD: return new AddVDNode(n1, n2, vt); - case Op_SubVB: return new (C) SubVBNode(n1, n2, vt); - case Op_SubVS: return new (C) SubVSNode(n1, n2, vt); - case Op_SubVI: return new (C) SubVINode(n1, n2, vt); - case Op_SubVL: return new (C) SubVLNode(n1, n2, vt); - case Op_SubVF: return new (C) SubVFNode(n1, n2, vt); - case Op_SubVD: return new (C) SubVDNode(n1, n2, vt); + case Op_SubVB: return new SubVBNode(n1, n2, vt); + case Op_SubVS: return new SubVSNode(n1, n2, vt); + case Op_SubVI: return new SubVINode(n1, n2, vt); + case Op_SubVL: return new SubVLNode(n1, n2, vt); + case Op_SubVF: return new SubVFNode(n1, n2, vt); + case Op_SubVD: return new SubVDNode(n1, n2, vt); - case Op_MulVS: return new (C) MulVSNode(n1, n2, vt); - case Op_MulVI: return new (C) MulVINode(n1, n2, vt); - case Op_MulVF: return new (C) MulVFNode(n1, n2, vt); - case Op_MulVD: return new (C) MulVDNode(n1, n2, vt); + case Op_MulVS: return new MulVSNode(n1, n2, vt); + case Op_MulVI: return new MulVINode(n1, n2, vt); + case Op_MulVF: return new MulVFNode(n1, n2, vt); + case Op_MulVD: return new MulVDNode(n1, n2, vt); - case Op_DivVF: return new (C) DivVFNode(n1, n2, vt); - case Op_DivVD: return new (C) DivVDNode(n1, n2, vt); + case Op_DivVF: return new DivVFNode(n1, n2, vt); + case Op_DivVD: return new DivVDNode(n1, n2, vt); - case Op_LShiftVB: return new (C) LShiftVBNode(n1, n2, vt); - case Op_LShiftVS: return new (C) LShiftVSNode(n1, n2, vt); - case Op_LShiftVI: return new (C) LShiftVINode(n1, n2, vt); - case Op_LShiftVL: return new (C) LShiftVLNode(n1, n2, vt); + case Op_LShiftVB: return new LShiftVBNode(n1, n2, vt); + case Op_LShiftVS: return new LShiftVSNode(n1, n2, vt); + case Op_LShiftVI: return new LShiftVINode(n1, n2, vt); + case Op_LShiftVL: return new LShiftVLNode(n1, n2, vt); - case Op_RShiftVB: return new (C) RShiftVBNode(n1, n2, vt); - case Op_RShiftVS: return new (C) RShiftVSNode(n1, n2, vt); - case Op_RShiftVI: return new (C) RShiftVINode(n1, n2, vt); - case Op_RShiftVL: return new (C) RShiftVLNode(n1, n2, vt); + case Op_RShiftVB: return new RShiftVBNode(n1, n2, vt); + case Op_RShiftVS: return new RShiftVSNode(n1, n2, vt); + case Op_RShiftVI: return new RShiftVINode(n1, n2, vt); + case Op_RShiftVL: return new RShiftVLNode(n1, n2, vt); - case Op_URShiftVB: return new (C) URShiftVBNode(n1, n2, vt); - case Op_URShiftVS: return new (C) URShiftVSNode(n1, n2, vt); - case Op_URShiftVI: return new (C) URShiftVINode(n1, n2, vt); - case Op_URShiftVL: return new (C) URShiftVLNode(n1, n2, vt); + case Op_URShiftVB: return new URShiftVBNode(n1, n2, vt); + case Op_URShiftVS: return new URShiftVSNode(n1, n2, vt); + case Op_URShiftVI: return new URShiftVINode(n1, n2, vt); + case Op_URShiftVL: return new URShiftVLNode(n1, n2, vt); - case Op_AndV: return new (C) AndVNode(n1, n2, vt); - case Op_OrV: return new (C) OrVNode (n1, n2, vt); - case Op_XorV: return new (C) XorVNode(n1, n2, vt); + case Op_AndV: return new AndVNode(n1, n2, vt); + case Op_OrV: return new OrVNode (n1, n2, vt); + case Op_XorV: return new XorVNode(n1, n2, vt); } fatal(err_msg_res("Missed vector creation for '%s'", NodeClassNames[vopc])); return NULL; @@ -306,18 +306,18 @@ VectorNode* VectorNode::scalar2vector(Compile* C, Node* s, uint vlen, const Type switch (bt) { case T_BOOLEAN: case T_BYTE: - return new (C) ReplicateBNode(s, vt); + return new ReplicateBNode(s, vt); case T_CHAR: case T_SHORT: - return new (C) ReplicateSNode(s, vt); + return new ReplicateSNode(s, vt); case T_INT: - return new (C) ReplicateINode(s, vt); + return new ReplicateINode(s, vt); case T_LONG: - return new (C) ReplicateLNode(s, vt); + return new ReplicateLNode(s, vt); case T_FLOAT: - return new (C) ReplicateFNode(s, vt); + return new ReplicateFNode(s, vt); case T_DOUBLE: - return new (C) ReplicateDNode(s, vt); + return new ReplicateDNode(s, vt); } fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt))); return NULL; @@ -330,12 +330,12 @@ VectorNode* VectorNode::shift_count(Compile* C, Node* shift, Node* cnt, uint vle switch (shift->Opcode()) { case Op_LShiftI: case Op_LShiftL: - return new (C) LShiftCntVNode(cnt, vt); + return new LShiftCntVNode(cnt, vt); case Op_RShiftI: case Op_RShiftL: case Op_URShiftI: case Op_URShiftL: - return new (C) RShiftCntVNode(cnt, vt); + return new RShiftCntVNode(cnt, vt); } fatal(err_msg_res("Missed vector creation for '%s'", NodeClassNames[shift->Opcode()])); return NULL; @@ -347,18 +347,18 @@ PackNode* PackNode::make(Compile* C, Node* s, uint vlen, BasicType bt) { switch (bt) { case T_BOOLEAN: case T_BYTE: - return new (C) PackBNode(s, vt); + return new PackBNode(s, vt); case T_CHAR: case T_SHORT: - return new (C) PackSNode(s, vt); + return new PackSNode(s, vt); case T_INT: - return new (C) PackINode(s, vt); + return new PackINode(s, vt); case T_LONG: - return new (C) PackLNode(s, vt); + return new PackLNode(s, vt); case T_FLOAT: - return new (C) PackFNode(s, vt); + return new PackFNode(s, vt); case T_DOUBLE: - return new (C) PackDNode(s, vt); + return new PackDNode(s, vt); } fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt))); return NULL; @@ -383,18 +383,18 @@ PackNode* PackNode::binary_tree_pack(Compile* C, int lo, int hi) { switch (bt) { case T_BOOLEAN: case T_BYTE: - return new (C) PackSNode(n1, n2, TypeVect::make(T_SHORT, 2)); + return new PackSNode(n1, n2, TypeVect::make(T_SHORT, 2)); case T_CHAR: case T_SHORT: - return new (C) PackINode(n1, n2, TypeVect::make(T_INT, 2)); + return new PackINode(n1, n2, TypeVect::make(T_INT, 2)); case T_INT: - return new (C) PackLNode(n1, n2, TypeVect::make(T_LONG, 2)); + return new PackLNode(n1, n2, TypeVect::make(T_LONG, 2)); case T_LONG: - return new (C) Pack2LNode(n1, n2, TypeVect::make(T_LONG, 2)); + return new Pack2LNode(n1, n2, TypeVect::make(T_LONG, 2)); case T_FLOAT: - return new (C) PackDNode(n1, n2, TypeVect::make(T_DOUBLE, 2)); + return new PackDNode(n1, n2, TypeVect::make(T_DOUBLE, 2)); case T_DOUBLE: - return new (C) Pack2DNode(n1, n2, TypeVect::make(T_DOUBLE, 2)); + return new Pack2DNode(n1, n2, TypeVect::make(T_DOUBLE, 2)); } fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt))); } @@ -405,14 +405,14 @@ PackNode* PackNode::binary_tree_pack(Compile* C, int lo, int hi) { LoadVectorNode* LoadVectorNode::make(Compile* C, int opc, Node* ctl, Node* mem, Node* adr, const TypePtr* atyp, uint vlen, BasicType bt) { const TypeVect* vt = TypeVect::make(bt, vlen); - return new (C) LoadVectorNode(ctl, mem, adr, atyp, vt); + return new LoadVectorNode(ctl, mem, adr, atyp, vt); } // Return the vector version of a scalar store node. StoreVectorNode* StoreVectorNode::make(Compile* C, int opc, Node* ctl, Node* mem, Node* adr, const TypePtr* atyp, Node* val, uint vlen) { - return new (C) StoreVectorNode(ctl, mem, adr, atyp, val); + return new StoreVectorNode(ctl, mem, adr, atyp, val); } // Extract a scalar element of vector. @@ -421,21 +421,21 @@ Node* ExtractNode::make(Compile* C, Node* v, uint position, BasicType bt) { ConINode* pos = ConINode::make(C, (int)position); switch (bt) { case T_BOOLEAN: - return new (C) ExtractUBNode(v, pos); + return new ExtractUBNode(v, pos); case T_BYTE: - return new (C) ExtractBNode(v, pos); + return new ExtractBNode(v, pos); case T_CHAR: - return new (C) ExtractCNode(v, pos); + return new ExtractCNode(v, pos); case T_SHORT: - return new (C) ExtractSNode(v, pos); + return new ExtractSNode(v, pos); case T_INT: - return new (C) ExtractINode(v, pos); + return new ExtractINode(v, pos); case T_LONG: - return new (C) ExtractLNode(v, pos); + return new ExtractLNode(v, pos); case T_FLOAT: - return new (C) ExtractFNode(v, pos); + return new ExtractFNode(v, pos); case T_DOUBLE: - return new (C) ExtractDNode(v, pos); + return new ExtractDNode(v, pos); } fatal(err_msg_res("Type '%s' is not supported for vectors", type2name(bt))); return NULL; diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index a68ed456899..15f316aa6c2 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -503,6 +503,159 @@ WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method)) } WB_END +template +static bool GetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, bool (*TAt)(const char*, T*)) { + if (name == NULL) { + return false; + } + ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI + const char* flag_name = env->GetStringUTFChars(name, NULL); + bool result = (*TAt)(flag_name, value); + env->ReleaseStringUTFChars(name, flag_name); + return result; +} + +template +static bool SetVMFlag(JavaThread* thread, JNIEnv* env, jstring name, T* value, bool (*TAtPut)(const char*, T*, Flag::Flags)) { + if (name == NULL) { + return false; + } + ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI + const char* flag_name = env->GetStringUTFChars(name, NULL); + bool result = (*TAtPut)(flag_name, value, Flag::INTERNAL); + env->ReleaseStringUTFChars(name, flag_name); + return result; +} + +template +static jobject box(JavaThread* thread, JNIEnv* env, Symbol* name, Symbol* sig, T value) { + ResourceMark rm(thread); + jclass clazz = env->FindClass(name->as_C_string()); + CHECK_JNI_EXCEPTION_(env, NULL); + jmethodID methodID = env->GetStaticMethodID(clazz, + vmSymbols::valueOf_name()->as_C_string(), + sig->as_C_string()); + CHECK_JNI_EXCEPTION_(env, NULL); + jobject result = env->CallStaticObjectMethod(clazz, methodID, value); + CHECK_JNI_EXCEPTION_(env, NULL); + return result; +} + +static jobject booleanBox(JavaThread* thread, JNIEnv* env, jboolean value) { + return box(thread, env, vmSymbols::java_lang_Boolean(), vmSymbols::Boolean_valueOf_signature(), value); +} +static jobject integerBox(JavaThread* thread, JNIEnv* env, jint value) { + return box(thread, env, vmSymbols::java_lang_Integer(), vmSymbols::Integer_valueOf_signature(), value); +} +static jobject longBox(JavaThread* thread, JNIEnv* env, jlong value) { + return box(thread, env, vmSymbols::java_lang_Long(), vmSymbols::Long_valueOf_signature(), value); +} +/* static jobject floatBox(JavaThread* thread, JNIEnv* env, jfloat value) { + return box(thread, env, vmSymbols::java_lang_Float(), vmSymbols::Float_valueOf_signature(), value); +}*/ +static jobject doubleBox(JavaThread* thread, JNIEnv* env, jdouble value) { + return box(thread, env, vmSymbols::java_lang_Double(), vmSymbols::Double_valueOf_signature(), value); +} + +WB_ENTRY(jobject, WB_GetBooleanVMFlag(JNIEnv* env, jobject o, jstring name)) + bool result; + if (GetVMFlag (thread, env, name, &result, &CommandLineFlags::boolAt)) { + ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI + return booleanBox(thread, env, result); + } + return NULL; +WB_END + +WB_ENTRY(jobject, WB_GetIntxVMFlag(JNIEnv* env, jobject o, jstring name)) + intx result; + if (GetVMFlag (thread, env, name, &result, &CommandLineFlags::intxAt)) { + ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI + return longBox(thread, env, result); + } + return NULL; +WB_END + +WB_ENTRY(jobject, WB_GetUintxVMFlag(JNIEnv* env, jobject o, jstring name)) + uintx result; + if (GetVMFlag (thread, env, name, &result, &CommandLineFlags::uintxAt)) { + ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI + return longBox(thread, env, result); + } + return NULL; +WB_END + +WB_ENTRY(jobject, WB_GetUint64VMFlag(JNIEnv* env, jobject o, jstring name)) + uint64_t result; + if (GetVMFlag (thread, env, name, &result, &CommandLineFlags::uint64_tAt)) { + ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI + return longBox(thread, env, result); + } + return NULL; +WB_END + +WB_ENTRY(jobject, WB_GetDoubleVMFlag(JNIEnv* env, jobject o, jstring name)) + double result; + if (GetVMFlag (thread, env, name, &result, &CommandLineFlags::doubleAt)) { + ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI + return doubleBox(thread, env, result); + } + return NULL; +WB_END + +WB_ENTRY(jstring, WB_GetStringVMFlag(JNIEnv* env, jobject o, jstring name)) + ccstr ccstrResult; + if (GetVMFlag (thread, env, name, &ccstrResult, &CommandLineFlags::ccstrAt)) { + ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI + jstring result = env->NewStringUTF(ccstrResult); + CHECK_JNI_EXCEPTION_(env, NULL); + return result; + } + return NULL; +WB_END + +WB_ENTRY(void, WB_SetBooleanVMFlag(JNIEnv* env, jobject o, jstring name, jboolean value)) + bool result = value == JNI_TRUE ? true : false; + SetVMFlag (thread, env, name, &result, &CommandLineFlags::boolAtPut); +WB_END + +WB_ENTRY(void, WB_SetIntxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) + intx result = value; + SetVMFlag (thread, env, name, &result, &CommandLineFlags::intxAtPut); +WB_END + +WB_ENTRY(void, WB_SetUintxVMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) + uintx result = value; + SetVMFlag (thread, env, name, &result, &CommandLineFlags::uintxAtPut); +WB_END + +WB_ENTRY(void, WB_SetUint64VMFlag(JNIEnv* env, jobject o, jstring name, jlong value)) + uint64_t result = value; + SetVMFlag (thread, env, name, &result, &CommandLineFlags::uint64_tAtPut); +WB_END + +WB_ENTRY(void, WB_SetDoubleVMFlag(JNIEnv* env, jobject o, jstring name, jdouble value)) + double result = value; + SetVMFlag (thread, env, name, &result, &CommandLineFlags::doubleAtPut); +WB_END + +WB_ENTRY(void, WB_SetStringVMFlag(JNIEnv* env, jobject o, jstring name, jstring value)) + ThreadToNativeFromVM ttnfv(thread); // can't be in VM when we call JNI + const char* ccstrValue = (value == NULL) ? NULL : env->GetStringUTFChars(value, NULL); + ccstr ccstrResult = ccstrValue; + bool needFree; + { + ThreadInVMfromNative ttvfn(thread); // back to VM + needFree = SetVMFlag (thread, env, name, &ccstrResult, &CommandLineFlags::ccstrAtPut); + } + if (value != NULL) { + env->ReleaseStringUTFChars(value, ccstrValue); + } + if (needFree) { + FREE_C_HEAP_ARRAY(char, ccstrResult, mtInternal); + } +WB_END + + WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString)) ResourceMark rm(THREAD); int len; @@ -561,11 +714,7 @@ WB_ENTRY(jobjectArray, WB_GetNMethod(JNIEnv* env, jobject o, jobject method, jbo return result; } - clazz = env->FindClass(vmSymbols::java_lang_Integer()->as_C_string()); - CHECK_JNI_EXCEPTION_(env, NULL); - jmethodID constructor = env->GetMethodID(clazz, vmSymbols::object_initializer_name()->as_C_string(), vmSymbols::int_void_signature()->as_C_string()); - CHECK_JNI_EXCEPTION_(env, NULL); - jobject obj = env->NewObject(clazz, constructor, code->comp_level()); + jobject obj = integerBox(thread, env, code->comp_level()); CHECK_JNI_EXCEPTION_(env, NULL); env->SetObjectArrayElement(result, 0, obj); @@ -695,7 +844,26 @@ static JNINativeMethod methods[] = { CC"(Ljava/lang/reflect/Executable;II)Z", (void*)&WB_EnqueueMethodForCompilation}, {CC"clearMethodState", CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState}, - {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, + {CC"setBooleanVMFlag", CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag}, + {CC"setIntxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetIntxVMFlag}, + {CC"setUintxVMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUintxVMFlag}, + {CC"setUint64VMFlag", CC"(Ljava/lang/String;J)V",(void*)&WB_SetUint64VMFlag}, + {CC"setDoubleVMFlag", CC"(Ljava/lang/String;D)V",(void*)&WB_SetDoubleVMFlag}, + {CC"setStringVMFlag", CC"(Ljava/lang/String;Ljava/lang/String;)V", + (void*)&WB_SetStringVMFlag}, + {CC"getBooleanVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Boolean;", + (void*)&WB_GetBooleanVMFlag}, + {CC"getIntxVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Long;", + (void*)&WB_GetIntxVMFlag}, + {CC"getUintxVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Long;", + (void*)&WB_GetUintxVMFlag}, + {CC"getUint64VMFlag", CC"(Ljava/lang/String;)Ljava/lang/Long;", + (void*)&WB_GetUint64VMFlag}, + {CC"getDoubleVMFlag", CC"(Ljava/lang/String;)Ljava/lang/Double;", + (void*)&WB_GetDoubleVMFlag}, + {CC"getStringVMFlag", CC"(Ljava/lang/String;)Ljava/lang/String;", + (void*)&WB_GetStringVMFlag}, + {CC"isInStringTable", CC"(Ljava/lang/String;)Z", (void*)&WB_IsInStringTable }, {CC"fullGC", CC"()V", (void*)&WB_FullGC }, {CC"readReservedMemory", CC"()V", (void*)&WB_ReadReservedMemory }, {CC"getCPUFeatures", CC"()Ljava/lang/String;", (void*)&WB_GetCPUFeatures }, diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 91e485e7aed..3c032fbf270 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -2187,6 +2187,10 @@ bool Arguments::check_vm_args_consistency() { } } + if (!(UseParallelGC || UseParallelOldGC) && FLAG_IS_DEFAULT(ScavengeBeforeFullGC)) { + FLAG_SET_DEFAULT(ScavengeBeforeFullGC, false); + } + status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit"); status = status && verify_percentage(GCTimeLimit, "GCTimeLimit"); if (GCTimeLimit == 100) { @@ -3834,10 +3838,6 @@ jint Arguments::apply_ergo() { // 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); - } #endif if (PrintAssembly && FLAG_IS_DEFAULT(DebugNonSafepoints)) { diff --git a/hotspot/src/share/vm/runtime/deoptimization.cpp b/hotspot/src/share/vm/runtime/deoptimization.cpp index e4b1292c6b6..b15664f4b52 100644 --- a/hotspot/src/share/vm/runtime/deoptimization.cpp +++ b/hotspot/src/share/vm/runtime/deoptimization.cpp @@ -1840,6 +1840,7 @@ const char* Deoptimization::_trap_reason_name[] = { "speculate_class_check", "speculate_null_check", "rtm_state_change", + "unstable_if", "tenured" }; const char* Deoptimization::_trap_action_name[] = { diff --git a/hotspot/src/share/vm/runtime/deoptimization.hpp b/hotspot/src/share/vm/runtime/deoptimization.hpp index 02daabccb98..ee461196bd0 100644 --- a/hotspot/src/share/vm/runtime/deoptimization.hpp +++ b/hotspot/src/share/vm/runtime/deoptimization.hpp @@ -62,6 +62,10 @@ class Deoptimization : AllStatic { Reason_speculate_class_check, // saw unexpected object class from type speculation Reason_speculate_null_check, // saw unexpected null from type speculation Reason_rtm_state_change, // rtm state change detected + Reason_unstable_if, // a branch predicted always false was taken + + // Reason_tenured is counted separately, add normal counted Reasons above. + // Related to MethodData::_trap_hist_limit where Reason_tenured isn't included Reason_tenured, // age of the code has reached the limit Reason_LIMIT, // Note: Keep this enum in sync. with _trap_reason_name. @@ -319,6 +323,8 @@ class Deoptimization : AllStatic { return Reason_class_check; else if (reason == Reason_speculate_null_check) return Reason_null_check; + else if (reason == Reason_unstable_if) + return Reason_intrinsic; else return Reason_none; } diff --git a/hotspot/src/share/vm/runtime/globals.cpp b/hotspot/src/share/vm/runtime/globals.cpp index 05daec54cf8..928f7134e14 100644 --- a/hotspot/src/share/vm/runtime/globals.cpp +++ b/hotspot/src/share/vm/runtime/globals.cpp @@ -611,7 +611,7 @@ static void trace_flag_changed(const char* name, const T old_value, const T new_ e.commit(); } -bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) { +bool CommandLineFlags::boolAt(const char* name, size_t len, bool* value) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_bool()) return false; @@ -619,7 +619,7 @@ bool CommandLineFlags::boolAt(char* name, size_t len, bool* value) { return true; } -bool CommandLineFlags::boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin) { +bool CommandLineFlags::boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_bool()) return false; @@ -639,7 +639,7 @@ void CommandLineFlagsEx::boolAtPut(CommandLineFlagWithType flag, bool value, Fla faddr->set_origin(origin); } -bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) { +bool CommandLineFlags::intxAt(const char* name, size_t len, intx* value) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_intx()) return false; @@ -647,7 +647,7 @@ bool CommandLineFlags::intxAt(char* name, size_t len, intx* value) { return true; } -bool CommandLineFlags::intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin) { +bool CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_intx()) return false; @@ -667,7 +667,7 @@ void CommandLineFlagsEx::intxAtPut(CommandLineFlagWithType flag, intx value, Fla faddr->set_origin(origin); } -bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) { +bool CommandLineFlags::uintxAt(const char* name, size_t len, uintx* value) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_uintx()) return false; @@ -675,7 +675,7 @@ bool CommandLineFlags::uintxAt(char* name, size_t len, uintx* value) { return true; } -bool CommandLineFlags::uintxAtPut(char* name, size_t len, uintx* value, Flag::Flags origin) { +bool CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_uintx()) return false; @@ -695,7 +695,7 @@ void CommandLineFlagsEx::uintxAtPut(CommandLineFlagWithType flag, uintx value, F faddr->set_origin(origin); } -bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) { +bool CommandLineFlags::uint64_tAt(const char* name, size_t len, uint64_t* value) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_uint64_t()) return false; @@ -703,7 +703,7 @@ bool CommandLineFlags::uint64_tAt(char* name, size_t len, uint64_t* value) { return true; } -bool CommandLineFlags::uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin) { +bool CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_uint64_t()) return false; @@ -723,7 +723,7 @@ void CommandLineFlagsEx::uint64_tAtPut(CommandLineFlagWithType flag, uint64_t va faddr->set_origin(origin); } -bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) { +bool CommandLineFlags::doubleAt(const char* name, size_t len, double* value) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_double()) return false; @@ -731,7 +731,7 @@ bool CommandLineFlags::doubleAt(char* name, size_t len, double* value) { return true; } -bool CommandLineFlags::doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin) { +bool CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_double()) return false; @@ -751,7 +751,7 @@ void CommandLineFlagsEx::doubleAtPut(CommandLineFlagWithType flag, double value, faddr->set_origin(origin); } -bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) { +bool CommandLineFlags::ccstrAt(const char* name, size_t len, ccstr* value) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_ccstr()) return false; @@ -759,7 +759,7 @@ bool CommandLineFlags::ccstrAt(char* name, size_t len, ccstr* value) { return true; } -bool CommandLineFlags::ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin) { +bool CommandLineFlags::ccstrAtPut(const char* name, size_t len, ccstr* value, Flag::Flags origin) { Flag* result = Flag::find_flag(name, len); if (result == NULL) return false; if (!result->is_ccstr()) return false; diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 9952ad96bb7..1dbf51c8632 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -362,37 +362,37 @@ class DoubleFlagSetting { class CommandLineFlags { public: - static bool boolAt(char* name, size_t len, bool* value); - static bool boolAt(char* name, bool* value) { return boolAt(name, strlen(name), value); } - static bool boolAtPut(char* name, size_t len, bool* value, Flag::Flags origin); - static bool boolAtPut(char* name, bool* value, Flag::Flags origin) { return boolAtPut(name, strlen(name), value, origin); } + static bool boolAt(const char* name, size_t len, bool* value); + static bool boolAt(const char* name, bool* value) { return boolAt(name, strlen(name), value); } + static bool boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin); + static bool boolAtPut(const char* name, bool* value, Flag::Flags origin) { return boolAtPut(name, strlen(name), value, origin); } - static bool intxAt(char* name, size_t len, intx* value); - static bool intxAt(char* name, intx* value) { return intxAt(name, strlen(name), value); } - static bool intxAtPut(char* name, size_t len, intx* value, Flag::Flags origin); - static bool intxAtPut(char* name, intx* value, Flag::Flags origin) { return intxAtPut(name, strlen(name), value, origin); } + static bool intxAt(const char* name, size_t len, intx* value); + static bool intxAt(const char* name, intx* value) { return intxAt(name, strlen(name), value); } + static bool intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin); + static bool intxAtPut(const char* name, intx* value, Flag::Flags origin) { return intxAtPut(name, strlen(name), value, origin); } - static bool uintxAt(char* name, size_t len, uintx* value); - static bool uintxAt(char* name, uintx* value) { return uintxAt(name, strlen(name), value); } - static bool uintxAtPut(char* name, size_t len, uintx* value, Flag::Flags origin); - static bool uintxAtPut(char* name, uintx* value, Flag::Flags origin) { return uintxAtPut(name, strlen(name), value, origin); } + static bool uintxAt(const char* name, size_t len, uintx* value); + static bool uintxAt(const char* name, uintx* value) { return uintxAt(name, strlen(name), value); } + static bool uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin); + static bool uintxAtPut(const char* name, uintx* value, Flag::Flags origin) { return uintxAtPut(name, strlen(name), value, origin); } - static bool uint64_tAt(char* name, size_t len, uint64_t* value); - static bool uint64_tAt(char* name, uint64_t* value) { return uint64_tAt(name, strlen(name), value); } - static bool uint64_tAtPut(char* name, size_t len, uint64_t* value, Flag::Flags origin); - static bool uint64_tAtPut(char* name, uint64_t* value, Flag::Flags origin) { return uint64_tAtPut(name, strlen(name), value, origin); } + static bool uint64_tAt(const char* name, size_t len, uint64_t* value); + static bool uint64_tAt(const char* name, uint64_t* value) { return uint64_tAt(name, strlen(name), value); } + static bool uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin); + static bool uint64_tAtPut(const char* name, uint64_t* value, Flag::Flags origin) { return uint64_tAtPut(name, strlen(name), value, origin); } - static bool doubleAt(char* name, size_t len, double* value); - static bool doubleAt(char* name, double* value) { return doubleAt(name, strlen(name), value); } - static bool doubleAtPut(char* name, size_t len, double* value, Flag::Flags origin); - static bool doubleAtPut(char* name, double* value, Flag::Flags origin) { return doubleAtPut(name, strlen(name), value, origin); } + static bool doubleAt(const char* name, size_t len, double* value); + static bool doubleAt(const char* name, double* value) { return doubleAt(name, strlen(name), value); } + static bool doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin); + static bool doubleAtPut(const char* name, double* value, Flag::Flags origin) { return doubleAtPut(name, strlen(name), value, origin); } - static bool ccstrAt(char* name, size_t len, ccstr* value); - static bool ccstrAt(char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); } + static bool ccstrAt(const char* name, size_t len, ccstr* value); + static bool ccstrAt(const char* name, ccstr* value) { return ccstrAt(name, strlen(name), value); } // Contract: Flag will make private copy of the incoming value. // Outgoing value is always malloc-ed, and caller MUST call free. - static bool ccstrAtPut(char* name, size_t len, ccstr* value, Flag::Flags origin); - static bool ccstrAtPut(char* name, ccstr* value, Flag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); } + static bool ccstrAtPut(const char* name, size_t len, ccstr* value, Flag::Flags origin); + static bool ccstrAtPut(const char* name, ccstr* value, Flag::Flags origin) { return ccstrAtPut(name, strlen(name), value, origin); } // Returns false if name is not a command line flag. static bool wasSetOnCmdline(const char* name, bool* value); @@ -599,6 +599,9 @@ class CommandLineFlags { product(bool, UseAES, false, \ "Control whether AES instructions can be used on x86/x64") \ \ + product(bool, UseSHA, false, \ + "Control whether SHA instructions can be used on SPARC") \ + \ product(uintx, LargePageSizeInBytes, 0, \ "Large page size (0 to let VM choose the page size)") \ \ @@ -705,6 +708,15 @@ class CommandLineFlags { product(bool, UseAESIntrinsics, false, \ "Use intrinsics for AES versions of crypto") \ \ + product(bool, UseSHA1Intrinsics, false, \ + "Use intrinsics for SHA-1 crypto hash function") \ + \ + product(bool, UseSHA256Intrinsics, false, \ + "Use intrinsics for SHA-224 and SHA-256 crypto hash functions") \ + \ + product(bool, UseSHA512Intrinsics, false, \ + "Use intrinsics for SHA-384 and SHA-512 crypto hash functions") \ + \ product(bool, UseCRC32Intrinsics, false, \ "use intrinsics for java.util.zip.CRC32") \ \ @@ -1097,7 +1109,7 @@ class CommandLineFlags { "Call loadClassInternal() rather than loadClass()") \ \ product_pd(bool, DontYieldALot, \ - "Throw away obvious excess yield calls (for Solaris only)") \ + "Throw away obvious excess yield calls") \ \ product_pd(bool, ConvertSleepToYield, \ "Convert sleep(0) to thread yield " \ @@ -1105,7 +1117,7 @@ class CommandLineFlags { \ product(bool, ConvertYieldToSleep, false, \ "Convert yield to a sleep of MinSleepInterval to simulate Win32 " \ - "behavior (Solaris only)") \ + "behavior") \ \ product(bool, UseBoundThreads, true, \ "Bind user level threads to kernel threads (for Solaris only)") \ @@ -1143,8 +1155,8 @@ class CommandLineFlags { "avoid NPTL-FUTEX hang pthread_cond_timedwait") \ \ product(bool, FilterSpuriousWakeups, true, \ - "Prevent spurious or premature wakeups from object.wait " \ - "(Solaris only)") \ + "When true prevents OS-level spurious, or premature, wakeups " \ + "from Object.wait (Ignored for Windows)") \ \ product(intx, NativeMonitorTimeout, -1, "(Unstable)") \ \ @@ -1450,8 +1462,7 @@ class CommandLineFlags { "(ParallelGC only)") \ \ product(bool, ScavengeBeforeFullGC, true, \ - "Scavenge youngest generation before each full GC, " \ - "used with UseParallelGC") \ + "Scavenge youngest generation before each full GC.") \ \ develop(bool, ScavengeWithObjectsInToSpace, false, \ "Allow scavenges to occur when to-space contains objects") \ @@ -2252,9 +2263,6 @@ class CommandLineFlags { notproduct(bool, CheckMemoryInitialization, false, \ "Check memory initialization") \ \ - product(bool, CollectGen0First, false, \ - "Collect youngest generation before each full GC") \ - \ diagnostic(bool, BindCMSThreadToCPU, false, \ "Bind CMS Thread to CPU if possible") \ \ @@ -2333,11 +2341,11 @@ class CommandLineFlags { NOT_LP64(2200*K) LP64_ONLY(4*M), \ "Initial size of the boot class loader data metaspace") \ \ - product(bool, TraceGen0Time, false, \ - "Trace accumulated time for Gen 0 collection") \ + product(bool, TraceYoungGenTime, false, \ + "Trace accumulated time for young collection") \ \ - product(bool, TraceGen1Time, false, \ - "Trace accumulated time for Gen 1 collection") \ + product(bool, TraceOldGenTime, false, \ + "Trace accumulated time for old collection") \ \ product(bool, PrintTenuringDistribution, false, \ "Print tenuring age information") \ diff --git a/hotspot/src/share/vm/runtime/stubRoutines.cpp b/hotspot/src/share/vm/runtime/stubRoutines.cpp index ff12ca65163..6febb5bcee9 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.cpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -125,6 +125,13 @@ address StubRoutines::_aescrypt_decryptBlock = NULL; address StubRoutines::_cipherBlockChaining_encryptAESCrypt = NULL; address StubRoutines::_cipherBlockChaining_decryptAESCrypt = NULL; +address StubRoutines::_sha1_implCompress = NULL; +address StubRoutines::_sha1_implCompressMB = NULL; +address StubRoutines::_sha256_implCompress = NULL; +address StubRoutines::_sha256_implCompressMB = NULL; +address StubRoutines::_sha512_implCompress = NULL; +address StubRoutines::_sha512_implCompressMB = NULL; + address StubRoutines::_updateBytesCRC32 = NULL; address StubRoutines::_crc_table_adr = NULL; diff --git a/hotspot/src/share/vm/runtime/stubRoutines.hpp b/hotspot/src/share/vm/runtime/stubRoutines.hpp index 9548ede87f0..78381168fc4 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.hpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -207,6 +207,13 @@ class StubRoutines: AllStatic { static address _cipherBlockChaining_encryptAESCrypt; static address _cipherBlockChaining_decryptAESCrypt; + static address _sha1_implCompress; + static address _sha1_implCompressMB; + static address _sha256_implCompress; + static address _sha256_implCompressMB; + static address _sha512_implCompress; + static address _sha512_implCompressMB; + static address _updateBytesCRC32; static address _crc_table_adr; @@ -356,6 +363,13 @@ class StubRoutines: AllStatic { static address cipherBlockChaining_encryptAESCrypt() { return _cipherBlockChaining_encryptAESCrypt; } static address cipherBlockChaining_decryptAESCrypt() { return _cipherBlockChaining_decryptAESCrypt; } + static address sha1_implCompress() { return _sha1_implCompress; } + static address sha1_implCompressMB() { return _sha1_implCompressMB; } + static address sha256_implCompress() { return _sha256_implCompress; } + static address sha256_implCompressMB() { return _sha256_implCompressMB; } + static address sha512_implCompress() { return _sha512_implCompress; } + static address sha512_implCompressMB() { return _sha512_implCompressMB; } + static address updateBytesCRC32() { return _updateBytesCRC32; } static address crc_table_addr() { return _crc_table_adr; } diff --git a/hotspot/src/share/vm/runtime/vframe.cpp b/hotspot/src/share/vm/runtime/vframe.cpp index a32d03a7b21..79da635c443 100644 --- a/hotspot/src/share/vm/runtime/vframe.cpp +++ b/hotspot/src/share/vm/runtime/vframe.cpp @@ -274,7 +274,8 @@ StackValueCollection* interpretedVFrame::locals() const { // Get oopmap describing oops and int for current bci InterpreterOopMap oop_mask; if (TraceDeoptimization && Verbose) { - methodHandle m_h(thread(), method()); + // need the current JavaThread and not thread() + methodHandle m_h(Thread::current(), method()); OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); } else { method()->mask_for(bci(), &oop_mask); @@ -335,7 +336,8 @@ StackValueCollection* interpretedVFrame::expressions() const { if (!method()->is_native()) { // Get oopmap describing oops and int for current bci if (TraceDeoptimization && Verbose) { - methodHandle m_h(method()); + // need the current JavaThread and not thread() + methodHandle m_h(Thread::current(), method()); OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); } else { method()->mask_for(bci(), &oop_mask); diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 49f0b321011..1ae7ddf6681 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -2504,6 +2504,7 @@ typedef TwoOopHashtable SymbolTwoOopHashtable; declare_constant(Deoptimization::Reason_speculate_class_check) \ declare_constant(Deoptimization::Reason_speculate_null_check) \ declare_constant(Deoptimization::Reason_rtm_state_change) \ + declare_constant(Deoptimization::Reason_unstable_if) \ declare_constant(Deoptimization::Reason_tenured) \ declare_constant(Deoptimization::Reason_LIMIT) \ declare_constant(Deoptimization::Reason_RECORDED_LIMIT) \ diff --git a/hotspot/src/share/vm/utilities/growableArray.hpp b/hotspot/src/share/vm/utilities/growableArray.hpp index 1fca26e4b28..c92848d200e 100644 --- a/hotspot/src/share/vm/utilities/growableArray.hpp +++ b/hotspot/src/share/vm/utilities/growableArray.hpp @@ -349,6 +349,7 @@ template class GrowableArray : public GenericGrowableArray { // inserts the given element before the element at index i void insert_before(const int idx, const E& elem) { + assert(0 <= idx && idx <= _len, "illegal index"); check_nesting(); if (_len == _max) grow(_len); for (int j = _len - 1; j >= idx; j--) { @@ -360,7 +361,7 @@ template class GrowableArray : public GenericGrowableArray { void appendAll(const GrowableArray* l) { for (int i = 0; i < l->_len; i++) { - raw_at_put_grow(_len, l->_data[i], 0); + raw_at_put_grow(_len, l->_data[i], E()); } } diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups index 962df9e87c5..22ff9c82228 100644 --- a/hotspot/test/TEST.groups +++ b/hotspot/test/TEST.groups @@ -117,6 +117,7 @@ compact3 = \ # Tests that require compact3 API's # needs_compact3 = \ + compiler/8009761/Test8009761.java \ compiler/whitebox/DeoptimizeMethodTest.java \ compiler/whitebox/SetForceInlineMethodTest.java \ compiler/whitebox/SetDontInlineMethodTest.java \ @@ -216,3 +217,111 @@ compact1_minimal = \ -:needs_compact3 \ -:needs_jre \ -:needs_jdk + +# All tests that explicitly set the G1 GC +# +needs_g1gc = \ + compiler/regalloc/C1ObjectSpillInLogicOp.java \ + gc/8000311/Test8000311.java \ + gc/TestG1ZeroPGCTJcmdThreadPrint.java \ + gc/TestSystemGC.java \ + gc/arguments/TestAlignmentToUseLargePages.java \ + gc/arguments/TestG1HeapRegionSize.java \ + gc/arguments/TestG1HeapSizeFlags.java \ + gc/arguments/TestMaxHeapSizeTools.java \ + gc/arguments/TestMaxNewSize.java \ + gc/arguments/TestUseCompressedOopsErgo.java \ + gc/g1/ \ + gc/metaspace/G1AddMetaspaceDependency.java \ + gc/metaspace/TestMetaspacePerfCounters.java \ + gc/startup_warnings/TestG1.java + +# All tests that explicitly set the serial GC +# +needs_serialgc = \ + gc/TestSystemGC.java \ + gc/arguments/TestAlignmentToUseLargePages.java \ + gc/arguments/TestMaxNewSize.java \ + gc/arguments/TestSerialHeapSizeFlags.java \ + gc/arguments/TestUseCompressedOopsErgo.java \ + gc/defnew/HeapChangeLogging.java \ + gc/metaspace/TestMetaspacePerfCounters.java \ + gc/metaspace/TestPerfCountersAndMemoryPools.java \ + gc/startup_warnings/TestSerialGC.java + +# All tests that explicitly set the parallel GC +# +needs_parallelgc = \ + gc/TestSystemGC.java \ + gc/arguments/TestAlignmentToUseLargePages.java \ + gc/arguments/TestMaxNewSize.java \ + gc/arguments/TestMinInitialErgonomics.java \ + gc/arguments/TestUseCompressedOopsErgo.java \ + gc/metaspace/TestMetaspacePerfCounters.java \ + gc/parallelScavenge/ \ + gc/startup_warnings/TestParallelGC.java \ + gc/startup_warnings/TestParallelScavengeSerialOld.java + +# All tests that explicitly set the CMS GC +# +needs_cmsgc = \ + gc/6581734/Test6581734.java \ + gc/TestSystemGC.java \ + gc/arguments/TestAlignmentToUseLargePages.java \ + gc/arguments/TestCMSHeapSizeFlags.java \ + gc/arguments/TestMaxNewSize.java \ + gc/arguments/TestUseCompressedOopsErgo.java \ + gc/concurrentMarkSweep/ \ + gc/startup_warnings/TestCMS.java \ + gc/startup_warnings/TestCMSIncrementalMode.java \ + gc/startup_warnings/TestCMSNoIncrementalMode.java \ + gc/startup_warnings/TestDefNewCMS.java \ + gc/startup_warnings/TestParNewCMS.java + +# All tests that explicitly set some GC +# +needs_gc = \ + :needs_g1gc \ + :needs_serialgc \ + :needs_parallelgc \ + :needs_cmsgc + +# All tests that do not set any GC explicitly +# +not_needs_gc = \ + :jdk \ + -:needs_gc + +# All tests that could be executed with the G1 GC without VM flags conflict +# +applicable_g1gc = \ + :jdk \ + -:needs_serialgc \ + -:needs_parallelgc \ + -:needs_cmsgc + +# All tests that could be executed with the serial GC without VM flags conflict +# +applicable_serialgc = \ + :jdk \ + -:needs_g1gc \ + -:needs_parallelgc \ + -:needs_cmsgc + +# All tests that could be executed with the parallel GC without VM flags conflict +# +applicable_parallelgc = \ + :jdk \ + -:needs_g1gc \ + -:needs_serialgc \ + -:needs_cmsgc + +# All tests that could be executed with the CMS GC without VM flags conflict +# +applicable_cmsgc = \ + :jdk \ + -:needs_g1gc \ + -:needs_serialgc \ + -:needs_parallelgc + + diff --git a/hotspot/test/compiler/8009761/Test8009761.java b/hotspot/test/compiler/8009761/Test8009761.java index 401458b6b92..39a25748348 100644 --- a/hotspot/test/compiler/8009761/Test8009761.java +++ b/hotspot/test/compiler/8009761/Test8009761.java @@ -21,19 +21,27 @@ * questions. */ +import com.sun.management.HotSpotDiagnosticMXBean; +import com.sun.management.VMOption; +import sun.hotspot.WhiteBox; +import sun.management.ManagementFactoryHelper; + +import java.lang.reflect.Method; + /* * @test * @bug 8009761 + * @library /testlibrary /testlibrary/whitebox * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates - * @run main/othervm -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761 - * + * @build Test8009761 + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=exclude,Test8009761::m2 -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -Xss256K Test8009761 */ - public class Test8009761 { - static class UnloadedClass { - volatile int i; - } + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + private static int COMP_LEVEL_FULL_OPTIMIZATION = 4; + private static Method m3 = null; static Object m1(boolean deopt) { // When running interpreted, on sparc, the caller's stack is @@ -142,9 +150,11 @@ public class Test8009761 { ll508, ll509, ll510, ll511; if (deopt) { - UnloadedClass res = new UnloadedClass(); // sufficient to force deopt with c2 but not c1 - res.i = 0; // forces deopt with c1 - return res; + // Force deoptimization of m3 + WHITE_BOX.deoptimizeMethod(m3); + if(WHITE_BOX.isMethodCompiled(m3)) { + throw new RuntimeException(m3 + " not deoptimized"); + } } return null; } @@ -225,6 +235,18 @@ public class Test8009761 { } static public void main(String[] args) { + // Make sure background compilation is disabled + if (backgroundCompilationEnabled()) { + throw new RuntimeException("Background compilation enabled"); + } + + try { + // Get Method object for m3 + m3 = Test8009761.class.getDeclaredMethod("m3", boolean.class, boolean.class); + } catch (NoSuchMethodException | SecurityException ex) { + throw new RuntimeException("Failed to retrieve method m3"); + } + int c1; // Call m2 from m3 recursively until stack overflow. Count the number of recursive calls. try { @@ -232,10 +254,14 @@ public class Test8009761 { } catch(StackOverflowError soe) { } c1 = count; + // Force the compilation of m3() that will inline m1() - for (int i = 0; i < 20000; i++) { - m3(false, false); + WHITE_BOX.enqueueMethodForCompilation(m3, COMP_LEVEL_FULL_OPTIMIZATION); + // Because background compilation is disabled, method should now be compiled + if(!WHITE_BOX.isMethodCompiled(m3)) { + throw new RuntimeException(m3 + " not compiled"); } + count = 0; // Force deoptimization of m3() in m1(), then return from m1() // to m3(), call recursively m2(). If deoptimization correctly @@ -245,11 +271,26 @@ public class Test8009761 { m3(false, true); } catch(StackOverflowError soe) { } - if (c1 != count) { - System.out.println("Failed: init recursive calls: " + c1 + ". After deopt " + count); - System.exit(97); + // Allow number of recursive calls to vary by 1 + if ((c1 < (count - 1)) || (c1 > (count + 1))) { + throw new RuntimeException("Failed: init recursive calls: " + c1 + ". After deopt " + count); } else { System.out.println("PASSED " + c1); } } + + /** + * Checks if background compilation (-XX:+BackgroundCompilation) is enabled. + * @return True if background compilation is enabled, false otherwise + */ + private static boolean backgroundCompilationEnabled() { + HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean(); + VMOption backgroundCompilation; + try { + backgroundCompilation = diagnostic.getVMOption("BackgroundCompilation"); + } catch (IllegalArgumentException e) { + return false; + } + return Boolean.valueOf(backgroundCompilation.getValue()); + } } diff --git a/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java b/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java new file mode 100644 index 00000000000..8a9759d6b93 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/* + * @test + * @bug 8033626 + * @summary assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place + * @library /testlibrary + * @run main/othervm -XX:-TieredCompilation -Xbatch -XX:CompileOnly=TestObjectClone::f TestObjectClone + */ +import com.oracle.java.testlibrary.Asserts; + +public class TestObjectClone implements Cloneable { + static class A extends TestObjectClone {} + static class B extends TestObjectClone { + public B clone() { + return (B)TestObjectClone.b; + } + } + static class C extends TestObjectClone { + public C clone() { + return (C)TestObjectClone.c; + } + } + static class D extends TestObjectClone { + public D clone() { + return (D)TestObjectClone.d; + } + } + static TestObjectClone a = new A(), b = new B(), c = new C(), d = new D(); + + public static Object f(TestObjectClone o) throws CloneNotSupportedException { + // Polymorphic call site: >90% Object::clone / <10% other methods + return o.clone(); + } + + public static void main(String[] args) throws Exception { + TestObjectClone[] params1 = {a, a, a, a, a, a, a, a, a, a, a, + a, a, a, a, a, a, a, a, a, a, a, + a, a, a, a, a, a, a, a, a, a, a, + b, c, d}; + + for (int i = 0; i < 15000; i++) { + f(params1[i % params1.length]); + } + + Asserts.assertTrue(f(a) != a); + Asserts.assertTrue(f(b) == b); + Asserts.assertTrue(f(c) == c); + Asserts.assertTrue(f(d) == d); + + try { + f(null); + throw new AssertionError(""); + } catch (NullPointerException e) { /* expected */ } + + System.out.println("TEST PASSED"); + } +} diff --git a/hotspot/test/compiler/intrinsics/hashcode/TestHashCode.java b/hotspot/test/compiler/intrinsics/hashcode/TestHashCode.java new file mode 100644 index 00000000000..f7d5450b351 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/hashcode/TestHashCode.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8011646 + * @summary SEGV in compiled code with loop predication + * @run main/othervm -XX:-TieredCompilation -XX:CompileOnly=TestHashCode.m1,Object.hashCode TestHashCode + * + */ + +public class TestHashCode { + static class A { + int i; + } + + static class B extends A { + } + + static boolean crash = false; + + static A m2() { + if (crash) { + return null; + } + return new A(); + } + + static int m1(A aa) { + int res = 0; + for (int i = 0; i < 10; i++) { + A a = m2(); + int j = a.i; + if (aa instanceof B) { + } + res += a.hashCode(); + } + return res; + } + + public static void main(String[] args) { + A a = new A(); + for (int i = 0; i < 20000; i++) { + m1(a); + } + crash = true; + try { + m1(a); + } catch (NullPointerException e) { + System.out.println("Test passed"); + } + } +} diff --git a/hotspot/test/compiler/intrinsics/sha/TestSHA.java b/hotspot/test/compiler/intrinsics/sha/TestSHA.java new file mode 100644 index 00000000000..08af909ee34 --- /dev/null +++ b/hotspot/test/compiler/intrinsics/sha/TestSHA.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 8035968 + * @summary C2 support for SHA on SPARC + * + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-1 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-224 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-256 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-384 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-512 TestSHA + * + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-1 -Doffset=1 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-224 -Doffset=1 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-256 -Doffset=1 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-384 -Doffset=1 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-512 -Doffset=1 TestSHA + * + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-1 -Dalgorithm2=SHA-256 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-1 -Dalgorithm2=SHA-512 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-256 -Dalgorithm2=SHA-512 TestSHA + * + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=SHA-1 -Dalgorithm2=MD5 TestSHA + * @run main/othervm/timeout=600 -Xbatch -Dalgorithm=MD5 -Dalgorithm2=SHA-1 TestSHA + */ + +import java.security.MessageDigest; +import java.util.Arrays; + +public class TestSHA { + private static final int HASH_LEN = 64; /* up to 512-bit */ + private static final int ALIGN = 8; /* for different data alignments */ + + public static void main(String[] args) throws Exception { + String provider = System.getProperty("provider", "SUN"); + String algorithm = System.getProperty("algorithm", "SHA-1"); + String algorithm2 = System.getProperty("algorithm2", ""); + int msgSize = Integer.getInteger("msgSize", 1024); + int offset = Integer.getInteger("offset", 0) % ALIGN; + int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 100000); + int warmupIters = (args.length > 1 ? Integer.valueOf(args[1]) : 20000); + + testSHA(provider, algorithm, msgSize, offset, iters, warmupIters); + + if (algorithm2.equals("") == false) { + testSHA(provider, algorithm2, msgSize, offset, iters, warmupIters); + } + } + + static void testSHA(String provider, String algorithm, int msgSize, + int offset, int iters, int warmupIters) throws Exception { + System.out.println("provider = " + provider); + System.out.println("algorithm = " + algorithm); + System.out.println("msgSize = " + msgSize + " bytes"); + System.out.println("offset = " + offset); + System.out.println("iters = " + iters); + + byte[] expectedHash = new byte[HASH_LEN]; + byte[] hash = new byte[HASH_LEN]; + byte[] data = new byte[msgSize + offset]; + for (int i = 0; i < (msgSize + offset); i++) { + data[i] = (byte)(i & 0xff); + } + + try { + MessageDigest sha = MessageDigest.getInstance(algorithm, provider); + + /* do once, which doesn't use intrinsics */ + sha.reset(); + sha.update(data, offset, msgSize); + expectedHash = sha.digest(); + + /* warm up */ + for (int i = 0; i < warmupIters; i++) { + sha.reset(); + sha.update(data, offset, msgSize); + hash = sha.digest(); + } + + /* check result */ + if (Arrays.equals(hash, expectedHash) == false) { + System.out.println("TestSHA Error: "); + showArray(expectedHash, "expectedHash"); + showArray(hash, "computedHash"); + //System.exit(1); + throw new Exception("TestSHA Error"); + } else { + showArray(hash, "hash"); + } + + /* measure performance */ + long start = System.nanoTime(); + for (int i = 0; i < iters; i++) { + sha.reset(); + sha.update(data, offset, msgSize); + hash = sha.digest(); + } + long end = System.nanoTime(); + double total = (double)(end - start)/1e9; /* in seconds */ + double thruput = (double)msgSize*iters/1e6/total; /* in MB/s */ + System.out.println("TestSHA runtime = " + total + " seconds"); + System.out.println("TestSHA throughput = " + thruput + " MB/s"); + System.out.println(); + } catch (Exception e) { + System.out.println("Exception: " + e); + //System.exit(1); + throw new Exception(e); + } + } + + static void showArray(byte b[], String name) { + System.out.format("%s [%d]: ", name, b.length); + for (int i = 0; i < Math.min(b.length, HASH_LEN); i++) { + System.out.format("%02x ", b[i] & 0xff); + } + System.out.println(); + } +} diff --git a/hotspot/test/compiler/loopopts/TestLogSum.java b/hotspot/test/compiler/loopopts/TestLogSum.java new file mode 100644 index 00000000000..a32963dfa02 --- /dev/null +++ b/hotspot/test/compiler/loopopts/TestLogSum.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8046516 + * @summary Segmentation fault in JVM (easily reproducible) + * @run main/othervm -XX:-TieredCompilation -Xbatch TestLogSum + * @author jackkamm@gmail.com + */ + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +public class TestLogSum { + public static void main(String[] args) { + double sum; + + for (int i = 0; i < 6; i++) { + for (int n = 2; n < 30; n++) { + for (int j = 1; j <= n; j++) { + for (int k = 1; k <= j; k++) { + // System.out.println(computeSum(k, j)); + sum = computeSum(k, j); + } + } + } + } + } + + private static Map, Double> cache = new HashMap, Double>(); + public static double computeSum(int x, int y) { + List key = Arrays.asList(new Integer[] {x, y}); + + if (!cache.containsKey(key)) { + + // explicitly creating/updating a double[] array, instead of using the LogSumArray wrapper object, will prevent the error + LogSumArray toReturn = new LogSumArray(x); + + // changing loop indices will prevent the error + // in particular, for(z=0; z generatedClassFiles); + static public void main(String[] args) { } } diff --git a/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java b/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java index 88e5cd835e4..acede605a4f 100644 --- a/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java +++ b/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java @@ -28,7 +28,7 @@ * @build IsMethodCompilableTest * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform - * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest + * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest * @summary testing of WB::isMethodCompilable() * @author igor.ignatyev@oracle.com */ diff --git a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java index a959900459a..8c817182e4c 100644 --- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java +++ b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java @@ -129,7 +129,7 @@ public class WhiteBox { } public native int getCompileQueueSize(int compLevel); public native boolean testSetForceInlineMethod(Executable method, boolean value); - public boolean enqueueMethodForCompilation(Executable method, int compLevel) { + public boolean enqueueMethodForCompilation(Executable method, int compLevel) { return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/); } public native boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci); @@ -156,4 +156,17 @@ public class WhiteBox { // CPU features public native String getCPUFeatures(); + // VM flags + public native void setBooleanVMFlag(String name, boolean value); + public native void setIntxVMFlag(String name, long value); + public native void setUintxVMFlag(String name, long value); + public native void setUint64VMFlag(String name, long value); + public native void setStringVMFlag(String name, String value); + public native void setDoubleVMFlag(String name, double value); + public native Boolean getBooleanVMFlag(String name); + public native Long getIntxVMFlag(String name); + public native Long getUintxVMFlag(String name); + public native Long getUint64VMFlag(String name); + public native String getStringVMFlag(String name); + public native Double getDoubleVMFlag(String name); } diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java new file mode 100644 index 00000000000..cf313c37962 --- /dev/null +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/BooleanTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test BooleanTest + * @bug 8028756 + * @library /testlibrary /testlibrary/whitebox + * @build BooleanTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI BooleanTest + * @summary testing of WB::set/getBooleanVMFlag() + * @author igor.ignatyev@oracle.com + */ + +import sun.hotspot.WhiteBox; +import com.oracle.java.testlibrary.*; +import sun.management.*; +import com.sun.management.*; + +public class BooleanTest { + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + private static final Boolean[] TESTS = {true, false, true, true, false}; + private static final String TEST_NAME = "BooleanTest"; + private static final String FLAG_NAME = "PrintCompilation"; + private static final String METHOD = TEST_NAME + "::method"; + private static final String METHOD1 = METHOD + "1"; + private static final String METHOD2 = METHOD + "2"; + + public static void main(String[] args) throws Exception { + if (args.length == 0) { + VmFlagTest.runTest(FLAG_NAME, TESTS, + VmFlagTest.WHITE_BOX::setBooleanVMFlag, + VmFlagTest.WHITE_BOX::getBooleanVMFlag); + testFunctional(false); + testFunctional(true); + } else { + boolean value = Boolean.valueOf(args[0]); + method1(); + VmFlagTest.WHITE_BOX.setBooleanVMFlag(FLAG_NAME, value); + method2(); + } + } + + private static void testFunctional(boolean value) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-Xcomp", + "-XX:CompileCommand=compileonly," + METHOD + "*", + "-XX:" + (value ? "-" : "+") + FLAG_NAME, + TEST_NAME, + "" + value); + OutputAnalyzer out = new OutputAnalyzer(pb.start()); + if (value) { + out.shouldNotContain(METHOD1); + out.shouldContain(METHOD2); + } else { + out.shouldContain(METHOD1); + out.shouldNotContain(METHOD2); + } + } + + private static void method1() { } + private static void method2() { } +} + diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java new file mode 100644 index 00000000000..2110fb9d7a7 --- /dev/null +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test DoubleTest + * @bug 8028756 + * @library /testlibrary /testlibrary/whitebox + * @build DoubleTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI DoubleTest + * @summary testing of WB::set/getDoubleVMFlag() + * @author igor.ignatyev@oracle.com + */ + +public class DoubleTest { + private static final String FLAG_NAME = null; + private static final Double[] TESTS = {0d, -0d, -1d, 1d, + Double.MAX_VALUE, Double.MIN_VALUE, Double.NaN, + Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}; + + public static void main(String[] args) throws Exception { + VmFlagTest.runTest(FLAG_NAME, TESTS, + VmFlagTest.WHITE_BOX::setDoubleVMFlag, + VmFlagTest.WHITE_BOX::getDoubleVMFlag); + } +} + diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/TypeElement.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java similarity index 51% rename from jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/TypeElement.java rename to hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java index b7b826edef2..6ffbd832611 100644 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/TypeElement.java +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java @@ -1,12 +1,10 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -22,25 +20,27 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.apple.internal.jobjc.generator.model; -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.model.types.Type; - -/** - * A TypeElement represents a Type, such as a struct or cftype. +/* + * @test IntxTest + * @bug 8028756 + * @library /testlibrary /testlibrary/whitebox + * @build IntxTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI IntxTest + * @summary testing of WB::set/getIntxVMFlag() + * @author igor.ignatyev@oracle.com */ -public abstract class TypeElement

> extends ElementWType

{ - public TypeElement(String name, Type type, final P parent) { - super(name, type, parent); - } - public TypeElement(final Node node, final String declType, final P parent) { - super(node, declType, parent); - } +public class IntxTest { + private static final String FLAG_NAME = "OnStackReplacePercentage"; + private static final Long[] TESTS = {0L, 100L, -1L, + (long) Integer.MAX_VALUE, (long) Integer.MIN_VALUE}; - public TypeElement(final Node node, final P parent) { - super(node, parent); + public static void main(String[] args) throws Exception { + VmFlagTest.runTest(FLAG_NAME, TESTS, + VmFlagTest.WHITE_BOX::setIntxVMFlag, + VmFlagTest.WHITE_BOX::getIntxVMFlag); } } + diff --git a/jdk/src/macosx/native/jobjc/src/core/native/ID.m b/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java similarity index 52% rename from jdk/src/macosx/native/jobjc/src/core/native/ID.m rename to hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java index 2e40a03fad2..70aa0664c54 100644 --- a/jdk/src/macosx/native/jobjc/src/core/native/ID.m +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java @@ -1,12 +1,10 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -23,29 +21,25 @@ * questions. */ -#include "com_apple_jobjc_ID.h" - -#include - -#include -#include - /* - * Class: com_apple_jobjc_ID - * Method: getNativeDescription - * Signature: (J)Ljava/lang/String; + * @test StringTest + * @bug 8028756 + * @library /testlibrary /testlibrary/whitebox + * @build StringTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI StringTest + * @summary testing of WB::set/getStringVMFlag() + * @author igor.ignatyev@oracle.com */ -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_ID_getNativeDescription -(JNIEnv *env, jclass clazz, jlong objPtr) -{ - jstring ret = NULL; -JNF_COCOA_ENTER(env); +public class StringTest { + private static final String FLAG_NAME = "CompileOnly"; + private static final String[] TESTS = {"StringTest::*", ""}; - NSString *desc = [((id)jlong_to_ptr(objPtr)) description]; - ret = JNFNSToJavaString(env, desc); - -JNF_COCOA_EXIT(env); - - return ret; + public static void main(String[] args) throws Exception { + VmFlagTest.runTest(FLAG_NAME, TESTS, + VmFlagTest.WHITE_BOX::setStringVMFlag, + VmFlagTest.WHITE_BOX::getStringVMFlag); + } } + diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java new file mode 100644 index 00000000000..2f616d45507 --- /dev/null +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test Uint64Test + * @bug 8028756 + * @library /testlibrary /testlibrary/whitebox + * @build Uint64Test + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI Uint64Test + * @summary testing of WB::set/getUint64VMFlag() + * @author igor.ignatyev@oracle.com + */ + +public class Uint64Test { + private static final String FLAG_NAME = "MaxRAM"; + private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE, + -1L, Long.MAX_VALUE, Long.MIN_VALUE}; + + public static void main(String[] args) throws Exception { + VmFlagTest.runTest(FLAG_NAME, TESTS, + VmFlagTest.WHITE_BOX::setUint64VMFlag, + VmFlagTest.WHITE_BOX::getUint64VMFlag); + } +} + diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/UintxTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/UintxTest.java new file mode 100644 index 00000000000..7141221f204 --- /dev/null +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/UintxTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test UintxTest + * @bug 8028756 + * @library /testlibrary /testlibrary/whitebox + * @build UintxTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI UintxTest + * @summary testing of WB::set/getUintxVMFlag() + * @author igor.ignatyev@oracle.com + */ +import com.oracle.java.testlibrary.Platform; + +public class UintxTest { + private static final String FLAG_NAME = "VerifyGCStartAt"; + private static final Long[] TESTS = {0L, 100L, (long) Integer.MAX_VALUE, + (1L << 32L) - 1L, 1L << 32L}; + private static final Long[] EXPECTED_64 = TESTS; + private static final Long[] EXPECTED_32 = {0L, 100L, + (long) Integer.MAX_VALUE, (1L << 32L) - 1L, 0L}; + + public static void main(String[] args) throws Exception { + VmFlagTest.runTest(FLAG_NAME, TESTS, + Platform.is64bit() ? EXPECTED_64 : EXPECTED_32, + VmFlagTest.WHITE_BOX::setUintxVMFlag, + VmFlagTest.WHITE_BOX::getUintxVMFlag); + } +} + diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/VmFlagTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/VmFlagTest.java new file mode 100644 index 00000000000..0818f21f1c0 --- /dev/null +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/VmFlagTest.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.Objects; +import java.util.function.BiConsumer; +import java.util.function.Function; +import sun.hotspot.WhiteBox; +import sun.management.*; +import com.sun.management.*; +import com.oracle.java.testlibrary.*; + +public final class VmFlagTest { + public static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + + private static final String NONEXISTENT_FLAG = "NonexistentFlag"; + private final String flagName; + private final BiConsumer test; + private final BiConsumer set; + private final Function get; + + protected VmFlagTest(String flagName, BiConsumer set, + Function get, boolean isPositive) { + this.flagName = flagName; + this.set = set; + this.get = get; + if (isPositive) { + test = this::testPositive; + } else { + test = this::testNegative; + } + } + + private void setNewValue(T value) { + set.accept(flagName, value); + } + + private T getValue() { + return get.apply(flagName); + } + + protected static void runTest(String existentFlag, T[] tests, + BiConsumer set, Function get) { + runTest(existentFlag, tests, tests, set, get); + } + + protected static void runTest(String existentFlag, T[] tests, + T[] results, BiConsumer set, Function get) { + if (existentFlag != null) { + new VmFlagTest(existentFlag, set, get, true).test(tests, results); + } + new VmFlagTest(NONEXISTENT_FLAG, set, get, false).test(tests, results); + } + + public final void test(T[] tests, T[] results) { + Asserts.assertEQ(tests.length, results.length, "[TESTBUG] tests.length != results.length"); + for (int i = 0, n = tests.length ; i < n; ++i) { + test.accept(tests[i], results[i]); + } + } + + protected String getVMOptionAsString() { + HotSpotDiagnosticMXBean diagnostic + = ManagementFactoryHelper.getDiagnosticMXBean(); + VMOption tmp; + try { + tmp = diagnostic.getVMOption(flagName); + } catch (IllegalArgumentException e) { + tmp = null; + } + return tmp == null ? null : tmp.getValue(); + } + + private void testPositive(T value, T expected) { + Asserts.assertEQ(getVMOptionAsString(), asString(getValue())); + setNewValue(value); + String newValue = getVMOptionAsString(); + Asserts.assertEQ(newValue, asString(expected)); + Asserts.assertEQ(getVMOptionAsString(), asString(getValue())); + } + + private void testNegative(T value, T expected) { + String oldValue = getVMOptionAsString(); + Asserts.assertEQ(oldValue, asString(getValue())); + setNewValue(value); + String newValue = getVMOptionAsString(); + Asserts.assertEQ(oldValue, newValue); + } + + private String asString(Object value) { + return value == null ? null : "" + value; + } +} + diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 0bc9cacf9a9..52f9145880b 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -261,3 +261,5 @@ e88cecf5a21b760ff7d7761c2db6bb8c82bc9f0c jdk9-b12 a1461221b05d4620e4d7d1907e2a0282aaedf31c jdk9-b16 6f923fcbe5129eceb9617a9a18dbdd743980e785 jdk9-b17 5afa90c28742d175431be75f9098745510bd2b30 jdk9-b18 +f9c82769a6bc2b219a8f01c24afe5c91039267d7 jdk9-b19 +94fd4d9d3a75819644b21e18c8a567fd0e973eaf jdk9-b20 diff --git a/jaxws/.hgtags b/jaxws/.hgtags index a2cf881e532..b242b0bc918 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -264,3 +264,5 @@ e9780330017a6b464a385356d77e5136f9de8d09 jdk9-b15 1e1a3b2215b7551d88e89d1ca8c1e1ebe3d3c0ab jdk9-b16 6b159e727dac283f424b7d19f5be3ddd9f85acf5 jdk9-b17 275f2385aed80c84297840638d58656366350c58 jdk9-b18 +7f922a73e8a2c6ce42634238090fce7c6d599541 jdk9-b19 +6a9f8ff45c04a172df446a418c586da6a86564d5 jdk9-b20 diff --git a/jdk/.hgtags b/jdk/.hgtags index 6f8633b7e61..827ca017224 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -261,3 +261,5 @@ c7c8002d02721e02131d104549ebeb8b379fb8d2 jdk9-b13 ab7d2c565b0de5bee1361d282d4029371327fc9e jdk9-b16 fd8e675f141b9bdb2f46d1ae8251f4ee3a895d64 jdk9-b17 6ad17b31f0d30593392b1e8695b9709dbbd7fb70 jdk9-b18 +27561aede285c25a3e9ed8bf8918234ad3bb81e3 jdk9-b19 +f87c5be90e01a7ffb47947108eb3e0b0b1920880 jdk9-b20 diff --git a/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser b/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser deleted file mode 100644 index cda3de5e2f2..00000000000 --- a/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/default.pbxuser +++ /dev/null @@ -1,207 +0,0 @@ -// !$*UTF8*$! -/* - * Copyright (c) 2011, 2012, 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. - * - */ -{ - 00E6828EFEC88D1A11DB9C8B /* Project object */ = { - activeBuildConfigurationName = Release; - activeExecutable = 6A9FA6570246BA6C0CC91562 /* JObjC */; - activeTarget = EB9FD8610AEECCF5008E157E /* JObjC */; - addToTargets = ( - 4CEBA78E08679EF10015D03E /* JNILib */, - ); - breakpointsGroup = 0AB3651F0B2F67B300788B6C /* XCBreakpointsBucket */; - codeSenseManager = 0AB364DB0B2F66FD00788B6C /* Code sense */; - executables = ( - 6A9FA6570246BA6C0CC91562 /* JObjC */, - ); - perUserDictionary = { - PBXConfiguration.PBXFileTableDataSource3.PBXExecutablesDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXExecutablesDataSource_NameID; - PBXFileTableDataSourceColumnWidthsKey = ( - 22, - 300, - 131, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXExecutablesDataSource_ActiveFlagID, - PBXExecutablesDataSource_NameID, - PBXExecutablesDataSource_CommentsID, - ); - }; - PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; - PBXFileTableDataSourceColumnWidthsKey = ( - 20, - 245, - 20, - 48, - 43, - 43, - 20, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXFileDataSource_FiletypeID, - PBXFileDataSource_Filename_ColumnID, - PBXFileDataSource_Built_ColumnID, - PBXFileDataSource_ObjectSize_ColumnID, - PBXFileDataSource_Errors_ColumnID, - PBXFileDataSource_Warnings_ColumnID, - PBXFileDataSource_Target_ColumnID, - ); - }; - PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { - PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; - PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; - PBXFileTableDataSourceColumnWidthsKey = ( - 20, - 200, - 65, - 20, - 48, - 43, - 43, - ); - PBXFileTableDataSourceColumnsKey = ( - PBXFileDataSource_FiletypeID, - PBXFileDataSource_Filename_ColumnID, - PBXTargetDataSource_PrimaryAttribute, - PBXFileDataSource_Built_ColumnID, - PBXFileDataSource_ObjectSize_ColumnID, - PBXFileDataSource_Errors_ColumnID, - PBXFileDataSource_Warnings_ColumnID, - ); - }; - }; - sourceControlManager = 0AB364DA0B2F66FD00788B6C /* Source Control */; - userBuildSettings = { - }; - }; - 0AB364DA0B2F66FD00788B6C /* Source Control */ = { - isa = PBXSourceControlManager; - fallbackIsa = XCSourceControlManager; - isSCMEnabled = 0; - scmConfiguration = { - }; - scmType = ""; - }; - 0AB364DB0B2F66FD00788B6C /* Code sense */ = { - isa = PBXCodeSenseManager; - indexTemplatePath = ""; - }; - 0AB3651F0B2F67B300788B6C /* XCBreakpointsBucket */ = { - isa = XCBreakpointsBucket; - name = "Project Breakpoints"; - objects = ( - ); - }; - 0AB365570B2F6ABB00788B6C /* JObjCdylib.c */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {847, 783}}"; - sepNavSelRange = "{0, 0}"; - sepNavVisRect = "{{0, 0}, {847, 783}}"; - sepNavWindowFrame = "{{84, 198}, {886, 912}}"; - }; - }; - 0A3CC35E0B94BB8800F6BA26 /* java */ = { - isa = PBXFileReference; - explicitFileType = "compiled.mach-o.executable"; - name = java; - path = /usr/bin/java; - sourceTree = ""; - }; - 363028F90383184400C91562 /* Manifest */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {847, 783}}"; - sepNavSelRange = "{0, 0}"; - sepNavVisRect = "{{0, 0}, {847, 783}}"; - sepNavWindowFrame = "{{38, 240}, {886, 912}}"; - }; - }; - 4CEBA78E08679EF10015D03E /* Dylib */ = { - activeExec = 0; - }; - 6A9FA6570246BA6C0CC91562 /* JObjC */ = { - isa = PBXExecutable; - activeArgIndex = 0; - activeArgIndices = ( - YES, - ); - argumentStrings = ( - "-cp JObjC.jar JObjC", - ); - autoAttachOnCrash = 1; - configStateDict = { - "PBXLSLaunchAction-0" = { - PBXLSLaunchAction = 0; - PBXLSLaunchStartAction = 1; - PBXLSLaunchStdioStyle = 2; - PBXLSLaunchStyle = 0; - class = PBXLSRunLaunchConfig; - displayName = "Executable Runner"; - identifier = com.apple.Xcode.launch.runConfig; - remoteHostInfo = ""; - startActionInfo = ""; - }; - "PBXLSLaunchAction-1" = { - PBXLSLaunchAction = 1; - PBXLSLaunchStartAction = 1; - PBXLSLaunchStdioStyle = 2; - PBXLSLaunchStyle = 0; - class = PBXJavaDebuggingNativeLaunchConfig; - displayName = "Java Debugger"; - identifier = com.apple.Xcode.launch.JavaDebugNativeConfig; - remoteHostInfo = ""; - startActionInfo = ""; - }; - }; - customDataFormattersEnabled = 1; - debuggerPlugin = GDBDebugging; - disassemblyDisplayState = 0; - dylibVariantSuffix = ""; - enableDebugStr = 1; - environmentEntries = ( - ); - executableSystemSymbolLevel = 0; - executableUserSymbolLevel = 0; - launchableReference = 0A3CC35E0B94BB8800F6BA26 /* java */; - libgmallocEnabled = 0; - name = JObjC; - sourceDirectories = ( - ); - startupPath = "dist"; - }; - EB9FD8610AEECCF5008E157E /* JObjC */ = { - activeExec = 0; - }; - EB9FD8720AEECD83008E157E /* build.xml */ = { - uiCtxt = { - sepNavIntBoundsRect = "{{0, 0}, {847, 1260}}"; - sepNavSelRange = "{1260, 0}"; - sepNavVisRect = "{{0, 8}, {847, 783}}"; - sepNavWindowFrame = "{{752, 266}, {886, 912}}"; - }; - }; -} diff --git a/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/project.pbxproj b/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/project.pbxproj deleted file mode 100644 index 61cf3948d0d..00000000000 --- a/jdk/src/macosx/native/jobjc/JObjC.xcodeproj/project.pbxproj +++ /dev/null @@ -1,1397 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 44; - objects = { - -/* Begin PBXAggregateTarget section */ - 89EBD58C0C95F43D000F04A0 /* B&I */ = { - isa = PBXAggregateTarget; - buildConfigurationList = 89EBD5930C95F44E000F04A0 /* Build configuration list for PBXAggregateTarget "B&I" */; - buildPhases = ( - ); - dependencies = ( - C592D6590E12F27400D076FF /* PBXTargetDependency */, - C592D65B0E12F27600D076FF /* PBXTargetDependency */, - C592D65D0E12F27E00D076FF /* PBXTargetDependency */, - 89D7CB9C0CDC64F800472EA2 /* PBXTargetDependency */, - C592D65F0E12F28500D076FF /* PBXTargetDependency */, - C592D6610E12F28E00D076FF /* PBXTargetDependency */, - C592D6630E12F29200D076FF /* PBXTargetDependency */, - 89D7CC920CDE7A8200472EA2 /* PBXTargetDependency */, - ); - name = "B&I"; - productName = "B&I"; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - 89D7C9F70CDB900E00472EA2 /* CIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EC0CDB900E00472EA2 /* CIF.m */; }; - 89D7C9F80CDB900E00472EA2 /* Coder.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9ED0CDB900E00472EA2 /* Coder.m */; }; - 89D7C9F90CDB900E00472EA2 /* Function.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EE0CDB900E00472EA2 /* Function.m */; }; - 89D7C9FA0CDB900E00472EA2 /* ID.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EF0CDB900E00472EA2 /* ID.m */; }; - 89D7C9FB0CDB900E00472EA2 /* JObjCRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */; }; - 89D7C9FC0CDB900E00472EA2 /* MacOSXFramework.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */; }; - 89D7C9FD0CDB900E00472EA2 /* NativeBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */; }; - 89D7C9FE0CDB900E00472EA2 /* NativeBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */; }; - 89D7C9FF0CDB900E00472EA2 /* NativeObjectLifecycleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */; }; - 89D7CA000CDB900E00472EA2 /* NSClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F50CDB900E00472EA2 /* NSClass.m */; }; - 89D7CA010CDB900E00472EA2 /* SEL.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F60CDB900E00472EA2 /* SEL.m */; }; - 89D7CB770CDC4A6500472EA2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACC0C6F782C00902C32 /* Foundation.framework */; }; - 89D7CB780CDC4A6500472EA2 /* JavaVM.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACA0C6F781000902C32 /* JavaVM.framework */; }; - 89D7CB790CDC4A6500472EA2 /* JavaNativeFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */; }; - 89D7CB7A0CDC4A6500472EA2 /* libffi.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 89E437680C97A7F200C756EE /* libffi.dylib */; }; - 89D7CCA40CDF9A2600472EA2 /* NativeBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */; }; - 89D7CCA60CDF9A2600472EA2 /* CIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EC0CDB900E00472EA2 /* CIF.m */; }; - 89D7CCA70CDF9A2600472EA2 /* Coder.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9ED0CDB900E00472EA2 /* Coder.m */; }; - 89D7CCA80CDF9A2600472EA2 /* Function.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EE0CDB900E00472EA2 /* Function.m */; }; - 89D7CCA90CDF9A2600472EA2 /* ID.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9EF0CDB900E00472EA2 /* ID.m */; }; - 89D7CCAA0CDF9A2600472EA2 /* JObjCRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */; }; - 89D7CCAB0CDF9A2600472EA2 /* MacOSXFramework.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */; }; - 89D7CCAC0CDF9A2600472EA2 /* NativeBuffer.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */; }; - 89D7CCAD0CDF9A2600472EA2 /* NativeObjectLifecycleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */; }; - 89D7CCAE0CDF9A2600472EA2 /* NSClass.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F50CDB900E00472EA2 /* NSClass.m */; }; - 89D7CCAF0CDF9A2600472EA2 /* SEL.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7C9F60CDB900E00472EA2 /* SEL.m */; }; - 89D7CCB10CDF9A2600472EA2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACC0C6F782C00902C32 /* Foundation.framework */; }; - 89D7CCB20CDF9A2600472EA2 /* JavaVM.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACA0C6F781000902C32 /* JavaVM.framework */; }; - 89D7CCB30CDF9A2600472EA2 /* JavaNativeFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */; }; - 89D7CCB40CDF9A2600472EA2 /* libffi.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 89E437680C97A7F200C756EE /* libffi.dylib */; }; - 89D7CCBB0CDF9AA200472EA2 /* NativeString.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7CCBA0CDF9AA200472EA2 /* NativeString.m */; }; - 89D7CCBD0CDF9AB100472EA2 /* NativeNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */; }; - 89D7CCBF0CDF9AC600472EA2 /* NativeThread.m in Sources */ = {isa = PBXBuildFile; fileRef = 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */; }; - C5742F6D0E316EFA00093838 /* Subclassing.m in Sources */ = {isa = PBXBuildFile; fileRef = C5742F6B0E316EFA00093838 /* Subclassing.m */; }; - C5742F700E316F8600093838 /* Subclassing.m in Sources */ = {isa = PBXBuildFile; fileRef = C5742F6B0E316EFA00093838 /* Subclassing.m */; }; - C5D196C90DF9E43C006F9FB9 /* FFIType.m in Sources */ = {isa = PBXBuildFile; fileRef = C5D196C80DF9E43C006F9FB9 /* FFIType.m */; }; - C5D197D90DFB77C6006F9FB9 /* FFIType.m in Sources */ = {isa = PBXBuildFile; fileRef = C5D196C80DF9E43C006F9FB9 /* FFIType.m */; }; - C5E4547B0E36729F0046D3E8 /* Invoke.m in Sources */ = {isa = PBXBuildFile; fileRef = C5E454790E36729F0046D3E8 /* Invoke.m */; }; - C5E4547D0E367DAB0046D3E8 /* Invoke.m in Sources */ = {isa = PBXBuildFile; fileRef = C5E454790E36729F0046D3E8 /* Invoke.m */; }; - C5F3B23D0E39948300B771AE /* FunCallBench.m in Sources */ = {isa = PBXBuildFile; fileRef = C5F3B1370E398F8E00B771AE /* FunCallBench.m */; }; - C5F3B2620E3AB0F300B771AE /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C5F3B2610E3AB0F300B771AE /* AppKit.framework */; }; - C5F3B2640E3AB0F300B771AE /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C5F3B2630E3AB0F300B771AE /* Cocoa.framework */; }; - C5F3B2650E3AB0F300B771AE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 890FBACC0C6F782C00902C32 /* Foundation.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 2CC7556013A1322100B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = EB9FD8610AEECCF5008E157E; - remoteInfo = "build-core-java"; - }; - 2CC7556213A1322800B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = C5F3B1530E39927900B771AE; - remoteInfo = "build-test-java"; - }; - 2CC7556413A1323700B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CA160CDBA94D00472EA2; - remoteInfo = "build-generator-java"; - }; - 2CC7556613A1324300B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC600CDE75EC00472EA2; - remoteInfo = "build-additions-java"; - }; - 2CC7556813A1325700B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CB870CDC4ED000472EA2; - remoteInfo = "run-generator"; - }; - 2CC7556A13A132AF00B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CEBA78E08679EF10015D03E; - remoteInfo = "build-core-native"; - }; - 2CC7556C13A132B200B09D1B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = EB9FD8610AEECCF5008E157E; - remoteInfo = "build-core-java"; - }; - 89D7CB9B0CDC64F800472EA2 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CB870CDC4ED000472EA2; - remoteInfo = "run-generator"; - }; - 89D7CC910CDE7A8200472EA2 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC720CDE767500472EA2; - remoteInfo = "assemble-product-java"; - }; - C592D6580E12F27400D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = EB9FD8610AEECCF5008E157E; - remoteInfo = "build-core-java"; - }; - C592D65A0E12F27600D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CEBA78E08679EF10015D03E; - remoteInfo = "build-core-native"; - }; - C592D65C0E12F27E00D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CA160CDBA94D00472EA2; - remoteInfo = "build-generator-java"; - }; - C592D65E0E12F28500D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC4C0CDE4C0400472EA2; - remoteInfo = "build-generated-java"; - }; - C592D6600E12F28E00D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CC600CDE75EC00472EA2; - remoteInfo = "build-additions-java"; - }; - C592D6620E12F29200D076FF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 89D7CCA20CDF9A2600472EA2; - remoteInfo = "build-additions-native"; - }; - C5D197DA0DFB77E4006F9FB9 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00E6828EFEC88D1A11DB9C8B /* Project object */; - proxyType = 1; - remoteGlobalIDString = 4CEBA78E08679EF10015D03E; - remoteInfo = "build-core-native"; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 0AB364E40B2F671600788B6C /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; path = src; sourceTree = ""; }; - 890FBACA0C6F781000902C32 /* JavaVM.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaVM.framework; path = /System/Library/Frameworks/JavaVM.framework; sourceTree = ""; }; - 890FBACC0C6F782C00902C32 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; - 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaNativeFoundation.framework; path = /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework; sourceTree = ""; }; - 896D91230CC2ED34005625F5 /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.txt; sourceTree = ""; }; - 89736E5F0CE819E5008C4205 /* JObjC.jar */ = {isa = PBXFileReference; lastKnownFileType = archive.jar; path = JObjC.jar; sourceTree = BUILT_PRODUCTS_DIR; }; - 89D7C9EC0CDB900E00472EA2 /* CIF.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CIF.m; sourceTree = ""; }; - 89D7C9ED0CDB900E00472EA2 /* Coder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Coder.m; sourceTree = ""; }; - 89D7C9EE0CDB900E00472EA2 /* Function.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Function.m; sourceTree = ""; }; - 89D7C9EF0CDB900E00472EA2 /* ID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ID.m; sourceTree = ""; }; - 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JObjCRuntime.m; sourceTree = ""; }; - 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MacOSXFramework.m; sourceTree = ""; }; - 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeBuffer.h; sourceTree = ""; }; - 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeBuffer.m; sourceTree = ""; }; - 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeObjectLifecycleManager.m; sourceTree = ""; }; - 89D7C9F50CDB900E00472EA2 /* NSClass.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSClass.m; sourceTree = ""; }; - 89D7C9F60CDB900E00472EA2 /* SEL.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SEL.m; sourceTree = ""; }; - 89D7CCB80CDF9A2600472EA2 /* libJObjC.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libJObjC.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; - 89D7CCBA0CDF9AA200472EA2 /* NativeString.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeString.m; sourceTree = ""; }; - 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeNumber.m; sourceTree = ""; }; - 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeThread.m; sourceTree = ""; }; - 89E437680C97A7F200C756EE /* libffi.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libffi.dylib; path = /usr/lib/libffi.dylib; sourceTree = ""; }; - C5742F6B0E316EFA00093838 /* Subclassing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Subclassing.m; sourceTree = ""; }; - C5D196C80DF9E43C006F9FB9 /* FFIType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FFIType.m; sourceTree = ""; }; - C5E454790E36729F0046D3E8 /* Invoke.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Invoke.m; sourceTree = ""; }; - C5F3B1370E398F8E00B771AE /* FunCallBench.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FunCallBench.m; sourceTree = ""; }; - C5F3B1450E39910500B771AE /* libJObjC-tests.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = "libJObjC-tests.dylib"; sourceTree = BUILT_PRODUCTS_DIR; }; - C5F3B2610E3AB0F300B771AE /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; - C5F3B2630E3AB0F300B771AE /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - EB9FD8720AEECD83008E157E /* build.xml */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = build.xml; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 4CEBA78D08679EF10015D03E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7CB770CDC4A6500472EA2 /* Foundation.framework in Frameworks */, - 89D7CB780CDC4A6500472EA2 /* JavaVM.framework in Frameworks */, - 89D7CB790CDC4A6500472EA2 /* JavaNativeFoundation.framework in Frameworks */, - 89D7CB7A0CDC4A6500472EA2 /* libffi.dylib in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 89D7CCB00CDF9A2600472EA2 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7CCB10CDF9A2600472EA2 /* Foundation.framework in Frameworks */, - 89D7CCB20CDF9A2600472EA2 /* JavaVM.framework in Frameworks */, - 89D7CCB30CDF9A2600472EA2 /* JavaNativeFoundation.framework in Frameworks */, - 89D7CCB40CDF9A2600472EA2 /* libffi.dylib in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5F3B1430E39910500B771AE /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - C5F3B2620E3AB0F300B771AE /* AppKit.framework in Frameworks */, - C5F3B2640E3AB0F300B771AE /* Cocoa.framework in Frameworks */, - C5F3B2650E3AB0F300B771AE /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 00E6828FFEC88D1A11DB9C8B = { - isa = PBXGroup; - children = ( - 896D91230CC2ED34005625F5 /* README.txt */, - EB9FD8720AEECD83008E157E /* build.xml */, - 0AB364E40B2F671600788B6C /* src */, - 89D7C9EB0CDB900E00472EA2 /* native-core */, - 89D7CA020CDB902200472EA2 /* native-additions */, - C5A9597F0E398F050057C96D /* native-tests */, - 89D7CA030CDB903000472EA2 /* products */, - 890FBAC90C6F77B700902C32 /* frameworks */, - C5F3B1450E39910500B771AE /* libJObjC-tests.dylib */, - C5F3B2610E3AB0F300B771AE /* AppKit.framework */, - C5F3B2630E3AB0F300B771AE /* Cocoa.framework */, - ); - sourceTree = ""; - }; - 890FBAC90C6F77B700902C32 /* frameworks */ = { - isa = PBXGroup; - children = ( - 890FBACC0C6F782C00902C32 /* Foundation.framework */, - 890FBACA0C6F781000902C32 /* JavaVM.framework */, - 896D90BB0CC2877C005625F5 /* JavaNativeFoundation.framework */, - 89E437680C97A7F200C756EE /* libffi.dylib */, - ); - name = frameworks; - sourceTree = ""; - }; - 89D7C9EB0CDB900E00472EA2 /* native-core */ = { - isa = PBXGroup; - children = ( - 89D7C9EC0CDB900E00472EA2 /* CIF.m */, - 89D7C9ED0CDB900E00472EA2 /* Coder.m */, - C5D196C80DF9E43C006F9FB9 /* FFIType.m */, - 89D7C9EE0CDB900E00472EA2 /* Function.m */, - 89D7C9EF0CDB900E00472EA2 /* ID.m */, - C5E454790E36729F0046D3E8 /* Invoke.m */, - 89D7C9F00CDB900E00472EA2 /* JObjCRuntime.m */, - 89D7C9F10CDB900E00472EA2 /* MacOSXFramework.m */, - 89D7C9F20CDB900E00472EA2 /* NativeBuffer.h */, - 89D7C9F30CDB900E00472EA2 /* NativeBuffer.m */, - 89D7C9F40CDB900E00472EA2 /* NativeObjectLifecycleManager.m */, - 89D7C9F50CDB900E00472EA2 /* NSClass.m */, - 89D7C9F60CDB900E00472EA2 /* SEL.m */, - C5742F6B0E316EFA00093838 /* Subclassing.m */, - ); - name = "native-core"; - path = src/core/native; - sourceTree = ""; - }; - 89D7CA020CDB902200472EA2 /* native-additions */ = { - isa = PBXGroup; - children = ( - 89D7CCBA0CDF9AA200472EA2 /* NativeString.m */, - 89D7CCBC0CDF9AB100472EA2 /* NativeNumber.m */, - 89D7CCBE0CDF9AC600472EA2 /* NativeThread.m */, - ); - name = "native-additions"; - path = "src/runtime-additions/native"; - sourceTree = ""; - }; - 89D7CA030CDB903000472EA2 /* products */ = { - isa = PBXGroup; - children = ( - 89736E5F0CE819E5008C4205 /* JObjC.jar */, - 89D7CCB80CDF9A2600472EA2 /* libJObjC.dylib */, - ); - name = products; - path = "src/runtime-additions/native"; - sourceTree = ""; - }; - C5A9597F0E398F050057C96D /* native-tests */ = { - isa = PBXGroup; - children = ( - C5F3B1370E398F8E00B771AE /* FunCallBench.m */, - ); - name = "native-tests"; - path = src/tests/native; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - 4CEBA78B08679EF10015D03E /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7C9FD0CDB900E00472EA2 /* NativeBuffer.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 89D7CCA30CDF9A2600472EA2 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - 89D7CCA40CDF9A2600472EA2 /* NativeBuffer.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5F3B1410E39910500B771AE /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXLegacyTarget section */ - 89D7CA160CDBA94D00472EA2 /* build-generator-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CA1C0CDBA9B000472EA2 /* Build configuration list for PBXLegacyTarget "build-generator-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - 2CC7556D13A132B200B09D1B /* PBXTargetDependency */, - 2CC7556B13A132AF00B09D1B /* PBXTargetDependency */, - ); - name = "build-generator-java"; - passBuildSettingsInEnvironment = 1; - productName = "generator-build-java"; - }; - 89D7CB870CDC4ED000472EA2 /* run-generator */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CB8E0CDC4ED900472EA2 /* Build configuration list for PBXLegacyTarget "run-generator" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - 2CC7556513A1323700B09D1B /* PBXTargetDependency */, - ); - name = "run-generator"; - passBuildSettingsInEnvironment = 1; - productName = "run-generator"; - }; - 89D7CC4C0CDE4C0400472EA2 /* build-generated-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CC510CDE4C5200472EA2 /* Build configuration list for PBXLegacyTarget "build-generated-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - 2CC7556913A1325700B09D1B /* PBXTargetDependency */, - ); - name = "build-generated-java"; - passBuildSettingsInEnvironment = 1; - productName = "build-generated-java"; - }; - 89D7CC600CDE75EC00472EA2 /* build-additions-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CC630CDE762000472EA2 /* Build configuration list for PBXLegacyTarget "build-additions-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - ); - name = "build-additions-java"; - passBuildSettingsInEnvironment = 1; - productName = "build-additions-java"; - }; - 89D7CC720CDE767500472EA2 /* assemble-product-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = 89D7CC7A0CDE76F500472EA2 /* Build configuration list for PBXLegacyTarget "assemble-product-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - ); - name = "assemble-product-java"; - passBuildSettingsInEnvironment = 1; - productName = "package-product"; - }; - C5F3B1530E39927900B771AE /* build-test-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = C5F3B15B0E3992AC00B771AE /* Build configuration list for PBXLegacyTarget "build-test-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - dependencies = ( - ); - name = "build-test-java"; - passBuildSettingsInEnvironment = 1; - productName = "build-test"; - }; - EB9FD8610AEECCF5008E157E /* build-core-java */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "-verbose -emacs $ACTION"; - buildConfigurationList = EB9FD8690AEECD13008E157E /* Build configuration list for PBXLegacyTarget "build-core-java" */; - buildPhases = ( - ); - buildToolPath = /usr/bin/ant; - buildWorkingDirectory = ""; - dependencies = ( - ); - name = "build-core-java"; - passBuildSettingsInEnvironment = 1; - productName = AntJNIWrapper; - }; -/* End PBXLegacyTarget section */ - -/* Begin PBXNativeTarget section */ - 4CEBA78E08679EF10015D03E /* build-core-native */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4CEBA79108679F100015D03E /* Build configuration list for PBXNativeTarget "build-core-native" */; - buildPhases = ( - 4CEBA78B08679EF10015D03E /* Headers */, - 4CEBA78C08679EF10015D03E /* Sources */, - 4CEBA78D08679EF10015D03E /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 2CC7556113A1322100B09D1B /* PBXTargetDependency */, - ); - name = "build-core-native"; - productName = DylibN; - productType = "com.apple.product-type.library.dynamic"; - }; - 89D7CCA20CDF9A2600472EA2 /* build-additions-native */ = { - isa = PBXNativeTarget; - buildConfigurationList = 89D7CCB50CDF9A2600472EA2 /* Build configuration list for PBXNativeTarget "build-additions-native" */; - buildPhases = ( - 89D7CCA30CDF9A2600472EA2 /* Headers */, - 89D7CCA50CDF9A2600472EA2 /* Sources */, - 89D7CCB00CDF9A2600472EA2 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 2CC7556713A1324300B09D1B /* PBXTargetDependency */, - C5D197DB0DFB77E4006F9FB9 /* PBXTargetDependency */, - ); - name = "build-additions-native"; - productName = DylibN; - productReference = 89D7CCB80CDF9A2600472EA2 /* libJObjC.dylib */; - productType = "com.apple.product-type.library.dynamic"; - }; - C5F3B1440E39910500B771AE /* build-test-native */ = { - isa = PBXNativeTarget; - buildConfigurationList = C5F3B1480E39917500B771AE /* Build configuration list for PBXNativeTarget "build-test-native" */; - buildPhases = ( - C5F3B1410E39910500B771AE /* Headers */, - C5F3B1420E39910500B771AE /* Sources */, - C5F3B1430E39910500B771AE /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - 2CC7556313A1322800B09D1B /* PBXTargetDependency */, - ); - name = "build-test-native"; - productName = "build-tests-native"; - productReference = C5F3B1450E39910500B771AE /* libJObjC-tests.dylib */; - productType = "com.apple.product-type.library.dynamic"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 00E6828EFEC88D1A11DB9C8B /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0410; - }; - buildConfigurationList = 4CEBA75C08679E4D0015D03E /* Build configuration list for PBXProject "JObjC" */; - compatibilityVersion = "Xcode 3.0"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - English, - Japanese, - French, - German, - ); - mainGroup = 00E6828FFEC88D1A11DB9C8B; - productRefGroup = 00E6828FFEC88D1A11DB9C8B; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 89EBD58C0C95F43D000F04A0 /* B&I */, - EB9FD8610AEECCF5008E157E /* build-core-java */, - 4CEBA78E08679EF10015D03E /* build-core-native */, - 89D7CA160CDBA94D00472EA2 /* build-generator-java */, - 89D7CB870CDC4ED000472EA2 /* run-generator */, - 89D7CC4C0CDE4C0400472EA2 /* build-generated-java */, - 89D7CC600CDE75EC00472EA2 /* build-additions-java */, - 89D7CCA20CDF9A2600472EA2 /* build-additions-native */, - 89D7CC720CDE767500472EA2 /* assemble-product-java */, - C5F3B1530E39927900B771AE /* build-test-java */, - C5F3B1440E39910500B771AE /* build-test-native */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 4CEBA78C08679EF10015D03E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C5E4547B0E36729F0046D3E8 /* Invoke.m in Sources */, - C5742F6D0E316EFA00093838 /* Subclassing.m in Sources */, - 89D7C9F70CDB900E00472EA2 /* CIF.m in Sources */, - 89D7C9F80CDB900E00472EA2 /* Coder.m in Sources */, - 89D7C9F90CDB900E00472EA2 /* Function.m in Sources */, - 89D7C9FA0CDB900E00472EA2 /* ID.m in Sources */, - 89D7C9FB0CDB900E00472EA2 /* JObjCRuntime.m in Sources */, - 89D7C9FC0CDB900E00472EA2 /* MacOSXFramework.m in Sources */, - 89D7C9FE0CDB900E00472EA2 /* NativeBuffer.m in Sources */, - 89D7C9FF0CDB900E00472EA2 /* NativeObjectLifecycleManager.m in Sources */, - 89D7CA000CDB900E00472EA2 /* NSClass.m in Sources */, - 89D7CA010CDB900E00472EA2 /* SEL.m in Sources */, - C5D196C90DF9E43C006F9FB9 /* FFIType.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 89D7CCA50CDF9A2600472EA2 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C5E4547D0E367DAB0046D3E8 /* Invoke.m in Sources */, - C5742F700E316F8600093838 /* Subclassing.m in Sources */, - 89D7CCA60CDF9A2600472EA2 /* CIF.m in Sources */, - 89D7CCA70CDF9A2600472EA2 /* Coder.m in Sources */, - 89D7CCA80CDF9A2600472EA2 /* Function.m in Sources */, - 89D7CCA90CDF9A2600472EA2 /* ID.m in Sources */, - 89D7CCAA0CDF9A2600472EA2 /* JObjCRuntime.m in Sources */, - 89D7CCAB0CDF9A2600472EA2 /* MacOSXFramework.m in Sources */, - 89D7CCAC0CDF9A2600472EA2 /* NativeBuffer.m in Sources */, - 89D7CCAD0CDF9A2600472EA2 /* NativeObjectLifecycleManager.m in Sources */, - 89D7CCAE0CDF9A2600472EA2 /* NSClass.m in Sources */, - 89D7CCAF0CDF9A2600472EA2 /* SEL.m in Sources */, - 89D7CCBB0CDF9AA200472EA2 /* NativeString.m in Sources */, - 89D7CCBD0CDF9AB100472EA2 /* NativeNumber.m in Sources */, - 89D7CCBF0CDF9AC600472EA2 /* NativeThread.m in Sources */, - C5D197D90DFB77C6006F9FB9 /* FFIType.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - C5F3B1420E39910500B771AE /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C5F3B23D0E39948300B771AE /* FunCallBench.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 2CC7556113A1322100B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = EB9FD8610AEECCF5008E157E /* build-core-java */; - targetProxy = 2CC7556013A1322100B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556313A1322800B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = C5F3B1530E39927900B771AE /* build-test-java */; - targetProxy = 2CC7556213A1322800B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556513A1323700B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CA160CDBA94D00472EA2 /* build-generator-java */; - targetProxy = 2CC7556413A1323700B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556713A1324300B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC600CDE75EC00472EA2 /* build-additions-java */; - targetProxy = 2CC7556613A1324300B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556913A1325700B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CB870CDC4ED000472EA2 /* run-generator */; - targetProxy = 2CC7556813A1325700B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556B13A132AF00B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CEBA78E08679EF10015D03E /* build-core-native */; - targetProxy = 2CC7556A13A132AF00B09D1B /* PBXContainerItemProxy */; - }; - 2CC7556D13A132B200B09D1B /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = EB9FD8610AEECCF5008E157E /* build-core-java */; - targetProxy = 2CC7556C13A132B200B09D1B /* PBXContainerItemProxy */; - }; - 89D7CB9C0CDC64F800472EA2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CB870CDC4ED000472EA2 /* run-generator */; - targetProxy = 89D7CB9B0CDC64F800472EA2 /* PBXContainerItemProxy */; - }; - 89D7CC920CDE7A8200472EA2 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC720CDE767500472EA2 /* assemble-product-java */; - targetProxy = 89D7CC910CDE7A8200472EA2 /* PBXContainerItemProxy */; - }; - C592D6590E12F27400D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = EB9FD8610AEECCF5008E157E /* build-core-java */; - targetProxy = C592D6580E12F27400D076FF /* PBXContainerItemProxy */; - }; - C592D65B0E12F27600D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CEBA78E08679EF10015D03E /* build-core-native */; - targetProxy = C592D65A0E12F27600D076FF /* PBXContainerItemProxy */; - }; - C592D65D0E12F27E00D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CA160CDBA94D00472EA2 /* build-generator-java */; - targetProxy = C592D65C0E12F27E00D076FF /* PBXContainerItemProxy */; - }; - C592D65F0E12F28500D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC4C0CDE4C0400472EA2 /* build-generated-java */; - targetProxy = C592D65E0E12F28500D076FF /* PBXContainerItemProxy */; - }; - C592D6610E12F28E00D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CC600CDE75EC00472EA2 /* build-additions-java */; - targetProxy = C592D6600E12F28E00D076FF /* PBXContainerItemProxy */; - }; - C592D6630E12F29200D076FF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 89D7CCA20CDF9A2600472EA2 /* build-additions-native */; - targetProxy = C592D6620E12F29200D076FF /* PBXContainerItemProxy */; - }; - C5D197DB0DFB77E4006F9FB9 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 4CEBA78E08679EF10015D03E /* build-core-native */; - targetProxy = C5D197DA0DFB77E4006F9FB9 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 4CEBA75D08679E4D0015D03E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - "$(NATIVE_ARCH_32_BIT)", - "$(NATIVE_ARCH_64_BIT)", - ); - GCC_ENABLE_OBJC_GC = supported; - SYMROOT = build; - }; - name = Debug; - }; - 4CEBA75E08679E4D0015D03E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - GCC_ENABLE_OBJC_GC = supported; - INSTALL_PATH = /System/Library/Java/Extensions; - }; - name = Release; - }; - 4CEBA79208679F100015D03E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - "$(NATIVE_ARCH_32_BIT)", - "$(NATIVE_ARCH_64_BIT)", - ); - COPY_PHASE_STRIP = NO; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Debug; - }; - 4CEBA79308679F100015D03E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - i386, - ppc, - x86_64, - ); - COPY_PHASE_STRIP = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CA170CDBA94D00472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-generator"; - }; - name = Debug; - }; - 89D7CA180CDBA94D00472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-generator"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CB880CDC4ED000472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = "\U00010"; - PRODUCT_NAME = "run-generator"; - }; - name = Debug; - }; - 89D7CB890CDC4ED000472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "run-generator"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CC4D0CDE4C0400472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-generated"; - }; - name = Debug; - }; - 89D7CC4E0CDE4C0400472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-generated"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CC610CDE75EC00472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-additions"; - }; - name = Debug; - }; - 89D7CC620CDE75EC00472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-additions"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CC730CDE767500472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "assemble-product"; - }; - name = Debug; - }; - 89D7CC740CDE767500472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "assemble-product"; - ZERO_LINK = NO; - }; - name = Release; - }; - 89D7CCB60CDF9A2600472EA2 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - "$(NATIVE_ARCH_32_BIT)", - "$(NATIVE_ARCH_64_BIT)", - ); - COPY_PHASE_STRIP = NO; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\" \"$(OBJROOT)/src/jni_headers/additions\""; - INSTALL_PATH = /usr/local/lib; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Debug; - }; - 89D7CCB70CDF9A2600472EA2 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - x86_64, - ppc, - i386, - ); - COPY_PHASE_STRIP = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = YES; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - ); - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\" \"$(OBJROOT)/src/jni_headers/core\""; - HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\" \"$(OBJROOT)/src/jni_headers/additions\""; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - ); - LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/1.5.0/Libraries\""; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PRODUCT_NAME = JObjC; - SECTORDER_FLAGS = ""; - VALID_ARCHS = "ppc7400 ppc970 i386 x86_64 ppc"; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - "-Wformat", - "-Wformat-security", - "-Wcast-align", - "-Wwrite-strings", - "-Wuninitialized", - "-Wshadow", - "-Wshorten-64-to-32", - "-Wsign-compare", - "-Wpointer-arith", - "-Wall", - ); - ZERO_LINK = NO; - }; - name = Release; - }; - 89EBD58D0C95F43D000F04A0 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "B&I"; - }; - name = Debug; - }; - 89EBD58E0C95F43D000F04A0 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "B&I"; - ZERO_LINK = NO; - }; - name = Release; - }; - C5F3B1460E39910500B771AE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = ( - x86_64, - i386, - ppc, - ); - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_DYNAMIC_NO_PIC = NO; - GCC_MODEL_TUNING = G5; - GCC_OPTIMIZATION_LEVEL = 0; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\"", - "\"$(OBJROOT)/src/jni_headers/core\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\"", - "\"$(OBJROOT)/src/jni_headers/additions\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/test\"", - "\"$(OBJROOT)/src/jni_headers/test\"", - ); - INSTALL_PATH = /usr/local/lib; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - PRODUCT_NAME = "JObjC-tests"; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - C5F3B1470E39910500B771AE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = YES; - ARCHS = ( - x86_64, - i386, - ppc, - ); - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - EXECUTABLE_EXTENSION = dylib; - EXECUTABLE_PREFIX = lib; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - ); - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_2 = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/JavaVM.framework/Versions/A/Frameworks\""; - GCC_MODEL_TUNING = G5; - HEADER_SEARCH_PATHS = ( - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", - "$(HEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", - /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers, - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/core\"", - "\"$(OBJROOT)/src/jni_headers/core\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/additions\"", - "\"$(OBJROOT)/src/jni_headers/additions\"", - "\"$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/src/jni_headers/test\"", - "\"$(OBJROOT)/src/jni_headers/test\"", - ); - INSTALL_PATH = /usr/local/lib; - LIBRARY_STYLE = DYNAMIC; - MACH_O_TYPE = mh_dylib; - PRODUCT_NAME = "JObjC-tests"; - SKIP_INSTALL = YES; - ZERO_LINK = NO; - }; - name = Release; - }; - C5F3B1540E39927A00B771AE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-test"; - }; - name = Debug; - }; - C5F3B1550E39927A00B771AE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - PRODUCT_NAME = "build-test"; - ZERO_LINK = NO; - }; - name = Release; - }; - EB9FD86A0AEECD13008E157E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_DYNAMIC_NO_PIC = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - PRODUCT_NAME = "build-core"; - }; - name = Debug; - }; - EB9FD86B0AEECD13008E157E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - PRODUCT_NAME = "build-core"; - ZERO_LINK = NO; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 4CEBA75C08679E4D0015D03E /* Build configuration list for PBXProject "JObjC" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4CEBA75D08679E4D0015D03E /* Debug */, - 4CEBA75E08679E4D0015D03E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4CEBA79108679F100015D03E /* Build configuration list for PBXNativeTarget "build-core-native" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4CEBA79208679F100015D03E /* Debug */, - 4CEBA79308679F100015D03E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CA1C0CDBA9B000472EA2 /* Build configuration list for PBXLegacyTarget "build-generator-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CA170CDBA94D00472EA2 /* Debug */, - 89D7CA180CDBA94D00472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CB8E0CDC4ED900472EA2 /* Build configuration list for PBXLegacyTarget "run-generator" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CB880CDC4ED000472EA2 /* Debug */, - 89D7CB890CDC4ED000472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CC510CDE4C5200472EA2 /* Build configuration list for PBXLegacyTarget "build-generated-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CC4D0CDE4C0400472EA2 /* Debug */, - 89D7CC4E0CDE4C0400472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CC630CDE762000472EA2 /* Build configuration list for PBXLegacyTarget "build-additions-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CC610CDE75EC00472EA2 /* Debug */, - 89D7CC620CDE75EC00472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CC7A0CDE76F500472EA2 /* Build configuration list for PBXLegacyTarget "assemble-product-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CC730CDE767500472EA2 /* Debug */, - 89D7CC740CDE767500472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89D7CCB50CDF9A2600472EA2 /* Build configuration list for PBXNativeTarget "build-additions-native" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89D7CCB60CDF9A2600472EA2 /* Debug */, - 89D7CCB70CDF9A2600472EA2 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 89EBD5930C95F44E000F04A0 /* Build configuration list for PBXAggregateTarget "B&I" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 89EBD58D0C95F43D000F04A0 /* Debug */, - 89EBD58E0C95F43D000F04A0 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C5F3B1480E39917500B771AE /* Build configuration list for PBXNativeTarget "build-test-native" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C5F3B1460E39910500B771AE /* Debug */, - C5F3B1470E39910500B771AE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - C5F3B15B0E3992AC00B771AE /* Build configuration list for PBXLegacyTarget "build-test-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C5F3B1540E39927A00B771AE /* Debug */, - C5F3B1550E39927A00B771AE /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - EB9FD8690AEECD13008E157E /* Build configuration list for PBXLegacyTarget "build-core-java" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - EB9FD86A0AEECD13008E157E /* Debug */, - EB9FD86B0AEECD13008E157E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 00E6828EFEC88D1A11DB9C8B /* Project object */; -} diff --git a/jdk/src/macosx/native/jobjc/README.txt b/jdk/src/macosx/native/jobjc/README.txt deleted file mode 100644 index 3bde08a77c4..00000000000 --- a/jdk/src/macosx/native/jobjc/README.txt +++ /dev/null @@ -1,132 +0,0 @@ -#title JObjC -# -# Copyright (c) 2011, 2012, 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. -# - -JObjC core provides a pure Java interface for calling C functions and -sending ObjC messages. Given some information, it can marshal types -automatically. - -It also parses BridgeSupport to generate Java wrappers around -Framework bundles. These wrappers rely on the core to provide access -to the C constants, enums, structs, functions, ObjC classes, etc of a -framework. - -* How to build it - -Your best option is `ant all`. There's an Xcode "B&I" target that -works for buildit. - -You'll need a recent JavaNativeFoundation, and perhaps some other -things. Everything is usually there on SnowLeopard (or Leopard after -the common ~javabuild/bin/update runs). - -The build process is quite involved. Xcode takes care of the native -parts, ant takes care of the Java parts, and there's an unholy mix of -external targets and hidden dependencies that keep Xcode and ant (and -buildit on top of that) from stepping on each other. So a warning: the -ant and Xcode targets don't have proper dependencies set up because of -this. They have some dependencies configured, but not the entire -chain. This is because of the jumping back and forth between -externals. If you run the aggregate targets (Xcode B&I, ant all, ant -test, ant bench), everything's is good. But if you manually invoke -individual targets, chances are you'll miss something. Let's go over -it all step by step: - -** ant gen-pcoder - -The PrimitiveCoder subclasses have a lot of boiler plate which -simplifies the generated MixedPrimitiveCoder classes. So instead of -maintaining it, I maintain a tiny Haskell script that spits out the -Java code. This ant target runs that script if Haskell is available on -the system. If it isn't available, this will silently fail. That's -okay, because chances are the PrimitiveCoder.java that you got from -svn is current and does not need to be updated. - -** ant build-core / Xcode build-core-java - -Build core simply builds the JObjC core java classes, and also -generates headers for the JNI for Xcode. - -** ant build-core-native / Xcode build-core-native - -Xcode builds the native core, using the headers from the Java core. It -generates libJObjC.dylib. - -** ant build-generator / Xcode build-generator-java - -ant builds the generator. - -** ant run-generator / Xcode run-generator - -ant runs the generator, using the core Java and native classes. - -What is rungen? And what's run-generator-old? run-generator-old is the -preferred way to run the generator from ant, but there's a strange bug -when running from buildit that causes run-generator-old to -freeze. Pratik was helping me debug it, inspecting the stack and -snooping dtrace probes, but we never found the reason for the -block. So I figured that maybe if I just add a layer of indirection -maybe it'll work around that. And it did. Sad but true. - -** ant build-generated / Xcode build-generated-java - -Build the generator output. - -** ant build-additions / Xcode build-additions-java - -Builds java additions. - -** ant build-additions-native / Xcode build-additions-native - -This builds a new version of libJObjC.dylib. It will rebuild -everything from the core, and include everything from additions. - -** ant assemble-product / Xcode assemble-product-java - -Create a jar, copy products to destination, etc. - -* How to test it - -The test cases also contain a Java component and a native component, -and are built similarly to the above. The benchmarks are built -together with the tests. So "ant build-test" and "ant -build-test-native" will build both the benchmarks and the test. "ant -test" will run the test. "ant bench" will run benchmarks. If you only -want to run a specific benchmark, you can pass a regexp in the -environment variable BENCH_MATCH. - - -ant test -ant bench -BENCH_MATCH=Foo ant bench - - -Test and bench reports will end up in -build/JObjC.build/Debug/test-reports/ - -* How to use it - -Include the jar in your classpath and set your java.library.path to -the directory that contains the dylib. Same thing for app bundles. diff --git a/jdk/src/macosx/native/jobjc/TODOS b/jdk/src/macosx/native/jobjc/TODOS deleted file mode 100644 index 16abea13760..00000000000 --- a/jdk/src/macosx/native/jobjc/TODOS +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2011, 2012, 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. -# -# -egrep "(TODO|FIXME|XXX|HACK)" -r src diff --git a/jdk/src/macosx/native/jobjc/bridgesupport.gmk b/jdk/src/macosx/native/jobjc/bridgesupport.gmk deleted file mode 100644 index 1de9bd1d5c5..00000000000 --- a/jdk/src/macosx/native/jobjc/bridgesupport.gmk +++ /dev/null @@ -1,54 +0,0 @@ -# -# Copyright (c) 2011, 2012, 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. -# - -# makefile for generating a stable set of bridgesupport files that change timestamp -# only when the bridgesupport data actually changes - -FRAMEWORKS_DIR = /System/Library/Frameworks -GBM = /usr/bin/gen_bridge_metadata -GEN_HEADERS = $(addsuffix .headers,$(FRAMEWORKS)) -GEN_BRIDGESUPPORT = $(addsuffix .bridgesupport,$(FRAMEWORKS)) - -%.bridgesupport : %.headers $(FRAMEWORKS_DIR)/%.framework/Headers/*.h - @echo "generating bridge support for" $< - if [ -f $(FRAMEWORKS_DIR)/$(<:.headers=.framework)/Resources/BridgeSupport/$(<:.headers=Full.bridgesupport) ] ; \ - then cp $(FRAMEWORKS_DIR)/$(<:.headers=.framework)/Resources/BridgeSupport/$(<:.headers=Full.bridgesupport) $@ ; \ - else $(GBM) -F complete --framework $(<:.headers=.framework) -o $@ ; \ - fi - if cmp -s $@ $(STABLE_GEN_DIR)/$(@:.bridgesupport=Full.bridgesupport) ; \ - then : ; \ - else cp $@ $(STABLE_GEN_DIR)/$(@:.bridgesupport=Full.bridgesupport) ; \ - fi - -%.headers : $(FRAMEWORKS_DIR)/%.framework/Headers - @echo linking $< - ln -s $< $@ - -$(STABLE_GEN_DIR): - mkdir -p $(STABLE_GEN_DIR) - -$(GEN_BRIDGESUPPORT): $(GEN_HEADERS) $(STABLE_GEN_DIR) - -all: $(GEN_BRIDGESUPPORT) diff --git a/jdk/src/macosx/native/jobjc/build.xml b/jdk/src/macosx/native/jobjc/build.xml deleted file mode 100644 index 9f638840fcf..00000000000 --- a/jdk/src/macosx/native/jobjc/build.xml +++ /dev/null @@ -1,520 +0,0 @@ - - - - - - - - Nothing to do for install-headers build phase - - - - Nothing to do for install-source build phase - - - - - - - This Ant build file depends on the native Xcode project to invoke - targets by defining $PRODUCT_NAME to specify the target. - - - --- Redirecting to target "${env.PRODUCT_NAME}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jdk/src/macosx/native/jobjc/extract_classes.pl b/jdk/src/macosx/native/jobjc/extract_classes.pl deleted file mode 100644 index b0950db4699..00000000000 --- a/jdk/src/macosx/native/jobjc/extract_classes.pl +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/perl -# -# Copyright (c) 2011, 2012, 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. -## - -$file_dir = $ARGV[0]; -@file_list = qx("/usr/bin/find" "$file_dir"); - -foreach $file (@file_list) { - if ($file =~ s/\.class//) { - if ($file !~ s/\$[0-9]//) { - $file =~ s/$file_dir\///g; - $file =~ s/\//\./g; - chomp($file); - print "$file,"; - } - } -} diff --git a/jdk/src/macosx/native/jobjc/run-and-write-if-okay b/jdk/src/macosx/native/jobjc/run-and-write-if-okay deleted file mode 100644 index 8d0bb690276..00000000000 --- a/jdk/src/macosx/native/jobjc/run-and-write-if-okay +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env ruby -# -# Copyright (c) 2011, 2012, 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. -# -# - -if ARGV.length < 2 - puts <&1`. If it returns successfully, it writes the output to OUTPATH. -This script will return successfully unless writing the output fails. -EOF - exit -end - -EXECPATH = ARGV[0] -OUTPATH = ARGV[1] - -output = `#{EXECPATH}` -puts output - -if $?.to_i == 0 - puts "Writing output of #{EXECPATH} to #{OUTPATH}" - File.open(OUTPATH, 'w') {|f| f.write(output) } -else - puts "#{EXECPATH} failed to run trial. Ignoring." -end diff --git a/jdk/src/macosx/native/jobjc/rungen b/jdk/src/macosx/native/jobjc/rungen deleted file mode 100644 index 17aeabea15d..00000000000 --- a/jdk/src/macosx/native/jobjc/rungen +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env ruby -# -# Copyright (c) 2011, 2012, 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. -# -# - -xcodeAction = ARGV[0] - -exit unless xcodeAction == "install" - -JOBJC_JAR = ARGV[1] -LIBPATH = ARGV[2] -OBJROOT = ARGV[3] -ARCHS = ARGV[4] -STABLE_GEN_DIR = ARGV[5] - -ourJavaHome = ENV['JAVA_HOME'] -ourJavaVersion = `java -fullversion 2>&1` -$stderr.puts "ENV['JAVA_HOME'] = #{ourJavaHome}" -$stderr.puts "java -fullversion = #{ourJavaVersion}" - -$stderr.puts "jobjc_jar = #{JOBJC_JAR}" -$stderr.puts "libpath = #{LIBPATH}" -$stderr.puts "objroot = #{OBJROOT}" -$stderr.puts "ARCHS = #{ARCHS}" -$stderr.puts "STABLE_GEN_DIR = #{STABLE_GEN_DIR}" - -jarch = if ARCHS =~ /x86_64/ then "-d64" else "-d32" end - -# compute the boot class path, but remove the JObjC jar file that may have been installed in the boot jdk - -bootclasspathcmd = "java -classpath #{OBJROOT}/bin/core:#{OBJROOT}/bin/generator com.apple.internal.jobjc.generator.BootClassPathMinus #{JOBJC_JAR}" -$stderr.puts bootclasspathcmd -bootclasspath = `#{bootclasspathcmd}` - -$stderr.puts "bootclasspath is: " -$stderr.puts bootclasspath - -# we run the generator with our newly created JObjC. The installed version (if available) has been removed from -# the boot class path, so we are building with everything newly created. -cmd = "java #{jarch} -Xms128m -Xmx512m -Djava.library.path=#{LIBPATH} -Xbootclasspath:#{bootclasspath.chomp} -classpath #{OBJROOT}/bin/core:#{OBJROOT}/bin/generator -ea com.apple.internal.jobjc.generator.Generator dst=#{OBJROOT}/src/jobjc frameworks=#{STABLE_GEN_DIR}" - -$stderr.puts cmd -puts `#{cmd} 2>&1` - -raise $?.to_i if $?.to_i != 0 diff --git a/jdk/src/macosx/native/jobjc/runjava b/jdk/src/macosx/native/jobjc/runjava deleted file mode 100644 index a6e91547e7d..00000000000 --- a/jdk/src/macosx/native/jobjc/runjava +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2011, 2012, 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. -# -# -java -ea -classpath "lib/junit-4.4.jar:build/JObjC.build/Debug/bin/core:build/JObjC.build/Debug/bin/generator:build/JObjC.build/Debug/bin/additions:build/JObjC.build/Debug/bin/test:build/JObjC.build/Debug/bin/generated" -Djava.library.path=build/Debug $@ diff --git a/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs b/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs deleted file mode 100644 index b9b0070fcb4..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/PrimitiveCoder.hs +++ /dev/null @@ -1,275 +0,0 @@ -#!/usr/bin/env runhaskell - -{- -/* - * Copyright (c) 2011, 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. - */ --} -{- -The simplest way to get Haskell is through MacPorts: sudo port install ghc - -Otherwise, see http://www.haskell.org/ghc/ --} - -import Data.List -import Data.Maybe -import Data.Char - -data Width = W32 | W64 - deriving (Show, Eq, Bounded, Enum) - -data NType = NBOOL | Nschar | Nuchar | Nsshort | Nushort | Nsint | Nuint - | Nslong | Nulong | Nslonglong | Nulonglong | Nfloat | Ndouble - deriving (Show, Eq, Bounded, Enum) - -data JPrim = Jboolean | Jbyte | Jchar | Jshort | Jint | Jlong | Jfloat | Jdouble - deriving (Show, Eq, Bounded, Enum) - -data JClass = JBoolean | JByte | JCharacter | JShort | JInteger | JLong - | JFloat | JDouble - deriving (Show, Eq, Bounded, Enum) - -data FFIType = SINT8 | UINT8 | SINT16 | UINT16 | SINT32 | UINT32 - | SINT64 | UINT64 | FLOAT | DOUBLE - deriving (Show, Eq, Bounded, Enum) - -widths = [minBound..maxBound] :: [Width] -ntypes = [minBound..maxBound] :: [NType] -jprims = [minBound..maxBound] :: [JPrim] -jclasses = [minBound..maxBound] :: [JClass] -ffitypes = [minBound..maxBound] :: [FFIType] - --- What's the FFIType for a given Width and NType? For example: W32 NBOOL -> SINT8 -ffitype :: Width -> NType -> FFIType -ffitype _ NBOOL = SINT8 -ffitype _ Nschar = SINT8 -ffitype _ Nuchar = UINT8 -ffitype _ Nsshort = SINT16 -ffitype _ Nushort = UINT16 -ffitype _ Nsint = SINT32 -ffitype _ Nuint = UINT32 -ffitype W32 Nslong = SINT32 -ffitype W64 Nslong = SINT64 -ffitype W32 Nulong = UINT32 -ffitype W64 Nulong = UINT64 -ffitype _ Nslonglong = SINT64 -ffitype _ Nulonglong = UINT64 -ffitype _ Nfloat = FLOAT -ffitype _ Ndouble = DOUBLE - -sizeof :: FFIType -> Int -sizeof SINT8 = 1 -sizeof UINT8 = 1 -sizeof SINT16 = 2 -sizeof UINT16 = 2 -sizeof SINT32 = 4 -sizeof UINT32 = 4 -sizeof SINT64 = 8 -sizeof UINT64 = 8 -sizeof FLOAT = 4 -sizeof DOUBLE = 8 - --- What's the Obj-C encoding for a given NType? For example: unsigned char -> 'C' -encoding nt = fromJust $ lookup nt $ - [(NBOOL, 'B'), (Nschar, 'c'), (Nuchar, 'C'), (Nsshort, 's'), - (Nushort, 'S'), (Nsint, 'i'), (Nuint, 'I'), (Nslong, 'l'), - (Nulong, 'L'), (Nslonglong, 'q'), (Nulonglong, 'Q'), - (Nfloat, 'f'), (Ndouble, 'd')] - --- What's the JPrim for a given NType? For example: native signed long long -> java long -ntype2jprim nt = fromJust $ lookup nt $ - [(NBOOL, Jboolean), (Nschar, Jbyte), (Nuchar, Jbyte), - (Nsshort, Jshort), (Nushort, Jshort), (Nsint, Jint), (Nuint, Jint), - (Nslong, Jlong), (Nulong, Jlong), - (Nslonglong, Jlong), (Nulonglong, Jlong), - (Nfloat, Jfloat), (Ndouble, Jdouble)] - --- What's the JClass for a given JPrim? For example: int -> Integer -jprim2jclass jp = fromJust $ lookup jp $ - [(Jboolean, JBoolean), (Jbyte, JByte), (Jchar, JCharacter), - (Jshort, JShort), (Jint, JInteger), (Jlong, JLong), - (Jfloat, JFloat), (Jdouble, JDouble)] - --- Convert a type to something suitable for Java code. For example: Jboolean -> boolean -ntype2js nt = tail $ show nt -jclass2js t = tail $ show t -jprim2js p = tail $ show p -ffitype2js f = "FFI_" ++ (show f) - --- Capitalize the first letter of a String -capitalize [] = [] -capitalize s = [toUpper $ head s] ++ tail s - --- Given an Width and NType, return the Java code for reading said NType from memory. -popAddr :: Width -> NType -> String -popAddr _ NBOOL = "rt.unsafe.getByte(addr) != 0" -popAddr _ Nschar = "rt.unsafe.getByte(addr)" -popAddr _ Nuchar = "rt.unsafe.getByte(addr)" -popAddr W32 Nslong = "rt.unsafe.getInt(addr)" -popAddr W32 Nulong = "rt.unsafe.getInt(addr)" -popAddr _ ntype = "rt.unsafe.get" ++ (capitalize.jprim2js.ntype2jprim $ ntype) ++ "(addr)" - --- Given an Width and NType, return the Java code for writing said NType to memory. -pushAddr :: Width -> NType -> String -pushAddr _ NBOOL = "rt.unsafe.putByte(addr, (byte) (x ? 1 : 0));" -pushAddr _ Nschar = "rt.unsafe.putByte(addr, x);" -pushAddr _ Nuchar = "rt.unsafe.putByte(addr, x);" -pushAddr W32 Nslong = "rt.unsafe.putInt(addr, (int) x);" -pushAddr W32 Nulong = "rt.unsafe.putInt(addr, (int) x);" -pushAddr _ ntype = "rt.unsafe.put" ++ (capitalize jprimS) ++ "(addr, (" ++ jprimS ++ ") x);" - where jprimS = jprim2js.ntype2jprim $ ntype - --- Helpers for generating Java ternarnies and conditionals. -archExpr x32 x64 = if x32 /= x64 then retdiff else x32 - where retdiff = "(JObjCRuntime.IS64 ? (" ++ x64 ++ ") : (" ++ x32 ++ "))" - -archStmt x32 x64 = if x32 /= x64 then retdiff else x32 - where retdiff = "if(JObjCRuntime.IS64){ " ++ x64 ++ " }else{ " ++ x32 ++ " }" - --- Get a Java expression for the correct FFIType at runtime. For example: (JObjCRuntime.IS64 ? FFI_SINT64 : FFI_SINT32) -ffitypeVal nt = archExpr (ffitype2js $ ffitype W32 nt) - (ffitype2js $ ffitype W64 nt) - --- Similar to ffiTypeVal. Get the correct pop expression and push statement. -popAddrVal nt = archExpr (popAddr W32 nt) (popAddr W64 nt) -pushAddrVal nt = archStmt (pushAddr W32 nt) (pushAddr W64 nt) - --- What's the Coder class name we're using for a given NType? -coderName nt = aux nt ++ "Coder" - where - aux NBOOL = "Bool" - aux Nschar = "SChar" - aux Nuchar = "UChar" - aux Nsshort = "SShort" - aux Nushort = "UShort" - aux Nsint = "SInt" - aux Nuint = "UInt" - aux Nslong = "SLong" - aux Nulong = "ULong" - aux Nslonglong = "SLongLong" - aux Nulonglong = "ULongLong" - aux Nfloat = "Float" - aux Ndouble = "Double" - --- Operation for converting between primitives. Usually it just casts, but booleans are special. -jconvertPrims sym Jboolean Jboolean = sym -jconvertPrims sym Jboolean b = "((" ++ jprim2js b ++ ")(" ++ sym ++ " ? 1 : 0))" -jconvertPrims sym a Jboolean = "(" ++ sym ++ " != 0)" -jconvertPrims sym a b = if a == b then sym else "((" ++ jprim2js b ++ ")" ++ sym ++ ")" - -sizeofRet nt = - let ffitypes = map (\w -> ffitype w nt) widths - sizes = map sizeof ffitypes in - if (length $ nub sizes) == 1 - then "\t\treturn " ++ (show.head $ sizes) ++ ";" - else unlines [ - "\t\tswitch(w){", - (unlines $ map casestmt widths), - "\t\tdefault: return -1;", - "\t\t}"] - where - casestmt w = "\t\t\tcase " ++ (show w) ++ ": return " ++ - (show.sizeof $ ffitype w nt) ++ ";" - --- Generate a coder class for a given NType. -c2java ntype = - unlines [ - "// native " ++ ntypeS ++ " -> java " ++ jprimS, - "public static final class " ++ className ++ " extends PrimitiveCoder<" ++ jclassS ++ ">{", - "\tpublic static final " ++ className ++ " INST = new " ++ className ++ "();", - "\tpublic " ++ className ++ "(){ super("++ffitypeVal ntype++", \"" ++ [encoding ntype] ++ "\", "++jclassS++".class, "++jprimS++".class); }", - "\t// compile time", - "\t@Override public void push(JObjCRuntime rt, long addr, " ++ jprimS ++ " x){", - "\t\t" ++ pushAddrVal ntype, - "\t}", - "\t@Override public " ++ jprimS ++ " pop" ++ capitalize jprimS ++ "(JObjCRuntime rt, long addr){", - "\t\treturn " ++ popAddrVal ntype ++ ";", - "\t}", - "\t// for runtime coding", - "\t@Override public int sizeof(Width w){", - sizeofRet ntype, - "\t}", - "\t@Override public void push(JObjCRuntime rt, long addr, " ++ jclassS ++ " x){ " ++ - "push(rt, addr, (" ++ jprimS ++ ") x); }", - "\t@Override public " ++ jclassS ++ " pop(JObjCRuntime rt, long addr){ " ++ - "return pop" ++ capitalize jprimS ++ "(rt, addr); }", - "\t// proxies for mixed encoding", - makeProxyMethods ntype, - "}" - ] - where - jprim = ntype2jprim ntype - jclass = jprim2jclass jprim - jprimS = jprim2js jprim - jclassS = jclass2js jclass - ntypeS = ntype2js ntype - className = coderName ntype - --- Generate push and pop methods that convert and proxy to actual implementation. -makeProxyMethods nt = unlines $ map aux jprims - where - targetJPrim = ntype2jprim nt - targetJPrimS = jprim2js targetJPrim - aux jprim = if targetJPrim == jprim then "" else unlines [ - "\t@Override public void push(JObjCRuntime rt, long addr, " ++ jprimS ++ " x){ " ++ - "push(rt, addr, " ++ pushConversion "x" ++ "); }", - "\t@Override public " ++ jprimS ++ " pop" ++ capitalize jprimS ++ "(JObjCRuntime rt, long addr){ " ++ - "return " ++ (popConversion ("pop" ++ capitalize targetJPrimS ++ "(rt, addr)")) ++ "; }" - ] - where - jprimS = jprim2js jprim - pushConversion sym = jconvertPrims sym jprim targetJPrim - popConversion sym = jconvertPrims sym targetJPrim jprim - -main = do - putStrLn "package com.apple.jobjc;" - - putStrLn "import com.apple.jobjc.JObjCRuntime.Width;" - - putStrLn "// Auto generated by PrimitiveCoder.hs" - putStrLn "// Do not edit by hand." - - putStrLn "public abstract class PrimitiveCoder extends Coder{" - - putStrLn "\tpublic PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){" - putStrLn "\t\tsuper(ffiTypeCode, objCEncoding, jclass, jprim);" - putStrLn "\t}" - - mapM_ (\p -> putStrLn $ unlines [makePopI p, makePushI p]) jprims - - mapM_ (putStrLn . c2java) ntypes - - putStrLn "}" - where - makePopI jprim = unlines ["\tpublic final " ++ jprim2js jprim ++ " pop" ++ (capitalize.jprim2js $ jprim) - ++ "(NativeArgumentBuffer args){\n" - ++ "\t\treturn pop" ++ (capitalize.jprim2js $ jprim) ++ "(args.runtime, args.retValPtr);\n" - ++ "\t}", - "\tpublic abstract " ++ jprim2js jprim ++ " pop" ++ (capitalize.jprim2js $ jprim) ++ "(JObjCRuntime runtime, long addr);"] - makePushI jprim = unlines ["\tpublic final void push" - ++ "(NativeArgumentBuffer args, " ++ jprim2js jprim ++ " x){\n" - ++ "\t\tpush(args.runtime, args.argValuesPtr, x);\n" - ++ "\t\targs.didPutArgValue(sizeof());\n" - ++ "\t}", - "\tpublic abstract void push(JObjCRuntime runtime, long addr, " ++ jprim2js jprim ++ " x);"] diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java deleted file mode 100644 index 5207cf81d57..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CFType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - - -public class CFType extends Pointer { - protected CFType(long ptr) { super(ptr); } - protected CFType(Pointer ptr) { super(ptr.ptr); } - - protected ID getTollFreeBridge(JObjCRuntime runtime){ - return ID.getObjCObjectFor(runtime, super.ptr); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CIF.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CIF.java deleted file mode 100644 index c32d822662f..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/CIF.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; - -class CIF { - private static native int getSizeofCIF(); - private static final int SIZEOF = getSizeofCIF(); - private static native boolean prepCIF(long cifPtr, int nargs, long retFFITypePtr, long argsPtr); - - public static CIF createCIFFor(final NativeArgumentBuffer args, final Coder returnCoder, final Coder ... argCoders) { - NativeBuffer cifBuf = new NativeBuffer(SIZEOF + (argCoders.length * JObjCRuntime.PTR_LEN)); - final long argsPtr = cifBuf.bufferPtr + SIZEOF; - - { - long argsIterPtr = argsPtr; - for(final Coder coder : argCoders){ - PrimitivePointerCoder.INST.push(args.runtime, argsIterPtr, coder.getFFITypePtr()); - argsIterPtr += JObjCRuntime.PTR_LEN; - } - } - - boolean ok = prepCIF(cifBuf.bufferPtr, argCoders.length, returnCoder.getFFITypePtr(), argsPtr); - if(!ok) - throw new RuntimeException("ffi_prep_cif failed."); - - return new CIF(cifBuf, returnCoder, argCoders); - } - - final NativeBuffer cif; - // CIF needs to keep refs to the Coders, so they don't get finalized and their FFITypes freed. - final Coder returnCoder; - final Coder[] argCoders; - - private CIF(final NativeBuffer cif, Coder returnCoder, Coder... argCoders) { - this.cif = cif; - this.returnCoder = returnCoder; - this.argCoders = argCoders; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java deleted file mode 100644 index 9efc76e9c05..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Coder.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - -import java.io.StringWriter; -import java.lang.reflect.Method; - -import com.apple.jobjc.JObjCRuntime.Width; -import com.apple.jobjc.PrimitiveCoder.BoolCoder; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; -import com.apple.jobjc.PrimitiveCoder.FloatCoder; -import com.apple.jobjc.PrimitiveCoder.SCharCoder; -import com.apple.jobjc.PrimitiveCoder.SIntCoder; -import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; -import com.apple.jobjc.PrimitiveCoder.SShortCoder; - -public abstract class Coder { - private static native long getNativeFFITypePtrForCode(final int code); - - static final int FFI_VOID = 0; - static final int FFI_PTR = FFI_VOID+1; - - static final int FFI_SINT8 = FFI_PTR+1; - static final int FFI_UINT8 = FFI_SINT8+1; - static final int FFI_SINT16 = FFI_UINT8+1; - static final int FFI_UINT16 = FFI_SINT16+1; - static final int FFI_SINT32 = FFI_UINT16+1; - static final int FFI_UINT32 = FFI_SINT32+1; - static final int FFI_SINT64 = FFI_UINT32+1; - static final int FFI_UINT64 = FFI_SINT64+1; - - static final int FFI_FLOAT = FFI_UINT64+1; - static final int FFI_DOUBLE = FFI_FLOAT+1; - static final int FFI_LONGDOUBLE = FFI_DOUBLE+1; - - private static long[] ffiCodesToFFITypePtrs; - static{ - System.loadLibrary("JObjC"); - ffiCodesToFFITypePtrs = new long[FFI_LONGDOUBLE + 1]; - for (int i = 0; i < FFI_LONGDOUBLE + 1; i++) ffiCodesToFFITypePtrs[i] = getNativeFFITypePtrForCode(i); - } - - long getFFITypePtr() { - return ffiCodesToFFITypePtrs[getTypeCode()]; - } - - // runtime coding - public abstract void push(final JObjCRuntime runtime, final long addr, final T x); - public abstract T pop(final JObjCRuntime runtime, final long addr); - - public void push(final NativeArgumentBuffer args, final T x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - - public T pop(final NativeArgumentBuffer args){ - return pop(args.runtime, args.retValPtr); - } - - public abstract int sizeof(Width w); - final public int sizeof(){ return sizeof(JObjCRuntime.WIDTH); } - - // - - public Coder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim) { - this.ffiTypeCode = ffiTypeCode; - this.objCEncoding = objCEncoding; - this.jclass = jclass; - this.jprim = jprim; - } - - public Coder(int ffiTypeCode, String objCEncoding, Class jclass) { - this(ffiTypeCode, objCEncoding, jclass, null); - } - - private final int ffiTypeCode; - private final String objCEncoding; - private final Class jclass; - private final Class jprim; - - final int getTypeCode() { return ffiTypeCode; } - final String getObjCEncoding(){ return objCEncoding; } - public final Class getJavaClass() { return jclass; } - public final Class getJavaPrimitive() { return jprim; } - - // runtime coding - - private static Coder[] runtimeCoders; - static public Coder getCoderAtRuntimeForType(Class cls){ - if(runtimeCoders == null) runtimeCoders = new Coder[]{ - NSClassCoder.INST, IDCoder.INST, PointerCoder.INST, - DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST, - SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST, - VoidCoder.INST - }; - - for(Coder c : runtimeCoders) - if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) || - (c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls))) - return c; - - if(Struct.class.isAssignableFrom(cls)){ - try { - Method m = cls.getDeclaredMethod("getStructCoder"); - m.setAccessible(true); - return (Coder) m.invoke(null); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - throw new RuntimeException("Could not find suitable coder for " + cls); - } - - static public Coder getCoderAtRuntime(Object inst){ - if(inst == null) return PointerCoder.INST; - if(inst instanceof Struct) return ((Struct) inst).getCoder(); - return getCoderAtRuntimeForType(inst.getClass()); - } - - // - - public static final class VoidCoder extends Coder{ - public static final VoidCoder INST = new VoidCoder(); - public VoidCoder(){ super(FFI_VOID, "v", Void.class, void.class); } - @Override public int sizeof(Width w) { return -1; } - @Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Trying to pop a Void."); } - @Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Trying to push a Void."); } - } - - public static final class UnknownCoder extends Coder { - public static final UnknownCoder INST = new UnknownCoder(); - public UnknownCoder(){ super(-1, "?", null, null); } - @Override public int sizeof(Width w) { return -1; } - @Override public void push(JObjCRuntime runtime, long addr, Object x) { throw new RuntimeException("Coder not implemented");} - @Override public Object pop(JObjCRuntime runtime, long addr) { throw new RuntimeException("Coder not implemented"); } - } - - public static final class PrimitivePointerCoder extends Coder { - public static final PrimitivePointerCoder INST = new PrimitivePointerCoder(); - public PrimitivePointerCoder(){ super(Coder.FFI_PTR, "^?", Long.class, long.class); } - @Override public int sizeof(Width w) { return JObjCRuntime.PTR_LEN; } - - public void push(JObjCRuntime runtime, long addr, long x) { - if(JObjCRuntime.IS64) - runtime.unsafe.putLong(addr, x); - else - runtime.unsafe.putInt(addr, (int) x); - } - - public void push(final JObjCRuntime runtime, final NativeArgumentBuffer argBuf, final long ptr) { - push(runtime, argBuf.argValuesPtr, ptr); - argBuf.didPutArgValue(sizeof()); - } - - public long popPtr(final JObjCRuntime runtime, final long addr) { - return JObjCRuntime.IS64 ? runtime.unsafe.getLong(addr) : runtime.unsafe.getInt(addr); - } - - public long popPtr(final JObjCRuntime runtime, final NativeArgumentBuffer argBuf) { - return popPtr(runtime, argBuf.retValPtr); - } - - @Override public Long pop(JObjCRuntime runtime, long addr) { return popPtr(runtime, addr); } - @Override public void push(JObjCRuntime runtime, long addr, Long x) { push(runtime, addr, (long) x); } - } - - public static final class PointerCoder extends Coder { - public static final PointerCoder INST = new PointerCoder(); - public PointerCoder(){ super(FFI_PTR, "^?", Pointer.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - @Override public Pointer pop(JObjCRuntime runtime, long addr) { - return new Pointer(PrimitivePointerCoder.INST.popPtr(runtime, addr)); - } - @Override public void push(JObjCRuntime runtime, long addr, Pointer x) { - PrimitivePointerCoder.INST.push(runtime, addr, x == null ? 0 : x.ptr); - } - } - - public static final class SELCoder extends Coder { - public static final SELCoder INST = new SELCoder(); - public SELCoder(){ super(FFI_PTR, ":", SEL.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - @Override public void push(JObjCRuntime runtime, long addr, SEL x) { - PrimitivePointerCoder.INST.push(runtime, addr, x == null ? 0 : x.selPtr); - } - @Override public SEL pop(JObjCRuntime runtime, long addr) { - return new SEL(PrimitivePointerCoder.INST.popPtr(runtime, addr)); - } - } - - public static abstract class StructCoder extends Coder { - private final FFIType ffiType; - final int sizeof; - - public StructCoder(final int sizeof, final Coder... elementCoders){ - super(-1, objCEncoding(elementCoders), null); - this.ffiType = new FFIType(elementCoders); - this.sizeof = sizeof; - } - - @Override public int sizeof(Width w) { return sizeof; } - - private static String objCEncoding(final Coder[] elementCoders) { - StringWriter str = new StringWriter(); - str.append("{?="); - for(Coder c : elementCoders) - str.append(c.getObjCEncoding()); - str.append("}"); - return str.toString(); - } - - @Override long getFFITypePtr() { return ffiType.getPtr(); } - - @Override public void push(NativeArgumentBuffer argBuf, Struct x) { - // Just point to the instance on the heap instead of copying it onto the arg buf. - argBuf.doPutArgPtr(x.raw.bufferPtr); - } - - @Override public void push(JObjCRuntime rt, long addr, Struct x) { - rt.unsafe.copyMemory(x.raw.bufferPtr, addr, sizeof); - } - - protected abstract Struct newInstance(JObjCRuntime runtime); - - @Override public Struct pop(final JObjCRuntime runtime, final long addr) { - Struct s = newInstance(runtime); - runtime.unsafe.copyMemory(addr, s.raw.bufferPtr, sizeof); - return s; - } - } - - public static final class IDCoder extends Coder{ - public static final IDCoder INST = new IDCoder(); - public IDCoder(){ super(FFI_PTR, "@", ID.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - public T newID(final JObjCRuntime runtime, final long objPtr) { - return (T) ID.getObjCObjectFor(runtime, objPtr); - } - - @Override public ID pop(final JObjCRuntime runtime, final long addr) { - return newID(runtime, PrimitivePointerCoder.INST.popPtr(runtime, addr)); - } - - @Override public void push(final JObjCRuntime runtime, final long addr, final ID x) { - PointerCoder.INST.push(runtime, addr, x); - } - } - - public static final class NSClassCoder extends Coder{ - public static final NSClassCoder INST = new NSClassCoder(); - public NSClassCoder(){ super(FFI_PTR, "#", NSClass.class); } - @Override public int sizeof(Width w) { return PrimitivePointerCoder.INST.sizeof(w); } - - @Override public NSClass pop(JObjCRuntime runtime, long addr) { - final long clsPtr = PrimitivePointerCoder.INST.popPtr(runtime, addr); - if (clsPtr == 0) return null; - return NSClass.getObjCClassFor(runtime, clsPtr); - } - @Override public void push(JObjCRuntime runtime, long addr, NSClass x) { - PointerCoder.INST.push(runtime, addr, x); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java deleted file mode 100644 index dcff0035587..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/FFIType.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; - - -class FFIType{ - private static native void makeFFIType(long ffi_type_buf, long elements_buf); - private static native int getFFITypeSizeof(); - private static int FFI_TYPE_SIZEOF = getFFITypeSizeof(); - final NativeBuffer ffi_type; - final NativeBuffer elements; - final Coder[] elementCoders; - - public FFIType(final Coder... elementCoders){ - final JObjCRuntime runtime = JObjCRuntime.inst(); - this.elementCoders = elementCoders; - this.ffi_type = new NativeBuffer(FFI_TYPE_SIZEOF); - this.elements = new NativeBuffer(JObjCRuntime.PTR_LEN * (elementCoders.length + 1)); - - long elIterPtr = elements.bufferPtr; - for(Coder c : elementCoders){ - PrimitivePointerCoder.INST.push(runtime, elIterPtr, c.getFFITypePtr()); - elIterPtr += PrimitivePointerCoder.INST.sizeof(); - } - PrimitivePointerCoder.INST.push(runtime, elIterPtr, 0); - - makeFFIType(ffi_type.bufferPtr, elements.bufferPtr); - } - - public long getPtr(){ - return ffi_type.bufferPtr; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java deleted file mode 100644 index 413d8fafe76..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Function.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - - -public class Function { - private static native long getFxnPtrForFunctionName(final String functionName); - private static native long getFxnPtrForFunctionNameAndLib(final long libPtr, final String functionName); - - final long fxnPtr; - - Function(final long fxnPtr) { - this.fxnPtr = fxnPtr; - } - - public Function(final String name) { - this(getFxnPtr(name)); - } - - public Function(final MacOSXFramework framework, final String name) { - this(getFxnPtr(name, framework)); - } - - static long getFxnPtr(final String name){ - long fxnPtr = getFxnPtrForFunctionName(name); - if(fxnPtr == 0) throw new RuntimeException("Function pointer for " + name + " not found in runtime."); - return fxnPtr; - } - - static long getFxnPtr(final String name, final MacOSXFramework framework){ - long fxnPtr = 0; - for(int i = 0; fxnPtr == 0 && i < framework.nativeLibPtrs.length; i++){ - fxnPtr = getFxnPtrForFunctionNameAndLib(framework.nativeLibPtrs[i], name); - if(fxnPtr != 0) return fxnPtr; - } - throw new RuntimeException("Function pointer for " + name + " not found in framework " + framework + "."); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java deleted file mode 100644 index aa202cf0943..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/ID.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - -import java.lang.ref.WeakReference; -import java.lang.reflect.Constructor; -import java.util.LinkedHashMap; -import java.util.Map; - - -public class ID extends Pointer{ - static native String getNativeDescription(final long objPtr); - - final JObjCRuntime runtime; - - static final Class[] CTOR_ARGS = { long.class, JObjCRuntime.class }; - protected ID(final long objPtr, final JObjCRuntime runtime) { - super(objPtr); - runtime.assertOK(); - this.runtime = runtime; - } - - protected ID(final ID obj, final JObjCRuntime runtime) { - this(obj.ptr, runtime); - } - - @Override protected NativeObjectLifecycleManager getNativeObjectLifecycleManager() { - return NativeObjectLifecycleManager.CFRetainRelease.INST; - } - - protected final JObjCRuntime getRuntime() { return runtime; } - - @Override public String toString(){ - String s = super.toString(); - return s + " (ObjC: " + ptr + " / " + Long.toHexString(ptr) + ")"; - } - - // - - public static T getInstance(final long ptr, final JObjCRuntime runtime){ - return (T) getObjCObjectFor(runtime, ptr); - } - - static T getObjCObjectFor(final JObjCRuntime runtime, final long objPtr){ - if (objPtr == 0) return null; - - final WeakReference cachedObj = objectCache.get().get(objPtr); - if(cachedObj != null && cachedObj.get() != null) return (T) cachedObj.get(); - - final long clsPtr = NSClass.getClass(objPtr); - - final T newObj = (T) (runtime.subclassing.isUserClass(clsPtr) ? - Subclassing.getJObjectFromIVar(objPtr) - : createNewObjCObjectFor(runtime, objPtr, clsPtr)); - - objectCache.get().put(objPtr, new WeakReference(newObj)); - return newObj; - } - - static T createNewObjCObjectFor(final JObjCRuntime runtime, final long objPtr, final long clsPtr) { - final Constructor ctor = getConstructorForClassPtr(runtime, clsPtr); - return (T) createNewObjCObjectForConstructor(ctor, objPtr, runtime); - } - - @SuppressWarnings("unchecked") - static Constructor getConstructorForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final Constructor cachedCtor = (Constructor) constructorCache.get().get(clazzPtr); - if(cachedCtor != null) return cachedCtor; - - final Class clazz = getClassForClassPtr(runtime, clazzPtr); - Constructor ctor; - try { - ctor = clazz.getDeclaredConstructor(CTOR_ARGS); - } catch (SecurityException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - ctor.setAccessible(true); - constructorCache.get().put(clazzPtr, (Constructor) ctor); - return ctor; - } - - @SuppressWarnings("unchecked") - static Class getClassForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final String className = NSClass.getClassNameOfClass(clazzPtr); - final Class clazz = (Class) runtime.getClassForNativeClassName(className); - if(clazz == null){ - final long superClazzPtr = NSClass.getSuperClassOfClass(clazzPtr); - if(superClazzPtr != 0) - return getClassForClassPtr(runtime, superClazzPtr); - } - return clazz; - } - - static T createNewObjCObjectForConstructor(final Constructor ctor, final long objPtr, final JObjCRuntime runtime) { - try { - final T newInstance = (T) ctor.newInstance(new Object[] { Long.valueOf(objPtr), runtime }); - objectCache.get().put(objPtr, new WeakReference(newInstance)); - return newInstance; - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - static T createNewObjCObjectForClass(final Class clazz, final long objPtr, final JObjCRuntime runtime) { - try { - final Constructor constructor = clazz.getDeclaredConstructor(CTOR_ARGS); - constructor.setAccessible(true); - return (T) createNewObjCObjectForConstructor(constructor, objPtr, runtime); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - // - - static final ThreadLocal> constructorCache = new ThreadLocal>(){ - @Override protected LinkedHashMap initialValue(){ - final int MAX_ENTRIES = 1000; - final float LOAD_FACTOR = 0.75f; - return new LinkedHashMap((int) (MAX_ENTRIES/LOAD_FACTOR), LOAD_FACTOR, true) { - @Override protected boolean removeEldestEntry(Map.Entry eldest) { - return size() > MAX_ENTRIES; - } - }; - } - }; - - static final ThreadLocal> objectCache = new ThreadLocal>(){ - @Override protected LinkedHashMap initialValue(){ - final int MAX_ENTRIES = 1000; - final float LOAD_FACTOR = 0.75f; - return new LinkedHashMap((int) (MAX_ENTRIES/LOAD_FACTOR), LOAD_FACTOR, true) { - @Override protected boolean removeEldestEntry(Map.Entry eldest) { - return size() > MAX_ENTRIES || eldest.getValue().get() == null; - } - }; - } - }; -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java deleted file mode 100644 index 48ffc98663f..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Invoke.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - -import com.apple.jobjc.Coder.IDCoder; -import com.apple.jobjc.Coder.NSClassCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.SELCoder; -import com.apple.jobjc.Coder.StructCoder; - - -public abstract class Invoke { - public abstract void invoke(NativeArgumentBuffer argBuf); - public abstract void invoke(NativeArgumentBuffer buffer, Struct retvalStruct); - - // - - public static final class FunCall extends Invoke{ - static native void invoke(long cifPtr, long fxnPtr, long retValPtr, long argsPtr); - - final long fxnPtr; - final CIF cif; - - FunCall(long fxnPtr, CIF cif) { - this.fxnPtr = fxnPtr; - this.cif = cif; - } - - public FunCall(final JObjCRuntime runtime, final String name, final Coder returnCoder, final Coder ... argCoders) { - this(Function.getFxnPtr(name), CIF.createCIFFor(runtime.getThreadLocalState(), returnCoder, argCoders)); - } - - public FunCall(final MacOSXFramework framework, final String name, final Coder returnCoder, final Coder ... argCoders) { - this(Function.getFxnPtr(name, framework), CIF.createCIFFor(framework.getRuntime().getThreadLocalState(), returnCoder, argCoders)); - } - - public void init(final NativeArgumentBuffer argBuf) { - argBuf.reset(); - } - - @Override public void invoke(final NativeArgumentBuffer argBuf) { - invoke(argBuf, argBuf.retValPtr); - } - - @Override public void invoke(final NativeArgumentBuffer buffer, final Struct retvalStruct) { - invoke(buffer, retvalStruct.raw.bufferPtr); - } - - void invoke(final NativeArgumentBuffer argBuf, final long retValPtr) { - invoke(cif.cif.bufferPtr, fxnPtr, retValPtr, argBuf.buffer.bufferPtr); - } - } - - public static final class MsgSend extends Invoke{ - static{ System.load("/usr/lib/libobjc.dylib"); } - - private static final long OBJC_MSG_SEND_FXN_PTR = new Function("objc_msgSend").fxnPtr; - private static final long OBJC_MSG_SEND_FPRET_FXN_PTR = new Function("objc_msgSend_fpret").fxnPtr; - private static final long OBJC_MSG_SEND_STRET_FXN_PTR = new Function("objc_msgSend_stret").fxnPtr; - - final FunCall funCall; - final long selPtr; - - public MsgSend(final JObjCRuntime runtime, final String name, final Coder returnCoder, final Coder ... argCoders) { - this.funCall = new FunCall(getMsgSendFxnPtr(returnCoder), - CIF.createCIFFor(runtime.getThreadLocalState(), returnCoder, getSelCoders(argCoders))); - this.selPtr = SEL.getSelectorPtr(name); - } - - public void init(final NativeArgumentBuffer nativeBuffer, final ID obj) { - funCall.init(nativeBuffer); - IDCoder.INST.push(nativeBuffer, obj); - PrimitivePointerCoder.INST.push(nativeBuffer.runtime, nativeBuffer, selPtr); - } - - @Override public void invoke(final NativeArgumentBuffer argBuf) { - funCall.invoke(argBuf); - } - - @Override public void invoke(final NativeArgumentBuffer buffer, final Struct retvalStruct) { - funCall.invoke(buffer, retvalStruct); - } - - // support - - static Coder[] getSelCoders(final Coder[] argCoders) { - final Coder[] selArgCoders = new Coder[argCoders.length + 2]; - selArgCoders[0] = IDCoder.INST; - selArgCoders[1] = SELCoder.INST; - for (int i = 0; i < argCoders.length; i++) - selArgCoders[i + 2] = argCoders[i]; - return selArgCoders; - } - - static long getMsgSendFxnPtr(final Coder returnCoder) { - if(returnCoder instanceof StructCoder){ - StructCoder scoder = (StructCoder) returnCoder; - - switch(JObjCRuntime.ARCH){ - case ppc: - return OBJC_MSG_SEND_STRET_FXN_PTR; - case i386: - switch(scoder.sizeof){ - case 1: case 2: case 4: case 8: - return OBJC_MSG_SEND_FXN_PTR; - } - return OBJC_MSG_SEND_STRET_FXN_PTR; - case x86_64: - if(scoder.sizeof > 16) - return OBJC_MSG_SEND_STRET_FXN_PTR; - else - return OBJC_MSG_SEND_FXN_PTR; - default: - throw new RuntimeException(); - } - } - - final int typeCode = returnCoder.getTypeCode(); - - switch(JObjCRuntime.ARCH){ - case ppc: - return OBJC_MSG_SEND_FXN_PTR; - case i386: - switch(typeCode) { - case Coder.FFI_FLOAT: case Coder.FFI_DOUBLE: case Coder.FFI_LONGDOUBLE: - return OBJC_MSG_SEND_FPRET_FXN_PTR; - } - return OBJC_MSG_SEND_FXN_PTR; - case x86_64: - if(typeCode == Coder.FFI_LONGDOUBLE) - return OBJC_MSG_SEND_FPRET_FXN_PTR; - return OBJC_MSG_SEND_FXN_PTR; - default: - throw new RuntimeException(); - } - } - } - - public static final class MsgSendSuper extends Invoke{ - static{ System.load("/usr/lib/libobjc.dylib"); } - - private static final long OBJC_MSG_SEND_SUPER_FXN_PTR = new Function("objc_msgSendSuper").fxnPtr; - private static final long OBJC_MSG_SEND_SUPER_STRET_FXN_PTR = new Function("objc_msgSendSuper_stret").fxnPtr; - - final FunCall funCall; - final long selPtr; - - public MsgSendSuper(final JObjCRuntime runtime, final String name, final Coder returnCoder, final Coder ... argCoders) { - this.funCall = new FunCall(getMsgSendSuperFxnPtr(returnCoder), - CIF.createCIFFor(runtime.getThreadLocalState(), returnCoder, getSuperSelCoders(argCoders))); - this.selPtr = SEL.getSelectorPtr(name); - } - - public void init(final NativeArgumentBuffer argBuf, final ID obj, final NSClass cls) { - funCall.init(argBuf); - - // Instead of mallocing a struct, or keeping another thread local, - // let's write objc_super out to the argbuf, and then point an argument - // to the data. - - final long valPtr = argBuf.argValuesPtr; - final int ptrLen = JObjCRuntime.PTR_LEN; - - IDCoder .INST.push(argBuf.runtime, valPtr, obj); - NSClassCoder.INST.push(argBuf.runtime, valPtr + ptrLen, cls); - argBuf.argValuesPtr += ptrLen + ptrLen; - - PrimitivePointerCoder.INST.push(argBuf.runtime, argBuf, valPtr); - PrimitivePointerCoder.INST.push(argBuf.runtime, argBuf, selPtr); - } - - @Override public void invoke(final NativeArgumentBuffer argBuf) { - funCall.invoke(argBuf); - } - - @Override public void invoke(final NativeArgumentBuffer buffer, final Struct retvalStruct) { - funCall.invoke(buffer, retvalStruct); - } - - // - - private final static StructCoder objc_super_coder = new StructCoder(JObjCRuntime.PTR_LEN*2, IDCoder.INST, NSClassCoder.INST){ - @Override protected Struct newInstance(JObjCRuntime runtime) { return null; }}; - - static Coder[] getSuperSelCoders(final Coder[] argCoders) { - final Coder[] selArgCoders = new Coder[argCoders.length + 2]; - selArgCoders[0] = objc_super_coder; - selArgCoders[1] = SELCoder.INST; - for (int i = 0; i < argCoders.length; i++) - selArgCoders[i + 2] = argCoders[i]; - return selArgCoders; - } - - static long getMsgSendSuperFxnPtr(final Coder returnCoder){ - long normal = MsgSend.getMsgSendFxnPtr(returnCoder); - if(normal == MsgSend.OBJC_MSG_SEND_STRET_FXN_PTR) - return OBJC_MSG_SEND_SUPER_STRET_FXN_PTR; - else - return OBJC_MSG_SEND_SUPER_FXN_PTR; - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java deleted file mode 100644 index 5bc01bc4e97..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/JObjCRuntime.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - -import java.lang.reflect.Field; -import java.nio.ByteOrder; -import java.util.ArrayList; -import java.util.List; - -import sun.misc.Unsafe; - - -public final class JObjCRuntime { - static { System.loadLibrary("JObjC"); } - - public static enum Arch{ ppc, i386, x86_64 }; - public static enum Width{ W32, W64 }; - - public static final Arch ARCH = getArch(); - public static final Width WIDTH = getWidth(); - - private static Arch getArch(){ - String arch = System.getProperty("os.arch"); - if("ppc".equals(arch)) return Arch.ppc; - if("i386".equals(arch)) return Arch.i386; - if("x86_64".equals(arch)) return Arch.x86_64; - if("amd64".equals(arch)) return Arch.x86_64; - if("universal".equals(arch)) return Arch.x86_64; - throw new RuntimeException("Did not recognize os.arch system property: '" + arch + "'"); - } - - private static Width getWidth(){ - String width = System.getProperty("sun.arch.data.model"); - if("32".equals(width)) return Width.W32; - if("64".equals(width)) return Width.W64; - throw new RuntimeException("Did not recognize sun.arch.data.model system property: '" + width + "'"); - } - - public static final boolean IS32 = System.getProperty("sun.arch.data.model").equals("32"); - public static final boolean IS64 = System.getProperty("sun.arch.data.model").equals("64"); - public static final int PTR_LEN = IS64 ? 8 : 4; - public static final boolean IS_BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN; - static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("JObjC.debug")); - - static void checkPermission(){ - final SecurityManager security = System.getSecurityManager(); - if (security != null) security.checkPermission(new RuntimePermission("canProcessApplicationEvents")); - } - - public final void assertOK(){ - if(this != instance) - throw new SecurityException("runtime"); - } - - private JObjCRuntime(){} - - private static JObjCRuntime instance; - static JObjCRuntime inst() { - if (instance == null) instance = new JObjCRuntime(); - return instance; - } - - public static JObjCRuntime getInstance() { - checkPermission(); - return inst(); - } - - public final NativeArgumentBuffer getThreadLocalState() { - return NativeArgumentBuffer.getThreadLocalBuffer(this); - } - - final Unsafe unsafe = getUnsafe(); - final Subclassing subclassing = new Subclassing(this); - final List registeredPackages = new ArrayList(); - - @SuppressWarnings("unchecked") - Class getClassForNativeClassName(final String className) { - for (final String pkg : registeredPackages) { - try { - final Class clazz = Class.forName(pkg + "." + className); - if (clazz != null) return (Class)clazz; - } catch (final ClassNotFoundException e) { } - } - - return null; - } - - private final static Unsafe getUnsafe() { - Unsafe inst = null; - try { - Field f = Unsafe.class.getDeclaredField("theUnsafe"); - f.setAccessible(true); - inst = (Unsafe) f.get(null); - if(inst == null) throw new NullPointerException("Unsafe.theUnsafe == null"); - } catch (Exception e) { - throw new RuntimeException("Unable to get instance of Unsafe.", e); - } - return inst; - } - - public void registerPackage(final String pkg) { - registeredPackages.add(pkg); - } - - /** - * Register a subclass of NSObject to allow the native side to send - * messages which in turn call java methods declared on the class. - * If a native class by the same name already exists, registerClass - * will simply return without doing anything. - * - * For a usage example, see the SubclassingTest. - */ - public boolean registerUserClass(Class clazz, Class clazzClazz) { - return subclassing.registerUserClass(clazz, clazzClazz); - } - -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java deleted file mode 100644 index bd776688f7d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/MacOSXFramework.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - - - -public class MacOSXFramework { - private static native long retainFramework(final String frameworkName); - private static native void releaseFramework(final long frameworkPtr); - private static native void getConstant(final long frameworkPtr, String symbol, final long bufferPtr, final int size); - - private final JObjCRuntime runtime; - protected final long[] nativeLibPtrs; - - final long getFrameworkPtr() { return nativeLibPtrs.length > 0 ? nativeLibPtrs[0] : 0; } - - private static long[] createFrameworkPtrsFromPaths(final String[] frameworkLibPaths) { - final long[] libPtrs = new long[frameworkLibPaths.length]; - for(int i = 0; i < libPtrs.length; i++){ - libPtrs[i] = retainFramework(frameworkLibPaths[i]); - if(libPtrs[i] == 0) throw new RuntimeException("Could not open library at " + frameworkLibPaths[i]); - } - return libPtrs; - } - - protected MacOSXFramework(final JObjCRuntime runtime, final String[] nativeLibPaths) { - runtime.assertOK(); - this.runtime = runtime; - this.nativeLibPtrs = createFrameworkPtrsFromPaths(nativeLibPaths); - } - - @Override protected final synchronized void finalize() throws Throwable { - for(long lib : nativeLibPtrs) - if(lib != 0) releaseFramework(lib); - } - - protected final JObjCRuntime getRuntime(){ return runtime; } - - protected void getConstant(final String symbol, final long retValPtr, final int size){ - assert size >= 0; - assert retValPtr != 0; - getConstant(getFrameworkPtr(), symbol, retValPtr, size); - } - - protected void getConstant(final String symbol, final NativeArgumentBuffer out, final int size){ - getConstant(symbol, out.retValPtr, size); - } - - protected void getConstant(final String symbol, final Struct out, final int size){ - getConstant(symbol, out.raw.bufferPtr, size); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java deleted file mode 100644 index dfda99acf35..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NSClass.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - -import java.lang.ref.WeakReference; -import java.lang.reflect.Constructor; - - -public class NSClass extends ID { - public static class NSClassNotFoundException extends RuntimeException{ - public NSClassNotFoundException(String m){ super(m); } - public NSClassNotFoundException(String m, Throwable cause){ super(m, cause); } - } - - static native long getNativeClassByName(String name); - static native long getSuperClassOfClass(long classPtr); - static native String getClassNameOfClass(long classPtr); - static native long getClass(long objPtr); - - public NSClass(final long ptr, final JObjCRuntime runtime) { - super(ptr, runtime); - } - - public NSClass(final String name, final JObjCRuntime runtime) { - this(getNativeClassByName(name), runtime); - if(ptr == 0) throw new NSClassNotFoundException("NSClass pointer is 0. Found no class named " + name); - } - - protected NSClass(final JObjCRuntime runtime){ - super(0, runtime); - final String sn = getClass().getSimpleName(); - final String name = sn.substring(0, sn.lastIndexOf("Class")); - ptr = getNativeClassByName(name); - if(ptr == 0) throw new NSClassNotFoundException("NSClass pointer is 0. Found no class named " + name); - } - - NSClass getSuperClass() { - return new NSClass(getSuperClassOfClass(ptr), runtime); - } - - String getClassName() { return getClassNameOfClass(ptr); } - - @Override protected NativeObjectLifecycleManager getNativeObjectLifecycleManager() { - return NativeObjectLifecycleManager.Nothing.INST; - } - - @Override public boolean equals(Object o){ - return (o instanceof NSClass) && (this.ptr == ((NSClass) o).ptr); - } - - // - - static T getObjCClassFor(final JObjCRuntime runtime, final long clsPtr){ - if (clsPtr == 0) return null; - - final WeakReference cachedObj = objectCache.get().get(clsPtr); - if(cachedObj != null && cachedObj.get() != null) return (T) cachedObj.get(); - - final T newObj = (T) createNewObjCClassFor(runtime, clsPtr); - objectCache.get().put(clsPtr, new WeakReference(newObj)); - return newObj; - } - - static T createNewObjCClassFor(final JObjCRuntime runtime, final long clsPtr) { - final Constructor ctor = getNSClassConstructorForClassPtr(runtime, clsPtr); - return (T) createNewObjCObjectForConstructor(ctor, clsPtr, runtime); - } - - @SuppressWarnings("unchecked") - static Constructor getNSClassConstructorForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final Class clazz = getNSClassForClassPtr(runtime, clazzPtr); - Constructor ctor; - try { - ctor = clazz.getDeclaredConstructor(CTOR_ARGS); - } catch (SecurityException e) { - throw new RuntimeException(e); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - ctor.setAccessible(true); - return ctor; - } - - @SuppressWarnings("unchecked") - static Class getNSClassForClassPtr(final JObjCRuntime runtime, final long clazzPtr){ - final String className = NSClass.getClassNameOfClass(clazzPtr); - final Class clazz = (Class) runtime.getClassForNativeClassName(className + "Class"); - if(clazz == null){ - final long superClazzPtr = NSClass.getSuperClassOfClass(clazzPtr); - if(superClazzPtr != 0) - return getNSClassForClassPtr(runtime, superClazzPtr); - } - return clazz; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java deleted file mode 100644 index 7f8949a2b40..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeArgumentBuffer.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - -import java.nio.ByteOrder; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; - - -public final class NativeArgumentBuffer{ - private static final ThreadLocal threadLocal = new ThreadLocal(); - - static NativeArgumentBuffer getThreadLocalBuffer(final JObjCRuntime runtime) { - runtime.assertOK(); - final NativeArgumentBuffer alreadyCreated = threadLocal.get(); - if (alreadyCreated != null) return alreadyCreated; - - final NativeArgumentBuffer newThreadLocalState = new NativeArgumentBuffer(runtime); - threadLocal.set(newThreadLocalState); - return newThreadLocalState; - } - - final JObjCRuntime runtime; - - final NativeBuffer buffer; - - long argPtrsPtr; - long argValuesPtr; - final long retValPtr; - - private static final int MAX_ARGS = 512; - private static final int BUF_SIZE = MAX_ARGS * 8 * 2; - private static final int ARG_VALS_OFFSET = BUF_SIZE/2; - - private NativeArgumentBuffer(final JObjCRuntime runtime) { - runtime.assertOK(); - this.runtime = runtime; - this.buffer = new NativeBuffer(BUF_SIZE); - this.buffer.buffer.order(ByteOrder.nativeOrder()); - - reset(); - this.retValPtr = buffer.bufferPtr; - } - - - // Call before each new call - public void reset() { - argPtrsPtr = buffer.bufferPtr; - argValuesPtr = buffer.bufferPtr + ARG_VALS_OFFSET; - assert buffer.ptrInBounds(argValuesPtr); - } - - // Push a pointer to a block of memory - public void doPutArgPtr(long ptr) { - assert buffer.ptrInBounds(argPtrsPtr); - PrimitivePointerCoder.INST.push(runtime, argPtrsPtr, ptr); - argPtrsPtr += JObjCRuntime.PTR_LEN; - } - - // Call this after having written a value of size `sizeof` to `argValuesPtr`. - public void didPutArgValue(int sizeof) { - assert buffer.ptrInBounds(argValuesPtr); - doPutArgPtr(argValuesPtr); - argValuesPtr += sizeof; - } - - - @Override public String toString() { - final StringBuilder builder = new StringBuilder(); - final long bptr = buffer.bufferPtr; - - for(long i = bptr; i < bptr + ARG_VALS_OFFSET; i += JObjCRuntime.PTR_LEN){ - if(argPtrsPtr == i) - builder.append("*"); - builder.append(PrimitivePointerCoder.INST.popPtr(JObjCRuntime.inst(), i)); - builder.append(" "); - } - - builder.append("\n"); - - for(long i = bptr + ARG_VALS_OFFSET; i < bptr + BUF_SIZE; i += JObjCRuntime.PTR_LEN){ - if(argValuesPtr == i) - builder.append("*"); - builder.append(PrimitivePointerCoder.INST.popPtr(JObjCRuntime.inst(), i)); - builder.append(" "); - } - - return builder.toString(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java deleted file mode 100644 index 8630971c206..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeBuffer.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - - -/** - * A wrapper around a direct ByteBuffer and its native pointer. For documentation, @see java.nio.ByteBuffer - */ -public class NativeBuffer { - static native long getPtrOfBuffer(final ByteBuffer byteBuffer); - - public final ByteBuffer buffer; - public final long bufferPtr; - - public NativeBuffer(final int capacity){ - this(ByteBuffer.allocateDirect(capacity)); - } - - /** - * Wrap a ByteBuffer and set the ByteOrder to nativeOrder. - */ - public NativeBuffer(ByteBuffer buffer){ - this.buffer = buffer; - this.bufferPtr = getPtrOfBuffer(buffer); - assert buffer != null; - assert bufferPtr != 0; - this.buffer.order(ByteOrder.nativeOrder()); - } - - public byte get() { return buffer.get(); } - public char getChar() { return buffer.getChar(); } - public double getDouble() { return buffer.getDouble(); } - public float getFloat() { return buffer.getFloat(); } - public int getInt() { return buffer.getInt(); } - public long getLong() { return buffer.getLong(); } - public short getShort() { return buffer.getShort(); } - public NativeBuffer put(byte b) { buffer.put(b); return this; } - public NativeBuffer put(NativeBuffer src) { buffer.put(src.buffer); return this; } - public NativeBuffer putChar(char c) { buffer.putChar(c); return this; } - public NativeBuffer putDouble(double d) { buffer.putDouble(d); return this; } - public NativeBuffer putFloat(float f) { buffer.putFloat(f); return this; } - public NativeBuffer putInt(int i) { buffer.putInt(i); return this; } - public NativeBuffer putLong(long l) { buffer.putLong(l); return this; } - public NativeBuffer putShort(short s) { buffer.putShort(s); return this; } - - public int capacity() { return buffer.capacity(); } - public int position() { return buffer.position(); } - public NativeBuffer position(int newPosition) { buffer.position(newPosition); return this; } - public NativeBuffer rewind(){ buffer.rewind(); return this; } - - public int limit() { return buffer.limit(); } - public NativeBuffer limit(final int sizeof) { buffer.limit(sizeof); return this; } - - public int remaining() { return buffer.remaining(); } - - public NativeBuffer slice(){ return new NativeBuffer(buffer.slice()); } - - @Override public String toString() { - final StringBuilder builder = new StringBuilder(); - - for(int i = 0; i < limit(); i += JObjCRuntime.PTR_LEN){ - if(position() == i) - builder.append("*"); - if(JObjCRuntime.IS32) - builder.append(buffer.getInt(i)); - else - builder.append(buffer.getLong(i)); - builder.append(" "); - } - - return builder.toString(); - } - - public long positionPtr() { - return bufferPtr + position(); - } - - /** - * bufferPtr <= ptr && ptr < bufferPtr + capacity(); - */ - public boolean ptrInBounds(final long ptr){ - return bufferPtr <= ptr && ptr < bufferPtr + capacity(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java deleted file mode 100644 index 993be3337fe..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/NativeObjectLifecycleManager.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - - -public abstract class NativeObjectLifecycleManager { - private static native void retainNativeObject(final long ptr); - private static native void releaseNativeObject(final long ptr); - private static native void freeNativeObject(final long ptr); - - abstract void begin(final long ptr); - abstract void end(final long ptr); - boolean shouldPreRetain() { return false; } - - public static class CFRetainRelease extends NativeObjectLifecycleManager { - public static final NativeObjectLifecycleManager INST = new CFRetainRelease(); - @Override void begin(final long ptr) { retainNativeObject(ptr); } - @Override void end(final long ptr) { releaseNativeObject(ptr); } - @Override boolean shouldPreRetain() { return true; } - } - - public static class Free extends NativeObjectLifecycleManager { - public static final NativeObjectLifecycleManager INST = new Free(); - @Override void begin(final long ptr) { } - @Override void end(final long ptr) { freeNativeObject(ptr); } - } - - public static class Nothing extends NativeObjectLifecycleManager { - public static final NativeObjectLifecycleManager INST = new Nothing(); - @Override void begin(final long ptr) { } - @Override void end(final long ptr) { } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java deleted file mode 100644 index d5b83b93930..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Pointer.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - - -public class Pointer implements Comparable>{ - long ptr; - - protected Pointer(final long ptr) { - this.ptr = ptr; - getNativeObjectLifecycleManager().begin(ptr); - } - - @Override protected final synchronized void finalize() throws Throwable { - long pptr = ptr; - ptr = 0; - if (pptr != 0) getNativeObjectLifecycleManager().end(pptr); - } - - protected NativeObjectLifecycleManager getNativeObjectLifecycleManager() { - return NativeObjectLifecycleManager.Nothing.INST; - } - - @Override public boolean equals(Object o) { - return o instanceof Pointer && ptr == ((Pointer) o).ptr; - } - - @Override public int hashCode() { return (int)(ptr^(ptr>>>32)); } - - public int compareTo(Pointer o) { - if(this==o || ptr==o.ptr) return 0; - if(ptr < o.ptr) return -1; - return 1; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java deleted file mode 100644 index eab34a7e6af..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/PrimitiveCoder.java +++ /dev/null @@ -1,700 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; -import com.apple.jobjc.JObjCRuntime.Width; -// Auto generated by PrimitiveCoder.hs -// Do not edit by hand. -public abstract class PrimitiveCoder extends Coder{ - public PrimitiveCoder(int ffiTypeCode, String objCEncoding, Class jclass, Class jprim){ - super(ffiTypeCode, objCEncoding, jclass, jprim); - } - public final boolean popBoolean(NativeArgumentBuffer args){ - return popBoolean(args.runtime, args.retValPtr); - } - public abstract boolean popBoolean(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, boolean x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, boolean x); - - - public final byte popByte(NativeArgumentBuffer args){ - return popByte(args.runtime, args.retValPtr); - } - public abstract byte popByte(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, byte x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, byte x); - - - public final char popChar(NativeArgumentBuffer args){ - return popChar(args.runtime, args.retValPtr); - } - public abstract char popChar(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, char x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, char x); - - - public final short popShort(NativeArgumentBuffer args){ - return popShort(args.runtime, args.retValPtr); - } - public abstract short popShort(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, short x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, short x); - - - public final int popInt(NativeArgumentBuffer args){ - return popInt(args.runtime, args.retValPtr); - } - public abstract int popInt(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, int x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, int x); - - - public final long popLong(NativeArgumentBuffer args){ - return popLong(args.runtime, args.retValPtr); - } - public abstract long popLong(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, long x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, long x); - - - public final float popFloat(NativeArgumentBuffer args){ - return popFloat(args.runtime, args.retValPtr); - } - public abstract float popFloat(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, float x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, float x); - - - public final double popDouble(NativeArgumentBuffer args){ - return popDouble(args.runtime, args.retValPtr); - } - public abstract double popDouble(JObjCRuntime runtime, long addr); - - public final void push(NativeArgumentBuffer args, double x){ - push(args.runtime, args.argValuesPtr, x); - args.didPutArgValue(sizeof()); - } - public abstract void push(JObjCRuntime runtime, long addr, double x); - - -// native BOOL -> java boolean -public static final class BoolCoder extends PrimitiveCoder{ - public static final BoolCoder INST = new BoolCoder(); - public BoolCoder(){ super(FFI_SINT8, "B", Boolean.class, boolean.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, boolean x){ - rt.unsafe.putByte(addr, (byte) (x ? 1 : 0)); - } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ - return rt.unsafe.getByte(addr) != 0; - } - // for runtime coding - @Override public int sizeof(Width w){ - return 1; - } - @Override public void push(JObjCRuntime rt, long addr, Boolean x){ push(rt, addr, (boolean) x); } - @Override public Boolean pop(JObjCRuntime rt, long addr){ return popBoolean(rt, addr); } - // proxies for mixed encoding - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, (x != 0)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, (x != 0)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, (x != 0)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, (x != 0)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, (x != 0)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, (x != 0)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)(popBoolean(rt, addr) ? 1 : 0)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, (x != 0)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)(popBoolean(rt, addr) ? 1 : 0)); } - - -} - -// native schar -> java byte -public static final class SCharCoder extends PrimitiveCoder{ - public static final SCharCoder INST = new SCharCoder(); - public SCharCoder(){ super(FFI_SINT8, "c", Byte.class, byte.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, byte x){ - rt.unsafe.putByte(addr, x); - } - @Override public byte popByte(JObjCRuntime rt, long addr){ - return rt.unsafe.getByte(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 1; - } - @Override public void push(JObjCRuntime rt, long addr, Byte x){ push(rt, addr, (byte) x); } - @Override public Byte pop(JObjCRuntime rt, long addr){ return popByte(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((byte)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popByte(rt, addr) != 0); } - - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((byte)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((byte)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((byte)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((byte)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((byte)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((byte)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popByte(rt, addr)); } - - -} - -// native uchar -> java byte -public static final class UCharCoder extends PrimitiveCoder{ - public static final UCharCoder INST = new UCharCoder(); - public UCharCoder(){ super(FFI_UINT8, "C", Byte.class, byte.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, byte x){ - rt.unsafe.putByte(addr, x); - } - @Override public byte popByte(JObjCRuntime rt, long addr){ - return rt.unsafe.getByte(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 1; - } - @Override public void push(JObjCRuntime rt, long addr, Byte x){ push(rt, addr, (byte) x); } - @Override public Byte pop(JObjCRuntime rt, long addr){ return popByte(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((byte)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popByte(rt, addr) != 0); } - - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((byte)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((byte)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((byte)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((byte)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((byte)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popByte(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((byte)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popByte(rt, addr)); } - - -} - -// native sshort -> java short -public static final class SShortCoder extends PrimitiveCoder{ - public static final SShortCoder INST = new SShortCoder(); - public SShortCoder(){ super(FFI_SINT16, "s", Short.class, short.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, short x){ - rt.unsafe.putShort(addr, (short) x); - } - @Override public short popShort(JObjCRuntime rt, long addr){ - return rt.unsafe.getShort(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 2; - } - @Override public void push(JObjCRuntime rt, long addr, Short x){ push(rt, addr, (short) x); } - @Override public Short pop(JObjCRuntime rt, long addr){ return popShort(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((short)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popShort(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((short)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((short)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popShort(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((short)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((short)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((short)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((short)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popShort(rt, addr)); } - - -} - -// native ushort -> java short -public static final class UShortCoder extends PrimitiveCoder{ - public static final UShortCoder INST = new UShortCoder(); - public UShortCoder(){ super(FFI_UINT16, "S", Short.class, short.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, short x){ - rt.unsafe.putShort(addr, (short) x); - } - @Override public short popShort(JObjCRuntime rt, long addr){ - return rt.unsafe.getShort(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 2; - } - @Override public void push(JObjCRuntime rt, long addr, Short x){ push(rt, addr, (short) x); } - @Override public Short pop(JObjCRuntime rt, long addr){ return popShort(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((short)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popShort(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((short)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((short)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popShort(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((short)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((short)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((short)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popShort(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((short)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popShort(rt, addr)); } - - -} - -// native sint -> java int -public static final class SIntCoder extends PrimitiveCoder{ - public static final SIntCoder INST = new SIntCoder(); - public SIntCoder(){ super(FFI_SINT32, "i", Integer.class, int.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, int x){ - rt.unsafe.putInt(addr, (int) x); - } - @Override public int popInt(JObjCRuntime rt, long addr){ - return rt.unsafe.getInt(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 4; - } - @Override public void push(JObjCRuntime rt, long addr, Integer x){ push(rt, addr, (int) x); } - @Override public Integer pop(JObjCRuntime rt, long addr){ return popInt(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((int)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popInt(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((int)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((int)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((int)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popInt(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((int)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((int)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((int)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popInt(rt, addr)); } - - -} - -// native uint -> java int -public static final class UIntCoder extends PrimitiveCoder{ - public static final UIntCoder INST = new UIntCoder(); - public UIntCoder(){ super(FFI_UINT32, "I", Integer.class, int.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, int x){ - rt.unsafe.putInt(addr, (int) x); - } - @Override public int popInt(JObjCRuntime rt, long addr){ - return rt.unsafe.getInt(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 4; - } - @Override public void push(JObjCRuntime rt, long addr, Integer x){ push(rt, addr, (int) x); } - @Override public Integer pop(JObjCRuntime rt, long addr){ return popInt(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((int)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popInt(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((int)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((int)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((int)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popInt(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((int)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((int)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popInt(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((int)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popInt(rt, addr)); } - - -} - -// native slong -> java long -public static final class SLongCoder extends PrimitiveCoder{ - public static final SLongCoder INST = new SLongCoder(); - public SLongCoder(){ super((JObjCRuntime.IS64 ? (FFI_SINT64) : (FFI_SINT32)), "l", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - if(JObjCRuntime.IS64){ rt.unsafe.putLong(addr, (long) x); }else{ rt.unsafe.putInt(addr, (int) x); } - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return (JObjCRuntime.IS64 ? (rt.unsafe.getLong(addr)) : (rt.unsafe.getInt(addr))); - } - // for runtime coding - @Override public int sizeof(Width w){ - switch(w){ - case W32: return 4; - case W64: return 8; - - default: return -1; - } - - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native ulong -> java long -public static final class ULongCoder extends PrimitiveCoder{ - public static final ULongCoder INST = new ULongCoder(); - public ULongCoder(){ super((JObjCRuntime.IS64 ? (FFI_UINT64) : (FFI_UINT32)), "L", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - if(JObjCRuntime.IS64){ rt.unsafe.putLong(addr, (long) x); }else{ rt.unsafe.putInt(addr, (int) x); } - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return (JObjCRuntime.IS64 ? (rt.unsafe.getLong(addr)) : (rt.unsafe.getInt(addr))); - } - // for runtime coding - @Override public int sizeof(Width w){ - switch(w){ - case W32: return 4; - case W64: return 8; - - default: return -1; - } - - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native slonglong -> java long -public static final class SLongLongCoder extends PrimitiveCoder{ - public static final SLongLongCoder INST = new SLongLongCoder(); - public SLongLongCoder(){ super(FFI_SINT64, "q", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - rt.unsafe.putLong(addr, (long) x); - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return rt.unsafe.getLong(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 8; - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native ulonglong -> java long -public static final class ULongLongCoder extends PrimitiveCoder{ - public static final ULongLongCoder INST = new ULongLongCoder(); - public ULongLongCoder(){ super(FFI_UINT64, "Q", Long.class, long.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, long x){ - rt.unsafe.putLong(addr, (long) x); - } - @Override public long popLong(JObjCRuntime rt, long addr){ - return rt.unsafe.getLong(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 8; - } - @Override public void push(JObjCRuntime rt, long addr, Long x){ push(rt, addr, (long) x); } - @Override public Long pop(JObjCRuntime rt, long addr){ return popLong(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((long)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popLong(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((long)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((long)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((long)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((long)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popLong(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((long)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popLong(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((long)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popLong(rt, addr)); } - - -} - -// native float -> java float -public static final class FloatCoder extends PrimitiveCoder{ - public static final FloatCoder INST = new FloatCoder(); - public FloatCoder(){ super(FFI_FLOAT, "f", Float.class, float.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, float x){ - rt.unsafe.putFloat(addr, (float) x); - } - @Override public float popFloat(JObjCRuntime rt, long addr){ - return rt.unsafe.getFloat(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 4; - } - @Override public void push(JObjCRuntime rt, long addr, Float x){ push(rt, addr, (float) x); } - @Override public Float pop(JObjCRuntime rt, long addr){ return popFloat(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((float)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popFloat(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((float)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((float)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((float)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((float)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popFloat(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((float)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popFloat(rt, addr)); } - - - @Override public void push(JObjCRuntime rt, long addr, double x){ push(rt, addr, ((float)x)); } - @Override public double popDouble(JObjCRuntime rt, long addr){ return ((double)popFloat(rt, addr)); } - - -} - -// native double -> java double -public static final class DoubleCoder extends PrimitiveCoder{ - public static final DoubleCoder INST = new DoubleCoder(); - public DoubleCoder(){ super(FFI_DOUBLE, "d", Double.class, double.class); } - // compile time - @Override public void push(JObjCRuntime rt, long addr, double x){ - rt.unsafe.putDouble(addr, (double) x); - } - @Override public double popDouble(JObjCRuntime rt, long addr){ - return rt.unsafe.getDouble(addr); - } - // for runtime coding - @Override public int sizeof(Width w){ - return 8; - } - @Override public void push(JObjCRuntime rt, long addr, Double x){ push(rt, addr, (double) x); } - @Override public Double pop(JObjCRuntime rt, long addr){ return popDouble(rt, addr); } - // proxies for mixed encoding - @Override public void push(JObjCRuntime rt, long addr, boolean x){ push(rt, addr, ((double)(x ? 1 : 0))); } - @Override public boolean popBoolean(JObjCRuntime rt, long addr){ return (popDouble(rt, addr) != 0); } - - @Override public void push(JObjCRuntime rt, long addr, byte x){ push(rt, addr, ((double)x)); } - @Override public byte popByte(JObjCRuntime rt, long addr){ return ((byte)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, char x){ push(rt, addr, ((double)x)); } - @Override public char popChar(JObjCRuntime rt, long addr){ return ((char)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, short x){ push(rt, addr, ((double)x)); } - @Override public short popShort(JObjCRuntime rt, long addr){ return ((short)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, int x){ push(rt, addr, ((double)x)); } - @Override public int popInt(JObjCRuntime rt, long addr){ return ((int)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, long x){ push(rt, addr, ((double)x)); } - @Override public long popLong(JObjCRuntime rt, long addr){ return ((long)popDouble(rt, addr)); } - - @Override public void push(JObjCRuntime rt, long addr, float x){ push(rt, addr, ((double)x)); } - @Override public float popFloat(JObjCRuntime rt, long addr){ return ((float)popDouble(rt, addr)); } - - - -} - -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java deleted file mode 100644 index 7e085f8d54d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/SEL.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - - -public class SEL { - static native long getSelectorPtr(String selectorName); - static native String getSelectorName(long ptr); - - final long selPtr; - - SEL(long ptr) { - this.selPtr = ptr; - } - - public SEL(final String name) { - this(getSelectorPtr(name)); - } - - @Override public String toString(){ - return ((int)selPtr) + " / " + selPtr + " : " + getSelectorName(selPtr); - } - - /** - * Converts something like "performSelectorOnMainThread_withObject_wait" - * to "performSelectorOnMainThread:withObject:wait:" - */ - public static String selectorName(String jMethodName, boolean hasArgs){ - String b = jMethodName.replaceAll("_", ":"); - return hasArgs ? b + ":" : b; - } - - public static String jMethodName(String selectorName){ - return selectorName.replaceAll(":", "_").replaceAll("_$", ""); - } - - public static boolean validName(String selectorName){ - return selectorName.matches("^[a-zA-Z_][a-zA-Z0-9_:]*$"); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java deleted file mode 100644 index b14e84dcaca..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Struct.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - - -/** - * A struct is malloced on the C heap and accessed in Java through a ByteBuffer. - */ -public abstract class Struct{ - protected final NativeBuffer raw; - private final JObjCRuntime runtime; - protected final JObjCRuntime getRuntime(){ return runtime; } - - /** - * Create a brand new struct from nothing. - */ - protected Struct(final JObjCRuntime runtime, final int SIZEOF){ - this(runtime, new NativeBuffer(SIZEOF), SIZEOF); - } - - /** - * Create a struct by taking ownership of an existing buffer. - * Used for struct fields of type struct. For example, the origin and size fields - * in NSRect would be initialized with this constructor. - */ - protected Struct(final JObjCRuntime runtime, final NativeBuffer buffer, final int SIZEOF){ - if(runtime == null) throw new NullPointerException("runtime"); - this.runtime = runtime; - this.raw = buffer; - this.raw.limit(SIZEOF); - } - - abstract public Coder getCoder(); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java b/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java deleted file mode 100644 index c0e72b13e33..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Subclassing.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ -package com.apple.jobjc; - -import java.io.StringWriter; -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Set; - -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.VoidCoder; -import com.apple.jobjc.Invoke.MsgSend; - - -final class Subclassing { - static native long allocateClassPair(long superClass, String name); - static native boolean addIVarForJObj(long clazz); - static native boolean patchAlloc(long classPtr); - static native boolean addMethod(long cls, String name, Method jMethod, CIF cif, long cifPtr, String objCEncodedType); - static native void registerClassPair(long clazz); - - static native T getJObjectFromIVar(long objPtr); - static native void initJObjectToIVar(long objPtr, ID object); - - final Set registeredUserSubclasses = new HashSet(); - final JObjCRuntime runtime; - - Subclassing(JObjCRuntime runtime){ - this.runtime = runtime; - } - - boolean registerUserClass(final Class clazz, final Class clazzClazz) { - final String nativeClassName = clazz.getSimpleName(); - // Is it already registered? - if(0 != NSClass.getNativeClassByName(nativeClassName)) - return false; - - if(clazz.isAnonymousClass()) - throw new RuntimeException("JObjC cannot register anonymous classes."); - - // Verify superclass - long superClass = NSClass.getNativeClassByName(clazz.getSuperclass().getSimpleName()); - if(0 == superClass) - throw new RuntimeException(clazz.getSuperclass() + ", the superclass of " + clazz + ", must be a registered class."); - - runtime.registerPackage(clazz.getPackage().getName()); - - // Create class - long classPtr = Subclassing.allocateClassPair(superClass, nativeClassName); - if(classPtr == 0) throw new RuntimeException("objc_allocateClassPair returned 0."); - - // Add ivar to hold jobject - boolean addedI = Subclassing.addIVarForJObj(classPtr); - if(!addedI) throw new RuntimeException("class_addIvar returned false."); - - // Verify constructor - try { - clazz.getConstructor(ID.CTOR_ARGS); - } catch (Exception e) { - throw new RuntimeException("Could not access required constructor: " + ID.CTOR_ARGS, e); - } - - // Patch alloc to create corresponding jobject on invoke - patchAlloc(classPtr); - - // Add methods - Set takenSelNames = new HashSet(); - for(Method method : clazz.getDeclaredMethods()){ - // No overloading - String selName = SEL.selectorName(method.getName(), method.getParameterTypes().length > 0); - if(takenSelNames.contains(selName)) - throw new RuntimeException("Obj-C does not allow method overloading. The Objective-C selector '" - + selName + "' appears more than once in class " + clazz.getCanonicalName() + " / " + nativeClassName + "."); - - method.setAccessible(true); - - // Divine CIF - Coder returnCoder = Coder.getCoderAtRuntimeForType(method.getReturnType()); - Class[] paramTypes = method.getParameterTypes(); - Coder[] argCoders = new Coder[paramTypes.length]; - for(int i = 0; i < paramTypes.length; i++) - argCoders[i] = Coder.getCoderAtRuntimeForType(paramTypes[i]); - - CIF cif = new MsgSend(runtime, selName, returnCoder, argCoders).funCall.cif; - - // .. and objc encoding - StringWriter encType = new StringWriter(); - encType.append(returnCoder.getObjCEncoding()); - encType.append("@:"); - for(int i = 0; i < argCoders.length; i++) - encType.append(argCoders[i].getObjCEncoding()); - - // Add it! - boolean addedM = Subclassing.addMethod(classPtr, selName, method, cif, cif.cif.bufferPtr, encType.toString()); - if(!addedM) throw new RuntimeException("Failed to add method."); - takenSelNames.add(selName); - } - - // Seal it - Subclassing.registerClassPair(classPtr); - registeredUserSubclasses.add(classPtr); - - return true; - } - - boolean isUserClass(long clsPtr) { - return registeredUserSubclasses.contains(clsPtr); - } - - // Called from JNI - - private static void initJObject(final long objPtr){ -// System.err.println("initJObject " + objPtr + " / " + Long.toHexString(objPtr)); - ID newObj = ID.createNewObjCObjectFor(JObjCRuntime.inst(), objPtr, NSClass.getClass(objPtr)); -// System.err.println("... " + newObj); - initJObjectToIVar(objPtr, newObj); - } - - private static void invokeFromJNI(ID obj, Method method, CIF cif, long result, long args){ - assert obj != null; - assert obj.getClass().equals(method.getDeclaringClass()) : - obj.getClass().toString() + " != " + method.getDeclaringClass().toString(); - - final int argCount = method.getParameterTypes().length; - - // The first two args & coders are for objc id and sel. Skip them. - final Object[] argObjects = new Object[argCount]; - for(int i = 0; i < argCount; i++){ - final long argAddrAddr = args + ((i+2) * JObjCRuntime.PTR_LEN); - final long argAddr = PrimitivePointerCoder.INST.popPtr(obj.runtime, argAddrAddr); - argObjects[i] = cif.argCoders[i + 2].pop(obj.runtime, argAddr); - } - - Object retVal; - try { - retVal = method.invoke(obj, argObjects); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - - if(!(cif.returnCoder instanceof VoidCoder)) - cif.returnCoder.push(obj.runtime, result, retVal); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/CIF.m b/jdk/src/macosx/native/jobjc/src/core/native/CIF.m deleted file mode 100644 index 7aa4dd542a5..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/CIF.m +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_CIF.h" - -#define MACOSX -#include -#include - -#include "NativeBuffer.h" - -JNIEXPORT jint JNICALL Java_com_apple_jobjc_CIF_getSizeofCIF -(JNIEnv *env, jclass clazz) -{ - return (jint) sizeof(ffi_cif); -} - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_CIF_prepCIF -(JNIEnv *env, jclass clazz, jlong jCIFPtr, jint jNargs, jlong jRetTypePtr, jlong jArgsPtr) -{ - ffi_cif *cif = jlong_to_ptr(jCIFPtr); - unsigned int nargs = jNargs; - ffi_type *rtype = jlong_to_ptr(jRetTypePtr); - ffi_type **atypes = jlong_to_ptr(jArgsPtr); - -// NSLog(@"rtype->(size: %d, alignment: %d, type: %d)", rtype->size, rtype->alignment, rtype->type); - return (jboolean) (FFI_OK == ffi_prep_cif(cif, FFI_DEFAULT_ABI, nargs, rtype, atypes)); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/Coder.m b/jdk/src/macosx/native/jobjc/src/core/native/Coder.m deleted file mode 100644 index af3553949bf..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/Coder.m +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_Coder.h" - -#include -#define MACOSX -#include -#include - -/* - * Class: com_apple_jobjc_Coder - * Method: getNativeFFITypeCodeForCode - * Signature: (I)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Coder_getNativeFFITypePtrForCode -(JNIEnv *env, jclass clazz, jint code) -{ - switch ((long)code) { - case com_apple_jobjc_Coder_FFI_VOID: return ptr_to_jlong(&ffi_type_void); - case com_apple_jobjc_Coder_FFI_PTR: return ptr_to_jlong(&ffi_type_pointer); - case com_apple_jobjc_Coder_FFI_SINT8: return ptr_to_jlong(&ffi_type_sint8); - case com_apple_jobjc_Coder_FFI_UINT8: return ptr_to_jlong(&ffi_type_uint8); - case com_apple_jobjc_Coder_FFI_SINT16: return ptr_to_jlong(&ffi_type_sint16); - case com_apple_jobjc_Coder_FFI_UINT16: return ptr_to_jlong(&ffi_type_uint16); - case com_apple_jobjc_Coder_FFI_SINT32: return ptr_to_jlong(&ffi_type_sint32); - case com_apple_jobjc_Coder_FFI_UINT32: return ptr_to_jlong(&ffi_type_uint32); - case com_apple_jobjc_Coder_FFI_SINT64: return ptr_to_jlong(&ffi_type_sint64); - case com_apple_jobjc_Coder_FFI_UINT64: return ptr_to_jlong(&ffi_type_uint64); - case com_apple_jobjc_Coder_FFI_FLOAT: return ptr_to_jlong(&ffi_type_float); - case com_apple_jobjc_Coder_FFI_DOUBLE: return ptr_to_jlong(&ffi_type_double); - case com_apple_jobjc_Coder_FFI_LONGDOUBLE: return ptr_to_jlong(&ffi_type_longdouble); - } - - return ptr_to_jlong(NULL); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/FFIType.m b/jdk/src/macosx/native/jobjc/src/core/native/FFIType.m deleted file mode 100644 index 731397e1a01..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/FFIType.m +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ -#include -#include - -#include "com_apple_jobjc_FFIType.h" - -JNIEXPORT void JNICALL Java_com_apple_jobjc_FFIType_makeFFIType -(JNIEnv *env, jclass clazz, jlong ffi_type_jlong, jlong ffi_type_elements_jlong) -{ - ffi_type *type = jlong_to_ptr(ffi_type_jlong); - type->elements = jlong_to_ptr(ffi_type_elements_jlong); - type->type = FFI_TYPE_STRUCT; - type->size = type->alignment = 0; -} - -JNIEXPORT jint JNICALL Java_com_apple_jobjc_FFIType_getFFITypeSizeof -(JNIEnv *env, jclass clazz) -{ - return (jint) sizeof(ffi_type); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/Function.m b/jdk/src/macosx/native/jobjc/src/core/native/Function.m deleted file mode 100644 index 9060a0fd158..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/Function.m +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_Function.h" - -#define MACOSX -#include -#include - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Function_getFxnPtrForFunctionName -(JNIEnv *env, jclass clazz, jstring fxnName) -{ - const char *functionName = (*env)->GetStringUTFChars(env, fxnName, NULL); - void *fxnPtr = dlsym(RTLD_SELF, functionName); - (*env)->ReleaseStringUTFChars(env, fxnName, functionName); - return ptr_to_jlong(fxnPtr); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Function_getFxnPtrForFunctionNameAndLib -(JNIEnv *env, jclass clazz, jlong frameworkPtr, jstring fxnName) -{ - void *frameworkHandle = jlong_to_ptr(frameworkPtr); - - const char *functionName = (*env)->GetStringUTFChars(env, fxnName, NULL); - void *fxnPtr = dlsym(frameworkHandle, functionName); - (*env)->ReleaseStringUTFChars(env, fxnName, functionName); - - return ptr_to_jlong(fxnPtr); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m b/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m deleted file mode 100644 index 28a11d92d80..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/Invoke.m +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#include "com_apple_jobjc_Invoke_FunCall.h" -#include -#include -#include - -JNIEXPORT void JNICALL Java_com_apple_jobjc_Invoke_00024FunCall_invoke -(JNIEnv *env, jclass clazz, jlong cifPtr, jlong fxnPtr, jlong retValPtr, jlong argsPtr) -{ - ffi_cif *cif = jlong_to_ptr(cifPtr); - void *fxn = jlong_to_ptr(fxnPtr); - void *retVal = jlong_to_ptr(retValPtr); - void **args = jlong_to_ptr(argsPtr); - - ffi_call(cif, fxn, retVal, args); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/MacOSXFramework.m b/jdk/src/macosx/native/jobjc/src/core/native/MacOSXFramework.m deleted file mode 100644 index 4609d79fdcd..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/MacOSXFramework.m +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_MacOSXFramework.h" - -#include -#include - -/* - * Class: com_apple_jobjc_MacOSXFramework - * Method: retainFramework - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_MacOSXFramework_retainFramework -(JNIEnv *env, jclass clazz, jstring frameworkName) -{ - if (frameworkName == NULL) return ptr_to_jlong(NULL); - const char *frameworkNameCStr = (*env)->GetStringUTFChars(env, frameworkName, JNI_FALSE); - const void *library = dlopen(frameworkNameCStr, RTLD_LOCAL); - (*env)->ReleaseStringUTFChars(env, frameworkName, frameworkNameCStr); - return ptr_to_jlong(library); -} - -/* - * Class: com_apple_jobjc_MacOSXFramework - * Method: releaseFramework - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_MacOSXFramework_releaseFramework -(JNIEnv *env, jclass clazz, jlong frameworkPtr) -{ - dlclose(jlong_to_ptr(frameworkPtr)); -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_MacOSXFramework_getConstant -(JNIEnv *env, jclass clazz, jlong frameworkPtr, jstring constSymbol, jlong retBuffer, jint size) -{ - const char *symbol = (*env)->GetStringUTFChars(env, constSymbol, JNI_FALSE); - void *handle = frameworkPtr ? jlong_to_ptr(frameworkPtr) : RTLD_DEFAULT; - void *data = dlsym(handle, symbol); - (*env)->ReleaseStringUTFChars(env, constSymbol, symbol); - - if(!data) - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), dlerror()); - else - memcpy(jlong_to_ptr(retBuffer), data, (size_t) size); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/NSClass.m b/jdk/src/macosx/native/jobjc/src/core/native/NSClass.m deleted file mode 100644 index 8ae15e3a368..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/NSClass.m +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_NSClass.h" -#include - -#include - -/* - * Class: com_apple_jobjc_NSClass - * Method: getNativeClassByName - * Signature: (JLjava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NSClass_getNativeClassByName -(JNIEnv *env, jclass clazz, jstring className) -{ - if (className == NULL) return ptr_to_jlong(NULL); - const char *classNameCStr = (*env)->GetStringUTFChars(env, className, JNI_FALSE); - const id obj = objc_getClass(classNameCStr); - (*env)->ReleaseStringUTFChars(env, className, classNameCStr); - - if (obj == nil) return ptr_to_jlong(NULL); - return ptr_to_jlong(obj); -} - -/* - * Class: com_apple_jobjc_NSClass - * Method: getSuperClass - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NSClass_getSuperClassOfClass -(JNIEnv *env, jclass clazz, jlong clazzPtr) -{ - if (clazzPtr == 0L) return ptr_to_jlong(NULL); - const Class objClazz = (Class)jlong_to_ptr(clazzPtr); - return ptr_to_jlong(class_getSuperclass(objClazz)); -} - -/* - * Class: com_apple_jobjc_NSClass - * Method: getClassName - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_NSClass_getClassNameOfClass -(JNIEnv *env, jclass clazz, jlong clazzPtr) -{ - const char *clazzName = (char *)class_getName((Class)jlong_to_ptr(clazzPtr)); - return (*env)->NewStringUTF(env, clazzName); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NSClass_getClass -(JNIEnv *env, jclass clazz, jlong objPtr) -{ - id obj = (id)jlong_to_ptr(objPtr); - return ptr_to_jlong(object_getClass(obj)); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.h b/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.h deleted file mode 100644 index 0fafa6ef3a8..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -/* - * NativeBuffer.h - * Copyright 2007 Apple Inc. All rights reserved. - * - */ - -#define BUFFER_AT(buffer, offset) (((UInt8 *)buffer) + offset) -#define GET_VALUE(type, buffer, offset) (*((type *)BUFFER_AT(buffer, offset))) -#define PUT_VALUE(type, buffer, offset, value) (*((type *)BUFFER_AT(buffer, offset)) = value) - -#define GET_INT_AT(buffer, offset) GET_VALUE(jint, buffer, offset) -#define GET_LONG_AT(buffer, offset) GET_VALUE(jlong, buffer, offset) - -#define PUT_INT_AT(buffer, offset, value) PUT_VALUE(jint, buffer, offset, value) -#define PUT_LONG_AT(buffer, offset, value) PUT_VALUE(jlong, buffer, offset, value) diff --git a/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.m b/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.m deleted file mode 100644 index 8f7b9b0fe01..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/NativeBuffer.m +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_NativeBuffer.h" - -#define MACOSX -#include -#include - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_NativeBuffer_getPtrOfBuffer -(JNIEnv *env, jclass clazz, jobject buffer) -{ - if (buffer == NULL) return ptr_to_jlong(0); - return ptr_to_jlong((*env)->GetDirectBufferAddress(env, buffer)); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/NativeObjectLifecycleManager.m b/jdk/src/macosx/native/jobjc/src/core/native/NativeObjectLifecycleManager.m deleted file mode 100644 index 012f83a1d6a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/NativeObjectLifecycleManager.m +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_NativeObjectLifecycleManager.h" - -#include - - -/* - * Class: com_apple_jobjc_NativeObjectLifecycleManager - * Method: retainNativeObject - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_NativeObjectLifecycleManager_retainNativeObject -(JNIEnv *env, jclass clazz, jlong ptr) -{ - if (ptr == 0L) return; - CFRetain(jlong_to_ptr(ptr)); -} - -/* - * Class: com_apple_jobjc_NativeObjectLifecycleManager - * Method: releaseNativeObject - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_NativeObjectLifecycleManager_releaseNativeObject -(JNIEnv *env, jclass clazz, jlong ptr) -{ - if (ptr == 0L) return; - CFRelease(jlong_to_ptr(ptr)); -} - -/* - * Class: com_apple_jobjc_NativeObjectLifecycleManager - * Method: freeNativeObject - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_NativeObjectLifecycleManager_freeNativeObject -(JNIEnv *env, jclass clazz, jlong ptr) -{ - if (ptr == 0L) return; - free(jlong_to_ptr(ptr)); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/SEL.m b/jdk/src/macosx/native/jobjc/src/core/native/SEL.m deleted file mode 100644 index dc39ed10132..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/SEL.m +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#include "com_apple_jobjc_SEL.h" - -#include -#include - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_SEL_getSelectorPtr -(JNIEnv *env, jclass jclazz, jstring selName) -{ - const char *selNameAsChars = (*env)->GetStringUTFChars(env, selName, JNI_FALSE); - const SEL sel = sel_registerName(selNameAsChars); - (*env)->ReleaseStringUTFChars(env, selName, selNameAsChars); - return ptr_to_jlong((void*)sel); -} - -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_SEL_getSelectorName -(JNIEnv *env, jclass jclazz, jlong selPtr) -{ - return (*env)->NewStringUTF(env, sel_getName(jlong_to_ptr(selPtr))); -} diff --git a/jdk/src/macosx/native/jobjc/src/core/native/Subclassing.m b/jdk/src/macosx/native/jobjc/src/core/native/Subclassing.m deleted file mode 100644 index 0e9d4651db8..00000000000 --- a/jdk/src/macosx/native/jobjc/src/core/native/Subclassing.m +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_Subclassing.h" - -#include -#include -#include - -#include -#include - -#include -#include - -#include - -// Subclassing of Obj-C classes in Java -// -// See: -// - Objective-C Runtime documentation -// - man ffi_prep_closure -// - Subclassing.java - - -#pragma mark Accessing object in IVar - -#define JOBJ_IVAR_NAME "jObjWrapper" -static jobject getJObjectFromIVar(id obj); - -jobject getJObjectFromIVar(id obj) -{ - JNFJObjectWrapper *wrapper = NULL; - object_getInstanceVariable(obj, JOBJ_IVAR_NAME, (void**) &wrapper); - return wrapper ? [wrapper jObject] : NULL; -} - -JNIEXPORT jobject JNICALL Java_com_apple_jobjc_Subclassing_getJObjectFromIVar -(JNIEnv *env, jclass jClass, jlong jPtr) -{ - id obj = (id) jlong_to_ptr(jPtr); - if(obj == NULL){ - (*env)->ThrowNew(env, (*env)->FindClass(env, - "java/lang/NullPointerException"), "obj"); - return NULL; - } - - JNFJObjectWrapper *wrapper; - - if(!object_getInstanceVariable(obj, JOBJ_IVAR_NAME, (void**) &wrapper)){ - NSLog(@"IVar '%s' not found. obj: %@", JOBJ_IVAR_NAME, obj); - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), - "Could not find instance variable that holds Java object."); - return NULL; - } - - return wrapper ? [wrapper jObject] : NULL; -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_Subclassing_initJObjectToIVar -(JNIEnv *env, jclass jClass, jlong jPtr, jobject jObject) -{ - id obj = (id) jlong_to_ptr(jPtr); - JNFJObjectWrapper *wrapper = [[JNFJObjectWrapper alloc] - initWithJObject:jObject withEnv:env]; - [wrapper retain]; - - if(!object_setInstanceVariable(obj, JOBJ_IVAR_NAME, wrapper)){ - NSLog(@"IVar '%s' not found. obj: %@", JOBJ_IVAR_NAME, obj); - (*env)->ThrowNew(env, (*env)->FindClass(env, "java/lang/RuntimeException"), - "Could not find instance variable that holds Java object."); - return; - } -} - -#pragma mark Registering class - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Subclassing_allocateClassPair -(JNIEnv *env, jclass clazz, jlong jSuperClass, jstring jName) -{ - const Class superClass = (Class)jlong_to_ptr(jSuperClass); - assert(superClass); - - const char *name = (*env)->GetStringUTFChars(env, jName, JNI_FALSE); - const Class newClass = objc_allocateClassPair(superClass, name, 0); - (*env)->ReleaseStringUTFChars(env, jName, name); - - return ptr_to_jlong(newClass); -} - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_Subclassing_addIVarForJObj -(JNIEnv *env, jclass clazz, jlong jSynthClass) -{ - return class_addIvar( - jlong_to_ptr(jSynthClass), - JOBJ_IVAR_NAME, - sizeof(id), - (uint8_t)log2((double)sizeof(id)), - "@"); -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_Subclassing_registerClassPair -(JNIEnv *env, jclass clazz, jlong jClass) -{ - Class c = jlong_to_ptr(jClass); -// NSLog(@"Registering class pair %p / %s", c, class_getName(c)); - objc_registerClassPair(c); -} - - -#pragma mark Patching +alloc - -static id patchedAllocIMP(id obj, SEL sel); -static void addJavaInstance(id obj); - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_Subclassing_patchAlloc -(JNIEnv *env, jclass clazz, jlong jNativeClass) -{ - Class metaClass = object_getClass(jlong_to_ptr(jNativeClass)); - return class_addMethod(metaClass, - sel_registerName("alloc"), - (IMP) patchedAllocIMP, - "@@:"); -} - -static id patchedAllocIMP(id cls, SEL sel){ - id inst = class_createInstance(cls, 0); - addJavaInstance(inst); - return inst; -} - -static void addJavaInstance(id obj){ -// NSLog(@"addJavaInstance %p", obj); -// NSLog(@"... calling up to Java"); - - static JNF_CLASS_CACHE(jc_Subclassing, "com/apple/jobjc/Subclassing"); - static JNF_STATIC_MEMBER_CACHE(jm_Subclassing_initJObject, - jc_Subclassing, - "initJObject", - "(J)V"); - - JNFThreadContext threadWasAttached = JNFThreadDetachOnThreadDeath; - JNIEnv *env = JNFObtainEnv(&threadWasAttached); - JNFCallStaticVoidMethod(env, jm_Subclassing_initJObject, - ptr_to_jlong(obj)); - - JNFReleaseEnv(env, &threadWasAttached); -} - - -#pragma mark Adding methods - -static ffi_closure *make_closure(ffi_cif *cif, void *user_data); -static void sel_closure_call(ffi_cif* cif, void* result, void** args, void* user_data); - -typedef struct closure_data_t{ - JNFJObjectWrapper *jMethod; - JNFJObjectWrapper *jCIF; -} closure_data_t; - -static ffi_closure *make_closure(ffi_cif *cif, void *user_data){ - // Allocate a page to hold the closure with read and write permissions. - ffi_closure *closure; - if ((closure = mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE, - MAP_ANON | MAP_PRIVATE, -1, (off_t) 0)) == (void*)-1) - { - fprintf(stderr, "mmap failed with errno: %d", errno); - return NULL; - } - - // Prepare the ffi_closure structure. - ffi_status status; - if ((status = ffi_prep_closure(closure, cif, sel_closure_call, (void *)user_data)) != FFI_OK) - { - fprintf(stderr, "ffi_prep_closure failed with ffi_status: %d", status); - munmap(closure, sizeof(ffi_closure)); - return NULL; - } - - // Ensure that the closure will execute on all architectures. - if (mprotect(closure, sizeof(closure), PROT_READ | PROT_EXEC) == -1) - { - fprintf(stderr, "mprotect failed with errno: %d", errno); - munmap(closure, sizeof(ffi_closure)); - return NULL; - } - return closure; -} - -JNIEXPORT jboolean JNICALL Java_com_apple_jobjc_Subclassing_addMethod -(JNIEnv *env, jclass clazz, jlong jClass, jstring jSelName, jobject jMethod, - jobject jCIF, jlong jCIFPtr, jstring jObjCEncodedType) -{ - ffi_cif *cif = jlong_to_ptr(jCIFPtr); - - closure_data_t *user_data = malloc(sizeof(closure_data_t)); - user_data->jMethod = [[JNFJObjectWrapper alloc] initWithJObject:jMethod withEnv:env]; - user_data->jCIF = [[JNFJObjectWrapper alloc] initWithJObject:jCIF withEnv:env]; - - ffi_closure *closure;; - if(!(closure = make_closure(cif, user_data))){ - [user_data->jMethod release]; - [user_data->jCIF release]; - free(user_data); - return NO; - } - - const Class objcClass = (Class)jlong_to_ptr(jClass); - - const char *selName = (*env)->GetStringUTFChars(env, jSelName, JNI_FALSE); - const char *objCEncodedType = (*env)->GetStringUTFChars(env, jObjCEncodedType, JNI_FALSE); - -// NSLog(@"Adding method '%s' :: '%s' to '%s' / %p", -// selName, -// objCEncodedType, -// class_getName(objcClass), -// objcClass); - - BOOL ret = class_addMethod(objcClass, sel_registerName(selName), (IMP) closure, objCEncodedType); - - (*env)->ReleaseStringUTFChars(env, jSelName, selName); - (*env)->ReleaseStringUTFChars(env, jObjCEncodedType, objCEncodedType); - - if(!ret){ - NSLog(@"class_addMethod failed"); - munmap(closure, sizeof(ffi_closure)); - [user_data->jMethod release]; - [user_data->jCIF release]; - free(user_data); - return NO; - } - - return ret; -} - -static void sel_closure_call(ffi_cif* cif, void* result, void** args, void* user_data) -{ - id obj = *(id*) args[0]; -// SEL sel = *(SEL*) args[1]; - -// NSLog(@"Subclassing: sel_closure_call: %p %p", obj, sel); -// NSLog(@"Subclassing: sel_closure_call: obj class: %@ sel name: %s", object_getClass(obj), sel_getName(sel)); - - jobject jObj = getJObjectFromIVar(obj); - - if(!jObj){ - addJavaInstance(obj); - jObj = getJObjectFromIVar(obj); - } - - closure_data_t *jmeta = user_data; - jobject jMethod = [jmeta->jMethod jObject]; - jobject jCIF = [jmeta->jCIF jObject]; - - JNFThreadContext threadWasAttached = JNFThreadDetachOnThreadDeath; - JNIEnv *env = JNFObtainEnv(&threadWasAttached); - - if((*env)->ExceptionOccurred(env)) goto bail; - - static JNF_CLASS_CACHE(jc, "com/apple/jobjc/Subclassing"); - static JNF_STATIC_MEMBER_CACHE(jm_invokeFromJNI, jc, "invokeFromJNI", - "(Lcom/apple/jobjc/ID;Ljava/lang/reflect/Method;Lcom/apple/jobjc/CIF;JJ)V"); - - JNFCallStaticVoidMethod(env, jm_invokeFromJNI, - jObj, - jMethod, - jCIF, - ptr_to_jlong(result), - ptr_to_jlong(args)); - -bail: - JNFReleaseEnv(env, &threadWasAttached); - - if((*env)->ExceptionOccurred(env)){ - NSLog(@"Exception!"); - (*env)->ExceptionDescribe(env); - } - JNFReleaseEnv(env, &threadWasAttached); -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/BootClassPathMinus.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/BootClassPathMinus.java deleted file mode 100644 index efbad58a104..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/BootClassPathMinus.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator; - -public class BootClassPathMinus { - - /* - * return the default boot class path with all parts mentioned in arguments removed - */ - public static void main(String[] args) { - String bootClassPath = System.getProperty("sun.boot.class.path"); - StringBuffer newPath = new StringBuffer(bootClassPath.length()); - String[] bootClassPathParts = bootClassPath.split(java.io.File.pathSeparator, 0); - for (String part : bootClassPathParts) { - boolean found = false; - for (String minus : args) { - if (part.endsWith(minus)) { - found = true; - } - } - if (!found) { - if (newPath.length() > 0) newPath.append(java.io.File.pathSeparatorChar); - newPath.append(part); - } - } - System.out.println(newPath.toString()); - } - -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassConsolidator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassConsolidator.java deleted file mode 100644 index 69a872f8dbc..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassConsolidator.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Framework; - -public class ClassConsolidator { - private static String[] PREFERRED_FRAMEWORKS = { "Foundation", "AppKit" }; - - static void consolidateClassesForFrameworks(final List frameworks) throws Throwable { - System.out.println("--2-- Resolving duplicate classes:"); - final Map> allClasses = new HashMap>(); - - for (final Framework framework : frameworks) { - for (final Clazz clazz : framework.classes) { - final List existingClazzList = allClasses.get(clazz.name); - if(existingClazzList != null) - existingClazzList.add(clazz); - else - allClasses.put(clazz.name, new ArrayList(Arrays.asList(clazz))); - } - } - - final Map filteredClasses = new HashMap(); - final List> dreggs = new ArrayList>(); - - final Collection> clazzLists = allClasses.values(); - for (final List clazzList : clazzLists) { - if (clazzList.size() > 1) { - // add to the list for later analysis - dreggs.add(clazzList); - continue; - } - - // if there is only one class definition, go with it! - final Clazz clazz = clazzList.get(0); - filteredClasses.put(clazz.name, clazz); - } - - // figure out which class is the real class, and convert the rest to categories - for (final List dreg : dreggs) - deriveCategoriesFrom(dreg, filteredClasses); - - // patch up the inheritance hierarchy - System.out.println("Determining super classes:"); - for (final Framework framework : frameworks) - framework.resolveSuperClasses(filteredClasses); - } - - private static void deriveCategoriesFrom(final List clazzes, final Map filteredClasses) { - final List clazzesToDerive = new ArrayList(clazzes); - - for (final String preferredFrameworkName : PREFERRED_FRAMEWORKS) { - for (final Clazz clazz : clazzesToDerive) { - if (!preferredFrameworkName.equals(clazz.parent.name)) continue; - - System.out.print("\t" + clazz.parent.name + " owns \"" + clazz.name + "\", "); - addCategoriesAndPatchClasses(clazzes, clazz); - filteredClasses.put(clazz.name, clazz); - return; - } - } - - final List frameworkNameList = new ArrayList(clazzes.size()); - for (final Clazz clazz : clazzes) frameworkNameList.add(clazz.parent.name); - throw new RuntimeException("Could not derived a preferred framework for: " + clazzes.get(0).name + ", from (" + Utils.joinWComma(frameworkNameList) + ")"); - } - - private static void addCategoriesAndPatchClasses(final List clazzes, final Clazz clazz) { - final List fwNames = new ArrayList(clazzes.size()); - - for (final Clazz cls : clazzes) { - if (cls == clazz) continue; - fwNames.add(cls.parent.name); - cls.parent.classes.remove(cls); - cls.parent.categories.add(new Category(cls, clazz)); - } - - System.out.println("creating categories in: " + Utils.joinWComma(fwNames)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassGenerator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassGenerator.java deleted file mode 100644 index 8953fa306c0..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/ClassGenerator.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator; - -import java.util.*; - -import com.apple.internal.jobjc.generator.classes.*; -import com.apple.internal.jobjc.generator.model.Framework; - -public class ClassGenerator { - public static final String JOBJC_PACKAGE = "com.apple.jobjc"; - - public static List generateClasses(final List frameworks) { - final List generatedClassFiles = new ArrayList(); - - generatedClassFiles.add(new RootJObjCClass(frameworks)); - for (final Framework f : frameworks) { - f.generateClasses(generatedClassFiles); - } - - return generatedClassFiles; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FileCopier.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FileCopier.java deleted file mode 100644 index bcaf5bcb8c7..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FileCopier.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator; - -import java.io.File; -import java.util.*; - -import com.apple.internal.jobjc.generator.classes.*; - -public class FileCopier { - public static List addSourceFilesFrom(final String srcPath) { - final List outputFileList = new ArrayList(); - - final List fileList = getFileList(srcPath); - for (final File file : fileList) { - outputFileList.add(new CopiedFile(file, ClassGenerator.JOBJC_PACKAGE, file.getName().replace("\\.java", ""))); - } - - return outputFileList; - } - - private static List getFileList(final String srcPath) { - final File srcRoot = new File(srcPath); - if (!srcRoot.exists()) throw new RuntimeException("Source root " + srcRoot + " does not exist. Nowhere to copy base runtime objects from."); - - final File targetDir = new File(srcRoot, ClassGenerator.JOBJC_PACKAGE.replaceAll("\\.", "\\/")); - if (!targetDir.exists() || !targetDir.isDirectory()) throw new RuntimeException("Base runtime object source directory " + targetDir + " does not exist. No runtime class files to copy."); - - final List fileList = new ArrayList(); - final File[] targetDirFileList = targetDir.listFiles(); - for (final File file : targetDirFileList) { - if (!file.isFile()) continue; - if (!file.getName().endsWith(".java")) continue; - fileList.add(file); - } - - return fileList; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FrameworkGenerator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FrameworkGenerator.java deleted file mode 100644 index 1f11ed9038b..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FrameworkGenerator.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Framework.FrameworkDependency; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.StructOffsetResolverBigBang; -import com.apple.jobjc.JObjCRuntime; - -public class FrameworkGenerator { - private static final String BRIDGESUPPORT_FILE_EXTENSION = "Full.bridgesupport"; - private static final String FRAMEWORK_MATCH = "^.*Full\\.bridgesupport$"; - private static final String FRAMEWORK_PRUNE = "^.*(PyObjC|/Versions|\\.lproj|/Headers|/PrivateHeaders).*$"; - - static List findFrameworkFilesIn(final File file) throws IOException{ - final List bridgeSupportFiles = Utils.find(file, FRAMEWORK_MATCH, FRAMEWORK_PRUNE); - System.out.println("found " + bridgeSupportFiles.size() + " frameworks"); - return bridgeSupportFiles; - } - - static List parseFrameworksFrom(final List bridgeSupportFiles) { - final List frameworks = new ArrayList(); - - System.out.println("Parsing XML"); - for (final File file : bridgeSupportFiles){ - Framework f = new Framework(extractFrameworkNameFrom(file), file); - try{ - f.load(); - frameworks.add(f); - System.out.println("Generator@" + JObjCRuntime.ARCH + " loaded " - + f.name + " (" + Fp.join(":", f.binaries) + ")"); - } - catch(Exception x){ - System.out.println("!! Generator@" + JObjCRuntime.ARCH + " failed to load " - + f.name + " (" + Fp.join(":", f.binaries) + "). SKIPPING"); - } - } - - System.out.println("Parsing dependencies"); - for (final Framework f : frameworks) f.parseDependencies(frameworks); - - Set alreadyWarnedDependency = new HashSet(); - for(final Framework f : frameworks) - for(final FrameworkDependency dep : f.dependencies) - if(dep.object == null && !alreadyWarnedDependency.contains(dep.name)){ - System.out.println(String.format("Warning: unresolved dependency: %1$30s -> %2$s", f.name, dep.name)); - alreadyWarnedDependency.add(dep.name); - } - if(alreadyWarnedDependency.size() > 0) - System.out.println("Unresolved dependencies lead to unresolved types."); - - Utils.topologicalSort(frameworks); - List cycle = Utils.getDependencyCycle(frameworks); - if(cycle != null) - System.out.println("Warning: cycle found in framework dependencies: " + Fp.join(" -> ", cycle)); - - System.out.println("Parsing types"); - for (final Framework f : frameworks){ - f.parseCFTypes(); - f.parseOpaques(); - } - for (final Framework f : frameworks) f.parseStructs(); - - new StructOffsetResolverBigBang().resolve(frameworks); - - System.out.println("Parsing classes"); - for (final Framework f : frameworks) f.parseClasses(); - - System.out.println("Parsing constants"); - for (final Framework f : frameworks) f.parseConstants(); - - System.out.println("Parsing functions"); - for (final Framework f : frameworks) f.parseFunctions(); - - return frameworks; - } - - private static String extractFrameworkNameFrom(final File file) { - final String fileName = file.getName(); - return fileName.substring(0, fileName.lastIndexOf(BRIDGESUPPORT_FILE_EXTENSION)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FunctionGenerator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FunctionGenerator.java deleted file mode 100644 index 37f67aa39bd..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/FunctionGenerator.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator; - -import java.io.PrintStream; -import java.io.StringWriter; - -import com.apple.internal.jobjc.generator.model.Arg; -import com.apple.internal.jobjc.generator.model.Function; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.internal.jobjc.generator.model.types.JType; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLCall; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLField; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLTertiary; -import com.apple.jobjc.Coder; -import com.apple.jobjc.Invoke; -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.Invoke.MsgSend; - -public class FunctionGenerator { - private final static String VARARGS_NAME = "varargs"; - - private static String createFieldCache(final Class type, final Function fxn) { - final String identifier = makeInstanceName(fxn); - - JLField field = new JLField("private static", type.getCanonicalName(), identifier); - // It's okay to make it static, because the getter isn't static, so the only way to access it is through an instance. - JLMethod getter = new JLMethod("private final", type.getCanonicalName(), "get_" + identifier); - - JLCall createIt = new JLCall("new " + type.getCanonicalName()); - createIt.args.add(firstArg(fxn)); - createIt.args.add("\"" + fxn.name + "\""); - createIt.args.add(fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName()); - for (final Arg arg : fxn.args) - createIt.args.add(arg.type.getJType().getCoderDescriptor().getCoderInstanceName()); - - getter.body.add("return " + new JLTertiary(identifier + " != null", identifier, identifier + " = " + createIt) + ";"); - - return field.toString() + getter.toString(); - } - - private static String createLocalForward(final Class type, final Function fxn) { - final String identifier = makeInstanceName(fxn); - return new JLField("final", type.getCanonicalName(), identifier, new JLCall("get_" + identifier)).toString(); - } - - private static String createLocalNew(final Class type, final Function fxn) { - final String identifier = makeInstanceName(fxn); - StringWriter out = new StringWriter(); - - out.append(String.format("%3$s[] argCoders = new %3$s[%1$d + %2$s.length];\n", fxn.args.size(), VARARGS_NAME, Coder.class.getCanonicalName())); - - for(int i = 0; i < fxn.args.size(); i++) - out.append(String.format("argCoders[%1$d] = %2$s;\n", i, fxn.args.get(0).type.getJType().getCoderDescriptor().getCoderInstanceName())); - - if(fxn.variadic){ - out.append(String.format("for(int i = %1$d; i < (%1$d + %2$s.length); i++)\n", fxn.args.size(), VARARGS_NAME)); - out.append(String.format("\targCoders[i] = %1$s.getCoderAtRuntime(%2$s[i - %3$s]);\n", Coder.class.getCanonicalName(), VARARGS_NAME, fxn.args.size())); - } - - out.append("final " + type.getCanonicalName() + " " + identifier + " = new " + type.getCanonicalName() + "(" + firstArg(fxn) + ", \"" + fxn.name + "\", " - + fxn.returnValue.type.getJType().getCoderDescriptor().getCoderInstanceName() + ", argCoders);"); - - return out.toString(); - } - - private static final String CONTEXT_NAME = "nativeBuffer"; - - public static void writeOutFunction(final PrintStream out, final Class type, final Function fxn, final String initWithObj) { - final String instName = makeInstanceName(fxn); - final JType returnJavaType = fxn.returnValue.type.getJType(); - - if(!fxn.variadic){ - out.print(createFieldCache(type, fxn)); - out.println(); - } - - JLMethod meth = new JLMethod("public", returnJavaType.getJavaReturnTypeName(), fxn.getJavaName()); - - for(Arg arg : fxn.args) - meth.args.add("final " + arg.type.getJType().getTypeNameAsParam() + " " + arg.javaName); - - if(fxn.variadic) - meth.args.add("final Object... " + VARARGS_NAME); - - if(fxn instanceof Method && ((Method)fxn).ignore){ - String suggestion = ((Method)fxn).suggestion == null ? "" : (" Suggested work-around: " + ((Method)fxn).suggestion); - meth.jdoc.add("@deprecated The framework recommends that this method be ignored. (It may be deprecated.)" + suggestion); - meth.attrs.add("@Deprecated"); - } - - // type mismatch warning - { - { - String retMsg = fxn.returnValue.type.getJType().getCoderDescriptor().mismatchMessage(); - if(retMsg != null){ - meth.jdoc.add("@deprecated Possible type mismatch: (return value) " + retMsg); - meth.attrs.add("@Deprecated"); - } - } - - for(int i = 0; i < fxn.args.size(); i++){ - final Arg arg = fxn.args.get(i); - String argMsg = arg.type.getJType().getCoderDescriptor().mismatchMessage(); - if(argMsg != null){ - meth.jdoc.add("@deprecated Possible type mismatch: (arg" + i + ": " + arg.javaName + ") " + argMsg); - meth.attrs.add("@Deprecated"); - } - } - } - - if(fxn.variadic) - meth.body.add(createLocalNew(coreType(fxn), fxn)); - else - meth.body.add(createLocalForward(coreType(fxn), fxn)); - - meth.body.add(returnJavaType.createDeclareBuffer(CONTEXT_NAME)); - meth.body.add(returnJavaType.createInit(CONTEXT_NAME, instName, initWithObj)); - - for(final Arg arg : fxn.args) - meth.body.add(arg.type.getJType().getCoderDescriptor().getPushStatementFor(CONTEXT_NAME, arg.javaName)); - - if(fxn.variadic){ - meth.body.add(String.format("for(int i = %1$d; i < (%1$d + %2$s.length); i++)", fxn.args.size(), VARARGS_NAME)); - meth.body.add(String.format("\targCoders[i].push(%1$s, %2$s[i - %3$d]);", CONTEXT_NAME, VARARGS_NAME, fxn.args.size())); - } - - meth.body.add(returnJavaType.createInvoke(CONTEXT_NAME, instName)); - meth.body.add(returnJavaType.createPop(CONTEXT_NAME)); - meth.body.add(returnJavaType.createReturn()); - - out.print(meth.toString()); - out.println(); - } - - private static Class coreType(final Function fxn){ - return fxn instanceof Method ? MsgSend.class : FunCall.class; - } - - private static String firstArg(Function fxn){ - return fxn instanceof Method ? "getRuntime()" : "this"; - } - - private static String makeInstanceName(Function fxn){ - String ext; - if(fxn instanceof Method){ - if(((Method) fxn).isClassMethod) ext = "CMetInst"; - else ext = "IMetInst"; - } - else - ext = "FxnInst"; - - return fxn.getJavaName() + "_" + ext; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Generator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Generator.java deleted file mode 100644 index f1411e83e7d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Generator.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator; - -import java.io.File; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.classes.MixedPrimitiveCoderClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.model.types.TypeCache; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; - -public class Generator { - private static final String DEFAULT_FRAMEWORKS_PATH = "/System/Library/Frameworks"; - private static final String DEFAULT_OUTPUT_PATH = "/tmp/JObjC"; - - public static void main(final String...args) throws Throwable { - final Map argMap = Utils.getArgs(args); - - final String dst = get(argMap, "dst", DEFAULT_OUTPUT_PATH); - System.out.println("Cleaning up: " + dst); - final File dstLoc = new File(dst); - Utils.recDelete(dstLoc); - dstLoc.mkdirs(); - System.out.println("Outputting classes to: " + dst); - - final String frameworksPath = get(argMap, "frameworks", DEFAULT_FRAMEWORKS_PATH); - System.out.println("Searching for bridged frameworks in: " + frameworksPath); - - final List bridgeSupportFiles = FrameworkGenerator.findFrameworkFilesIn(new File(frameworksPath)); - final List frameworks = FrameworkGenerator.parseFrameworksFrom(bridgeSupportFiles); - - System.out.println("--1-- Generator: consolidateClassesForFrameworks"); - ClassConsolidator.consolidateClassesForFrameworks(frameworks); - - System.out.println("--1-- Generator: TypeCache load"); - TypeCache.inst().load(frameworks); - - System.out.println("--1-- Generator: disambiguateMethodNames"); - MethodDisambiguator.disambiguateMethodNames(); - - System.out.println("--1-- Generator: disambiguateFunctionsIn"); - MethodDisambiguator.disambiguateFunctionsIn(frameworks); - - System.out.println("--1-- Generator: generateClasses"); - final List sourceFiles = ClassGenerator.generateClasses(frameworks); - sourceFiles.add(new MixedPrimitiveCoderClassFile(ComplexCoderDescriptor.getMixedEncoders())); - - System.out.println("--1-- Generator: writing " + sourceFiles.size() + " files"); - for (final OutputFile sourceFile : sourceFiles) sourceFile.write(dstLoc); - - System.out.println("I have " + TypeCache.inst().getUnknownTypes().size() + " unresolved types."); - for (final Type type : TypeCache.inst().getUnknownTypes()) - System.out.println("[Warning] unknown type: " + type); - - for(Type type : TypeCache.inst().typesByNTypes.values()){ - if(!type.type32.getClass().equals(type.type64.getClass())){ - System.out.format("Type with differing NTypes: %1$15s: %2$s\n", type.name, new Pair(type.type32, type.type64)); - } - } - } - - private static String get(final Map defaults, final String key, final String defaultValue) { - final String value = defaults.get(key); - if (value != null) return value; - return defaultValue; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/MethodDisambiguator.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/MethodDisambiguator.java deleted file mode 100644 index 5b8bcb2ec79..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/MethodDisambiguator.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator; - -import java.util.List; - -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Function; -import com.apple.internal.jobjc.generator.model.types.TypeCache; - -public class MethodDisambiguator { - static void disambiguateMethodNames() { - // link all subclassers off their parents - for (final Clazz clazz : TypeCache.inst().getAllClasses()) { - final Clazz superClazz = clazz.superClass; - if (superClazz != null) superClazz.subClassers.add(clazz); - } - - // recursively call all subclassers, starting from NSObject on down - disambiguateMethodNamesFor(TypeCache.inst().getClassForName("NSObject")); - - // NSProxy does not appear to subclass from NSObject, but it is still a real full class...? - disambiguateMethodNamesFor(TypeCache.inst().getClassForName("NSProxy")); - } - - static void disambiguateMethodNamesFor(final Clazz clazz) { - clazz.disambiguateMethods(); - for (final Clazz subClazz : clazz.subClassers) { - disambiguateMethodNamesFor(subClazz); - } - } - - public static void disambiguateFunctionsIn(final List frameworks) { - for (final Framework framework : frameworks) { - disambiguateFunctionsInFramework(framework); - } - } - - static void disambiguateFunctionsInFramework(final Framework framework) { - for (final Function fxn : framework.functions) - fxn.disambiguateArgs(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/RestrictedKeywords.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/RestrictedKeywords.java deleted file mode 100644 index aeaaeee548a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/RestrictedKeywords.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public class RestrictedKeywords { - static final String[] JAVA_KEYWORD_CONFLICTS = { - "wait", "null", "class", "new", "toString", "finalize", "boolean", "interface", "final", "static" - }; - - static final Set originalRestrictedSet = new HashSet(Arrays.asList(JAVA_KEYWORD_CONFLICTS)); - - public static Set getNewRestrictedSet() { - return new HashSet(originalRestrictedSet); - } - - public static boolean isRestricted(String s){ - return originalRestrictedSet.contains(s); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Utils.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Utils.java deleted file mode 100644 index 7a3459c2164..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/Utils.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Pattern; - -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Framework.FrameworkDependency; -import com.apple.internal.jobjc.generator.utils.Fp; - -public class Utils { - public static boolean isLeopard = System.getProperty("os.version").startsWith("10.5"); - public static boolean isSnowLeopard = System.getProperty("os.version").startsWith("10.6"); - - @SuppressWarnings("unchecked") - public static List list(final Object...args) { - final ArrayList list = new ArrayList(args.length); - for (final Object arg : args) list.add(arg); - return (List)list; - } - - /** - * A small implementation of UNIX find. - * @param matchRegex Only collect paths that match this regex. - * @param pruneRegex Don't recurse down a path that matches this regex. May be null. - * @throws IOException if File.getCanonicalPath() fails. - */ - public static List find(final File startpath, final String matchRegex, final String pruneRegex) throws IOException{ - final Pattern matchPattern = Pattern.compile(matchRegex, Pattern.CASE_INSENSITIVE); - final Pattern prunePattern = pruneRegex == null ? null : Pattern.compile(pruneRegex, Pattern.CASE_INSENSITIVE); - final Set visited = new HashSet(); - final List found = new ArrayList(); - class Search{ - void search(final File path) throws IOException{ - if(prunePattern != null && prunePattern.matcher(path.getAbsolutePath()).matches()) return; - String cpath = path.getCanonicalPath(); - if(!visited.add(cpath)) return; - if(matchPattern.matcher(path.getAbsolutePath()).matches()) - found.add(path); - if(path.isDirectory()) - for(File sub : path.listFiles()) - search(sub); - } - } - new Search().search(startpath); - return found; - } - - public static String joinWComma(final List list) { return Fp.join(", ", list); } - public static String joinWComma(final Object[] list) { return Fp.join(", ", Arrays.asList(list)); } - - public static class Substituter { - String str; - - public Substituter(final String str) { - this.str = str.replaceAll("\\#", "\t").replaceAll("\\~", "\n"); - } - - public void replace(final String key, final String value) { - str = str.replaceAll("\\$" + key, value); - } - - /** - * Apply String.format first, and then pass through Substituter. - */ - public static String format(String format, Object... args){ - return new Substituter(String.format(format, args)).toString(); - } - - @Override public String toString() { - return str; - } - } - - static Map getArgs(final String...args) { - final Map argMap = new HashMap(); - for (final String arg : args) { - final String[] splitArg = arg.split("\\="); - if (splitArg.length != 2) continue; - argMap.put(splitArg[0], splitArg[1]); - } - return argMap; - } - - static void recDelete(final File file) { - if (!file.exists()) return; - if (file.isDirectory()) for (final File f : file.listFiles()) recDelete(f); - file.delete(); - } - - public static String capitalize(String s){ - if(s.length() == 0) return s; - return Character.toString(Character.toUpperCase(s.charAt(0))) + s.substring(1); - } - - /** - * Sort frameworks by dependencies. If A is a dependency of B, - * then A will come before B in the list. - */ - public static void topologicalSort(final List frameworks) { - final Set visited = new TreeSet(); - final List sorted = new ArrayList(frameworks.size()); - class Rec{ - void visit(final Framework fw){ - if(!visited.add(fw)) return; - for(FrameworkDependency dep : fw.dependencies) - if(dep.object != null) - visit(dep.object); - sorted.add(fw); - } - } - for(Framework fw : frameworks) new Rec().visit(fw); - frameworks.clear(); - frameworks.addAll(sorted); - } - - /** - * If there is a cycle it is returned. Otherwise null is returned. - */ - public static List getDependencyCycle(List frameworks) { - @SuppressWarnings("serial") - class FoundCycle extends Throwable{ - public final List cycle; - public FoundCycle(List cycle){ - this.cycle = cycle; - } - }; - class Rec{ - void visit(final Framework fw, List visited) throws FoundCycle{ - visited = new LinkedList(visited); - if(visited.contains(fw)){ - visited.add(fw); - throw new FoundCycle(visited); - } - visited.add(fw); - for(FrameworkDependency dep : fw.dependencies) - if(dep.object != null) - visit(dep.object, visited); - } - } - try{ for(Framework fw : frameworks){ new Rec().visit(fw, new LinkedList()); }} - catch(FoundCycle x){ return x.cycle; } - return null; - } - - public static String getCanonicalPath(File file) throws RuntimeException{ - try { - return file.getCanonicalPath(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/AbstractObjCClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/AbstractObjCClassFile.java deleted file mode 100644 index e3208d17167..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/AbstractObjCClassFile.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import com.apple.internal.jobjc.generator.model.Clazz; - -public abstract class AbstractObjCClassFile extends GeneratedClassFile { - final Clazz clazz; - - public AbstractObjCClassFile(final Clazz clazz, final String classname, final String genericArgs, final String superClass) { - super(clazz.getPackage(), classname, genericArgs, superClass); - this.clazz = clazz; - } - - public AbstractObjCClassFile(final Clazz clazz, final String classname, final String superClass) { - super(clazz.getPackage(), classname, superClass); - this.clazz = clazz; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CFTypeClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CFTypeClassFile.java deleted file mode 100644 index 774cae18e6e..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CFTypeClassFile.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.jobjc.Pointer; - -public class CFTypeClassFile extends GeneratedClassFile { - final CFType cftype; - - public CFTypeClassFile(final CFType cftype) { - super(cftype.parent.pkg, cftype.type.getJType().getJavaClassName(), com.apple.jobjc.CFType.class.getCanonicalName()); - this.cftype = cftype; - } - - @Override public void writeBeginning(PrintStream out){ - out.println("\tpublic " + className + "(" + Pointer.class.getName() + " ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - out.println(""); - out.println("\tpublic " + className + "(long ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - } - - @Override public void writeBody(PrintStream out){ - if(cftype.getTypeIdFunc != null){ - out.println("\tpublic static long getTypeId(){"); - out.println("\t\treturn " + RootJObjCClass.runtimeFrameworkInst(cftype.parent.name) + "." + cftype.getTypeIdFunc + "();"); - out.println("\t}"); - } - else - out.println("\t// getTypeIdFunc not found"); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassClassFile.java deleted file mode 100644 index f89c24320cf..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassClassFile.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.HashSet; -import java.util.Set; - -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.Invoke.MsgSend; - -public class CategoryClassClassFile extends AbstractObjCClassFile { - final Category category; - - public CategoryClassClassFile(final Category category) { - super(category.category, category.category.name + "Class", - category.category.superClass.getFullPath() + "Class"); - this.category = category; - } - - @Override public void writeBeginning(final PrintStream out) { - out.format( - "\t%1$s(%2$s runtime) {\n" + - "\t\tsuper(\"%3$s\", runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName(), category.category.superClass.name); - } - - @Override public void writeBody(final PrintStream out) { - Set written = new HashSet(); - for(final Method method : this.clazz.classMethods) - if(written.add(method.name)) - FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this"); - else - System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name); - } - - @Override protected boolean isFinal(){ return true; } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassFile.java deleted file mode 100644 index c858546d092..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CategoryClassFile.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.jobjc.JObjCRuntime; - -public class CategoryClassFile extends JObjCClassFile { - private final Category category; - - public CategoryClassFile(final Category category) { - super(category.category); - this.category = category; - } - - @Override public void writeBeginning(final PrintStream out) { - String targetCls = category.category.superClass.getFullPath(); - out.format("\tpublic %1$s(final %2$s obj, final %3$s runtime) {\n" + - "\t\tsuper(obj, runtime);\n" + - "\t}\n", - className, targetCls, JObjCRuntime.class.getCanonicalName()); - super.writeBeginning(out); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/FrameworkClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/FrameworkClassFile.java deleted file mode 100644 index aade30f05fe..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/FrameworkClassFile.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.File; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; -import java.util.TreeSet; - -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.model.Category; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Constant; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Function; -import com.apple.internal.jobjc.generator.model.NativeEnum; -import com.apple.internal.jobjc.generator.model.StringConstant; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.types.JType; -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.JavaLang; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLCall; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLField; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLReturn; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.MacOSXFramework; -import com.apple.jobjc.Invoke.FunCall; - -public class FrameworkClassFile extends GeneratedClassFile { - final Framework framework; - - public FrameworkClassFile(final Framework framework) { - super(framework.pkg, framework.name + "Framework", MacOSXFramework.class.getName()); - this.framework = framework; - } - - @Override public void writeBeginning(final PrintStream out) { - List binPaths = Fp.map(new Map1(){ - public String apply(File a) { return "\"" + a.getAbsolutePath() + "\""; }}, - framework.binaries); - out.println(new Utils.Substituter( - "#public " + className + "(" + JObjCRuntime.class.getName() + " runtime) {~" + - "##super(runtime, new String[]{" + Fp.join(", ", binPaths) + "});~" + - "#}~" - )); - } - - @Override public void writeBody(final PrintStream out) { - for(final Struct struct : new ArrayList(framework.structs)){ - out.println("\tpublic " + struct.name + " make" + struct.name + "(){"); - out.println("\t\treturn new " + struct.name + "(getRuntime());"); - out.println("\t}"); - out.println("\tpublic " + struct.name + " make" + struct.name + "(com.apple.jobjc.NativeBuffer base){"); - out.println("\t\treturn new " + struct.name + "(getRuntime(), base);"); - out.println("\t}"); - } - - for(final NativeEnum nenum : framework.enums){ - if(nenum.ignore){ - out.println("\t/**"); - out.println("\t * @deprecated Suggestion: " + nenum.suggestion); - out.println("\t */"); - out.println("\t@Deprecated"); - } - out.println(String.format("\tpublic final %3$s %1$s(){ return %2$s; }", - nenum.name, nenum.valueToString(), nenum.type.getJType().getJavaReturnTypeName())); - } - - for(final Constant konst : framework.constants){ - String cacheName = "_" + konst.name; - final JType jtype = konst.type.getJType(); - final String cast = jtype.getReturnTypeCast() == null ? "" : "(" + jtype.getReturnTypeCast() + ")"; - out.println(); - - out.print(new JLField("private", jtype.getJavaTypeName(), cacheName, jtype.getDefaultReturnValue())); - - JLMethod reader = new JLMethod("public final", jtype.getJavaReturnTypeName(), konst.name); - reader.body.add("if(" + cacheName + " != " + jtype.getDefaultReturnValue() + ") return " + cast + cacheName + ";"); - - String contextName = jtype instanceof JStruct ? "returnValue" : "nativeBuffer"; - - if(jtype instanceof JStruct) - reader.body.add(((JStruct)jtype).createReturnValue()); - else - reader.body.add(jtype.createDeclareBuffer(contextName)); - - reader.body.add("getConstant(\"" + konst.name + "\", " + contextName + ", " + jtype.getCoderDescriptor().getCoderInstanceName() + ".sizeof());"); - - reader.body.add(jtype.createPop(contextName)); - reader.body.add(cacheName + " = returnValue;"); - reader.body.add(jtype.createReturn()); - - out.print(reader); - } - - for(final StringConstant konst : framework.stringConstants){ - if(Fp.any(new Map1(){ public Boolean apply(Constant a) { - return a.name.equals(konst.name); - }}, new ArrayList(framework.constants))){ - System.out.println("Warning: [" + framework.name + "] String constant " + konst.name + " is already defined in constants. Skipping."); - } - else{ - out.println("\tpublic final String " + konst.name + "(){ return \"" + escapeQuotes(konst.value) + "\"; }"); - } - } - - /** - * Order classes to get stable output - */ - TreeSet sortedClasses = new TreeSet(framework.classes); - for (final Clazz clazz : sortedClasses) { - final String classClassName = clazz.name + "Class"; - out.println(JavaLang.makeSingleton("_" + classClassName, clazz.name, classClassName, "getRuntime()")); - } - - for (final Category cat : framework.categories) { - final String classClassName = cat.category.name + "Class"; - out.println(JavaLang.makeSingleton("_" + classClassName, cat.category.name, classClassName, "getRuntime()")); - - JLMethod jlm = new JLMethod("public", cat.category.name, cat.category.name, "final " + cat.category.superClass.getFullPath() + " obj"); - jlm.body.add(new JLReturn(new JLCall("new " + cat.category.name, "obj", "getRuntime()"))); - out.println(jlm); - } - - for (final Function fxn : framework.functions){ - FunctionGenerator.writeOutFunction(out, FunCall.class, fxn, null); - } - } - - private String escapeQuotes(String s){ - return s.replace("\"", "\\\""); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/GeneratedClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/GeneratedClassFile.java deleted file mode 100644 index 0098d4d442c..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/GeneratedClassFile.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; - -public class GeneratedClassFile extends OutputFile { - protected final String className; - protected final String genericArgs; - protected final String superClass; - - public GeneratedClassFile(final String pkg, final String classname, final String superClass) { - this(pkg, classname, null, superClass); - } - - public GeneratedClassFile(final String pkg, final String classname, final String genericArgs, final String superClass) { - super(pkg, classname + ".java"); - this.className = classname; - this.genericArgs = genericArgs; - this.superClass = superClass; - } - - @Override - public void write(final File parentDir) { - try { - final PrintStream out = open(parentDir); - out.println("package " + pkg + ";"); - out.println(); - out.print("public " + (isFinal() ? "final" : "") + " class " + className); - if(genericArgs != null) out.print("<" + genericArgs + ">"); - if (superClass != null) out.print(" extends " + superClass); - out.println(" {"); - writeBeginning(out); - writeBody(out); - writeEnd(out); - out.println("}"); - close(out); - } catch (final IOException e) { throw new RuntimeException(e); } - } - - public void writeBeginning(final PrintStream out) { - - } - - public void writeBody(final PrintStream out) { - - } - - public void writeEnd(final PrintStream out) { - - } - - protected boolean isFinal(){ return false; } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassClassFile.java deleted file mode 100644 index a22bb5b5fa3..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassClassFile.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.HashSet; -import java.util.Set; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.Invoke.MsgSend; - -public class JObjCClassClassFile extends AbstractObjCClassFile { - public JObjCClassClassFile(final Clazz clazz) { - super(clazz, clazz.name + "Class", clazz.superClass != null ? clazz.superClass.getFullPath() + "Class" : ClassGenerator.JOBJC_PACKAGE + ".NSClass<" + clazz.name + ">"); - } - - @Override public void writeBeginning(final PrintStream out) { - out.format( - "\tpublic %1$s(%2$s runtime) {\n" + - "\t\tsuper(runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - out.format( - "\tpublic %1$s(String name, %2$s runtime) {\n" + - "\t\tsuper(name, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - out.format( - "\tpublic %1$s(long ptr, %2$s runtime) {\n" + - "\t\tsuper(ptr, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - } - - @Override public void writeBody(final PrintStream out) { - Set written = new HashSet(); - for(final Method method : this.clazz.classMethods) - if(written.add(method.name)) - FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this"); - else - System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassFile.java deleted file mode 100644 index 276c76b3a97..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/JObjCClassFile.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -import com.apple.internal.jobjc.generator.FunctionGenerator; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Method; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.NativeObjectLifecycleManager; -import com.apple.jobjc.Invoke.MsgSend; - -public class JObjCClassFile extends AbstractObjCClassFile { - public JObjCClassFile(final Clazz clazz) { - super(clazz, clazz.name, - clazz.superClass == null ? "com.apple.jobjc.ID" - : clazz.superClass.getFullPath()); - } - - private static Map nolmForClass = - new TreeMap(); - static{ - nolmForClass.put("NSAutoreleasePool", NativeObjectLifecycleManager.Nothing.INST); - } - - @Override public void writeBeginning(final PrintStream out) { - out.format("\tpublic %1$s(final long objPtr, final %2$s runtime) {\n" + - "\t\tsuper(objPtr, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - - out.format("\tpublic %1$s(final %1$s obj, final %2$s runtime) {\n" + - "\t\tsuper(obj, runtime);\n" + - "\t}\n", - className, JObjCRuntime.class.getCanonicalName()); - - NativeObjectLifecycleManager nolm = nolmForClass.get(clazz.name); - if(nolm != null) - out.format("\t@Override\n"+ - "\tprotected %1$s getNativeObjectLifecycleManager() {\n" + - "\t\treturn %2$s.INST;\n" + - "\t}\n", - NativeObjectLifecycleManager.class.getCanonicalName(), nolm.getClass().getCanonicalName()); - } - - @Override public void writeBody(final PrintStream out) { - Set written = new HashSet(); - for(final Method method : this.clazz.instanceMethods) - if(written.add(method.name)) - FunctionGenerator.writeOutFunction(out, MsgSend.class, method, "this"); - else - System.out.format("Duplicate method: %1$s %2$s -%3$s\n", clazz.parent.name, className, method.name); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/MixedPrimitiveCoderClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/MixedPrimitiveCoderClassFile.java deleted file mode 100644 index ea28298bc48..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/MixedPrimitiveCoderClassFile.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.Collection; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor.MixedEncodingDescriptor; -import com.apple.jobjc.PrimitiveCoder; - -public class MixedPrimitiveCoderClassFile extends GeneratedClassFile { - private static final String MULTI_CODER_CLASSNAME = "MixedPrimitiveCoder"; - public static final String FULL_MULTI_CODER_CLASSNAME = ClassGenerator.JOBJC_PACKAGE + "." + MULTI_CODER_CLASSNAME; - - final Collection coderDescs; - - public MixedPrimitiveCoderClassFile(final Collection coderDescs) { - super(ClassGenerator.JOBJC_PACKAGE, MULTI_CODER_CLASSNAME, "java.lang.Object"); - this.coderDescs = coderDescs; - } - - @Override - public void writeBody(final PrintStream out) { - for (final MixedEncodingDescriptor desc : coderDescs) { - out.println("\tpublic static final " + PrimitiveCoder.class.getCanonicalName() + " " + desc.getMixedName() + " = " + desc.getDefinition() + ";"); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OpaqueClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OpaqueClassFile.java deleted file mode 100644 index c7fa5d7f131..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OpaqueClassFile.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.jobjc.Pointer; - -public class OpaqueClassFile extends GeneratedClassFile { - final Opaque opaque; - - public OpaqueClassFile(final Opaque opaque) { - super(opaque.parent.pkg, opaque.type.getJType().getJavaClassName(), com.apple.jobjc.Opaque.class.getCanonicalName()); - this.opaque = opaque; - } - - @Override public void writeBeginning(PrintStream out){ - out.println("\t// " + opaque.type); - out.println("\t// " + opaque.type.getJType()); - out.println(""); - out.println("\tpublic " + className + "(" + Pointer.class.getName() + " ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - out.println(""); - out.println("\tpublic " + className + "(long ptr){"); - out.println("\t\tsuper(ptr);"); - out.println("\t}"); - } - -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OutputFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OutputFile.java deleted file mode 100644 index 615bb24acfa..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/OutputFile.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.*; - -public abstract class OutputFile { - final String pkg; - final String fileName; - - public OutputFile(final String pkg, final String filename) { - this.pkg = pkg; - this.fileName = filename; - } - - public PrintStream open(final File parentDir) throws IOException { - final File pkgDir = new File(parentDir, pkg.replace('.', '/')); - pkgDir.mkdirs(); - final File classFile = new File(pkgDir, fileName); - classFile.createNewFile(); - return new PrintStream(classFile); - } - - public void close(final PrintStream out) { - out.close(); - } - - public abstract void write(final File parentDir); - - public boolean isClass(final Class clazz) { - final String pkgName = clazz.getPackage().getName(); - if (!pkgName.equals(pkg)) return false; - - return fileName.contains(clazz.getSimpleName()); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/RootJObjCClass.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/RootJObjCClass.java deleted file mode 100644 index a581d1ce2ee..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/RootJObjCClass.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; -import java.util.List; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.utils.JavaLang; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLCtor; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLField; -import com.apple.internal.jobjc.generator.utils.JavaLang.JLMethod; -import com.apple.jobjc.JObjCRuntime; - -public class RootJObjCClass extends GeneratedClassFile { - private static final String JOBJC_CLASSNAME = "JObjC"; - public static final String FULL_JOBJC_CLASSNAME = ClassGenerator.JOBJC_PACKAGE + "." + JOBJC_CLASSNAME; - public static final String JOBJC_RUNTIME_INST = FULL_JOBJC_CLASSNAME + ".getInstance()"; - public static final String JOBJC_RUNTIME_INST_R = FULL_JOBJC_CLASSNAME + ".getInstance(getRuntime())"; - - public static final String runtimeFrameworkInst(String fwname){ - return JOBJC_RUNTIME_INST + "." + fwname + "()"; - } - - public static final String runtimeFrameworkInstR(String fwname){ - return JOBJC_RUNTIME_INST_R + "." + fwname + "()"; - } - - final List frameworks; - - public RootJObjCClass(final List frameworks) { - super(ClassGenerator.JOBJC_PACKAGE, JOBJC_CLASSNAME, "java.lang.Object"); - this.frameworks = frameworks; - } - - @Override public void writeBeginning(final PrintStream out) { - out.print(new JLField("private static", JOBJC_CLASSNAME, "instance")); - out.print(new JLField("private final", JObjCRuntime.class.getName(), "runtime")); - - JLMethod getInstR = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance", "final JObjCRuntime runtime"); - getInstR.body.add("if(runtime == null) throw new NullPointerException(\"runtime\");"); - getInstR.body.add("if(instance == null) instance = new JObjC(runtime);"); - getInstR.body.add("return instance;"); - out.print(getInstR); - - JLMethod getInst = new JLMethod("public static", JOBJC_CLASSNAME, "getInstance"); - getInst.body.add("return getInstance(JObjCRuntime.getInstance());"); - out.print(getInst); - - JLCtor ctor = new JLCtor("private", JOBJC_CLASSNAME, "final JObjCRuntime runtime"); - ctor.body.add("this.runtime = runtime;"); - for (final Framework f : frameworks) - ctor.body.add("runtime.registerPackage(\"" + f.pkg + "\");"); - out.print(ctor); - } - - @Override public void writeBody(final PrintStream out) { - for (final Framework f : frameworks) - out.println(JavaLang.makeSingleton("_" + f.name, f.name, f.pkg + "." + f.name + "Framework", "runtime")); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/StructClassFile.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/StructClassFile.java deleted file mode 100644 index 597d30a5818..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/StructClassFile.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.classes; - -import java.io.PrintStream; - -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.Struct.Field; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.JType; -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.JObjCRuntime; -import com.apple.jobjc.Coder.StructCoder; - -public class StructClassFile extends GeneratedClassFile { - final Struct struct; - - public StructClassFile(final Struct struct) { - super(struct.parent.pkg, struct.name, com.apple.jobjc.Struct.class.getName()); - this.struct = struct; - } - - @Override public boolean isFinal(){ return true; } - - @Override public void writeBeginning(final PrintStream out) { - out.println(); - out.println("\tpublic static int SIZEOF = " + JObjCRuntime.class.getName() + ".IS64 ? " - + ((NStruct) struct.type.type64).sizeof64() + " : " + ((NStruct) struct.type.type32).sizeof32() + ";"); - out.println(); - out.format("\tpublic final static %1$s getStructCoder(){ return coder; }\n", StructCoder.class.getCanonicalName()); - out.format("\t@Override public final %1$s getCoder(){ return coder; }\n", StructCoder.class.getCanonicalName()); - out.format("\tprivate final static %1$s coder = new %1$s(SIZEOF%2$s%3$s){\n", StructCoder.class.getCanonicalName(), - (struct.fields.size() > 0 ? ",\n\t\t" : ""), - Fp.join(",\n\t\t", Fp.map(new Map1(){ - public String apply(Field a) { - return a.type.getJType().getCoderDescriptor().getCoderInstanceName(); - }}, struct.fields))); - out.format("\t\t@Override protected %1$s newInstance(%2$s runtime){ return new %1$s(runtime); }\n", - struct.name, - JObjCRuntime.class.getCanonicalName()); - out.println("\t};"); - out.println(); - out.println("\t" + struct.name + "(final " + JObjCRuntime.class.getCanonicalName() + " runtime){"); - out.println("\t\tsuper(runtime, SIZEOF);"); - out.println("\t}"); - out.println(); - out.println("\tpublic " + struct.name + "(final " + JObjCRuntime.class.getCanonicalName() + " runtime, final com.apple.jobjc.NativeBuffer buffer) {"); - out.println("\t\tsuper(runtime, buffer, SIZEOF);"); - out.println("\t}"); - } - - @Override public void writeBody(final PrintStream out) { - for(Struct.Field field : struct.fields){ - if(field.type.type64 instanceof NStruct && field.type.type32 instanceof NStruct) - writeStructField(field, out); - else - writeField(field, out); - } - } - - private void writeField(final Struct.Field field, final PrintStream out){ - if(field.type.type32 instanceof NBitfield){ - out.format("\t// Skipping bitfield '%1$s'\n", field.name); - return; - } - String privName = field.name + "__"; - String offsetName = field.name.toUpperCase() + "_OFFSET"; - JType jtype = field.type.getJType(); - String retType = jtype.getJavaReturnTypeName(); - CoderDescriptor cdesc = jtype.getCoderDescriptor(); - out.println(); - out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() - + ".IS64 ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";"); - - out.println("\t//" + cdesc.getClass().toString()); - out.println("\tpublic " + retType + " " + getterName(field) + "(){"); - out.println(jtype.createPopAddr("getRuntime()", "this.raw.bufferPtr + " + offsetName)); - out.println(jtype.createReturn()); - out.println("\t}"); - out.println(); - out.println("\tpublic void " + setterName(field.name) + "(final " + retType + " " + privName + "){"); - out.println("\t\t" + cdesc.getPushAddrStatementFor("getRuntime()", "this.raw.bufferPtr + " + offsetName, privName)); - out.println("\t}"); - } - - private void writeStructField(final Struct.Field field, final PrintStream out){ - if(field.type.getJType() == null || !(field.type.getJType() instanceof JStruct)){ - out.println("\t// Found bad JavaType (" + field.type.getJType() + ") for field (" + field.name + ") of type (" + field.type + ")"); - return; - } - String privName = field.name + "__"; - String offsetName = field.name.toUpperCase() + "_OFFSET"; - JStruct jstype = (JStruct) field.type.getJType(); - String retTypeName = jstype.getJavaReturnTypeName(); - out.println(); - out.println("\tprivate static final int " + offsetName + " = " + JObjCRuntime.class.getName() + ".IS64" - + " ? " + field.field64.offset64() + " : " + field.field32.offset32() + ";"); - - out.println("\tprivate " + retTypeName + " " + privName + " = null;"); - out.println("\tpublic " + retTypeName + " " + getterName(field) + "(){"); - out.println("\t\tif(null==" + privName + "){"); - out.println("\t\t\tthis.raw.position(" + offsetName + ");"); - out.println("\t\t\t" + privName + " = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) + ".make" + jstype.struct.name + "(this.raw.slice());"); - out.println("\t\t}"); - out.println("\t\treturn " + privName + ";"); - out.println("\t}"); - } - - private String getterName(Struct.Field field) { - if(com.apple.internal.jobjc.generator.RestrictedKeywords.isRestricted(field.name)) - return field.name + field.type.getJType().getAppendableDescription(); - return field.name; - } - - private String setterName(String name) { - return "set" + name.substring(0, 1).toUpperCase() + name.substring(1); - } - - @Override public void writeEnd(final PrintStream out) { - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Arg.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Arg.java deleted file mode 100644 index ce296352c66..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Arg.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class Arg extends ElementWType{ - public String javaName; - - public Arg(final Node node, final Function parent) { - super(node, parent); - javaName = name; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/CFType.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/CFType.java deleted file mode 100644 index d71eec5fe8a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/CFType.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import java.util.List; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.classes.CFTypeClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; - -public class CFType extends TypeElement implements OutputFileGenerator { - public final String getTypeIdFunc; - public final String tollfree; - - public CFType(final Node node, final Framework parent) { - super(node, getAttr(node, "name"), parent); - getTypeIdFunc = getAttr(node, "gettypeid_func"); - tollfree = getAttr(node, "tollfree"); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new CFTypeClassFile(this)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Category.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Category.java deleted file mode 100644 index 8bd50646992..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Category.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import java.util.List; - -import com.apple.internal.jobjc.generator.classes.CategoryClassClassFile; -import com.apple.internal.jobjc.generator.classes.CategoryClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; - -public class Category implements OutputFileGenerator{ - public final Clazz category; - - public Category(Clazz fromClass, Clazz target) { - this.category = new Clazz(fromClass.name + "Category", fromClass.classMethods, fromClass.instanceMethods, target, fromClass.parent); - } - - public void generateClasses(List generatedClassFiles) { - generatedClassFiles.add(new CategoryClassFile(this)); - generatedClassFiles.add(new CategoryClassClassFile(this)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Clazz.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Clazz.java deleted file mode 100644 index 3571974ccdb..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Clazz.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import com.apple.internal.jobjc.generator.RestrictedKeywords; -import com.apple.internal.jobjc.generator.classes.JObjCClassClassFile; -import com.apple.internal.jobjc.generator.classes.JObjCClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.jobjc.MacOSXFramework; -import com.apple.jobjc.SuperClassExtractor; -import com.apple.jobjc.UnsafeRuntimeAccess; -import com.apple.jobjc.NSClass.NSClassNotFoundException; -import com.apple.jobjc.SEL; - -public class Clazz extends Element implements OutputFileGenerator { - private final Map instanceMethodsByName = new HashMap(); - private final Map classMethodsByName = new HashMap(); - - public final List classMethods; - public final List instanceMethods; - - public final List subClassers = new ArrayList(0); - public Clazz superClass; - - public Clazz(String name, List classMethods, List instanceMethods, Clazz superClass, Framework parent){ - super(name, parent); - this.classMethods = classMethods; - this.instanceMethods = instanceMethods; - this.superClass = superClass; - } - - public Clazz(final Node classNode, final Framework parent) { - super(classNode, parent); - this.classMethods = new ArrayList(); - this.instanceMethods = new ArrayList(); - - final NodeList methodNodes = classNode.getChildNodes(); - for (int i = 0; i < methodNodes.getLength(); i++) { - final Node node = methodNodes.item(i); - if (!"method".equals(node.getLocalName())) continue; - - final String selName = Element.getAttr(node, "selector"); - if(selName == null || !SEL.validName(selName)){ - System.err.format("Warning: Discarding method %1$s:%2$s:%3$s" - + " -- Invalid selector name. Verify.\n", - parent.name, name, selName); - continue; - } - - final Method method = new Method(node, parent); - if (method.isClassMethod) { - classMethods.add(method); - } else { - instanceMethods.add(method); - } - } - } - - public String getPackage() { - return parent.pkg; - } - - public String getFullPath(){ - return parent.pkg + "." + name; - } - - @Override - public String toString() { - return super.toString() + " " + classMethods + " " + instanceMethods; - } - - public boolean doesActuallyExist(){ - try{ - UnsafeRuntimeAccess.getNSClass(parent.load(), name); - }catch(NSClassNotFoundException x){ - return false; - } - return true; - } - - void resolveSuperClass(final MacOSXFramework nativeFramework, final Map allClasses) throws Throwable { - superClass = SuperClassExtractor.getSuperClassFor(name, nativeFramework, allClasses); - } - - public void disambiguateMethods() { - disambiguateMethods(instanceMethods, instanceMethodsByName); - disambiguateMethods(classMethods, classMethodsByName); - } - - private void disambiguateMethods(final List methods, final Map methodMap) { - final Set existingMethodNames = RestrictedKeywords.getNewRestrictedSet(); - for (final Method method : methods) { - method.disambiguateNameAndArgs(this, existingMethodNames); - methodMap.put(method.javaName, method); - } - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new JObjCClassClassFile(this)); - generatedClassFiles.add(new JObjCClassFile(this)); - } - - Method getParentMethodMatchingName(final String methodName) { - if(superClass == null) return null; - Method m = superClass.getMethodNamed(methodName); - if(m != null) return m; - return superClass.getParentMethodMatchingName(methodName); - } - - private Method getMethodNamed(final String methodName) { - final Method instanceMethod = instanceMethodsByName.get(methodName); - if (instanceMethod != null) return instanceMethod; - - final Method classMethod = classMethodsByName.get(methodName); - if (classMethod != null) return classMethod; - - return null; - } - - int compareTo(Clazz o) { - return toString().compareTo(o.toString()); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Element.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Element.java deleted file mode 100644 index 47fff332e6b..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Element.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.utils.ObjectInspector; - -/** - * Subclasses must implement ctor(Node, P) - */ -public class Element

> implements Comparable>{ - public final String name; - public final P parent; - - public Element(final String name, final P parent) { - this.name = Type.cleanName(name); - this.parent = parent; - } - - public Element(final Node node, final P parent) { - this(getAttr(node, "name"), parent); - } - - public static String getAttr(final Node node, final String key) { - final NamedNodeMap attrs = node.getAttributes(); - if (attrs == null) return null; - final Node name = attrs.getNamedItem(key); - if (name == null) return null; - return name.getNodeValue(); - } - - static

, T extends Element

> List getNodesFor(final Node parentNode, final String selection, final Class clazz, final P parent) { - Constructor ctor; - try { - ctor = clazz.getConstructor(new Class[] { Node.class, parent.getClass() }); - } catch (Exception e) { - throw new RuntimeException(e); - } - - final NodeList childNodes = parentNode.getChildNodes(); - final List nodes = new ArrayList(); - for (int i = 0; i < childNodes.getLength(); i++) { - final Node node = childNodes.item(i); - if (!selection.equals(node.getLocalName())) continue; - - T obj; - try { - obj = ctor.newInstance(new Object[] { node, parent }); - } catch (InvocationTargetException e) { - throw new RuntimeException(e.getCause()); - } catch (Exception e) { - throw new RuntimeException(e); - } - nodes.add(obj); - } - - return nodes; - } - - @Override public String toString() { - return name; - } - - public String reflectOnMySelf() { - return ObjectInspector.inspect(this); - } - - public int compareTo(Element o) { - return name.compareTo(o.name); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ElementWType.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ElementWType.java deleted file mode 100644 index 8bb31b9449e..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ElementWType.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import com.apple.internal.jobjc.generator.model.types.NType; -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.utils.NTypeParser; - -/** - * An ElementWType has a type but does not necessarily represent a type. Examples are constants, enums, arguments, return values. - */ -public class ElementWType

> extends Element

{ - public final Type type; - - public ElementWType(final String name, final Type t, final P parent) { - super(name, parent); - this.type = t; - } - - public ElementWType(final Node node, final Type t, final P parent) { - super(node, parent); - this.type = t; - } - - public ElementWType(final Node node, final String declType, final P parent) { - super(node, parent); - final String type32 = getAttr(node, "type"); - final String type64 = getAttr(node, "type64"); - this.type = Type.getType(declType, - type32 == null ? NType.NUnknown.inst() : NTypeParser.parseFrom(type32), - type64 == null ? null : NTypeParser.parseFrom(type64)); - } - - public ElementWType(final Node node, final P parent){ - this(node, getAttr(node, "declared_type"), parent); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Framework.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Framework.java deleted file mode 100644 index a63be7d4106..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Framework.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.w3c.dom.Node; -import org.xml.sax.InputSource; - -import com.apple.internal.jobjc.generator.ClassGenerator; -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.classes.FrameworkClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.MacOSXFramework; -import com.apple.jobjc.UnsafeRuntimeAccess; - -public class Framework extends Element> implements OutputFileGenerator { - public final String path; - public final String pkg; - public final List binaries; - public MacOSXFramework nativeFramework; - - public MacOSXFramework load(){ - if(nativeFramework == null){ - String[] bins = new String[binaries.size()]; - for(int i = 0; i < binaries.size(); ++i) - bins[i] = Utils.getCanonicalPath(binaries.get(i)); - nativeFramework = UnsafeRuntimeAccess.getFramework(bins); - } - return nativeFramework; - } - - public File getMainFrameworkBinary(){ return binaries.get(0); } - - final Node rootNode; - - public Set classes; - public List structs; - public List cfTypes; - public List opaques; - public List constants; - public List stringConstants; - public List enums; - public List functions; - public List functionAliases; - public List informalProtocols; - public List protocols; - public List categories; - public List dependencies; - - public static class FrameworkDependency extends Element{ - final String path; - public Framework object = null; - - public FrameworkDependency(final Node node, final Framework parent) { - super(getAttr(node, "path").replaceFirst("^.*/([^/]+)\\.framework$", "$1"), parent); - this.path = getAttr(node, "path"); - } - } - - public static final XPath XPATH = XPathFactory.newInstance().newXPath(); - public Framework(final String name, final File bsFile) { - super(name, null); - try { - final File pathf = bsFile.getCanonicalFile().getParentFile().getParentFile().getParentFile(); - path = pathf.getParentFile().getParentFile().getCanonicalPath(); - } catch (IOException x) { - throw new RuntimeException(x); - } - binaries = findBinaries(path, name); - - pkg = ClassGenerator.JOBJC_PACKAGE + "." + name.toLowerCase(); - try { - rootNode = (Node)XPATH.evaluate("signatures", new InputSource(bsFile.getAbsolutePath()), XPathConstants.NODE); - } catch (final XPathExpressionException e) { throw new RuntimeException(e); } - protocols = new ArrayList(); - categories = new ArrayList(); - } - - private static List findBinaries(final String rootPath, final String name){ - List bins = new ArrayList(2); - - File mainBin = new File(rootPath, name); - if(mainBin.exists()) bins.add(mainBin); - - File bsBin = new File(rootPath, "Resources/BridgeSupport/" + name + ".dylib"); - if(bsBin.exists()) bins.add(bsBin); - - return bins; - } - - public void parseDependencies(final Collection frameworks) { - // Parse - dependencies = getNodesFor(rootNode, "depends_on", FrameworkDependency.class, this); - // Resolve - for(final FrameworkDependency dep : dependencies) - dep.object = Fp.find(new Map1(){ - public Boolean apply(Framework f) { - return f.path.equals(dep.path); - }}, frameworks); - } - - public void parseStructs() { - structs = getNodesFor(rootNode, "struct", Struct.class, this); - - // HACK BS bug #6100313 - if(Utils.isSnowLeopard && name.equals("IOBluetooth")) - structs.remove(getStructByName("BluetoothHCIRequestNotificationInfo")); - - // GLIFunctionDispatch is frequently out of sync in BS / system - if(name.equals("OpenGL")) - structs.remove(getStructByName("GLIFunctionDispatch")); - } - - public void parseCFTypes() { - cfTypes = getNodesFor(rootNode, "cftype", CFType.class, this); - } - - public void parseOpaques() { - opaques = getNodesFor(rootNode, "opaque", Opaque.class, this); - } - - public void parseConstants() { - constants = getNodesFor(rootNode, "constant", Constant.class, this); - stringConstants = getNodesFor(rootNode, "string_constant", StringConstant.class, this); - enums = getNodesFor(rootNode, "enum", NativeEnum.class, this); - } - - public void parseFunctions() { - functions = getNodesFor(rootNode, "function", Function.class, this); - functionAliases = getNodesFor(rootNode, "function_alias", FunctionAlias.class, this); - } - - public void parseClasses() { - classes = new HashSet(getNodesFor(rootNode, "class", Clazz.class, this)); - classes = Fp.filterSet(new Map1(){ - public Boolean apply(Clazz a) { - if(a.doesActuallyExist()) - return true; - else{ - System.out.println("Could not find class " + name + ":" + a.name + " in runtime. Discarding."); - return false; - } - }}, classes); - informalProtocols = getNodesFor(rootNode, "informal_protocol", InformalProtocol.class, this); - } - - public void resolveSuperClasses(final Map allClasses) throws Throwable { - load(); - for (final Clazz clazz : classes) - clazz.resolveSuperClass(nativeFramework, allClasses); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new FrameworkClassFile(this)); - - final List> generatorLists = - Utils.list(new ArrayList(classes), structs, cfTypes, opaques, categories); - for (final List generators : generatorLists) { - for (final OutputFileGenerator generator : generators) - generator.generateClasses(generatedClassFiles); - } - } - - @Override public String toString() { return reflectOnMySelf(); } - - public Struct getStructByName(final String stname) { - return Fp.find(new Fp.Map1(){ - public Boolean apply(Struct a) { - return stname.equals(a.name); - }}, structs); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Function.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Function.java deleted file mode 100644 index c08d99925e9..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Function.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import java.util.*; - -import org.w3c.dom.*; - -import com.apple.internal.jobjc.generator.RestrictedKeywords; - -public class Function extends Element { - public final boolean variadic; - public final List args; - public final ReturnValue returnValue; - - public Function(final Node node, final Framework parent) { - this(node, getAttr(node, "name"), parent); - } - - public Function(final Node node, final String name, final Framework parent) { - super(name, parent); - - this.variadic = "true".equals(getAttr(node, "variadic")); - this.args = new ArrayList(); - - ReturnValue returnValue = null; - - final NodeList children = node.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - final Node child = children.item(i); - final String childName = child.getLocalName(); - - if ("retval".equals(childName)) { - returnValue = new ReturnValue(child, this); - } - - if ("arg".equals(childName)) { - final Arg arg = new Arg(child, this); - if (arg.name == null || "".equals(arg.name)) { - arg.javaName = "arg" + i; - } - args.add(arg); - } - } - - if (returnValue == null) returnValue = ReturnValue.VOID; - this.returnValue = returnValue; - } - - public String getJavaName(){ return name; } - - public void disambiguateArgs() { - final Set priorArgs = RestrictedKeywords.getNewRestrictedSet(); - for (int i = 0; i < args.size(); i++) { - final Arg arg = args.get(i); - if (priorArgs.contains(arg.name)) arg.javaName = arg.javaName + i; - priorArgs.add(arg.javaName); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/FunctionAlias.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/FunctionAlias.java deleted file mode 100644 index 641d5b5c92d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/FunctionAlias.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class FunctionAlias extends Element { - public FunctionAlias(final Node node, final Framework parent) { - super(node, parent); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/InformalProtocol.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/InformalProtocol.java deleted file mode 100644 index 8213e7d1b2c..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/InformalProtocol.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class InformalProtocol extends Element { - public InformalProtocol(final Node node, final Framework parent) { - super(node, parent); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Method.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Method.java deleted file mode 100644 index a1099078a4d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Method.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import java.util.Set; -import org.w3c.dom.Node; -import com.apple.jobjc.SEL; -import com.apple.internal.jobjc.generator.Utils; - -public class Method extends Function { - public final boolean isClassMethod; - - public String javaName; - - public boolean ignore; - public String suggestion; - - public Method(final Node node, final Framework fw) { - super(node, getAttr(node, "selector"), fw); - this.javaName = SEL.jMethodName(name); - this.isClassMethod = "true".equals(getAttr(node, "class_method")); - this.ignore = "true".equals(getAttr(node, "ignore")); - this.suggestion = getAttr(node, "suggestion"); - } - - @Override public String getJavaName(){ return javaName; } - - @Override public String toString() { - return returnValue + " " + super.toString() + args; - } - - public boolean returnTypeEquals(final ReturnValue returnValueIn) { - return returnValue.type.getJType().getJavaReturnTypeName().equals(returnValueIn.type.getJType().getJavaReturnTypeName()); - } - - public void disambiguateNameAndArgs(final Clazz parentClazz, final Set existingMethodNames) { - javaName = getDisambiguatedNameFor(parentClazz, javaName, existingMethodNames); - disambiguateArgs(); - } - - private String getDisambiguatedNameFor(final Clazz parentClazz, final String proposedName, final Set existingNames) { - // Does this method override a parent class method and change the return type? Example: IOBlueToothSDPUUID length - { - final Method superClassMethod = parentClazz.getParentMethodMatchingName(proposedName); - if (superClassMethod != null && !superClassMethod.returnValue.equals(returnValue)) { - final String usingReturnType = createMethodNameAppendingReturnType(proposedName); - if(existingNames.add(usingReturnType)) - return usingReturnType; - } - } - - if(existingNames.add(proposedName)) - return proposedName; - - final String usingReturnType = createMethodNameAppendingReturnType(proposedName); - if(existingNames.add(usingReturnType)) - return usingReturnType; - - throw new RuntimeException("Unable to disambiguate method: " + this); - } - - private String createMethodNameAppendingReturnType(final String proposedName) { - return proposedName + Utils.capitalize(returnValue.type.getJType().getAppendableDescription().replaceAll(".+\\.", "")); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/NativeEnum.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/NativeEnum.java deleted file mode 100644 index e6bbd9b0652..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/NativeEnum.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import java.util.Arrays; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.model.types.JType.JPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.jobjc.JObjCRuntime; - -public class NativeEnum extends ElementWType { - public final String value, value64, le_value, be_value; - public boolean ignore; - public String suggestion; - public NativeEnum(final Node node, final Framework parent) { - super(node, typeForEnum(getAttr(node, "name"), - getAttr(node, "value"), getAttr(node, "value64"), - getAttr(node, "le_value"), getAttr(node, "be_value"), - getAttr(node, "ignore")), parent); - this.value = getAttr(node, "value"); - this.value64 = getAttr(node, "value64"); - this.le_value = getAttr(node, "le_value"); - this.be_value = getAttr(node, "be_value"); - String ignoreS = getAttr(node, "ignore"); - this.ignore = ignoreS == null ? false : Boolean.parseBoolean(ignoreS); - this.suggestion = getAttr(node, "suggestion"); - assert valueToString() != null; - } - - private static Type typeForEnum(String name, String value32, String value64, String le_value, String be_value, String ignore){ - if("true".equals(ignore)) return Type.getType(null, NPrimitive.inst('i'), null); - - NumTest[] tests = new NumTest[]{new IntTest(), new LongTest(), new FloatTest(), new DoubleTest()}; - for(NumTest t : tests) - if(t.confirm(value32, value64, le_value, be_value)) - return t.getType(); - - throw new NumberFormatException(String.format("Failed to parse type for enum: %1$s = 32: %2$s / 64: %3$s / le: %4$s / be: %5$s\n", - name, value32, value64, le_value, be_value)); - } - - public String valueToString(){ - if(ignore == true) return "0"; - JPrimitive jprim = (JPrimitive) type.getJType(); - if(le_value == null && be_value == null){ - if(value == null && value64 != null) - return value64 + jprim.getLiteralSuffix(); - else if(value != null && value64 == null) - return value + jprim.getLiteralSuffix(); - else - return String.format("(%1$s.IS64 ? %2$s%4$s : %3$s%4$s)", JObjCRuntime.class.getName(), - value64, value, jprim.getLiteralSuffix()); - } - else if(value == null && value64 == null){ - return String.format("(%1$s.IS_BIG_ENDIAN ? %2$s%4$s : %3$s%4$s)", - JObjCRuntime.class.getName(), be_value, le_value, jprim.getLiteralSuffix()); - } - - throw new RuntimeException("Unable to produce a value for enum " + name); - } - - // Used to find the best type to use for the enum. - - static abstract class NumTest{ - public boolean confirm(String... values){ - return Fp.all(new Fp.Map1(){ - public Boolean apply(String a) { - try{ return a == null || confirm(a); } - catch(Exception x){ return false; } - }}, - Arrays.asList(values)); - } - - public abstract boolean confirm(String v); - public abstract Type getType(); - } - - static class IntTest extends NumTest{ - @Override public boolean confirm(String v) { - Integer.parseInt(v); - return true; - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('i'), null); } - } - - static class LongTest extends NumTest{ - @Override public boolean confirm(String v) { - Long.parseLong(v); - return true; - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('l'), null); } - } - - static class FloatTest extends NumTest{ - @Override public boolean confirm(String v) { - return Float.parseFloat(v) == Double.parseDouble(v); - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('f'), null); } - } - - static class DoubleTest extends NumTest{ - @Override public boolean confirm(String v) { - double d = Double.parseDouble(v); - return !Double.isInfinite(d) && !Double.isNaN(d); - } - - @Override public Type getType() { return Type.getType(null, NPrimitive.inst('d'), null); } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ReturnValue.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ReturnValue.java deleted file mode 100644 index 320f55a086a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/ReturnValue.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.model.types.Type; - -public class ReturnValue extends ElementWType{ - public static ReturnValue VOID = new ReturnValue(Type.VOID); - - public ReturnValue(final Node node, final Function parent) { - super(node, parent); - } - - public ReturnValue(Type type) { - super("return value", type, null); // TODO bad style, the null might lead to trouble - } - - @Override public boolean equals(Object o){ - return o instanceof ReturnValue && type.equals(((ReturnValue)o).type); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/StringConstant.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/StringConstant.java deleted file mode 100644 index acfbc6ab4a7..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/StringConstant.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import org.w3c.dom.Node; - -public class StringConstant extends Element { - public final String value; - - public StringConstant(final Node node, final Framework parent) { - super(node, parent); - this.value = getAttr(node, "value"); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Struct.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Struct.java deleted file mode 100644 index b583cdbf59c..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Struct.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model; - -import java.util.List; - -import org.w3c.dom.Node; - -import com.apple.internal.jobjc.generator.classes.OutputFile; -import com.apple.internal.jobjc.generator.classes.StructClassFile; -import com.apple.internal.jobjc.generator.model.types.Type; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.QA; -import com.apple.internal.jobjc.generator.utils.Fp.Map2; - -/** - * A struct has the following restrictions: - * - * - type32.fields.count == type64.fields.count - * - forAll i: type32.field[i].name == type64.field[i].name - * - forAll i: type32.field[i].class == type64.field[i].class - */ -public class Struct extends TypeElement implements OutputFileGenerator { - public final List fields; - public static class Field{ - public final String name; - public final Type type; - public final NField field32, field64; - public Field(String name, NField field32, NField field64) { - QA.nonNull(name); - this.name = name; - // TODO really should have a declared_type attr. See if BS patch is possible. - this.type = Type.getType(null, field32.type, field64.type); - this.field32 = field32; - this.field64 = field64; - } - } - - public Struct(final Node node, final Framework parent) throws Throwable { - super(node, getAttr(node, "name"), parent); - NStruct nstruct32 = (NStruct) type.type32; - NStruct nstruct64 = (NStruct) type.type64; - this.fields = Fp.map2(new Map2(){ - public Field apply(NField f32, NField f64) { - assert f32.name.equals(f64.name); - return new Field(f32.name, f32, f64); - } - }, nstruct32.fields, nstruct64.fields); - } - - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new StructClassFile(this)); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/CoderDescriptor.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/CoderDescriptor.java deleted file mode 100644 index b7a734fa975..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/CoderDescriptor.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model.coders; - -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.jobjc.Coder; -import com.apple.jobjc.Coder.IDCoder; -import com.apple.jobjc.Coder.NSClassCoder; -import com.apple.jobjc.Coder.PointerCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.SELCoder; -import com.apple.jobjc.Coder.UnknownCoder; -import com.apple.jobjc.Coder.VoidCoder; - -public class CoderDescriptor { - public static final CoderDescriptor VOID_DESC = new CoderDescriptor(VoidCoder.INST, null, null); - - final Coder coder; - private final String coderInstanceName; - final String pushName; - final String popName; - - public String mismatchMessage(){ return null; } - - public CoderDescriptor(final Coder coder, final String pushName, final String popName) { - this.coder = coder; - this.coderInstanceName = coder.getClass().getCanonicalName() + ".INST"; - if (coderInstanceName == null) throw new NullPointerException(); - - this.pushName = pushName; - this.popName = popName; - } - - public CoderDescriptor(final String pushName, final String popName) { - this.coder = null; - this.coderInstanceName = null; - this.pushName = pushName; - this.popName = popName; - } - - public CoderDescriptor(final Coder coder) { this(coder, "push", "pop"); } - public CoderDescriptor(){ this("push", "pop"); } - - public String getPopStatementFor(final String contextName, final String returnValueType, final String returnValueName, final String transform) { - return "final " + returnValueType + " " + returnValueName + " = " + "(" + returnValueType + ") " + (transform == null ? "" : transform) - + "(" + getCoderInstanceName() + "." + popName + "(" + contextName + "));"; - } - - public final String getPushStatementFor(final String contextName, final String argumentName) { - return getCoderInstanceName() + "." + pushName + "(" + contextName + ", " + argumentName + ");"; - } - - public String getPopAddrStatementFor(final String runtime, final String addr, final String returnValueType, final String returnValueName, final String transform) { - return "final " + returnValueType + " " + returnValueName + " = " + "(" + returnValueType + ") " + (transform == null ? "" : transform) - + "(" + getCoderInstanceName() + "." + popName + "(" + runtime + ", " + addr + "));"; - } - - public final String getPushAddrStatementFor(final String runtime, final String addr, final String argumentName) { - return getCoderInstanceName() + "." + pushName + "(" + runtime + ", " + addr + ", " + argumentName + ");"; - } - - public String getCoderInstanceName() { return coderInstanceName; } - public Coder getCoder() { return coder; } - public String getDefaultReturnValue() { return "null"; } - - // - // Specialized - // - - static public class UnknownCoderDescriptor extends CoderDescriptor { - public static final CoderDescriptor UNKNOWN_DESC = new UnknownCoderDescriptor(); - public UnknownCoderDescriptor() { super(UnknownCoder.INST); } - } - - static public class PrimitivePointerCoderDescriptor extends CoderDescriptor { - public static final PrimitivePointerCoderDescriptor POINTER_DESC = new PrimitivePointerCoderDescriptor(); - public PrimitivePointerCoderDescriptor() { super(PrimitivePointerCoder.INST, "push", "popPtr"); } - } - - static public class PointerCoderDescriptor extends CoderDescriptor { - public static final PointerCoderDescriptor INST = new PointerCoderDescriptor(); - public PointerCoderDescriptor() { super(PointerCoder.INST); } - } - - static public class SELCoderDescriptor extends CoderDescriptor { - public static final SELCoderDescriptor INST = new SELCoderDescriptor(); - public SELCoderDescriptor() { super(SELCoder.INST); } - } - - static public class IDCoderDescriptor extends CoderDescriptor { - public static final IDCoderDescriptor INST = new IDCoderDescriptor(); - public IDCoderDescriptor() { super(IDCoder.INST); } - } - - static public class NSClassCoderDescriptor extends CoderDescriptor { - public static final NSClassCoderDescriptor INST = new NSClassCoderDescriptor(); - public NSClassCoderDescriptor() { super(NSClassCoder.INST); } - } - - static public class StructCoderDescriptor extends CoderDescriptor { - public final JStruct jstruct; - public StructCoderDescriptor(JStruct jst) { this.jstruct = jst; } - @Override public String getCoderInstanceName(){ return jstruct.getJavaTypeName() + ".getStructCoder()"; } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/ComplexCoderDescriptor.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/ComplexCoderDescriptor.java deleted file mode 100644 index 929b0744ec3..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/ComplexCoderDescriptor.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model.coders; - -import java.util.HashMap; -import java.util.TreeSet; -import java.util.Map; -import java.util.Set; - -import com.apple.internal.jobjc.generator.classes.MixedPrimitiveCoderClassFile; -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; -import com.apple.jobjc.JObjCRuntime; - -/** - * Used to code two primitives of different 32/64 types. - */ -public class ComplexCoderDescriptor extends CoderDescriptor { - static Map, ComplexCoderDescriptor> cache = new HashMap, ComplexCoderDescriptor>(); - static Set mixedEncodingDescriptors = new TreeSet(); - - public static Set getMixedEncoders() { return mixedEncodingDescriptors; } - - public static ComplexCoderDescriptor getCoderDescriptorFor(final NType nt32, final NType nt64) { - Pair cacheKey = new Pair(nt32, nt64); - if(cache.containsKey(cacheKey)) return cache.get(cacheKey); - - final PrimitiveCoderDescriptor desc32 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt32); - final PrimitiveCoderDescriptor desc64 = PrimitiveCoderDescriptor.getCoderDescriptorFor((NPrimitive) nt64); - - final ComplexCoderDescriptor newDesc = nt32.equals(nt64) ? new ComplexCoderDescriptor(desc64) : new MixedEncodingDescriptor(desc32, desc64); - cache.put(cacheKey, newDesc); - if(newDesc instanceof MixedEncodingDescriptor) - mixedEncodingDescriptors.add((MixedEncodingDescriptor) newDesc); - - return newDesc; - } - - protected final PrimitiveCoderDescriptor desc64; - - public ComplexCoderDescriptor(final PrimitiveCoderDescriptor desc64) { - super(desc64.coder, desc64.pushName, desc64.popName); - this.desc64 = desc64; - } - - public String getName() { return desc64.javaPrimitiveClazz.getName(); } - @Override public String getDefaultReturnValue() { return desc64.defaultReturnValue; } - public String getJavaObjectClass() { return desc64.javaObjectClazz.getName(); } - public String getDefinition() { return get64CoderName(); } - public String getCoderAccessor() { return get64CoderName(); } - String get64CoderName() { return desc64.getCoderInstanceName(); } - - // ** Subclasses - // ------------- - - public static class MixedEncodingDescriptor extends ComplexCoderDescriptor implements java.lang.Comparable { - protected final PrimitiveCoderDescriptor desc32; - - public MixedEncodingDescriptor(final PrimitiveCoderDescriptor desc32, final PrimitiveCoderDescriptor desc64) { - super(desc64); - this.desc32 = desc32; - } - - @Override public String getDefinition() { return JObjCRuntime.class.getName() + ".IS64 ? " + get64CoderName() + " : " + get32CoderName(); } - @Override public String getCoderAccessor() { return MixedPrimitiveCoderClassFile.FULL_MULTI_CODER_CLASSNAME + "." + getMixedName(); } - String get32CoderName() { return desc32.getCoderInstanceName(); } - @Override public String getCoderInstanceName(){ return getCoderAccessor(); } - @Override public String toString() { return getMixedName(); } - - public String getMixedName() { - final String coder32Name = getBaseNameOfCoder(desc32.primitiveCoderName); - final String coder64Name = getBaseNameOfCoder(desc64.primitiveCoderName); - return coder32Name + coder64Name + "Coder"; - } - - static String getBaseNameOfCoder(final String coderName) { return coderName.substring(0, coderName.indexOf("Coder")); } - public int compareTo(Object _o) { MixedEncodingDescriptor o = (MixedEncodingDescriptor)_o; return getMixedName().compareTo(o.getMixedName()); } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/PrimitiveCoderDescriptor.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/PrimitiveCoderDescriptor.java deleted file mode 100644 index 82684415120..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/coders/PrimitiveCoderDescriptor.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model.coders; - -import java.util.HashMap; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.jobjc.Coder; -import com.apple.jobjc.PrimitiveCoder; -import com.apple.jobjc.PrimitiveCoder.BoolCoder; -import com.apple.jobjc.PrimitiveCoder.SCharCoder; -import com.apple.jobjc.PrimitiveCoder.SIntCoder; -import com.apple.jobjc.PrimitiveCoder.SLongCoder; -import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; -import com.apple.jobjc.PrimitiveCoder.SShortCoder; -import com.apple.jobjc.PrimitiveCoder.UCharCoder; -import com.apple.jobjc.PrimitiveCoder.UIntCoder; -import com.apple.jobjc.PrimitiveCoder.ULongCoder; -import com.apple.jobjc.PrimitiveCoder.ULongLongCoder; -import com.apple.jobjc.PrimitiveCoder.UShortCoder; -import com.apple.internal.jobjc.generator.Utils; - -public class PrimitiveCoderDescriptor extends CoderDescriptor { - static Map descriptors = new HashMap(); - - public static PrimitiveCoderDescriptor getCoderDescriptorFor(NPrimitive nt) { - return getCoderDescriptorFor(nt.type); - } - - public static PrimitiveCoderDescriptor getCoderDescriptorFor(char c) { - final PrimitiveCoderDescriptor desc = descriptors.get(c); - if (desc != null) return desc; - final PrimitiveCoderDescriptor newDesc = createCoderDescriptorFor(c); - descriptors.put(c, newDesc); - return newDesc; - } - - public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) { - switch(encoding) { - case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false"); - - case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0"); - case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0"); - - case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0"); - case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0"); - - case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0"); - case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0"); - - case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0"); - case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long."); - case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0"); - case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long."); - - case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0"); - case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0"); - default: throw new RuntimeException("unknown encoding: " + encoding); - } - } - - public final Class javaPrimitiveClazz; - final Class javaObjectClazz; - final String defaultReturnValue; - final String primitiveCoderName; - final String _mismatchMessage; - - public PrimitiveCoderDescriptor(final Coder coder, final String defaultRetVal) { - this(coder, defaultRetVal, null); - } - - public PrimitiveCoderDescriptor(final Coder coder, - final String defaultReturnValue, final String mismatchMessage) { - super(coder, "push", "pop" + Utils.capitalize(coder.getJavaPrimitive().getSimpleName())); - this.javaPrimitiveClazz = coder.getJavaPrimitive(); - this.javaObjectClazz = coder.getJavaClass(); - this.defaultReturnValue = defaultReturnValue; - this.primitiveCoderName = coder.getClass().getSimpleName(); - this._mismatchMessage = mismatchMessage; - } - - @Override public PrimitiveCoder getCoder(){ return (PrimitiveCoder) super.getCoder(); } - @Override public String mismatchMessage(){ return _mismatchMessage; } - @Override public String getDefaultReturnValue() { return defaultReturnValue; } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/JType.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/JType.java deleted file mode 100644 index 56e0f4b2386..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/JType.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model.types; - -import com.apple.internal.jobjc.generator.classes.RootJObjCClass; -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.IDCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.NSClassCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.PointerCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.SELCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.StructCoderDescriptor; -import com.apple.internal.jobjc.generator.model.coders.CoderDescriptor.UnknownCoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.jobjc.ID; -import com.apple.jobjc.NSClass; -import com.apple.jobjc.NativeArgumentBuffer; -import com.apple.jobjc.Pointer; -import com.apple.jobjc.SEL; - -public abstract class JType { - public abstract String getJavaTypeName(); - public String getJavaClassName() { return getJavaTypeName().substring(getJavaTypeName().lastIndexOf('.') + 1); } - public String getJavaReturnTypeName() { return getJavaTypeName(); } - public String getReturnTypeCast() { return null; } - public String getTypeNameAsParam() { return getJavaTypeName(); } - - public abstract CoderDescriptor getCoderDescriptor(); - public String getDefaultReturnValue() { return "null"; } - public String getAppendableDescription() { return getJavaTypeName().substring(getJavaTypeName().lastIndexOf('.') + 1); } - - /** - * Used for primitive types (like int) that can't be used as generic arguments. This returns an appropriate Java class (like Integer). - */ - public JType getParameterizableType() { return this; } - - // - // Writer ops - // - - public String createDeclareBuffer(String contextName) { - return "final " + NativeArgumentBuffer.class.getName() + " " + contextName + " = getRuntime().getThreadLocalState();"; - } - - public String createInit(final String contextName, final String functionIdentifier, final String initWithObj) { - return functionIdentifier + ".init(" + contextName + (initWithObj != null ? ", " + initWithObj : "") + ");"; - } - - public String createInvoke(final String contextName, final String functionIdentifier) { - return functionIdentifier + ".invoke(" + contextName + ");"; - } - - public String createPop(final String contextName) { - return getCoderDescriptor().getPopStatementFor(contextName, getJavaTypeName(), "returnValue", null); - } - - public String createPopAddr(final String runtime, final String addr) { - return getCoderDescriptor().getPopAddrStatementFor(runtime, addr, getJavaTypeName(), "returnValue", null); - } - - public String createReturn() { - final String preCast = getReturnTypeCast(); - return "return " + (preCast == null ? "" : "(" + preCast + ")") + "returnValue;"; - } - - // - // Specialized - // - - static public class JUnknown extends JType { - final Type type; - protected JUnknown(final Type type) { - this.type = type; - TypeCache.inst().getUnknownTypes().add(type); - } - @Override public String getJavaTypeName() { return "Object /* " + type + " */"; } - @Override public String getAppendableDescription() { return "Unknown"; } - @Override public CoderDescriptor getCoderDescriptor() { return UnknownCoderDescriptor.UNKNOWN_DESC; } - } - - static class JVoid extends JType { - public static JVoid INST = new JVoid(); - @Override public String getJavaTypeName() { return "Void"; } - @Override public String getJavaReturnTypeName() { return "void"; } - @Override public CoderDescriptor getCoderDescriptor(){ return CoderDescriptor.VOID_DESC; } - @Override public String createPop(final String contextName){ return ""; } - @Override public String createReturn(){ return ""; } - }; - - static class JSelector extends JType { - public static JSelector INST = new JSelector(); - @Override public String getJavaTypeName() { return SEL.class.getName(); } - @Override public CoderDescriptor getCoderDescriptor() { return SELCoderDescriptor.INST; } - }; - - static class JCFType extends JType{ - final CFType cfType; - public JCFType(final CFType cfType){ this.cfType = cfType; } - @Override public String getJavaTypeName() { return cfType.parent.pkg + "." + cfType.name + "CFType"; } - @Override public CoderDescriptor getCoderDescriptor() { return PointerCoderDescriptor.INST; } - @Override public String createPop(final String contextName) { - return "\t\t" + getCoderDescriptor().getPopStatementFor(contextName, getJavaReturnTypeName(), "returnValue", "new " + getJavaTypeName()); - } - } - - static class JOpaque extends JType{ - final Opaque opaque; - public JOpaque(final Opaque opaque){ this.opaque = opaque; } - @Override public String getJavaTypeName() { return opaque.parent.pkg + "." + opaque.name + "Opaque"; } - @Override public CoderDescriptor getCoderDescriptor() { return PointerCoderDescriptor.INST; } - @Override public String createPop(final String contextName) { - return "\t\t" + getCoderDescriptor().getPopStatementFor(contextName, getJavaReturnTypeName(), "returnValue", "new " + getJavaTypeName()); - } - } - - static class JPointer extends JType { - static JType VOID_PTR = new JPointer(JVoid.INST); - - final JType subject; - protected JPointer(final JType javaType) { this.subject = javaType; } - - @Override public String getJavaTypeName() { return Pointer.class.getName() + "<" + subject.getParameterizableType().getJavaTypeName() + ">"; } - @Override public String getAppendableDescription() { return "PointerTo" + subject.getAppendableDescription(); } - @Override public CoderDescriptor getCoderDescriptor() { return PointerCoderDescriptor.INST; } - } - - static class JObject extends JType { - public static JType ID_TYPE = new JType() { - @Override public String getJavaTypeName() { return ID.class.getName(); } - @Override public String getJavaReturnTypeName() { return " T"; } - @Override public String getReturnTypeCast() { return "T"; } - @Override public CoderDescriptor getCoderDescriptor() { return IDCoderDescriptor.INST; } - }; - - final Type type; - final Clazz clazz; - - public JObject(final Type type, final Clazz clazz) { - this.type = type; - this.clazz = clazz; - } - - @Override public String getJavaTypeName() { return clazz.getFullPath();} - @Override public CoderDescriptor getCoderDescriptor() { return IDCoderDescriptor.INST; } - } - - static class JClass extends JType { - public static JClass INST = new JClass(); - @Override public String getJavaTypeName() { return NSClass.class.getName(); } - @Override public String getJavaReturnTypeName() { return " T"; } - @Override public String getTypeNameAsParam() { return super.getTypeNameAsParam(); } - @Override public String getReturnTypeCast() { return "T"; } - @Override public CoderDescriptor getCoderDescriptor() { return NSClassCoderDescriptor.INST; } - }; - - public static class JStruct extends JType { - public final Struct struct; - public JStruct(final Struct struct) { this.struct = struct; } - - @Override public String getJavaTypeName() { return struct.parent.pkg + "." + struct.name; } - @Override public String getJavaReturnTypeName() { return getJavaTypeName(); } - - StructCoderDescriptor coderDescriptor = new StructCoderDescriptor(this); - @Override public CoderDescriptor getCoderDescriptor() { return coderDescriptor; } - - public String createReturnValue() { - return "\t\t" + getJavaReturnTypeName() + " returnValue = " + RootJObjCClass.runtimeFrameworkInstR(struct.parent.name) - + ".make" + struct.name + "();"; - } - - @Override public String createInvoke(final String contextName, final String functionIdentifier) { - return createReturnValue() + "\n\t\t" + functionIdentifier + ".invoke(" + contextName + ", returnValue);"; - } - - @Override public String createPop(final String contextName){ return ""; } - } - - public static class JPrimitive extends JType { - final Type type; - final ComplexCoderDescriptor coderDescriptor; - final JType parameterizable; - - public JPrimitive(final Type type, final ComplexCoderDescriptor coderDesc) { - this.type = type; - this.coderDescriptor = coderDesc; - - this.parameterizable = new JType() { - @Override public String getJavaTypeName() { return coderDescriptor.getJavaObjectClass(); } - @Override public CoderDescriptor getCoderDescriptor() { throw new RuntimeException(); } - }; - } - - @Override public String getJavaTypeName() { return coderDescriptor.getName(); } - @Override public String getDefaultReturnValue() { return coderDescriptor.getDefaultReturnValue(); } - @Override public JType getParameterizableType() { return parameterizable; } - @Override public CoderDescriptor getCoderDescriptor() { return coderDescriptor; } - - /** - * Return the suffix placed on java literals to indicate the type. If none applies, return ' '. - */ - public char getLiteralSuffix() { - char t = ((NPrimitive)type.type64).type; - switch(t){ - case 'l': case 'L': case 'f': case 'd': return t; - case 'q': case 'Q': return 'L'; - } - return ' '; - } - } - -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/NType.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/NType.java deleted file mode 100644 index 3c6d644eece..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/NType.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model.types; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.model.coders.PrimitiveCoderDescriptor; -import com.apple.internal.jobjc.generator.utils.Fp; -import com.apple.internal.jobjc.generator.utils.NTypePrinter; -import com.apple.internal.jobjc.generator.utils.QA; -import com.apple.jobjc.JObjCRuntime.Width; - -/** - * NType (Native Type) bridges the type and type64 attributes in BridgeSupport. - * - * For example: - * - *

- *   type="c"                 // BridgeSupport attribute
- *   (NPrimitive type: 'c')   // Java object (in sexp form here, for readability)
- *
- *   type="^v"
- *   (NPointer subject: (NVoid))
- *
- *   type="{foo_t="a"c"b"b8"c"[32^v]}"
- *   (NStruct
- *     name: "foo_t"
- *     fields:
- *       (List
- *         0: (NField name:"a" type: (NPrimitive type: 'c'))
- *         1: (NField name:"b" type: (NBitfield size: 8))
- *         2: (NField name:"c" type:
- *              (NArray size: 32
- *                      type: (NPointer subject: (NVoid))))))
- * 
- */ -public abstract class NType implements Comparable{ - public final Map sizeof; - - public NType(Map sizeof) { - this.sizeof = sizeof; - } - - public NType(){ - this(new HashMap()); - } - - public NType(int sz32, int sz64){ - this(); - this.sizeof.put(Width.W32, sz32); - this.sizeof.put(Width.W64, sz32); - } - - public int sizeof32(){ return sizeof.get(Width.W32); } - public int sizeof64(){ return sizeof.get(Width.W64); } - - protected abstract boolean equals2(NType nt); - - private String _toString; - @Override public String toString(){ return _toString != null ? _toString : (_toString = NTypePrinter.inst().print(this)); } - @Override public boolean equals(Object o) { - return o!=null && (o==this || (getClass().isInstance(o) - && this.sizeof.equals(((NType) o).sizeof) - && equals2((NType) o))); - } - public int compareTo(NType o){ return toString().compareTo(o.toString()); } - - // ** NType subclasses - // ------------------- - - public static class NBitfield extends NType{ - public final int length; - - public NBitfield(int length){ - super(-1, -1); - this.length = length; - } - - @Override protected boolean equals2(NType nt) { return ((NBitfield) nt).length == length; } - @Override public int hashCode() { return Integer.valueOf(length).hashCode(); } - } - - public static class NPrimitive extends NType{ - public static Collection CODES = Arrays.asList( - 'B', 'c', 'C', 's', 'S', 'i', 'I', 'l', 'L', 'q', 'Q', 'f', 'd'); - - public final char type; - - protected NPrimitive(char c){ - super(PrimitiveCoderDescriptor.createCoderDescriptorFor(c).getCoder().sizeof(Width.W32), - PrimitiveCoderDescriptor.createCoderDescriptorFor(c).getCoder().sizeof(Width.W64)); - type = c; - } - private static final Map cache = new HashMap(); - public static final NPrimitive inst(final char c){ - if(!cache.containsKey(c)) cache.put(c, new NPrimitive(c)); - return cache.get(c); - } - - @Override protected boolean equals2(NType nt) { return ((NPrimitive)nt).type == type; } - @Override public int hashCode() { return Character.valueOf(type).hashCode(); } - } - - public static class NVoid extends NType{ - protected NVoid(){ super(); } - private final static NVoid INST = new NVoid(); - public static NVoid inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true; } - } - - public static class NPointer extends NType{ - public final NType subject; - - public NPointer(NType subject){ - super(4, 8); - QA.nonNull(subject); - this.subject = subject; - } - - @Override protected boolean equals2(NType nt) { return ((NPointer)nt).subject.equals(subject); } - @Override public int hashCode() { return subject.hashCode(); } - } - - public static class NObject extends NType{ - protected NObject(){ super(4, 8); } - private final static NObject INST = new NObject(); - public static NObject inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true; } - } - - public static class NClass extends NType{ - protected NClass(){ super(4, 8); } - private final static NClass INST = new NClass(); - public static NClass inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true; } - } - - public static class NSelector extends NType{ - protected NSelector(){ super(4, 8); } - private final static NSelector INST = new NSelector(); - public static NSelector inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true;} - } - - public static class NField{ - public final Map offset; - public final String name; - public final NType type; - - public NField(String name, NType type, Map offset) { - QA.nonNull(name, type, offset); - this.name = name; - this.type = type; - this.offset = offset; - } - - public NField(String name, NType type) { - this(name, type, new HashMap()); - } - - public int offset32(){ return offset.get(Width.W32); } - public int offset64(){ return offset.get(Width.W64); } - - @Override public int hashCode() { return name.hashCode() + type.hashCode(); } - @Override public boolean equals(Object o) { - return o!=null && (o==this || - (o instanceof NField - && this.offset.equals(((NField) o).offset) - && ((NField) o).name.equals(this.name) - && ((NField) o).type.equals(this.type))); - } - } - - public static class NStruct extends NType{ - public final String name; - public final List fields; - - public NStruct(String name, List fields, Map sizeof){ - super(sizeof); - QA.nonNull(name, fields); - this.name = name; - this.fields = fields; - } - - public NStruct(String name, List fields){ - super(); - QA.nonNull(name, fields); - this.name = name; - this.fields = fields; - } - - @Override protected boolean equals2(NType nt) { - return ((NStruct)nt).name.equals(name) && ((NStruct)nt).fields.equals(fields); - } - - @Override public int hashCode() { return name.hashCode() + fields.hashCode(); } - } - - // A Union is like a Struct, but the offset of every field is 0. - public static class NUnion extends NStruct{ - public NUnion(String concreteName, List fields){ - super(concreteName, fields); - assert Fp.all(hasZeroOffsets, fields) : Utils.joinWComma(fields); - } - - public NUnion(String name, List fields, Map sizeof) { - super(name, fields, sizeof); - assert Fp.all(hasZeroOffsets, fields) : Utils.joinWComma(fields); - } - - public static final Fp.Map1 hasZeroOffsets = new Fp.Map1(){ - public Boolean apply(NField a) { - for(int i : a.offset.values()) - if(i != 0) - return false; - return true; - }}; - public static final Fp.Map1 zeroOffsets = new Fp.Map1(){ - public NField apply(NField a) { - Map off = new HashMap(); - for(Width w : a.offset.keySet()) - off.put(w, 0); - return new NField(a.name, a.type, off); - }}; - } - - public static class NArray extends NType{ - public final int length; - public final NType type; - - public NArray(int length, NType type){ - QA.nonNull(type); - this.length = length; - this.type = type; - } - - @Override protected boolean equals2(NType nt) { return ((NArray)nt).length == length && ((NArray)nt).type.equals(type); } - @Override public int hashCode(){ return Long.valueOf(length).hashCode() + type.hashCode(); } - } - - // Seems to be used for callbacks - public static class NUnknown extends NType{ - protected NUnknown(){ super(); } - private final static NUnknown INST = new NUnknown(); - public static NUnknown inst() { return INST; } - - @Override protected boolean equals2(NType nt) { return true;} - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/Type.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/Type.java deleted file mode 100644 index 740e68154b2..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/Type.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model.types; - -import java.util.ArrayList; -import java.util.List; -import java.util.HashMap; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.utils.NTypeMerger; -import com.apple.internal.jobjc.generator.utils.QA; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; -import com.apple.internal.jobjc.generator.utils.NTypeMerger.MergeFailed; - -public class Type implements Comparable{ - public static Type VOID = Type.getType("void", NVoid.inst(), null); - public static Type VOID_PTR = Type.getType("void*", new NPointer(NVoid.inst()), null); - - final public String name; - final public NType type32; - final public NType type64; - - // HACK BS bug where some types have inconsistent definitions in the metadata, - // e.g. (l / i) in some places and just (l) (and thus (l / l)) in others. - // This is a mapping from the type name to a Type object with the correct definition. - private static final Map exceptions; - static { - exceptions = new HashMap(); - exceptions.put("OSStatus", getType("OSStatus", new NPrimitive('l'), new NPrimitive('i'))); // (l / i) vs. (l) - exceptions.put("CGFloat", getType("CGFloat", new NPrimitive('f'), new NPrimitive('d'))); // (f / d) vs. (f) - exceptions.put("NSRect", getType("NSRect", getNSRectType(), getCGRectType())); // ({{_NSPoint}{_NSSize}} / {{CGPoint}{CGSize}}) vs. ({{_NSPoint}{_NSSize}}) - exceptions.put("NSPoint", getType("NSPoint", getNSPointType(), getCGPointType())); // (_NSPoint / CGPoint) vs. (_NSPoint) - exceptions.put("NSSize", getType("NSSize", getNSSizeType(), getCGSizeType())); // (_NSSize / CGSize) vs. (_NSSize) - exceptions.put("NSInteger", getType("NSInteger", new NPrimitive('i'), new NPrimitive('q'))); // (i / q) vs. (i) - exceptions.put("NSPointArray", getType("NSPointArray", new NPointer(getNSPointType()), new NPointer(getCGPointType()))); // (^_NSPoint / ^CGPoint) vs. (^_NSPoint) - exceptions.put("NSMultibyteGlyphPacking", getType("NSMultibyteGlyphPacking", new NPrimitive('I'), new NPrimitive('Q'))); // (I / Q) vs. (I) - exceptions.put("CFTypeRef", getType("CFTypeRef", new NPointer(NVoid.inst()), new NPointer(NVoid.inst()))); // (^v, ^v) vs. (@, @) - } - - public static Type getType(final String name, final NType t32, final NType t64){ - return TypeCache.inst().pingType(new Type(name, t32, t64)); - } - - private Type(final String name, final NType t32, final NType t64) { - QA.nonNull(t32); - this.name = cleanName(name); - this.type32 = t32; - this.type64 = t64 == null || t32.equals(t64) ? t32 : t64; - } - - private JType _getJType; - public JType getJType() { - return _getJType!=null ? _getJType : (_getJType = TypeToJType.inst().getJTypeFor(TypeCache.inst().pingType(this))); - } - - private String _toString; - @Override public String toString() { - return _toString != null ? _toString : (_toString = name + " " + new Pair(type32, type64).toString()); - } - - @Override public boolean equals(Object o){ - if(o==null || !(o instanceof Type)) return false; - Type t = (Type) o; - return QA.bothNullOrEquals(t.name, this.name) - && t.type32.equals(this.type32) - && t.type64.equals(this.type64); - } - - @Override public int hashCode(){ - return (name == null ? 0 : name.hashCode()) - + type32.hashCode() + type64.hashCode(); - } - - public int compareTo(Type o) { return toString().compareTo(o.toString()); } - - public static Type merge(Type a, Type b) throws MergeFailed{ - if(a!=null && b==null) return a; - if(a==null && b!=null) return b; - if(QA.bothNullOrEquals(a, b)) return a; - if (exceptions.containsKey(a.name)) return exceptions.get(a.name); // HACK BS bug - if(a.name != null && b.name != null && !a.name.equals(b.name)){ - System.out.println("Merging:"); - System.out.println("\ta.....: " + a.toString()); - System.out.println("\tb.....: " + b.toString()); - } - final Type merged = new Type(NTypeMerger.inst().mergeName(a.name, b.name), - NTypeMerger.inst().merge(a.type32, b.type32), - NTypeMerger.inst().merge(a.type64, b.type64)); - if(a.name != null && b.name != null && !a.name.equals(b.name)){ - System.out.println("\tmerged: " + merged.toString()); - } - return merged; - } - - // HACK BS bug where sometimes the name is declared as "id fields = new ArrayList(); - fields.add(new NField("origin", getCGPointType())); - fields.add(new NField("size", getCGSizeType())); - return new NStruct("CGRect", fields); - } - - private static NType getNSRectType() { - List fields = new ArrayList(); - fields.add(new NField("origin", getNSPointType())); - fields.add(new NField("size", getNSSizeType())); - return new NStruct("_NSRect", fields); - } - - private static NType getCGPointType() { - List fields = new ArrayList(); - fields.add(new NField("x", new NPrimitive('d'))); - fields.add(new NField("y", new NPrimitive('d'))); - return new NStruct("CGPoint", fields); - } - - private static NType getNSPointType() { - List fields = new ArrayList(); - fields.add(new NField("x", new NPrimitive('f'))); - fields.add(new NField("y", new NPrimitive('f'))); - return new NStruct("_NSPoint", fields); - } - - private static NType getCGSizeType() { - List fields = new ArrayList(); - fields.add(new NField("width", new NPrimitive('d'))); - fields.add(new NField("height", new NPrimitive('d'))); - return new NStruct("CGSize", fields); - } - - private static NType getNSSizeType() { - List fields = new ArrayList(); - fields.add(new NField("width", new NPrimitive('f'))); - fields.add(new NField("height", new NPrimitive('f'))); - return new NStruct("_NSSize", fields); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeCache.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeCache.java deleted file mode 100644 index dabf0d99ff2..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeCache.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model.types; - -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.utils.Fp.Pair; - -/** - * Central store for types found in the frameworks. - */ -public class TypeCache { - private static TypeCache INST = new TypeCache(); - public static TypeCache inst(){ return INST; } - protected TypeCache(){} - - /** - * When a new Type is discovered, pass it through here to - * hit the cache, potentially merge with other types, etc. - * - * Always do: - * - * Type type = TypeCache.inst().pingType(new Type(a,b,c)); - * - * because this should return a better merge for you. - */ - public Type pingType(final Type type_){ - Type typex = type_; - - // XXX Exception for void* clashes: void* (^{OpaqueCMProfileRef}), void* (^{X}), etc - if("void*".equals(typex.name) && getTypeByName(typex.name)!=null) - return getTypeByName(typex.name); - - if(typex.name != null) - typex = Type.merge(typex, getTypeByName(typex.name)); - else // type.name == null - typex = Type.merge(typex, getTypeByNTypes(new Pair(typex.type32, typex.type64))); - putTypeByName(typex.name, typex); - putTypeByNTypes(new Pair(typex.type32, typex.type64), typex); - return typex; - } - - public final Map typesByName = new HashMap(); - public Type getTypeByName(final String name) { return typesByName.get(Type.cleanName(name)); } - public void putTypeByName(String name, Type type) { if(name!=null) typesByName.put(name, type); } - - public final Map, Type> typesByNTypes = new HashMap, Type>(); - public Type getTypeByNTypes(Pair pair) { return typesByNTypes.get(pair); } - public void putTypeByNTypes(Pair pair, Type type) { if(pair!=null) typesByNTypes.put(pair, type); } - - private final Map classesByName = new HashMap(); - private final Map structsByName = new HashMap(); - private final Map cfTypesByName = new HashMap(); - private final Map opaquesByName = new HashMap(); - - public void load(final List frameworks) { - for (final Framework framework : frameworks) { - for (final Clazz obj : framework.classes) { - final Clazz previous = classesByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: class name: %1$-10s -- framework1: %2$-10s -- framework2: %3$-10s \n", - obj.name, obj.parent.name, previous.parent.name)); - } - - for (final Struct obj : framework.structs) { - final Struct previous = structsByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: name: %1$-10s -- type1: %2$-10s -- type2: %3$-10s \n", - obj.name, obj.type, previous.type)); - } - - for (final CFType obj : framework.cfTypes) { - final CFType previous = cfTypesByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: name: %1$-10s -- type1: %2$-10s -- type2: %3$-10s \n", - obj.name, obj.type, previous.type)); - } - - for (final Opaque obj : framework.opaques) { - final Opaque previous = opaquesByName.put(obj.name, obj); - if(previous != null) - throw new RuntimeException(String.format( - "TypeCache: naming collision: name: %1$-10s -- type1: %2$-10s -- type2: %3$-10s \n", - obj.name, obj.type, previous.type)); - } - } - } - - public Collection getAllClasses() { return classesByName.values(); } - public Clazz getClassForName(final String className) { return classesByName.get(className); } - public Struct getStructForName(final String declaredType) { return structsByName.get(declaredType); } - public CFType getCFTypeForName(final String declaredType) { return cfTypesByName.get(declaredType); } - public Opaque getOpaqueForName(final String declaredType) { return opaquesByName.get(declaredType); } - - final Set unknownTypes = new TreeSet(); - public Set getUnknownTypes() { return unknownTypes; } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeToJType.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeToJType.java deleted file mode 100644 index 82ee3f7aaef..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/types/TypeToJType.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.model.types; - -import com.apple.internal.jobjc.generator.model.CFType; -import com.apple.internal.jobjc.generator.model.Clazz; -import com.apple.internal.jobjc.generator.model.Opaque; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.coders.ComplexCoderDescriptor; -import com.apple.internal.jobjc.generator.model.types.JType.JCFType; -import com.apple.internal.jobjc.generator.model.types.JType.JClass; -import com.apple.internal.jobjc.generator.model.types.JType.JObject; -import com.apple.internal.jobjc.generator.model.types.JType.JOpaque; -import com.apple.internal.jobjc.generator.model.types.JType.JPointer; -import com.apple.internal.jobjc.generator.model.types.JType.JPrimitive; -import com.apple.internal.jobjc.generator.model.types.JType.JSelector; -import com.apple.internal.jobjc.generator.model.types.JType.JStruct; -import com.apple.internal.jobjc.generator.model.types.JType.JUnknown; -import com.apple.internal.jobjc.generator.model.types.JType.JVoid; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.utils.Fp.CacheMap; -import com.apple.internal.jobjc.generator.utils.Fp.Dispatcher; -import com.apple.internal.jobjc.generator.utils.Fp.Map0; - -public class TypeToJType { - private static TypeToJType INST = new TypeToJType(); - public static TypeToJType inst(){ return INST; } - - private CacheMap cache = new CacheMap(); - public JType getJTypeFor(final Type type){ - return cache.get(type, new Map0(){ - public JType apply() { - try { - return Dispatcher.dispatch(TypeToJType.this.getClass(), TypeToJType.this, "accept", type, type.type32, type.type64); - } catch (NoSuchMethodException e) { - return new JUnknown(type); - } - }}); - } - - protected JType accept(Type type, NObject nt32, NObject nt64){ - if ("id".equals(type.name)) return JObject.ID_TYPE; - - final String className = type.name.replaceAll("\\*$", ""); - assert !className.endsWith("*"); - - final Clazz clazz = TypeCache.inst().getClassForName(className); - if (clazz == null) return new JUnknown(type); - // TODO Instead of JUnknown, ID_TYPE might be more appropriate. Investigate. - - return new JObject(type, clazz); - } - - protected JType accept(Type type, NPointer nt32, NPointer nt64){ - final CFType cfType = TypeCache.inst().getCFTypeForName(type.name); - if(cfType != null) return new JCFType(cfType); - - final Opaque opaque = TypeCache.inst().getOpaqueForName(type.name); - if(opaque != null) return new JOpaque(opaque); - - if("void*".equals(type.name)) return JPointer.VOID_PTR; - - if(type.name != null && type.name.endsWith("*")){ - final String subDeclaredType = type.name.substring(0, type.name.length() - 1); - final Type subType = TypeCache.inst().getTypeByName(subDeclaredType); - if (subType == null) return new JUnknown(type); - // TODO Instead of JUnknown, VOID_PTR might be a good fallback. Investigate. - - final JType javaType = TypeToJType.inst().getJTypeFor(subType).getParameterizableType(); - - final JPointer pointer = new JPointer(javaType); - return pointer; - } - - return new JUnknown(type); - } - - protected JType accept(Type type, NPrimitive nt32, NPrimitive nt64){ - final ComplexCoderDescriptor coderDesc = ComplexCoderDescriptor.getCoderDescriptorFor(type.type32, type.type64); - if (coderDesc == null) return null; - return new JPrimitive(type, coderDesc); - } - - protected JType accept(Type type, NVoid nt32, NVoid nt64){ - return JVoid.INST; - } - - protected JType accept(Type type, NSelector nt32, NSelector nt64){ - return JSelector.INST; - } - - protected JType accept(Type type, NClass nt32, NClass nt64){ - return JClass.INST; - } - - protected JType accept(Type type, NStruct nt32, NStruct nt64){ - Struct st = TypeCache.inst().getStructForName(type.name); - return st != null ? new JStruct(st) : new JUnknown(type); - // TODO We could probably generate a struct here based on the type. But we need access to its parent framework. - // Maybe we could use a fallback anonymous struct, but we need the SIZEOF. - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/Fp.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/Fp.java deleted file mode 100644 index 5c7db20c91b..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/Fp.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.utils; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -/** - * Functional programming constructs and utilities. Java for Lisp and Haskell nerds. - */ -public abstract class Fp { - /** - * Multiple dynamic dispatch (multi-methods) for Java. - * - * This is implemented with Java reflection: - * Class.getDeclaredMethod and Method.invoke. - * It is about 20-40 times slower than chains of - * "if instanceof" statements. - */ - public static abstract class Dispatcher{ - /** - * Shorthand, works only if no arg is null. - */ - public static final R dispatch(Class clazz, Object instance, String method, Object... args) throws NoSuchMethodException{ - Class[] types = new Class[args.length]; - for(int i = 0; i < args.length; i++) types[i] = args[i].getClass(); - return (R) dispatch(clazz, instance, method, args, types); - } - - /** - * Dispatch `args` of `types` to `method` on `clazz` for `instance`. If `method` is static, `instance` should be null. - */ - public static final R dispatch(Class clazz, Object instance, String method, Object[] args, Class[] types) throws NoSuchMethodException{ - try{ - java.lang.reflect.Method m = clazz.getDeclaredMethod(method, types); - m.setAccessible(true); - return (R) m.invoke(instance, args); - } - catch(NoSuchMethodException x){ - if(clazz.getSuperclass() != null) return (R) dispatch(clazz.getSuperclass(), instance, method, args, types); - else throw x; - } - catch(Exception x){ - throw new RuntimeException(x); - } - } - } - - /** - * The "Maybe" type encapsulates an optional value. A value of type - * "Maybe a" either contains a value of type "a" (represented as "Just a"), - * or it is empty (represented as "Nothing"). - * - * http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Maybe.html - */ - public static abstract class Maybe{ - public abstract boolean isJust(); - public abstract boolean isNothing(); - public abstract A fromJust() throws ClassCastException; - public abstract A fromMaybe(final A fallback); - - public static class Nothing extends Maybe{ - @Override public A fromJust() throws ClassCastException { throw new ClassCastException("Cannot extract value from Nothing."); } - @Override public A fromMaybe(A fallback) { return fallback; } - @Override public boolean isJust() { return false; } - @Override public boolean isNothing() { return true; } - } - public static class Just extends Maybe{ - public final A a; - public Just(A a){ this.a = a; } - @Override public A fromJust(){ return a; } - @Override public A fromMaybe(A fallback) { return a; } - @Override public boolean isJust() { return true; } - @Override public boolean isNothing() { return false; } - } - } - - public static class NonNull{ - public final A obj; - public NonNull(A o){ - if(o==null) throw new RuntimeException("o may not be null."); - this.obj = o; - } - } - - // Closures - public static interface Map0{ A apply(); } - public static interface Map1{ B apply(final A a); } - public static interface Map2{ C apply(final A a, final B b); } - - public static class CacheMap,V>{ - private Map cache = new TreeMap(); - public V get(K key, Map0 create){ - if(cache.containsKey(key)) return cache.get(key); - V value = create.apply(); - cache.put(key, value); - return value; - } - } - - public static class Curry2to1 implements Map1{ - private Map2 target; private A a; - public Curry2to1(Map2 targett, A aa) { target = targett; a = aa; } - public C apply(B b) { return target.apply(a, b); } - } - - // Tuple - public static class Pair implements Comparable>{ - public final A a; public final B b; - public Pair(final A aa, final B bb){ a=aa; b=bb; } - @Override public int hashCode(){ return (a==null ? 0 : a.hashCode()) + (b==null ? 0 : b.hashCode()); } - @Override public boolean equals(Object o){ - if(!(o instanceof Pair)) return false; - Pair p = (Pair) o; - return QA.bothNullOrEquals(a, p.a) && QA.bothNullOrEquals(b, p.b); - } - @Override public String toString(){ return "(" + a + ", " + b + ")"; } - public int compareTo(Pair o){ return toString().compareTo(o.toString()); } - } - - /** - * @return [fn(x) | x <- items] - */ - public static List map(Map1 fn, final Collection xs){ - ArrayList rs = new ArrayList(xs.size()); - for(A x : xs) rs.add(fn.apply(x)); - return rs; - } - - public static List map2(Map2 fn, final Collection as, final Collection bs){ - assert as.size() == bs.size(); - ArrayList cs = new ArrayList(as.size()); - Iterator aiter = as.iterator(); - Iterator biter = bs.iterator(); - while(aiter.hasNext() && biter.hasNext()) - cs.add(fn.apply(aiter.next(), biter.next())); - return cs; - } - - /** - * Same as map, but does not retain results. - */ - public static void each(Map1 fn, final Collection xs){ - for(A x : xs) fn.apply(x); - } - - /** - * @return [x | x <- items, take(x)] - */ - public static List filter(Map1 take, final Collection xs){ - List rs = new ArrayList(xs.size()); - for(A x : xs) if(take.apply(x)) rs.add(x); - return rs; - } - - /** - * @return [x | x <- items, take(x)] - */ - public static Set filterSet(Map1 take, final Collection xs){ - Set rs = new HashSet(xs.size()); - for(A x : xs) if(take.apply(x)) rs.add(x); - return rs; - } - - /** - * @return the first x in items that satisfies take(x), or null if none - */ - public static X find(Map1 take, final Collection xs){ - for(X x : xs) if(take.apply(x)) return x; - return null; - } - - public static A foldl(final Map2 f, A a, final Collection xs){ - for(B b : xs) a = f.apply(a, b); - return a; - } - - /** - * @return All x : p(x) == true - */ - public static boolean all(Map1 p, Collection xs) { - for(A x : xs) if(!p.apply(x)) return false; - return true; - } - - /** - * @return Any x : p(x) == true - */ - public static boolean any(Map1 p, Collection xs) { - for(A x : xs) if(p.apply(x)) return true; - return false; - } - - public static String join(final String sep, final Collection xs) { - if(xs.size() == 0) return ""; - if(xs.size() == 1) return xs.iterator().next().toString(); - return Fp.foldl(new Fp.Map2(){ - public String apply(String a, A b) { - String sb = b==null? "null" : b.toString(); - return a == null ? sb : a + sep + sb; - }}, null, xs); - } - - public static Map2 operatorPlus = new Map2(){ - public Integer apply(Integer a, Integer b) { return (int)a + (int)b;} - }; - - public static int sum(Collection xs){ return foldl(operatorPlus, 0, xs); } - - public static List append(Collection xs, Collection ys) { - List rs = new ArrayList(xs.size() + ys.size()); - rs.addAll(xs); - rs.addAll(ys); - return rs; - } - - public static Set appendSet(Collection xs, Collection ys) { - Set rs = new HashSet(xs.size() + ys.size()); - rs.addAll(xs); - rs.addAll(ys); - return rs; - } - - public static Map litMap(K key, V value, Object... pairs){ - Map ret = new HashMap(1 + pairs.length/2); - ret.put(key, value); - for(int i = 0; i < pairs.length; i += 2) - ret.put(pairs[i], pairs[i+1]); - return ret; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/JavaLang.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/JavaLang.java deleted file mode 100644 index 799ab7770d3..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/JavaLang.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.Utils.Substituter; - -/** - * Utility for generating Java source code. - */ -public abstract class JavaLang { - - public static String makeSingleton(final String instanceVariable, final String methodName, final String className, final String...constructorArgs) { - return generateSingleton(new Substituter( - "#private $CLASS $IVAR = null;~" + - "#public $CLASS $METHOD() {~" + - "##return $IVAR != null ? $IVAR : ($IVAR = new $CLASS($CTORARGS));~" + - "#}~"), - instanceVariable, methodName, className, constructorArgs); - } - - public static String makeStaticSingleton(final String instanceVariable, final String methodName, final String className, final String...constructorArgs) { - return generateSingleton(new Substituter( - "#private static $CLASS $IVAR = null;~" + - "#public static $CLASS $METHOD() {~" + - "##return $IVAR != null ? $IVAR : ($IVAR = new $CLASS($CTORARGS));~" + - "#}~"), - instanceVariable, methodName, className, constructorArgs); - } - - private static String generateSingleton(final Substituter singleton, final String instanceVariable, final String methodName, final String className, final String...constructorArgs) { - singleton.replace("IVAR", instanceVariable); - singleton.replace("METHOD", methodName); - singleton.replace("CLASS", className); - singleton.replace("CTORARGS", Utils.joinWComma(constructorArgs)); - return singleton.toString(); - } - - /// - - public static class JLTertiary{ - public Object cond, tExp, fExp; - public JLTertiary(){} - public JLTertiary(Object cond, Object tExp, Object fExp){ - this.cond = cond; - this.tExp = tExp; - this.fExp = fExp; - } - @Override public String toString() { - return "((" + cond + ")\n\t? (" + tExp + ")\n\t: (" + fExp + "))"; - } - } - - public static class JLCall{ - public String fun; - public List args = new ArrayList(); - public JLCall(String fun, Object... args){ - this.fun = fun; - this.args.addAll(Arrays.asList(args)); - } - @Override public String toString(){ - return fun + "(" + Fp.join(", ", args) + ")"; - } - } - - public static class JLField{ - public Set mods = new TreeSet(); - public String type; - public String name; - public Object value; - - public JLField(String mods, String type, String name){ - this(mods, type, name, null); - } - - public JLField(String mods, String type, String name, Object value){ - this.mods.addAll(Arrays.asList(mods.split("\\s"))); - this.type = type; - this.name = name; - this.value = value; - } - - @Override public String toString(){ - return "\t" + Fp.join(" ", mods) + " " + type + " " + name + (value==null ? "" : " = " + value) + ";\n"; - } - } - - public static class JLCtor extends JLMethod{ - public JLCtor(String mods, String name, Object... args) { - super(mods, "", name, args); - } - - @Override public String toString(){ - this.type = ""; - return super.toString(); - } - } - - public static class JLReturn{ - public Object target; - public JLReturn(Object target){ - this.target = target; - } - @Override public String toString(){ - return "return " + target + ";"; - } - } - - public static class JLMethod{ - public List jdoc = new ArrayList(); - public Set attrs = new TreeSet(); - public Set mods = new TreeSet(); - public String type; - public String name; - public List args = new ArrayList(); - public List body = new ArrayList(); - - public JLMethod(){} - public JLMethod(String mods, String type, String name, Object... args) { - this.mods.addAll(Arrays.asList(mods.split("\\s"))); - this.type = type; - this.name = name; - this.args.addAll(Arrays.asList(args)); - } - - @Override public String toString(){ - StringWriter out = new StringWriter(); - if(jdoc.size() > 0){ - out.append("\t/**\n"); - out.append("\t * " + Fp.join("\n\t * ", jdoc)); - out.append("\t */\n"); - } - out.append("\t" + Fp.join(" ", attrs) + " " + Fp.join(" ", mods) + " " + type + " " + name + "(" + Fp.join(", ", args) + "){\n"); - out.append("\t\t" + Fp.join("\n\t\t", body) + "\n"); - out.append("\t}\n"); - return out.toString(); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeMerger.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeMerger.java deleted file mode 100644 index a1ad5658050..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeMerger.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.utils; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NArray; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NUnion; -import com.apple.internal.jobjc.generator.model.types.NType.NUnknown; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.utils.Fp.Dispatcher; -import com.apple.internal.jobjc.generator.utils.Fp.Map2; -import com.apple.jobjc.JObjCRuntime.Width; - -/** - * Merges two NTypes. All merge does is fill out missing information. It doesn't choose the larger primitive when there's a conflict or anything like that. - * - * Example: - *
- * a: {_NSRect={_NSPoint="x"f"y"f}"size"{_NSSize=ff}}
- * b: {_NSRect="origin"{_NSPoint=ff}{_NSSize="width"f"height"f}}
- * c: {_NSRect="origin"{_NSPoint="x"f"y"f}"size"{_NSSize="width"f"height"f}}
- *
- */ -public class NTypeMerger { - public static class MergeFailed extends RuntimeException{ - public MergeFailed(String reason, Object a, Object b){ - super(reason - + " -- (" + a.getClass().getSimpleName() + ") a: " + a - + " -- (" + b.getClass().getSimpleName() + ") b: " + b); - } - } - - private static NTypeMerger INST = new NTypeMerger(); - public static NTypeMerger inst(){ return INST; } - - /** - * Merge a and b. - */ - public NType merge(NType a, NType b) throws MergeFailed{ - if(a!=null && b==null) return a; - if(a==null && b!=null) return b; - if(a==null && b==null) return null; - if(a.equals(b)) return a; - try { - return Dispatcher.dispatch(getClass(), this, "accept", a, b); - } catch (NoSuchMethodException e) { - throw new MergeFailed("a and b are of different NType", a, b); - } - } - - private static Collection emptyNames = Arrays.asList(null, "", "?"); - /** - * Merge two identifiers: - * - If they're equal, return one. - * - If one is null, "", "?", return the other one. - * - else throw MergeFailed - * - * Exception: Due to a bug in BridgeSupport, this will return - * a (the first arg) instead of throwing MergeFailed. - */ - public String mergeName(String a, String b) throws MergeFailed{ - if(QA.bothNullOrEquals(a, b)) return a; - if(emptyNames.contains(a) && !emptyNames.contains(b)) return b; - if(emptyNames.contains(b) && !emptyNames.contains(a)) return a; - return a; // HACK BS bug #5954843 -// throw new MergeFailed("a and b have different names"); - } - - private Map mergeMap(Map a, Map b) throws MergeFailed{ - if(a.equals(b)) return a; - Map ret = new HashMap(); - Set keys = new HashSet(Fp.append(a.keySet(), b.keySet())); - for(Object key : keys){ - Object ai = a.get(key); - Object bi = b.get(key); - if(ai != null && bi == null) ret.put(key, ai); - else if(ai == null && bi != null) ret.put(key, bi); - else if(ai.equals(bi)) ret.put(key, ai); - else throw new MergeFailed("a and b are different", ai, bi); - } - return ret; - } - - public Map mergeSizeOf(Map a, Map b) throws MergeFailed{ - return mergeMap(a, b); - } - - public Map mergeOffset(Map a, Map b) throws MergeFailed{ - return mergeMap(a, b); - } - - // - - private void mustEqual(NType a, NType b){ - if(!a.equals(b)) throw new MergeFailed("a must equal b", a, b); - } - - protected NType accept(NBitfield a, NBitfield b) { - mustEqual(a, b); - return a; - } - - protected NType accept(NPrimitive a, NPrimitive b) { - mustEqual(a, b); - return a; - } - - protected NType accept(NPointer a, NPointer b) { - return new NPointer(NTypeMerger.inst().merge(a.subject, b.subject)); - } - - // Merge structs - - protected NField mergeNFields(NField a, NField b) { - return new NField(mergeName(a.name, b.name), - NTypeMerger.inst().merge(a.type, b.type), - mergeOffset(a.offset, b.offset)); - } - - protected NStruct mergeStructs(NStruct a, NStruct b){ - if(a.fields.size() != b.fields.size()) - throw new MergeFailed("a and b have different numbers of fields", a, b); - - List fields = Fp.map2(new Map2(){ - public NField apply(NField f32, NField f64) { return mergeNFields(f32, f64); } - }, a.fields, b.fields); - - return new NStruct(mergeName(a.name, b.name), - fields, mergeSizeOf(a.sizeof, b.sizeof)); - } - - protected NType accept(NStruct a, NStruct b) { - return mergeStructs(a, b); - } - - protected NType accept(NUnion a, NUnion b) { - NStruct nst = mergeStructs(a, b); - return new NUnion(nst.name, Fp.map(NUnion.zeroOffsets, nst.fields), nst.sizeof); - } - - protected NType accept(NArray a, NArray b) { - if(a.length != b.length) - throw new MergeFailed("a and b are of different sizes", a, b); - return new NArray(a.length, NTypeMerger.inst().merge(a.type, b.type)); - } - - protected NType accept(NVoid a, NVoid b) { return NVoid.inst(); } - protected NType accept(NObject a, NObject b) { return NObject.inst(); } - protected NType accept(NClass a, NClass b) { return NClass.inst(); } - protected NType accept(NSelector a, NSelector b) { return NSelector.inst(); } - protected NType accept(NUnknown a, NUnknown b) { return NUnknown.inst(); } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeParser.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeParser.java deleted file mode 100644 index 850076280a2..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypeParser.java +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.utils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NArray; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NUnion; -import com.apple.internal.jobjc.generator.model.types.NType.NUnknown; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; - -/** - * NTypeParser (Native Type Parser) parses type & type64 attributes from BridgeSupport. - * - * See Obj-C Language: Type Encodings - */ -public abstract class NTypeParser { - // ** Parser entry point - - private static Map cached = new HashMap(); - public static NType parseFrom(String s) { - if(!cached.containsKey(s)) cached.put(s, parseFrom(new StringStream(s))); - return cached.get(s); - } - - // ** Parser driver - - private static List PARSERS = new ArrayList( - Arrays.asList(new NBitfieldParser(), new NPrimitiveParser(), new NVoidParser(), - new NPointerParser(), new NStructParser(), new NUnionParser(), - new NObjectParser(), new NClassParser(), new NSelectorParser(), - new NArrayParser(), new NUnknownParser(), new NSpecifierParser())); - - protected static NType parseFrom(StringStream ss) { - if(ss.left() == 0) - return null; - try{ - for(NTypeParser nt : PARSERS) - if(nt.parsePossible(ss)) - return nt.parse(ss); - } - catch(RuntimeException x){ - throw new RuntimeException("Exception while parsing '" + ss.remainingToString() - + "' from '" + ss.toString() + "'", x); - } - throw new RuntimeException("Found no parser for '" + ss.remainingToString() - + "' from '" + ss.toString() + "'"); - } - - // ** Methods for parsers - - protected abstract boolean parsePossible(StringStream ss); - protected abstract NType parse(StringStream ss); - - // ** Individual parsers - - public static class NBitfieldParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.left() >= 2 && ss.peekAt(0) == 'b' && Character.isDigit(ss.peekAt(1)); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - ss.eat('b'); - return new NBitfield(Integer.parseInt(ss.readWhileDigits())); - } - } - - public static class NPrimitiveParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return NPrimitive.CODES.contains(ss.peek()); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - return NPrimitive.inst(ss.read()); - } - } - - public static class NVoidParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == 'v'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('v'); - return NVoid.inst(); - } - } - - public static class NPointerParser extends NTypeParser{ - private static NPointer CHAR_PTR = new NPointer(NPrimitive.inst('C')); - - @Override protected boolean parsePossible(StringStream ss) { - return (ss.left() >= 2 && ss.peek() == '^') || (ss.peek() == '*'); - } - - @Override protected NType parse(StringStream ss) { - if(ss.peek() == '*'){ - ss.eat('*'); - return CHAR_PTR; - } - else{ - ss.eat('^'); - return new NPointer(NTypeParser.parseFrom(ss)); - } - } - } - - public static class NStructParser extends NTypeParser{ - protected char getOpen(){ return '{'; }; - protected char getClose(){ return '}'; }; - - @Override protected boolean parsePossible(StringStream ss) { - return ss.left() >= 2 && ss.peek() == getOpen(); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - // {_NSRect= - // "origin"{_NSPoint="x"f"y"f} - // "size"{_NSSize="width"f"height"f}} - ss.eat(getOpen()); - String cname = ss.readUntilEither("=" + getClose()); - List fields = new ArrayList(); - if(ss.peek() == '='){ - ss.eat('='); - while(ss.peek() != getClose()){ - String fname = ""; - if(ss.peek() == '"'){ - ss.eat('"'); - fname = ss.readUntil('"'); - ss.eat('"'); - } - NType type = NTypeParser.parseFrom(ss); - fields.add(new NStruct.NField(fname, type)); - } - } - ss.eat(getClose()); - return getNew(cname, fields); - } - - protected NType getNew(String cname, List fields){ - return new NStruct(cname, fields); - } - } - - // A Union is very much like a Struct. - public static class NUnionParser extends NStructParser{ - @Override protected char getOpen(){ return '('; }; - - @Override protected char getClose(){ return ')'; }; - - @Override protected NType getNew(String cname, List fields){ - return new NUnion(cname, Fp.map(NUnion.zeroOffsets, fields)); - } - } - - public static class NArrayParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '['; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('['); - int size = Integer.parseInt(ss.readWhileDigits()); - NType type = NTypeParser.parseFrom(ss); - ss.eat(']'); - return new NArray(size, type); - } - } - - public static class NObjectParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '@'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('@'); - return NObject.inst(); - } - } - - public static class NClassParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '#'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('#'); - return NClass.inst(); - } - } - - public static class NSelectorParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == ':'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat(':'); - return NSelector.inst(); - } - } - - public static class NUnknownParser extends NTypeParser{ - @Override protected boolean parsePossible(StringStream ss) { - return ss.peek() == '?'; - } - - @Override protected NType parse(StringStream ss) { - ss.eat('?'); - return NUnknown.inst(); - } - } - - /** - * Specifier Encoding - * const r - * in n - * inout N - * out o - * bycopy O - * oneway V - */ - public static class NSpecifierParser extends NTypeParser{ - private static Collection SPECS = Arrays.asList('r', 'n', 'N', 'o', 'O', 'V'); - @Override protected boolean parsePossible(StringStream ss) { - return SPECS.contains(ss.peek()); - } - - @Override protected NType parse(StringStream ss) { - assert parsePossible(ss); - ss.seek(); // XXX Just ignore specs for now and return the affected type. - return NTypeParser.parseFrom(ss); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypePrinter.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypePrinter.java deleted file mode 100644 index 07ba7259e37..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/NTypePrinter.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.NType.NArray; -import com.apple.internal.jobjc.generator.model.types.NType.NBitfield; -import com.apple.internal.jobjc.generator.model.types.NType.NClass; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NObject; -import com.apple.internal.jobjc.generator.model.types.NType.NPointer; -import com.apple.internal.jobjc.generator.model.types.NType.NPrimitive; -import com.apple.internal.jobjc.generator.model.types.NType.NSelector; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.model.types.NType.NUnion; -import com.apple.internal.jobjc.generator.model.types.NType.NUnknown; -import com.apple.internal.jobjc.generator.model.types.NType.NVoid; -import com.apple.internal.jobjc.generator.utils.Fp.Dispatcher; - -/** - * Print an NType to the BridgeSupport encoding. - */ -public class NTypePrinter{ - private static NTypePrinter INST = new NTypePrinter(); - public static NTypePrinter inst(){ return INST; } - - public String print(NType nt){ - try { - return Dispatcher.dispatch(getClass(), this, "accept", nt); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - - protected String accept(NBitfield nt) { - return "b" + nt.length; - } - - protected String accept(NPrimitive nt) { - return Character.toString(nt.type); - } - - protected String accept(NPointer nt) { - if(nt.subject instanceof NPrimitive && ((NPrimitive) nt.subject).type == 'C') - return "*"; - else - return "^" + print(nt.subject); - } - - protected String printStruct(NStruct nt, char open, char close){ - StringWriter sw = new StringWriter(); - sw.append(open); - sw.append(nt.name); - if(nt.fields.size() > 0){ - sw.append('='); - for(NField f : nt.fields){ - if(f.name != null && f.name.length() > 0) - sw.append("\"" + f.name + "\""); - sw.append(print(f.type)); - } - } - sw.append(close); - return sw.toString(); - } - - protected String accept(NStruct nt) { - return printStruct(nt, '{', '}'); - } - - protected String accept(NUnion nt) { - return printStruct(nt, '(', ')'); - } - - protected String accept(NArray nt) { - return "[" + nt.length + print(nt.type) + "]"; - } - - protected String accept(NObject nt) { return "@"; } - protected String accept(NVoid nt) { return "v"; } - protected String accept(NClass nt) { return "#"; } - protected String accept(NSelector nt) { return ":"; } - protected String accept(NUnknown nt) { return "?"; } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/ObjectInspector.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/ObjectInspector.java deleted file mode 100644 index e54ba340987..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/ObjectInspector.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; -import java.lang.reflect.Field; - -public abstract class ObjectInspector { - /** - * @return a string representation of object internals. - */ - public static String inspect(Object obj) { - StringWriter sw = new StringWriter(); - inspectForClass(obj, obj.getClass(), sw); - return sw.toString(); - } - - private static void inspectForClass(Object instance, Class clazz, StringWriter sw){ - boolean willGoSuper = clazz.getSuperclass() != null && !clazz.getSuperclass().getName().equals("java.lang.Object"); - - sw.append(clazz.getSimpleName()); - sw.append("{"); - Field[] fs = clazz.getDeclaredFields(); - for(int i = 0; i < fs.length; i++){ - Field f = fs[i]; - f.setAccessible(true); - sw.append(f.getName()); - sw.append(": "); - try { - Object o = f.get(instance); - sw.append(o == null ? "null" : o.toString()); - } catch (IllegalArgumentException ex) { - throw new RuntimeException(ex); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex); - } - if(i < fs.length - 1 || willGoSuper) - sw.append(", "); - } - - if(willGoSuper){ - sw.append("super: "); - inspectForClass(instance, clazz.getSuperclass(), sw); - } - - sw.append("}"); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/QA.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/QA.java deleted file mode 100644 index e745636a38a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/QA.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.utils; - -import com.apple.internal.jobjc.generator.Utils; - -public class QA { - public static void nonNull(Object... os){ - for(Object o : os) if(o == null) throw new NullPointerException(Utils.joinWComma(os)); - } - - public static boolean bothNullOrEquals(Object a, Object b) { - if(a == null && b == null) return true; - if(a == null || b == null) return false; - return a.equals(b); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StringStream.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StringStream.java deleted file mode 100644 index 448d4be12e6..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StringStream.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.utils; - -import java.io.StringWriter; - -/** - * Stream-like class backed by a string. Useful for parsers. - */ -public class StringStream{ - private String data; - private int pos; - - public StringStream(String s){ - QA.nonNull(s); - this.data = s; - this.pos = 0; - } - - /** - * Number of characters left. - */ - public int left(){ return data.length() - pos; } - - /** - * Are there any characters left? - */ - public boolean atEOF(){ return left() <= 0; } - - /** - * Read next character. - */ - public char read(){ return data.charAt(pos++); } - - /** - * Read n characters and return string. - */ - public String readN(int n){ - String s = data.substring(pos, pos + n); - pos += n; - return s; - } - - /** - * Read until the next char is c, and return the string. - */ - public String readUntil(char c){ - int ix = data.indexOf(c, pos); - if(ix == -1) throw new RuntimeException("readUntil did not find character '" + c + "'"); - return readN(data.indexOf(c, pos) - pos); - } - - /** - * Read until the next char is one in s, and return the string. - */ - public String readUntilEither(String s) { - int ix = Integer.MAX_VALUE; - - for(char c : s.toCharArray()){ - int ixx = data.indexOf(c, pos); - if(ixx >= 0 && ixx < ix) - ix = ixx; - } - - if(ix == -1) throw new RuntimeException("readUntilEither did not find any character in '" + s + "'"); - return readN(ix - pos); - } - - public String readWhile(String s) { - StringWriter sw = new StringWriter(); - while(s.indexOf(peek()) != -1) - sw.append(read()); - return sw.toString(); - } - - public String readWhileDigits() { - return readWhile("0123456789"); - } - - /** - * @return the nth char from the current position. - */ - public char peekAt(int n){ return data.charAt(pos + n); } - - /** - * @return the next n chars. - */ - public String peekN(int n){ return data.substring(pos, pos + n); } - - /** - * @return the next char. - */ - public char peek(){ return peekAt(0); } - - /** - * Skip n chars ahead. - */ - public void seekN(int n){ pos += n; } - - /** - * Skip 1 char ahead. - */ - public void seek(){ seekN(1); } - - /** - * If the next character is c, seek over it. Otherwise throw RuntimeException. - */ - public void eat(char c) { - if(peek() != c) throw new RuntimeException("Parser expected '" + c + "' but got '" + peek() + "'."); - seek(); - } - - /** - * If the next characters are the same as those in s, seek over them. Otherwise throw RuntimeException. - */ - public void eat(String s) { - String pn = peekN(s.length()); - if(!pn.equals(s)) throw new RuntimeException("Parser expected '" + s + "' but got '" + pn + "'."); - seekN(s.length()); - } - - @Override - public String toString(){ - return data; - } - - /** - * @return the remaining characters as a String. - */ - public String remainingToString() { - return data.substring(pos); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolver.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolver.java deleted file mode 100644 index c207aae323a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolver.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.utils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileWriter; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.apple.internal.jobjc.generator.Utils; -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.model.Struct; -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.model.types.TypeCache; -import com.apple.internal.jobjc.generator.model.types.NType.NField; -import com.apple.internal.jobjc.generator.model.types.NType.NStruct; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.JObjCRuntime.Width; -import java.util.Date; - -/** - * Takes a framework, compiles a native source file with all its structs, - * and figures out their sizes and field offsets. - */ -public class StructOffsetResolver { - public void resolve(Collection fws){ - try { - _resolve(fws); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - protected void _resolve(final Collection fws) throws Exception{ - for(final Framework fw : fws){ - for(final Width width : Width.values()){ - System.out.println("SOR -- Getting Struct offsets @" + width + " for " + fw.name); - String nativeSrc = generateFileForFramework(fw, width); - String executable = compileObjC(nativeSrc, width); - execute(executable, new Map1(){ - public Object apply(String ln) { - try { - processLine(ln, fws, width); - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }); - } - } - } - - static Set alwaysHeaders_shared = new TreeSet(Arrays.asList( - "", - "\"/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/HIToolbox.h\"")); - static Map> alwaysHeaders = Fp.litMap( - Width.W32, alwaysHeaders_shared, - Width.W64, alwaysHeaders_shared); - - static Set bannedHeaders_shared = new TreeSet(Arrays.asList( - "NSJavaSetup.h", "IMKInputController.h", "NSSimpleHorizontalTypesetter.h", "NSSpellServer.h", "IMKServer.h", "IKImageBrowserCell.h")); - static Map> bannedHeaders = Fp.litMap( - Width.W32, bannedHeaders_shared, - Width.W64, Fp.appendSet(bannedHeaders_shared, - Arrays.asList("npapi.h", "npruntime.h", "npfunctions.h"))); - - // We can cache the last accessed framework because, 99% of the time, - // the caller will ask for the same one, over and over again. - protected Framework cachedFw; - protected Framework findFrameworkByName(Collection fws, String name){ - if(cachedFw != null && cachedFw.name.equals(name)) - return cachedFw; - cachedFw = null; - for(Framework fw : fws) - if(fw.name.equals(name)){ - cachedFw = fw; - break; - } - return cachedFw; - } - - protected void processLine(String ln, Collection fws, Width arch) throws Exception{ - System.out.println("\tSOR '" + ln + "'"); - if(ln.trim().length() == 0) return; - Pattern stinfo = Pattern.compile("^(.*) (.*):(\\d+).*$"); - Matcher m = stinfo.matcher(ln); - if(!m.matches()) throw new RuntimeException("Failed to parse line from exec: " + ln); - String fwname = m.group(1); - String stname = m.group(2); - int stsize = Integer.parseInt(m.group(3)); - - Framework fw = findFrameworkByName(fws, fwname); - - Struct st = fw.getStructByName(stname); - NStruct nst = wget(arch, st.type.type32, st.type.type64); - nst.sizeof.put(arch, stsize); - -// System.out.println(st.name + " : " + stsize); - - Pattern finfo = Pattern.compile(" (-?\\d+)"); - Matcher fm = finfo.matcher(ln); - int fi = 0; - while(fm.find()){ - NField sf = nst.fields.get(fi++); - sf.offset.put(arch, Integer.parseInt(fm.group(1))); -// System.out.println("\t" + sf.name + " : " + off); - } - - TypeCache.inst().pingType(st.type); - } - - /** - * Generates Objective-C file and returns absolute path name. - */ - private String generateFileForFramework(Framework fw, Width arch) throws Exception{ - File tempfile = File.createTempFile("JObjC-SOR-" + fw.name + "-" + arch + "-", ".mm"); - PrintWriter out = new PrintWriter(new FileWriter(tempfile)); - out.println("#include"); - printHeaderLines(fw, arch, out); - out.println(""); - out.println("int main(int argc, char** argv){"); - printStructInfos(fw, arch, out); - out.println("\treturn 0;"); - out.println("}"); - out.close(); - return tempfile.getAbsolutePath(); - } - - protected void execute(String executable, Fp.Map1 lineProcessor) throws Exception { -// System.out.println(">>>> Executing " + new Date().toString()); - Process p = Runtime.getRuntime().exec(new String[]{executable}); - - if(lineProcessor != null){ - BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream())); - String line; - while ((line = stdout.readLine()) != null) - lineProcessor.apply(line); - stdout.close(); - } - p.waitFor(); - if(p.exitValue() != 0) - throw new RuntimeException(executable + " did not execute successfully: " + p.exitValue()); - } - - private static Map gccFlag = Fp.litMap(Width.W32, "-m32", Width.W64, "-m64"); - - static boolean isDone(Process p){ - try{ - p.exitValue(); - return true; - } - catch(Exception x){ - return false; - } - } - - protected static String compileObjC(String nativeSrc, Width arch) throws Exception { - String execPath = nativeSrc.replace(".mm", ""); - Process p = Runtime.getRuntime().exec(new String[]{ - "llvm-g++", "-Wall", gccFlag.get(arch), "-ObjC++", "-framework", "Foundation", "-o", execPath, nativeSrc - }); - BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream())); - BufferedReader stderr = new BufferedReader(new InputStreamReader(p.getErrorStream())); - while(!isDone(p)){ - while(stdout.ready()) System.out.println(stdout.readLine()); - while(stderr.ready()) System.out.println(stderr.readLine()); - } - p.waitFor(); - while(stdout.ready() || stderr.ready()){ - if(stdout.ready()) System.out.println(stdout.readLine()); - if(stderr.ready()) System.out.println(stderr.readLine()); - } - if(p.exitValue() != 0) - throw new RuntimeException("gcc did not compile '" + nativeSrc + "' successfully: " + p.exitValue()); - return execPath; - } - - static void printStructInfos(Framework fw, Width arch, PrintWriter out){ - for(Struct st : fw.structs){ - NStruct nst = wget(arch, st.type.type32, st.type.type64); - out.println("std::cout << \"" + fw.name + " " + st.name + "\" << ':' << sizeof("+st.name+")"); - for(NField sf : nst.fields){ - out.print("\t<< ' ' << "); - out.println(sf.type instanceof NType.NBitfield - ? "-1" - : "offsetof("+st.name+","+sf.name+")"); - } - out.println("\t<< std::endl;"); - } - } - - static void printHeaderLines(Framework fw, Width arch, PrintWriter out) throws Exception { - Collection always = alwaysHeaders.get(arch); - Collection banned = bannedHeaders.get(arch); - out.println("#define COREFOUNDATION_CFPLUGINCOM_SEPARATE 0"); - for(String header : always) - out.println("#import " + header); - - out.println("#undef COREFOUNDATION_CFPLUGINCOM_SEPARATE"); - String umbrella = fw.path + "/Headers/" + fw.name; - if(new File(umbrella).exists()) - out.println("#import \"" + umbrella + "\""); - - for(File header : getHeaders(fw)) - if(!banned.contains(header.getName())) - out.println("#import \"" + header.getAbsolutePath() + "\""); - } - - static A wget(Width arch, B x32, B x64){ - switch(arch){ - case W32: return (A) x32; - case W64: return (A) x64; - default: throw new RuntimeException(); - } - } - - /** - * Gets the absolute path to every header in FOO.framework/Headers - */ - static Collection getHeaders(Framework fw) throws Exception { - String hpath = fw.path + "/Headers"; - return Utils.find(new File(hpath), "^.*\\.h$", ""); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolverBigBang.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolverBigBang.java deleted file mode 100644 index 212df7734b5..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/utils/StructOffsetResolverBigBang.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.internal.jobjc.generator.utils; - -import java.io.File; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.util.Collection; - -import com.apple.internal.jobjc.generator.model.Framework; -import com.apple.internal.jobjc.generator.utils.Fp.Map1; -import com.apple.jobjc.JObjCRuntime.Width; - -/** - * Takes a framework, compiles a native source file with all its structs, - * and figures out their sizes and field offsets. - * - * BigBang significantly speeds up the process by - * compiling all frameworks as one big Objective-C file. - */ -public class StructOffsetResolverBigBang extends StructOffsetResolver{ - - @Override protected void _resolve(final Collection fws) throws Exception{ - for(final Width arch : Width.values()){ - System.out.println("SORBB -- Getting Struct offsets @" + arch.toString()); - String nativeSrc = generateFileForFrameworks(fws, arch); - String executable = compileObjC(nativeSrc, arch); - execute(executable, new Map1(){ - public Object apply(String ln) { - try { - processLine(ln, fws, arch); - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - }); - } - } - - /** - * Generates Objective-C file and returns absolute path name. - */ - protected String generateFileForFrameworks(final Collection fws, final Width arch) throws Exception{ - File tempfile = File.createTempFile("JObjC-SORBB-" + arch + "-", ".mm"); - PrintWriter out = new PrintWriter(new FileWriter(tempfile)); - - out.println("#include"); - for(Framework fw : fws) printHeaderLines(fw, arch, out); - out.println("int main(int argc, char** argv){"); - for(Framework fw : fws) printStructInfos(fw, arch, out); - out.println("\treturn 0;"); - out.println("}"); - - out.close(); - return tempfile.getAbsolutePath(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/SuperClassExtractor.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/SuperClassExtractor.java deleted file mode 100644 index cc0b3f9047c..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/SuperClassExtractor.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import java.util.Map; - -import com.apple.internal.jobjc.generator.model.Clazz; - -/* - * Isolating all the reflection trickery to hijack the runtime into giving up its secrets - * without actually having a full working version of JObjC. Below is a bunch of evil reflection, - * but it allows the generated output to have a cleaner design. - */ -public class SuperClassExtractor { - public static Clazz getSuperClassFor(final String className, final MacOSXFramework nativeFramework, final Map allClasses) throws Throwable { - final NSClass nativeClass = new NSClass(className, nativeFramework.getRuntime()); - final NSClass nativeSuperClass = UnsafeRuntimeAccess.getSuperClass(nativeClass); - final String superClassName = UnsafeRuntimeAccess.getClassNameFor(nativeSuperClass); - if ("nil".equals(superClassName)) return null; - - final Clazz superClazz = allClasses.get(superClassName); - if (superClazz != null) return superClazz; - - final Clazz superClazzX = getSuperClassFor(superClassName, nativeFramework, allClasses); - System.out.print("[Warning] class \"" + superClassName + "\" not found in bridge support files, "); - System.out.println("using \"" + superClazzX.name + "\" as superclass for \"" + className + "\""); - return superClazzX; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/UnsafeRuntimeAccess.java b/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/UnsafeRuntimeAccess.java deleted file mode 100644 index 556ba97021a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/jobjc/UnsafeRuntimeAccess.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.Invoke.MsgSend; - -public class UnsafeRuntimeAccess { - public static NativeArgumentBuffer getNativeBuffer() { - return NativeArgumentBuffer.getThreadLocalBuffer(JObjCRuntime.getInstance()); - } - - public static String getClassNameFor(final long obj) { - return NSClass.getClassNameOfClass(obj); - } - - public static String getClassNameFor(final NSClass cls) { - return NSClass.getClassNameOfClass(cls.ptr); - } - - public static NSClass getSuperClass(final NSClass clazz) { - return clazz.getSuperClass(); - } - - public static String getDescriptionForPtr(final long objPtr) { - return ID.getNativeDescription(objPtr); - } - - public static MacOSXFramework getFramework(final String[] frameworkLibs) { - return new MacOSXFramework(JObjCRuntime.getInstance(), frameworkLibs); - } - - public static FunCall createFunCall(final MacOSXFramework framework, final String fxnName, final Coder returnCoder, final Coder ... argCoders) { - return new FunCall(framework, fxnName, returnCoder, argCoders); - } - - public static MsgSend createMsgSend(final NSClass clazz, final String selName, final Coder returnCoder, final Coder ... argCoders) { - return new MsgSend(clazz.getRuntime(), selName, returnCoder, argCoders); - } - - public static NSClass getNSClass(final MacOSXFramework framework, final String name) { - return new NSClass(name, framework.getRuntime()); - } - - public static long getObjPtr(final ID obj) { - return obj.ptr; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/runtime-additions/java/com/apple/jobjc/Utils.java b/jdk/src/macosx/native/jobjc/src/runtime-additions/java/com/apple/jobjc/Utils.java deleted file mode 100644 index a22851de4cb..00000000000 --- a/jdk/src/macosx/native/jobjc/src/runtime-additions/java/com/apple/jobjc/Utils.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import java.util.concurrent.Callable; - -import com.apple.jobjc.foundation.NSNumber; -import com.apple.jobjc.foundation.NSString; - -public class Utils { - JObjCRuntime runtime; - Utils(JObjCRuntime runtime){ this.runtime = runtime; } - - private static Utils utils; - public static Utils get() { - JObjCRuntime runtime = JObjCRuntime.getInstance(); // enforce security check - return utils != null ? utils : (utils = new Utils(runtime)); - } - - private Strings strings_; - public Strings strings() { - return strings_ != null ? strings_ : (strings_ = new Strings(runtime)); - } - - private Numbers numbers_; - public Numbers numbers() { - return numbers_ != null ? numbers_ : (numbers_ = new Numbers(runtime)); - } - - private Threads threads_; - public Threads threads() { - return threads_ != null ? threads_ : (threads_ = new Threads(runtime)); - } - - public static class Strings { - private static native long getNativeNSStringForJavaString(final String javaString); - private static native String getNativeJavaStringForNSString(final long nsString); - - JObjCRuntime runtime; - Strings(JObjCRuntime runtime) { this.runtime = runtime; } - - public NSString nsString(final String str) { - if (str == null) return null; - final long nsString = getNativeNSStringForJavaString(str); - return ID.createNewObjCObjectForClass(NSString.class, nsString, runtime); - } - - public String javaString(final NSString str) { - if (str == null) return null; - return getNativeJavaStringForNSString(((ID)str).ptr); - } - -// static public CString cStringForJavaString(final String str) { -// return null; -// } - } - - public static class Numbers { - private static native long getNativeNSNumberForJavaNumber(final Number num); - private static native Number getNativeJavaNumberForNSNumber(final long num); - - JObjCRuntime runtime; - Numbers(JObjCRuntime runtime) { this.runtime = runtime; } - - public NSNumber nsNumber(final Number num) { - if (num == null) return null; - final long nsNumber = getNativeNSNumberForJavaNumber(num); - return ID.createNewObjCObjectForClass(NSNumber.class, nsNumber, runtime); - } - - public Number javaNumber(final NSNumber num) { - if (num == null) return null; - return getNativeJavaNumberForNSNumber(((ID)num).ptr); - } - } - - public static class Threads { - private static native void performRunnableOnMainThread(final Runnable runnable, final boolean wait); - private static native V performCallableOnMainThread(final Callable callable) throws Exception; - - JObjCRuntime runtime; - Threads(JObjCRuntime runtime) { this.runtime = runtime; } - - /** - * Perform callable on main thread. Exceptions that are thrown on the main thread are ignored. - */ - public void performOnMainThread(final Runnable runnable, final boolean wait) { - performRunnableOnMainThread(runnable, wait); - } - - /** - * Perform callable on main thread, block until done, and return the result. - * This also catches any exceptions on the main thread, brings them back and throws them to the caller. - */ - public V performOnMainThread(final Callable callable) throws Exception{ - return performCallableOnMainThread(callable); - } - } -} diff --git a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeNumber.m b/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeNumber.m deleted file mode 100644 index 395f46fb211..00000000000 --- a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeNumber.m +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_Utils_Numbers.h" - -#include - -/* - * Class: com_apple_jobjc_Utils_Numbers - * Method: getNativeNSNumberForJavaNumber - * Signature: (Ljava/lang/Number;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Utils_00024Numbers_getNativeNSNumberForJavaNumber -(JNIEnv *env, jclass clazz, jobject javaNumber) -{ - return ptr_to_jlong(JNFJavaToNSNumber(env, javaNumber)); -} - -/* - * Class: com_apple_jobjc_Utils_Numbers - * Method: getNativeJavaNumberForNSNumber - * Signature: (J)Ljava/lang/Number; - */ -JNIEXPORT jobject JNICALL Java_com_apple_jobjc_Utils_00024Numbers_getNativeJavaNumberForNSNumber -(JNIEnv *env, jclass clazz, jlong nativeNumber) -{ - return JNFNSToJavaNumber(env, (NSNumber *)jlong_to_ptr(nativeNumber)); -} diff --git a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeString.m b/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeString.m deleted file mode 100644 index 1e01545555d..00000000000 --- a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeString.m +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_Utils_Strings.h" - -#include - -/* - * Class: com_apple_jobjc_Utils_Strings - * Method: getNativeNSStringForJavaString - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_Utils_00024Strings_getNativeNSStringForJavaString -(JNIEnv *env, jclass clazz, jstring javaString) -{ - return ptr_to_jlong(JNFJavaToNSString(env, javaString)); -} - -/* - * Class: com_apple_jobjc_Utils_Strings - * Method: getNativeJavaStringForNSString - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_com_apple_jobjc_Utils_00024Strings_getNativeJavaStringForNSString -(JNIEnv *env, jclass clazz, jlong nativeString) -{ - return JNFNSToJavaString(env, (NSString *)jlong_to_ptr(nativeString)); -} diff --git a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeThread.m b/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeThread.m deleted file mode 100644 index 75062e44e0c..00000000000 --- a/jdk/src/macosx/native/jobjc/src/runtime-additions/native/NativeThread.m +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ - -#include "com_apple_jobjc_Utils_Threads.h" - -#import -#import - - -@interface JObjCCallable : NSObject { - @public jobject returnValue; - @public jthrowable exception; -} -@property jobject returnValue; -@property jthrowable exception; -- (void) performCallable:(JNFJObjectWrapper *)callableWrapper; -@end - -/* - * Class: com_apple_jobjc_Utils_Threads - * Method: performRunnableOnMainThreadNative - * Signature: (Ljava/lang/Runnable;Z)V - */ -JNIEXPORT void JNICALL Java_com_apple_jobjc_Utils_00024Threads_performRunnableOnMainThread -(JNIEnv *env, jclass clazz, jobject runnable, jboolean jWaitUntilDone) -{ -JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:jWaitUntilDone - withBlock:[JNFRunnable blockWithRunnable:runnable - withEnv:env]]; -JNF_COCOA_EXIT(env); -} - -/* - * Class: com_apple_jobjc_Utils_Threads - * Method: performCallableOnMainThreadNative - * Signature: (Ljava/util/concurrent/Callable;)Ljava/lang/Object; - */ -JNIEXPORT jobject JNICALL Java_com_apple_jobjc_Utils_00024Threads_performCallableOnMainThread -(JNIEnv *env, jclass clazz, jobject callable) -{ - jobject returnValue = NULL; - -JNF_COCOA_ENTER(env); - JNFJObjectWrapper *callableWrapper = [[JNFJObjectWrapper alloc] initWithJObject:callable withEnv:env]; - JObjCCallable *ncallable = [JObjCCallable alloc]; - - [ncallable performSelectorOnMainThread:@selector(performCallable:) - withObject:callableWrapper - waitUntilDone:true]; - - returnValue = ncallable.returnValue; - jthrowable exception = ncallable.exception; - - [ncallable release]; - if(exception) (*env)->Throw(env, exception); - -JNF_COCOA_EXIT(env); - - return returnValue; -} - - -@implementation JObjCCallable -@synthesize returnValue; -@synthesize exception; - -- (void) performCallable:(JNFJObjectWrapper *)callableWrapper { - static JNF_CLASS_CACHE(jc_Callable, "java/util/concurrent/Callable"); - static JNF_MEMBER_CACHE(jm_Callable_call, jc_Callable, "call", "()Ljava/lang/Object;"); - - JNFThreadContext threadWasAttached = JNFThreadDetachOnThreadDeath; - JNIEnv *env = JNFObtainEnv(&threadWasAttached); - jobject callable = [callableWrapper jObject]; - - @try{ - self.returnValue = JNFCallObjectMethod(env, callable, jm_Callable_call); - } @catch (JNFException *x) { - [x raiseToJava:env]; - } - - self.exception = (*env)->ExceptionOccurred(env); - (*env)->ExceptionClear(env); - - [callableWrapper release]; - JNFReleaseEnv(env, &threadWasAttached); -} - -@end diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BaseBench.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BaseBench.java deleted file mode 100644 index dbbb80cd31f..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BaseBench.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import sun.misc.Unsafe; - -public class BaseBench extends PooledTestCase { - protected final static JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); - protected final static JObjC JOBJC = JObjC.getInstance(); - protected final static Unsafe UNSAFE = JObjCRuntime.getInstance().unsafe; - protected final static NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); - - public abstract static class Task{ - final String name; - public Task(String name){ this.name = name; } - public abstract void run(); - } - - public void bench(final String title, final long warmup, final long runs, final long iterations, final Task... tasks){ - final long[] runtimes = new long[tasks.length]; - - for(int t = 0; t < tasks.length; ++t){ - long runtime = 0; - for(int i = 0; i < warmup; ++i) - singleBench(iterations, tasks[t]); - for(int i = 0; i < runs; ++i) - runtime = runtime + singleBench(iterations, tasks[t]); - runtimes[t] = runtime; - } - - final float[] relatives = new float[tasks.length]; - - for(int t = 0; t < tasks.length; ++t) - relatives[t] = ((float) runtimes[t] / (float) runs); - - float min = relatives[0]; - for(float t : relatives) - if(t < min) - min = t; - - for(int t = 0; t < tasks.length; ++t) - relatives[t] = relatives[t] / min; - - System.out.format("\n* %1$s\n", title); - for(int t = 0; t < tasks.length; ++t) - System.out.format("%1$60s : %2$.1f\n", tasks[t].name, relatives[t]); - } - - public long singleBench(final long iterations, final Task task){ - long start = System.currentTimeMillis(); - for(long i = 0; i < iterations; ++i) - task.run(); - long end = System.currentTimeMillis(); - return end - start; - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchFunCall.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchFunCall.java deleted file mode 100644 index 417ad6d1187..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchFunCall.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; - -public final class BenchFunCall extends BaseBench{ - final static int ITERS = 1000; - final static FunCall fc = new FunCall(JObjCRuntime.getInstance(), "sin", DoubleCoder.INST, DoubleCoder.INST); - final static double ARG = 3.14159265 / 2.0; - final static double RET = 1.0; - - private static native double jniSin(double arg); - - public void testBench(){ - this.bench("Calling functions", 5, 3, 10000L, - - new Task("JNI Invoke"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i) - jniSin(ARG); - }}, - - new Task("JObjC FunCall"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - fc.init(ARGS); - DoubleCoder.INST.push(ARGS, ARG); - fc.invoke(ARGS); - DoubleCoder.INST.pop(ARGS); - } - }}, - - new Task("JObjC FunCall (inlined)"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - // init - ARGS.argPtrsPtr = ARGS.buffer.bufferPtr; - ARGS.argValuesPtr = ARGS.buffer.bufferPtr + 256; - // push double - //// push arg ptr - if(JObjCRuntime.IS64) - UNSAFE.putLong(ARGS.argPtrsPtr, ARGS.argValuesPtr); - else - UNSAFE.putInt(ARGS.argPtrsPtr, (int) ARGS.argValuesPtr); - ARGS.argPtrsPtr += JObjCRuntime.PTR_LEN; - //// push arg value - UNSAFE.putDouble(ARGS.argValuesPtr, ARG); - ARGS.argValuesPtr += 8; - // invoke - FunCall.invoke(fc.cif.cif.bufferPtr, fc.fxnPtr, ARGS.retValPtr, ARGS.buffer.bufferPtr); - // pop - UNSAFE.getDouble(ARGS.retValPtr); - } - }} - ); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchIDPop.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchIDPop.java deleted file mode 100644 index b24059b3644..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchIDPop.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSString; - -public class BenchIDPop extends BaseBench{ - static native long jniNSStringAlloc(); - static native long jniNSStringAllocAndRetain(); - static native long jniNSStringCached(); - static native void jniCFRetain(long x); - static native void jniCFRelease(long x); - - final static int ITERS = 1000; - final static FoundationFramework FND = JOBJC.Foundation(); - - private static class LongWrap{ - long l; - public LongWrap(long l){ this.l = l; } - } - - public void testIt(){ - bench("Alloc, retain, pop a new NSString", 2, 3, 2000, - new Task("jniNSStringAllocAndRetain()"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - jniNSStringAllocAndRetain(); - }}, - - new Task("new LongWrap(jniNSStringAllocAndRetain())"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - new LongWrap(jniNSStringAllocAndRetain()); - }}, - - new Task("FND.NSString().alloc()"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - FND.NSString().alloc(); - }}, - - new Task("new NSString(jniNSStringAlloc(), RUNTIME)"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - new NSString(jniNSStringAlloc(), RUNTIME); - }} - ); - - final long nsstringPtr = jniNSStringAlloc(); - - bench("Get and hold an existing object", 2, 3, 2000, - new Task("jniCFRetain(nsstringPtr)"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - jniCFRetain(nsstringPtr); - }}, - - new Task("jniCFRetain(new LongWrap(nsstringPtr).l"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - jniCFRetain(new LongWrap(nsstringPtr).l); - }}, - - new Task("ID.getInstance(nsstringPtr, RUNTIME)"){ - @Override public void run() { - for(int i = 0; i < ITERS; i++) - ID.getInstance(nsstringPtr, RUNTIME); - }} - ); - } - -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchStructCoding.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchStructCoding.java deleted file mode 100644 index 9d0a769805a..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchStructCoding.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.Coder.StructCoder; -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSRect; - -public class BenchStructCoding extends BaseBench { - final static FoundationFramework FND = JOBJC.Foundation(); - final static int ITERS = 1000; - final static PrimitiveCoder CODER = com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder; - final static StructCoder RCODER = NSRect.getStructCoder(); - final static FunCall nsMakePoint = - new com.apple.jobjc.Invoke.FunCall(FND, "NSMakeRect", com.apple.jobjc.foundation.NSRect.getStructCoder(), - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder, - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder, - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder, - com.apple.jobjc.MixedPrimitiveCoder.FloatDoubleCoder); - - public void testFoo(){ - bench("NSMakeRect", 3, 3, 10, - new Task("FND.NSMakeRect"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - NSRect s = FND.NSMakeRect(0, 1, 2, 3); -// assertEquals(1.0D, s.origin().y()); - } - }}, - - new Task("nsMakeRect.invoke(..., s)"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - nsMakePoint.init(ARGS); - CODER.push(ARGS, 0.0D); - CODER.push(ARGS, 1.0D); - CODER.push(ARGS, 2.0D); - CODER.push(ARGS, 3.0D); - NSRect s = FND.makeNSRect(); - nsMakePoint.invoke(ARGS, s); -// assertEquals(1.0D, s.origin().y()); - } - }}, - - new Task("nsMakeRect.invoke(..); NSRect r = pop(..);"){ - @Override public void run() { - for(int i = 0; i < ITERS; ++i){ - nsMakePoint.init(ARGS); - CODER.push(ARGS, 0.0D); - CODER.push(ARGS, 1.0D); - CODER.push(ARGS, 2.0D); - CODER.push(ARGS, 3.0D); - nsMakePoint.invoke(ARGS); - NSRect s = (NSRect) RCODER.pop(ARGS); -// assertEquals(1.0D, s.origin().y()); - } - }} - ); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchUnsafe.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchUnsafe.java deleted file mode 100644 index f04c99d3dc8..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/BenchUnsafe.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import java.nio.ByteBuffer; - -public class BenchUnsafe extends BaseBench{ - final static int ITERS = 1000000; - - final static NativeBuffer NBUF = new NativeBuffer(2 * ITERS); - final static ByteBuffer BBUF = NBUF.buffer; - final static long ADDR = NBUF.bufferPtr; - final static long ADDR_MAX = NBUF.bufferPtr + ITERS; - - final static NativeBuffer NBUF2 = new NativeBuffer(2 * ITERS); - final static ByteBuffer BBUF2 = NBUF2.buffer; - final static long ADDR2 = NBUF2.bufferPtr; - final static long ADDR2_MAX = NBUF2.bufferPtr + ITERS; - - final static long ARG = 345; - - final static long BUFSIZE = BBUF.limit(); - - public void testIt(){ - this.bench("Memory writes", 5, 3, 100L, - - new Task("buffer.putLong"){ - @Override public void run() { - for(long i = 0; i < ITERS; i++) - BBUF.putLong((int) i, ARG); - }}, - - new Task("unsafe.putLong"){ - @Override public void run() { - for(long i = ADDR; i < ADDR_MAX; i++) - UNSAFE.putLong(i, ARG); - }}); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/CategoryTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/CategoryTest.java deleted file mode 100644 index b762d7e9bb2..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/CategoryTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.appkit.AppKitFramework; -import com.apple.jobjc.appkit.NSStringCategory; -import com.apple.jobjc.foundation.NSSize; -import com.apple.jobjc.foundation.NSString; - -public class CategoryTest extends PooledTestCase { - public void testAppKit_NSString(){ - AppKitFramework APPKIT = JObjC.getInstance().AppKit(); - - NSString nstr = Utils.get().strings().nsString("mirzapirza"); - NSStringCategory nstrx = APPKIT.NSStringCategory(nstr); - NSSize sz = nstrx.sizeWithAttributes(null); - - assertEquals(57.0, sz.width()); - assertEquals(15.0, sz.height()); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(CategoryTest.class); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/FunctionTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/FunctionTest.java deleted file mode 100644 index 00e3c4deac1..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/FunctionTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.Coder.PointerCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Coder.VoidCoder; -import com.apple.jobjc.Invoke.FunCall; - -public class FunctionTest extends PooledTestCase { - NativeArgumentBuffer nativeBuffer; - JObjCRuntime runtime; - - @Override - public void setUp() throws Exception { - super.setUp(); - nativeBuffer = UnsafeRuntimeAccess.getNativeBuffer(); - runtime = nativeBuffer.runtime; - } - - public void testInvokeNoParamNoReturn() throws Throwable { - final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSBeep", VoidCoder.INST); - - fxn.init(nativeBuffer); - fxn.invoke(nativeBuffer); - } - - public void testInvokeNoParams() throws Throwable { - final FunCall fxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSFullUserName", PointerCoder.INST); - - fxn.init(nativeBuffer); - fxn.invoke(nativeBuffer); - - final long ptr = PrimitivePointerCoder.INST.pop(nativeBuffer); - System.out.println("0x" + Long.toHexString(ptr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(ptr)); - } - - public void testInvokeOneParam() throws Throwable { - final FunCall getHomeDirFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getAppKit(), "NSHomeDirectory", PointerCoder.INST); - - getHomeDirFxn.init(nativeBuffer); - getHomeDirFxn.invoke(nativeBuffer); - - final long homeDirPtr = PrimitivePointerCoder.INST.pop(nativeBuffer); - System.out.println("0x" + Long.toHexString(homeDirPtr) + ": " + UnsafeRuntimeAccess.getDescriptionForPtr(homeDirPtr)); - - final FunCall getTypeOfFxn = UnsafeRuntimeAccess.createFunCall(TestUtils.getFoundation(), "NSLog", PointerCoder.INST, PointerCoder.INST); - getTypeOfFxn.init(nativeBuffer); - PrimitivePointerCoder.INST.push(runtime, nativeBuffer, homeDirPtr); - getTypeOfFxn.invoke(nativeBuffer); - - // long typePtr = PointerCoder.pointer_coder.popPtr(nativeBuffer); - // System.out.println("0x" + Long.toHexString(typePtr) + ": " + TestUtils.getDescriptionForPtr(typePtr)); - } - - public static void main(final String[] args) { - junit.textui.TestRunner.run(FunctionTest.class); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/GUIDemo.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/GUIDemo.java deleted file mode 100644 index c9a3f46b05e..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/GUIDemo.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.Utils.Strings; -import com.apple.jobjc.appkit.NSApplication; -import com.apple.jobjc.appkit.NSButton; -import com.apple.jobjc.appkit.NSDrawer; -import com.apple.jobjc.appkit.NSMenu; -import com.apple.jobjc.appkit.NSWindow; -import com.apple.jobjc.foundation.NSAutoreleasePool; -import com.apple.jobjc.foundation.NSObject; -import com.apple.jobjc.foundation.NSObjectClass; -import com.apple.jobjc.foundation.NSRect; -import com.apple.jobjc.foundation.NSSize; - -class MyDelegate extends NSObject{ - static final JObjC objc = JObjC.getInstance(); - static final Strings str = Utils.get().strings(); - - public MyDelegate(long ptr, JObjCRuntime r) { super(ptr, r); } - - private NSWindow myWindow; - private NSDrawer myDrawer; - - public void printHello(ID sender){ - System.out.println("Hello!"); - myDrawer.toggle(this); - } - - public void createMenu(){ - NSMenu menu = objc.AppKit().NSMenu().newID(); - menu.addItemWithTitle_action_keyEquivalent( - str.nsString("Quit"), - new SEL("terminate:"), - str.nsString("q")); - NSApplication app = objc.AppKit().NSApp(); - app.setMainMenu(menu); - } - - public void createWindow(){ - NSRect rect; - int styleMask = objc.AppKit().NSTitledWindowMask() | objc.AppKit().NSMiniaturizableWindowMask(); - NSButton myButton; - NSSize buttonSize; - myButton = objc.AppKit().NSButton().newID(); - myButton.setTitle(str.nsString("Print Hello!")); - myButton.sizeToFit(); - myButton.setTarget(this); - myButton.setAction(new SEL("printHello:")); - buttonSize = myButton.frame().size(); - rect = objc.Foundation().NSMakeRect(100, 100, 2*buttonSize.width(), 2*buttonSize.height()); - myWindow = objc.AppKit().NSWindow().alloc(); - myWindow = myWindow.initWithContentRect_styleMask_backing_defer( - rect, styleMask, objc.AppKit().NSBackingStoreBuffered(), false); - myWindow.setTitle(str.nsString("This is a test window.")); - myWindow.setContentView(myButton); - - myDrawer = objc.AppKit().NSDrawer().alloc(); - myDrawer = myDrawer.initWithContentSize_preferredEdge( - objc.Foundation().NSMakeSize(100, 40), objc.Foundation().NSMinYEdge()); - myDrawer.setParentWindow(myWindow); - } - - public void applicationWillFinishLaunching(ID not){ - createMenu(); - createWindow(); - } - - public void applicationDidFinishLaunching(ID not){ - myWindow.makeKeyAndOrderFront(null); - } -} - -class MyDelegateClass extends NSObjectClass{ - public MyDelegateClass(JObjCRuntime r){ super(r); } -} - -public class GUIDemo{ - static final JObjC objc = JObjC.getInstance(); - - public static void main(String[] args){ - JObjCRuntime.getInstance().registerUserClass(MyDelegate.class, MyDelegateClass.class); - - objc.AppKit().NSApplication().sharedApplication(); - NSApplication app = objc.AppKit().NSApp(); - - NSAutoreleasePool pool = objc.Foundation().NSAutoreleasePool().alloc(); - pool = pool.init(); - app.setDelegate(new MyDelegateClass(JObjCRuntime.getInstance()).newID()); - app.run(); - pool.drain(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IBDemo.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IBDemo.java deleted file mode 100644 index dbfc1eff4a3..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IBDemo.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ -/** - * To locate the nib correctly, this demo must run from - * a .app (created with Jar Bundler...). - * - * TODO Add .app/Jar Bundler as ant task - */ - -package com.apple.jobjc; - -import java.awt.Toolkit; - -import com.apple.jobjc.appkit.AppKitFramework; -import com.apple.jobjc.appkit.NSApplication; -import com.apple.jobjc.appkit.NSView; -import com.apple.jobjc.appkit.NSViewClass; -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSRect; -import com.apple.jobjc.foundation.NSString; - -class MyView extends NSView{ - static final AppKitFramework APPKIT = JObjC.getInstance().AppKit(); - - public MyView(long objPtr, JObjCRuntime runtime) { super(objPtr, runtime); } - - @Override public void drawRect(NSRect r){ - APPKIT.NSColor().redColor().set(); - APPKIT.NSBezierPath().fillRect(r); - } -} - -class MyViewClass extends NSViewClass{ - protected MyViewClass(String name, JObjCRuntime runtime) { super(name, runtime); } - public MyViewClass(JObjCRuntime runtime){ this(MyView.class.getSimpleName(), runtime); } -} - -public class IBDemo{ - final static FoundationFramework FOUNDATION = JObjC.getInstance().Foundation(); - final static AppKitFramework APPKIT = JObjC.getInstance().AppKit(); - - // Works if the JVM is launched on the main thread, - // but JavaApplicationStub does not understand -XstartOnFirstThread - public static void mainWithAppMain(String[] args){ - APPKIT.NSApplicationMain(0, null); - } - - // Work around: let someone else init, and then - // get on the main thread to load the nib. - public static void mainWithoutAppMain(String[] args){ - Toolkit.getDefaultToolkit(); - - Utils.get().threads().performOnMainThread(new Runnable(){ - public void run() { - APPKIT.NSApplication().sharedApplication(); - NSApplication APP = APPKIT.NSApp(); - - NSString nibName = Utils.get().strings().nsString("MainMenu"); - boolean loadedNib = APPKIT.NSBundleCategory().loadNibNamed_owner(nibName, APP); - if(!loadedNib) throw new RuntimeException("Failed to load nib."); - }}, false); - } - - public static void main(String[] args){ - JObjCRuntime.getInstance().registerUserClass(MyView.class, MyViewClass.class); - mainWithoutAppMain(args); - //mainWithAppMain(args); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IntroTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IntroTest.java deleted file mode 100644 index edd5f072575..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/IntroTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import junit.framework.TestCase; - -import com.apple.jobjc.Invoke.FunCall; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; -import com.apple.jobjc.appkit.AppKitFramework; -import com.apple.jobjc.appkit.NSApplication; -import com.apple.jobjc.appkit.NSApplicationClass; -import com.apple.jobjc.appkit.NSColorPanel; -import com.apple.jobjc.appkit.NSWorkspace; -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSAutoreleasePool; -import com.apple.jobjc.foundation.NSPoint; -import com.apple.jobjc.foundation.NSString; -import com.apple.jobjc.foundation.NSStringClass; - -public class IntroTest extends TestCase{ - // The low-level core makes function calls, sends messages, marshals data, etc. - public void testCore(){ - // pass security check and get ahold of a runtime (should cache this) - final JObjCRuntime RUNTIME = JObjCRuntime.getInstance(); - final NativeArgumentBuffer ARGS = JObjCRuntime.getInstance().getThreadLocalState(); - - // create a funcall (should cache this) - final FunCall fc = new FunCall(RUNTIME, "sin", DoubleCoder.INST, DoubleCoder.INST); - - // start function call - fc.init(ARGS); - // push an arg - DoubleCoder.INST.push(ARGS, 3.14159265 / 2.0); - // make the call - fc.invoke(ARGS); - // read the return value - double ret = DoubleCoder.INST.pop(ARGS); - - assertEquals(1.0, ret); - } - - // Frameworks bridge the Mac OS X frameworks - public void testFrameworks(){ - // First, get an instance of JObjC: - final JObjC JOBJC = com.apple.jobjc.JObjC.getInstance(); - - // It's your gateway to the frameworks. - final FoundationFramework FND = JOBJC.Foundation(); - final AppKitFramework APP = JOBJC.AppKit(); - - // From which you can then access... - - // enums, defines, constants - int nsmye = FND.NSMaxYEdge(); - boolean debug = FND.NSDebugEnabled(); - - // structs - NSPoint p = FND.makeNSPoint(); - p.setX(3); - assertEquals(3.0, p.x()); - - // C functions - NSPoint p2 = FND.NSMakePoint(12, 34); - assertEquals(12.0, p2.x()); - - // ... Let's create an AutoreleasePool before we go on - NSAutoreleasePool pool = ((NSAutoreleasePool) FND.NSAutoreleasePool().alloc()).init(); - - // Objective-C classes - NSStringClass nsc = FND.NSString(); - - // class-methods - NSString nsStringClassDescr = nsc.description(); - - // instances - NSString nsi = ((NSString) FND.NSString().alloc()).init(); - - // instance methods - NSString d = nsi.description(); - - // The bridge marshals some types for you, but it doesn't - // convert between NSString and Java String automatically. - // For that we use Utils.get().strings().nsString(String) - // and Utils.get().strings().javaString(NSString); - - assertEquals("NSString", Utils.get().strings().javaString(nsStringClassDescr)); - - NSString format = Utils.get().strings().nsString("Foo bar %d baz"); - - NSString formatted = ((NSString) FND.NSString().alloc()).initWithFormat(format, 34); - String jformatted = Utils.get().strings().javaString(formatted); - - assertEquals("Foo bar 34 baz", jformatted); - - // Reveal in Finder -// NSString file = Utils.get().strings().nsString( -// "/Applications/Calculator.app/Contents/Resources/Calculator.icns"); -// APP.NSWorkspace().sharedWorkspace() -// .selectFile_inFileViewerRootedAtPath(file, null); - - pool.drain(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NSClassTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NSClassTest.java deleted file mode 100644 index cbd5105737f..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NSClassTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSString; -import com.apple.jobjc.foundation.NSStringClass; - -public class NSClassTest extends PooledTestCase{ - JObjC JOBJC = JObjC.getInstance(); - FoundationFramework FND = JOBJC.Foundation(); - - public void testNSClassName(){ - NSString s = ((NSString) FND.NSString().alloc()).init(); - - NSString cname = s.className(); - String jcname = Utils.get().strings().javaString(cname); - assertEquals("NSCFString", jcname); - } - - public void testNSClassPop(){ - NSString s = ((NSString) FND.NSString().alloc()).init(); - - NSStringClass c = s.classNSClass(); - String jdescr = Utils.get().strings().javaString(c.description()); - assertEquals("NSCFString", jdescr); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeBufferTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeBufferTest.java deleted file mode 100644 index a6c93ab382e..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeBufferTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import junit.framework.TestCase; - -public class NativeBufferTest extends TestCase{ - public void testSlicePtrs(){ - JObjC.getInstance(); - - NativeBuffer b = new NativeBuffer(123); - b.position(1); - NativeBuffer c = b.slice(); - assertEquals(b.bufferPtr + 1, c.bufferPtr); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeTypeTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeTypeTest.java deleted file mode 100644 index fb352f78046..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/NativeTypeTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.internal.jobjc.generator.model.types.NType; -import com.apple.internal.jobjc.generator.utils.NTypeMerger; -import com.apple.internal.jobjc.generator.utils.NTypeParser; - -public class NativeTypeTest extends PooledTestCase{ - - private NType doParse(String type){ - NType nt = NTypeParser.parseFrom(type); - String printed = nt.toString(); - System.out.println("Original: " + type); - System.out.println("Printed.: " + printed); - assertEquals(type, printed); - return nt; - } - - // {_NSRect= - // "origin"{_NSPoint="x"f"y"f} - // "size"{_NSSize="width"f"height"f}} - public void testStruct(){ - doParse("{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}"); - } - - // {IOBluetoothL2CAPChannelEvent= - // "eventType"i - // "u"(?= - // "data"{IOBluetoothL2CAPChannelDataBlock= - // "dataPtr"^v - // "dataSize"I} - // "writeRefCon"^v - // "padding"[32C]) - // "status"i} - public void testUnion(){ - doParse("{IOBluetoothL2CAPChannelEvent=\"eventType\"i\"u\"(?=\"data\"{IOBluetoothL2CAPChannelDataBlock=\"dataPtr\"^v\"dataSize\"I}\"writeRefCon\"^v\"padding\"[32C])\"status\"i}"); - } - - public void testUnknown(){ - doParse("{_CFSocketContext=\"version\"i\"info\"^v\"retain\"^?\"release\"^?\"copyDescription\"^?}"); - } - - public void testEmptyStruct(){ - doParse("{_CFSocketSignature=\"protocolFamily\"i\"socketType\"i\"protocol\"i\"address\"^{__CFData}}"); - } - - public void testCharPtr(){ - doParse("^*"); - } - - public void doEquals(final String s){ - assertEquals(doParse(s), doParse(s)); - } - - public void testEquals(){ - doEquals("{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}"); - doEquals("{IOBluetoothL2CAPChannelEvent=\"eventType\"i\"u\"(?=\"data\"{IOBluetoothL2CAPChannelDataBlock=\"dataPtr\"^v\"dataSize\"I}\"writeRefCon\"^v\"padding\"[32C])\"status\"i}"); - doEquals("{_CFSocketContext=\"version\"i\"info\"^v\"retain\"^?\"release\"^?\"copyDescription\"^?}"); - doEquals("{_CFSocketSignature=\"protocolFamily\"i\"socketType\"i\"protocol\"i\"address\"^{__CFData}}"); - } - - public void testMerge(){ - NType a = doParse("{_NSRect={_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=ff}}"); - NType b = doParse("{_NSRect=\"origin\"{_NSPoint=ff}{_NSSize=\"width\"f\"height\"f}}"); - NType c = NTypeMerger.inst().merge(a, b); - NType expected = doParse("{_NSRect=\"origin\"{_NSPoint=\"x\"f\"y\"f}\"size\"{_NSSize=\"width\"f\"height\"f}}"); - System.out.println("Merge results:"); - System.out.println("\ta: " + a.toString()); - System.out.println("\tb: " + b.toString()); - System.out.println("\tc: " + c.toString()); - System.out.println("\tx: " + expected.toString()); - assertEquals(expected, c); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/PooledTestCase.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/PooledTestCase.java deleted file mode 100644 index f52c3860f47..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/PooledTestCase.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import junit.framework.TestCase; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSAutoreleasePool; - -public class PooledTestCase extends TestCase { - static{ - System.loadLibrary("JObjC-tests"); - } - NSAutoreleasePool pool; - - @Override public void setUp() throws Exception { - FoundationFramework foundation = JObjC.getInstance().Foundation(); - pool = foundation.NSAutoreleasePool().alloc(); - pool.init(); - } - - @Override public void tearDown() throws Exception { - pool.drain(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SELTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SELTest.java deleted file mode 100644 index 1fd94e12ec1..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SELTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.Coder.PointerCoder; -import com.apple.jobjc.Coder.PrimitivePointerCoder; -import com.apple.jobjc.Invoke.MsgSend; - -public class SELTest extends PooledTestCase { - - NativeArgumentBuffer nativeBuffer; - JObjCRuntime runtime; - - @Override - public void setUp() throws Exception { - super.setUp(); - nativeBuffer = UnsafeRuntimeAccess.getNativeBuffer(); - runtime = nativeBuffer.runtime; - } - - public void testGetBlackColor() throws Throwable { - final MacOSXFramework appKit = TestUtils.getAppKit(); - final NSClass clazz = UnsafeRuntimeAccess.getNSClass(appKit, "NSColor"); - final MsgSend sel = UnsafeRuntimeAccess.createMsgSend(clazz, "redColor", PointerCoder.INST); - - sel.init(nativeBuffer, clazz); - sel.invoke(nativeBuffer); - - final long blackColorPtr = PrimitivePointerCoder.INST.pop(nativeBuffer); - String dscr = UnsafeRuntimeAccess.getDescriptionForPtr(blackColorPtr); - - System.out.println("0x" + Long.toHexString(blackColorPtr) + ": " + dscr); - assertEquals("NSCalibratedRGBColorSpace 1 0 0 1", dscr); - } - - public static void main(final String[] args) { - junit.textui.TestRunner.run(SELTest.class); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/StructTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/StructTest.java deleted file mode 100644 index b55e731fa58..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/StructTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import java.io.StringWriter; - -import com.apple.jobjc.coreaudio.AudioBuffer; -import com.apple.jobjc.foundation.NSPoint; -import com.apple.jobjc.foundation.NSRect; - -public class StructTest extends PooledTestCase { - public void testSimpleStruct(){ - AudioBuffer b = JObjC.getInstance().CoreAudio().makeAudioBuffer(); - assertEquals(0, b.mNumberChannels()); - assertEquals(0, b.mDataByteSize()); - b.setMNumberChannels(1); - b.setMDataByteSize(3); - assertEquals(1, b.mNumberChannels()); - assertEquals(3, b.mDataByteSize()); - } - - public void testNestedStruct(){ - NSRect r = JObjC.getInstance().Foundation().makeNSRect(); - assertTrue(0f == r.size().width()); - r.size().setWidth(3f); - assertTrue(3f == r.size().width()); - assertTrue(r.size() == r.size()); - } - - public void testSTRET(){ - NSPoint point = JObjC.getInstance().Foundation().NSMakePoint(3, 4); - assertTrue(point.x() == 3); - assertTrue(point.y() == 4); - - NSRect rect = JObjC.getInstance().Foundation().NSMakeRect(0, 1, 2, 3); - assertTrue(rect.origin().x() == 0); - assertTrue(rect.origin().y() == 1); - assertTrue(rect.size().width() == 2); - assertTrue(rect.size().height() == 3); - } - - // - - private char halfByteToHex(int b){ - return (b >= 0x0 && b < 0xA) ? (char) ('0' + b) : (char) ('A' + (b-0xA)); - } - - private String byteToHexString(Byte b){ - StringWriter sw = new StringWriter(); - sw.append(halfByteToHex(b & 0xF)); - sw.append(halfByteToHex((b & 0xF0) >> 4)); - return sw.toString(); - } - - String print(Struct st){ - StringWriter sw = new StringWriter(); - st.raw.position(0); - sw.append(st.getClass().getSimpleName() + ":" + st.raw.limit() + " @ " + Long.toHexString(st.raw.bufferPtr) + " : "); - for(int i = 0; i < st.raw.limit(); i++){ - sw.append(byteToHexString(st.raw.get()) + " "); - if((i+1) % 4 == 0) - sw.append(" "); - } - System.out.println(sw.toString().trim()); - return sw.toString().trim(); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(StructTest.class); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SubclassingTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SubclassingTest.java deleted file mode 100644 index bfe91440d2b..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/SubclassingTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.Coder.IDCoder; -import com.apple.jobjc.Coder.VoidCoder; -import com.apple.jobjc.Invoke.MsgSend; -import com.apple.jobjc.Invoke.MsgSendSuper; -import com.apple.jobjc.PrimitiveCoder.DoubleCoder; -import com.apple.jobjc.PrimitiveCoder.FloatCoder; -import com.apple.jobjc.PrimitiveCoder.SIntCoder; -import com.apple.jobjc.PrimitiveCoder.SLongLongCoder; -import com.apple.jobjc.foundation.NSObject; -import com.apple.jobjc.foundation.NSObjectClass; -import com.apple.jobjc.foundation.NSPoint; -import com.apple.jobjc.foundation.NSString; - -public class SubclassingTest extends PooledTestCase{ - JObjCRuntime runtime; - NativeArgumentBuffer ctx; - - @Override public void setUp() throws Exception{ - super.setUp(); - this.runtime = JObjCRuntime.getInstance(); - this.ctx = runtime.getThreadLocalState(); - - runtime.registerUserClass(MyObject.class, MyObjectClass.class); - } - - public void testClass(){ - final MyObjectClass cls = new MyObjectClass(runtime); - assertEquals(MyObject.class.getSimpleName(), UnsafeRuntimeAccess.getClassNameFor(cls)); - } - - public void testInst(){ - final MyObjectClass cls = new MyObjectClass(runtime); - final MyObject instObj = cls.alloc(); - final MyObject retrievedObj = Subclassing.getJObjectFromIVar(UnsafeRuntimeAccess.getObjPtr(instObj)); - assertTrue(instObj == retrievedObj); - } - - public void testVoidVoidMethod(){ - final MyObject instObj = new MyObjectClass(runtime).alloc(); - - assertEquals(0, instObj.myMethodHits); - MsgSend sel = new MsgSend(runtime, "myMethod", VoidCoder.INST); - sel.init(ctx, instObj); - sel.invoke(ctx); - assertEquals(1, instObj.myMethodHits); - } - - public void testMsgSendSuper(){ - final MyObjectClass cls = new MyObjectClass(runtime); - final MyObject obj = ((MyObject) cls.alloc()).init(); - - // direct descr - - assertEquals("foo", Utils.get().strings().javaString(obj.description())); - - // indirect (from native) descr - { - MsgSend msgSend = new MsgSend(runtime, "description", IDCoder.INST); - msgSend.init(ctx, obj); - msgSend.invoke(ctx); - assertEquals("foo", Utils.get().strings().javaString((NSString) IDCoder.INST.pop(ctx))); - } - - // indirect (from native) descr - { - MsgSendSuper msgSendSuper = new MsgSendSuper(runtime, "description", IDCoder.INST); - msgSendSuper.init(ctx, obj, cls); - msgSendSuper.invoke(ctx); - assertEquals("foo", Utils.get().strings().javaString((NSString) IDCoder.INST.pop(ctx))); - } - - // nso descr - { - MsgSendSuper msgSendSuper = new MsgSendSuper(runtime, "description", IDCoder.INST); - msgSendSuper.init(ctx, obj, JObjC.getInstance().Foundation().NSObject()); - msgSendSuper.invoke(ctx); - - final NSString nsod = (NSString) IDCoder.INST.pop(ctx); - String jde = Utils.get().strings().javaString(nsod); - assertEquals(jde.substring(0, 9), " 0) - js2 += jss; - return Utils.get().strings().nsString(js2); - } - - public double add_and_and(int a, long b, float c){ - return a + b + c; - } - - public NSPoint doubleIt(NSPoint p){ - System.out.println("Doubling NSPoint(" + p.x() + ", " + p.y() + ")."); - p.setX(p.x() * 2); - p.setY(p.y() * 2); - return p; - } - - @Override public NSString description(){ - return Utils.get().strings().nsString("foo"); - } -} - -class MyObjectClass extends NSObjectClass{ - protected MyObjectClass(String name, JObjCRuntime runtime) { - super(name, runtime); - } - - public MyObjectClass(JObjCRuntime runtime){ - this("MyObject", runtime); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/TestUtils.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/TestUtils.java deleted file mode 100644 index 1bf18154d84..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/TestUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - - -public class TestUtils { - static MacOSXFramework getAppKit() { - return UnsafeRuntimeAccess.getFramework(new String[]{"/System/Library/Frameworks/AppKit.framework/AppKit"}); - } - - static MacOSXFramework getFoundation() { - return UnsafeRuntimeAccess.getFramework(new String[]{"/System/Library/Frameworks/Foundation.framework/Foundation"}); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/UtilsTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/UtilsTest.java deleted file mode 100644 index b77a82f92af..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/UtilsTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import java.util.concurrent.Callable; - -import com.apple.jobjc.foundation.NSString; - -public class UtilsTest extends PooledTestCase{ - public void testStrings(){ - String s = "fooBarBazDazzle"; - NSString ns = Utils.get().strings().nsString(s); - String t = Utils.get().strings().javaString(ns); - assertEquals(s, t); - } - - public void testThreadsPerformRunnableOnMainThread(){ - final long testThreadId = Thread.currentThread().getId(); - class Wrap{ public long x = testThreadId; } - final Wrap wrap = new Wrap(); - assertTrue(testThreadId == wrap.x); - - Utils.get().threads().performOnMainThread(new Runnable(){ - public void run() { - wrap.x = Thread.currentThread().getId(); - } - }, true); - - assertTrue(testThreadId != wrap.x); - } - - public void testThreadsPerformCallableOnMainThread() throws Exception{ - final long testThreadId = Thread.currentThread().getId(); - final long mainThreadId = Utils.get().threads().performOnMainThread(new Callable(){ - public Long call() { return Thread.currentThread().getId(); } - }); - assertTrue(testThreadId != mainThreadId); - } - - public void testThreadsPerformCallableOnMainThreadException() throws Exception{ - class FooException extends RuntimeException{} - try { - Utils.get().threads().performOnMainThread(new Callable(){ - public Object call() { throw new FooException(); } - }); - } catch (FooException e) { - return; - } - fail("Failed to catch exception."); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(UtilsTest.class); - } -} - diff --git a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/VarArgsTest.java b/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/VarArgsTest.java deleted file mode 100644 index 6d8774ece87..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/java/com/apple/jobjc/VarArgsTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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.apple.jobjc; - -import com.apple.jobjc.foundation.FoundationFramework; -import com.apple.jobjc.foundation.NSDictionary; -import com.apple.jobjc.foundation.NSString; - -public class VarArgsTest extends PooledTestCase { - FoundationFramework FND = JObjC.getInstance().Foundation(); - - public void testNSString_initWithFormat(){ - String expected = "1 + 0.2 = 1.2 abracadabra"; - NSString format = Utils.get().strings().nsString("%d + %.1f = %.1f %@"); - - NSString abra = Utils.get().strings().nsString("abracadabra"); - - NSString nstr = ((NSString)FND.NSString().alloc()).initWithFormat(format, 1, 0.2, 1.2, abra); - String actual = Utils.get().strings().javaString(nstr); - - assertEquals(expected, actual); - } - - public void testNSDictionary(){ - NSString v1 = Utils.get().strings().nsString("value1"); - NSString v2 = Utils.get().strings().nsString("value2"); - NSString k1 = Utils.get().strings().nsString("key1"); - NSString k2 = Utils.get().strings().nsString("key2"); - - NSDictionary dict = ((NSDictionary)FND.NSDictionary().alloc()).initWithObjectsAndKeys(v1, k1, v2, k2, null); - - NSString nsdescr = dict.description(); - String jdescr = Utils.get().strings().javaString(nsdescr); - - assertEquals("{\n key1 = value1;\n key2 = value2;\n}", jdescr); - } - - public static void main(String[] args){ - junit.textui.TestRunner.run(VarArgsTest.class); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/tests/native/FunCallBench.m b/jdk/src/macosx/native/jobjc/src/tests/native/FunCallBench.m deleted file mode 100644 index 3c5f9adcc8f..00000000000 --- a/jdk/src/macosx/native/jobjc/src/tests/native/FunCallBench.m +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2011, 2012, 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. - */ -#include -#include - -#include "com_apple_jobjc_BenchFunCall.h" -#include - -JNIEXPORT jdouble JNICALL Java_com_apple_jobjc_BenchFunCall_jniSin -(JNIEnv *env, jclass clazz, jdouble x) -{ - return (jdouble) sin((double) x); -} - - -#include "com_apple_jobjc_BenchIDPop.h" - -JNIEXPORT void JNICALL Java_com_apple_jobjc_BenchIDPop_jniCFRetain -(JNIEnv *env, jclass clazz, jlong x) -{ - CFRetain(jlong_to_ptr(x)); -} - -JNIEXPORT void JNICALL Java_com_apple_jobjc_BenchIDPop_jniCFRelease -(JNIEnv *env, jclass clazz, jlong x) -{ - CFRelease(jlong_to_ptr(x)); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_BenchIDPop_jniNSStringAlloc -(JNIEnv *env, jclass clazz) -{ - return ptr_to_jlong([NSString alloc]); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_BenchIDPop_jniNSStringAllocAndRetain -(JNIEnv *env, jclass clazz) -{ - return ptr_to_jlong(CFRetain([NSString alloc])); -} - -JNIEXPORT jlong JNICALL Java_com_apple_jobjc_BenchIDPop_jniNSStringCached -(JNIEnv *env, jclass clazz) -{ - static jlong str = 0; - if(!str) str = ptr_to_jlong([NSString alloc]); - return str; -} diff --git a/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java b/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java index 8d54633adb1..6b5eea85d6d 100644 --- a/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java +++ b/jdk/src/share/classes/com/sun/crypto/provider/CipherCore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -720,6 +720,15 @@ final class CipherCore { int outLen = 0; if (len != 0) { // there is some work to do + if ((input == output) + && (outputOffset < (inputOffset + inputLen)) + && (inputOffset < (outputOffset + buffer.length))) { + // copy 'input' out to avoid its content being + // overwritten prematurely. + input = Arrays.copyOfRange(input, inputOffset, + inputOffset + inputLen); + inputOffset = 0; + } if (len <= buffered) { // all to-be-processed data are from 'buffer' if (decrypting) { @@ -732,37 +741,37 @@ final class CipherCore { System.arraycopy(buffer, len, buffer, 0, buffered); } } else { // len > buffered - if ((input != output) && (buffered == 0)) { - // all to-be-processed data are from 'input' - // however, note that if 'input' and 'output' are the same, - // then they can't be passed directly to the underlying cipher - // engine operations as data may be overwritten before they - // are read. + int inputConsumed = len - buffered; + int temp; + if (buffered > 0) { + int bufferCapacity = buffer.length - buffered; + if (bufferCapacity != 0) { + temp = Math.min(bufferCapacity, inputConsumed); + System.arraycopy(input, inputOffset, buffer, buffered, temp); + inputOffset += temp; + inputConsumed -= temp; + inputLen -= temp; + buffered += temp; + } + // process 'buffer' if (decrypting) { - outLen = cipher.decrypt(input, inputOffset, len, output, outputOffset); + outLen = cipher.decrypt(buffer, 0, buffered, output, outputOffset); } else { - outLen = cipher.encrypt(input, inputOffset, len, output, outputOffset); - } - inputOffset += len; - inputLen -= len; - } else { - // assemble the data using both 'buffer' and 'input' - byte[] in = new byte[len]; - int inConsumed = len - buffered; - if (buffered != 0) { - System.arraycopy(buffer, 0, in, 0, buffered); - buffered = 0; - } - if (inConsumed != 0) { - System.arraycopy(input, inputOffset, in, len - inConsumed, inConsumed); - inputOffset += inConsumed; - inputLen -= inConsumed; + outLen = cipher.encrypt(buffer, 0, buffered, output, outputOffset); } + outputOffset += outLen; + buffered = 0; + } + if (inputConsumed > 0) { // still has input to process if (decrypting) { - outLen = cipher.decrypt(in, 0, len, output, outputOffset); + outLen += cipher.decrypt(input, inputOffset, inputConsumed, + output, outputOffset); } else { - outLen = cipher.encrypt(in, 0, len, output, outputOffset); + outLen += cipher.encrypt(input, inputOffset, inputConsumed, + output, outputOffset); } + inputOffset += inputConsumed; + inputLen -= inputConsumed; } } // Let's keep track of how many bytes are needed to make @@ -925,8 +934,10 @@ final class CipherCore { byte[] finalBuf = input; int finalOffset = inputOffset; int finalBufLen = inputLen; - if ((input == output) || (buffered != 0) || - (!decrypting && padding != null)) { + if ((buffered != 0) || (!decrypting && padding != null) || + ((input == output) + && (outputOffset < (inputOffset + inputLen)) + && (inputOffset < (outputOffset + buffer.length)))) { if (decrypting || padding == null) { paddingLen = 0; } diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CopiedFile.java b/jdk/src/share/classes/java/awt/font/JavaAWTFontAccessImpl.java similarity index 53% rename from jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CopiedFile.java rename to jdk/src/share/classes/java/awt/font/JavaAWTFontAccessImpl.java index 7061b86be92..a15b9311fb9 100644 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/classes/CopiedFile.java +++ b/jdk/src/share/classes/java/awt/font/JavaAWTFontAccessImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,33 +22,36 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.apple.internal.jobjc.generator.classes; -import java.io.*; +package java.awt.font; -public class CopiedFile extends OutputFile { - final File sourceFile; +import java.lang.reflect.Field; +import sun.misc.JavaAWTFontAccess; - public CopiedFile(final File sourceFile, final String pkg, final String filename) { - super(pkg, filename); - this.sourceFile = sourceFile; - } +class JavaAWTFontAccessImpl implements sun.misc.JavaAWTFontAccess { - @Override - public void write(final File parentDir) { - try { - final PrintStream out = open(parentDir); - final InputStream in = new FileInputStream(sourceFile); - - copy(in, out); - close(out); - } catch (final IOException e) { throw new RuntimeException(e); } - } - - private static void copy(final InputStream in, final PrintStream out) throws IOException { - int bit; - while (-1 != (bit = in.read())) { - out.write(bit); + // java.awt.font.TextAttribute constants + public Object getTextAttributeConstant(String name) { + switch (name) { + case "RUN_DIRECTION": + case "NUMERIC_SHAPING": + case "BIDI_EMBEDDING": + case "RUN_DIRECTION_LTR": + try { + Field f = TextAttribute.class.getField(name); + return f.get(null); + } catch (NoSuchFieldException | IllegalAccessException x) { + throw new AssertionError(x); + } } + + throw new AssertionError("Constant name is not recognized"); } + + // java.awt.font.NumericShaper + public void shape(Object shaper, char[] text, int start, int count) { + assert shaper instanceof NumericShaper; + ((NumericShaper)shaper).shape(text, start,count); + } + } diff --git a/jdk/src/share/classes/java/awt/font/NumericShaper.java b/jdk/src/share/classes/java/awt/font/NumericShaper.java index 7e1980e9fe2..c02d959e0bd 100644 --- a/jdk/src/share/classes/java/awt/font/NumericShaper.java +++ b/jdk/src/share/classes/java/awt/font/NumericShaper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.util.Arrays; import java.util.Comparator; import java.util.EnumSet; import java.util.Set; +import sun.misc.SharedSecrets; /** * The NumericShaper class is used to convert Latin-1 (European) @@ -134,6 +135,14 @@ import java.util.Set; */ public final class NumericShaper implements java.io.Serializable { + + // For access from java.text.Bidi + static { + if (SharedSecrets.getJavaAWTFontAccess() == null) { + SharedSecrets.setJavaAWTFontAccess(new JavaAWTFontAccessImpl()); + } + } + /** * A {@code NumericShaper.Range} represents a Unicode range of a * script having its own decimal digits. For example, the {@link diff --git a/jdk/src/share/classes/java/awt/font/TextAttribute.java b/jdk/src/share/classes/java/awt/font/TextAttribute.java index 264871bd031..3a7714ba1dd 100644 --- a/jdk/src/share/classes/java/awt/font/TextAttribute.java +++ b/jdk/src/share/classes/java/awt/font/TextAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,7 @@ import java.io.InvalidObjectException; import java.text.AttributedCharacterIterator.Attribute; import java.util.Map; import java.util.HashMap; +import sun.misc.SharedSecrets; /** * The TextAttribute class defines attribute keys and @@ -257,6 +258,13 @@ public final class TextAttribute extends Attribute { private static final Map instanceMap = new HashMap(29); + // For access from java.text.Bidi + static { + if (SharedSecrets.getJavaAWTFontAccess() == null) { + SharedSecrets.setJavaAWTFontAccess(new JavaAWTFontAccessImpl()); + } + } + /** * Constructs a TextAttribute with the specified name. * @param name the attribute name to assign to this diff --git a/jdk/src/share/classes/java/io/File.java b/jdk/src/share/classes/java/io/File.java index f0528c73754..306cc84097d 100644 --- a/jdk/src/share/classes/java/io/File.java +++ b/jdk/src/share/classes/java/io/File.java @@ -1997,8 +1997,10 @@ public class File File directory) throws IOException { - if (prefix.length() < 3) - throw new IllegalArgumentException("Prefix string too short"); + if (prefix.length() < 3) { + throw new IllegalArgumentException("Prefix string \"" + prefix + + "\" too short: length must be at least 3"); + } if (suffix == null) suffix = ".tmp"; diff --git a/jdk/src/share/classes/java/security/package-info.java b/jdk/src/share/classes/java/security/package-info.java index 599e95259ba..2c8205b09b9 100644 --- a/jdk/src/share/classes/java/security/package-info.java +++ b/jdk/src/share/classes/java/security/package-info.java @@ -92,14 +92,14 @@ * * *
  • keytool - * ( + * ( * for Solaris/Linux) * ( * for Windows) *
  • * *
  • jarsigner - * ( + * ( * for Solaris/Linux) * ( * for Windows) diff --git a/jdk/src/share/classes/java/util/logging/FileHandler.java b/jdk/src/share/classes/java/util/logging/FileHandler.java index cad034ececb..d58fd0ebc84 100644 --- a/jdk/src/share/classes/java/util/logging/FileHandler.java +++ b/jdk/src/share/classes/java/util/logging/FileHandler.java @@ -25,6 +25,7 @@ package java.util.logging; +import static java.nio.file.StandardOpenOption.APPEND; import static java.nio.file.StandardOpenOption.CREATE_NEW; import static java.nio.file.StandardOpenOption.WRITE; @@ -34,10 +35,17 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.channels.FileChannel; +import java.nio.channels.OverlappingFileLockException; import java.nio.file.FileAlreadyExistsException; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; import java.nio.file.Paths; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.HashSet; +import java.util.Set; /** * Simple file logging Handler. @@ -149,7 +157,7 @@ public class FileHandler extends StreamHandler { private FileChannel lockFileChannel; private File files[]; private static final int MAX_LOCKS = 100; - private static final java.util.HashMap locks = new java.util.HashMap<>(); + private static final Set locks = new HashSet<>(); /** * A metered stream is a subclass of OutputStream that @@ -428,34 +436,80 @@ public class FileHandler extends StreamHandler { // between processes (and not within a process), we first check // if we ourself already have the file locked. synchronized(locks) { - if (locks.get(lockFileName) != null) { + if (locks.contains(lockFileName)) { // We already own this lock, for a different FileHandler // object. Try again. continue; } - try { - lockFileChannel = FileChannel.open(Paths.get(lockFileName), - CREATE_NEW, WRITE); - } catch (FileAlreadyExistsException ix) { - // try the next lock file name in the sequence - continue; + final Path lockFilePath = Paths.get(lockFileName); + FileChannel channel = null; + int retries = -1; + boolean fileCreated = false; + while (channel == null && retries++ < 1) { + try { + channel = FileChannel.open(lockFilePath, + CREATE_NEW, WRITE); + fileCreated = true; + } catch (FileAlreadyExistsException ix) { + // This may be a zombie file left over by a previous + // execution. Reuse it - but only if we can actually + // write to its directory. + // Note that this is a situation that may happen, + // but not too frequently. + if (Files.isRegularFile(lockFilePath, LinkOption.NOFOLLOW_LINKS) + && Files.isWritable(lockFilePath.getParent())) { + try { + channel = FileChannel.open(lockFilePath, + WRITE, APPEND); + } catch (NoSuchFileException x) { + // Race condition - retry once, and if that + // fails again just try the next name in + // the sequence. + continue; + } catch(IOException x) { + // the file may not be writable for us. + // try the next name in the sequence + break; + } + } else { + // at this point channel should still be null. + // break and try the next name in the sequence. + break; + } + } } + if (channel == null) continue; // try the next name; + lockFileChannel = channel; + boolean available; try { available = lockFileChannel.tryLock() != null; // We got the lock OK. + // At this point we could call File.deleteOnExit(). + // However, this could have undesirable side effects + // as indicated by JDK-4872014. So we will instead + // rely on the fact that close() will remove the lock + // file and that whoever is creating FileHandlers should + // be responsible for closing them. } catch (IOException ix) { // We got an IOException while trying to get the lock. // This normally indicates that locking is not supported // on the target directory. We have to proceed without - // getting a lock. Drop through. - available = true; + // getting a lock. Drop through, but only if we did + // create the file... + available = fileCreated; + } catch (OverlappingFileLockException x) { + // someone already locked this file in this VM, through + // some other channel - that is - using something else + // than new FileHandler(...); + // continue searching for an available lock. + available = false; } if (available) { // We got the lock. Remember it. - locks.put(lockFileName, lockFileName); + locks.add(lockFileName); break; } diff --git a/jdk/src/share/classes/java/util/stream/Collectors.java b/jdk/src/share/classes/java/util/stream/Collectors.java index 75ca1ca0f50..6f68322119d 100644 --- a/jdk/src/share/classes/java/util/stream/Collectors.java +++ b/jdk/src/share/classes/java/util/stream/Collectors.java @@ -729,7 +729,7 @@ public final class Collectors { * person in each city: *
    {@code
          *     Comparator byHeight = Comparator.comparing(Person::getHeight);
    -     *     Map tallestByCity
    +     *     Map> tallestByCity
          *         = people.stream().collect(groupingBy(Person::getCity, reducing(BinaryOperator.maxBy(byHeight))));
          * }
    * @@ -784,7 +784,7 @@ public final class Collectors { * Comparator byLength = Comparator.comparing(String::length); * Map longestLastNameByCity * = people.stream().collect(groupingBy(Person::getCity, - * reducing(Person::getLastName, BinaryOperator.maxBy(byLength)))); + * reducing("", Person::getLastName, BinaryOperator.maxBy(byLength)))); * } * * @param the type of the input elements @@ -1220,7 +1220,7 @@ public final class Collectors { * students to their grade point average: *
    {@code
          *     Map studentToGPA
    -     *         students.stream().collect(toMap(Functions.identity(),
    +     *         students.stream().collect(toMap(Function.identity(),
          *                                         student -> computeGPA(student)));
          * }
    * And the following produces a {@code Map} mapping a unique identifier to @@ -1228,7 +1228,7 @@ public final class Collectors { *
    {@code
          *     Map studentIdToStudent
          *         students.stream().collect(toMap(Student::getId,
    -     *                                         Functions.identity());
    +     *                                         Function.identity());
          * }
    * * @implNote @@ -1390,7 +1390,7 @@ public final class Collectors { * students to their grade point average: *
    {@code
          *     Map studentToGPA
    -     *         students.stream().collect(toMap(Functions.identity(),
    +     *         students.stream().collect(toMap(Function.identity(),
          *                                         student -> computeGPA(student)));
          * }
    * And the following produces a {@code Map} mapping a unique identifier to @@ -1398,7 +1398,7 @@ public final class Collectors { *
    {@code
          *     Map studentIdToStudent
          *         students.stream().collect(toConcurrentMap(Student::getId,
    -     *                                                   Functions.identity());
    +     *                                                   Function.identity());
          * }
    * *

    This is a {@link Collector.Characteristics#CONCURRENT concurrent} and diff --git a/jdk/src/share/classes/java/util/stream/package-info.java b/jdk/src/share/classes/java/util/stream/package-info.java index 016c86dd382..2353870425e 100644 --- a/jdk/src/share/classes/java/util/stream/package-info.java +++ b/jdk/src/share/classes/java/util/stream/package-info.java @@ -468,7 +468,7 @@ *

    {@code
      *     int sumOfWeights = widgets.stream()
      *                               .reduce(0,
    - *                                       (sum, b) -> sum + b.getWeight())
    + *                                       (sum, b) -> sum + b.getWeight(),
      *                                       Integer::sum);
      * }
    * though the explicit map-reduce form is more readable and therefore should diff --git a/jdk/src/share/classes/javax/swing/AbstractListModel.java b/jdk/src/share/classes/javax/swing/AbstractListModel.java index cc3003dc132..e4956670ee0 100644 --- a/jdk/src/share/classes/javax/swing/AbstractListModel.java +++ b/jdk/src/share/classes/javax/swing/AbstractListModel.java @@ -202,6 +202,7 @@ public abstract class AbstractListModel implements ListModel, Serializable * If no such listeners exist, * this method returns an empty array. * + * @param the type of {@code EventListener} class being requested * @param listenerType the type of listeners requested; * this parameter should specify an interface * that descends from java.util.EventListener diff --git a/jdk/src/share/classes/javax/swing/CellRendererPane.java b/jdk/src/share/classes/javax/swing/CellRendererPane.java index 70ba2afa04c..6050693eeeb 100644 --- a/jdk/src/share/classes/javax/swing/CellRendererPane.java +++ b/jdk/src/share/classes/javax/swing/CellRendererPane.java @@ -190,8 +190,12 @@ public class CellRendererPane extends Container implements Accessible // Accessibility support //////////////// + /** + * {@code AccessibleContext} associated with this {@code CellRendererPan} + */ protected AccessibleContext accessibleContext = null; + /** * Gets the AccessibleContext associated with this CellRendererPane. * For CellRendererPanes, the AccessibleContext takes the form of an diff --git a/jdk/src/share/classes/javax/swing/DefaultCellEditor.java b/jdk/src/share/classes/javax/swing/DefaultCellEditor.java index e0be97934fa..6114760c8a7 100644 --- a/jdk/src/share/classes/javax/swing/DefaultCellEditor.java +++ b/jdk/src/share/classes/javax/swing/DefaultCellEditor.java @@ -353,6 +353,7 @@ public class DefaultCellEditor extends AbstractCellEditor * Returns true to indicate that editing has begun. * * @param anEvent the event + * @return true to indicate editing has begun */ public boolean startCellEditing(EventObject anEvent) { return true; diff --git a/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java b/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java index 6c66c8d6cce..ebee71521d9 100644 --- a/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java +++ b/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java @@ -462,7 +462,12 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab f.revalidate(); } - /** Convenience method to remove the desktopIcon of f is necessary. */ + /** + * Convenience method to remove the desktopIcon of f is necessary. + * + * @param f the {@code JInternalFrame} for which to remove the + * {@code desktopIcon} + */ protected void removeIconFor(JInternalFrame f) { JInternalFrame.JDesktopIcon di = f.getDesktopIcon(); Container c = di.getParent(); @@ -472,10 +477,13 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab } } - /** The iconifyFrame() code calls this to determine the proper bounds - * for the desktopIcon. - */ - + /** + * The {@code iconifyFrame()} code calls this to determine the proper bounds + * for the desktopIcon. + * + * @param f the {@code JInternalFrame} of interest + * @return a {@code Rectangle} containing bounds for the {@code desktopIcon} + */ protected Rectangle getBoundsForIconOf(JInternalFrame f) { // // Get the icon for this internal frame and its preferred size @@ -592,6 +600,9 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab /** * Sets that the component has been iconized and the bounds of the * desktopIcon are valid. + * + * @param f the {@code JInternalFrame} of interest + * @param value a {@code Boolean} signifying if component has been iconized */ protected void setWasIcon(JInternalFrame f, Boolean value) { if (value != null) { diff --git a/jdk/src/share/classes/javax/swing/DefaultListModel.java b/jdk/src/share/classes/javax/swing/DefaultListModel.java index 2b10f45ad47..a4a826a0f5c 100644 --- a/jdk/src/share/classes/javax/swing/DefaultListModel.java +++ b/jdk/src/share/classes/javax/swing/DefaultListModel.java @@ -444,6 +444,7 @@ public class DefaultListModel extends AbstractListModel * (index < 0 || index >= size()). * * @param index index of element to return + * @return the element at the specified position in this list */ public E get(int index) { return delegate.elementAt(index); diff --git a/jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java b/jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java index a1cb79f8ea6..671b1a412f0 100644 --- a/jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java +++ b/jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java @@ -160,6 +160,9 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable, * Notifies ListSelectionListeners that the value * of the selection, in the closed interval firstIndex, * lastIndex, has changed. + * + * @param firstIndex the first index in the interval + * @param lastIndex the last index in the interval */ protected void fireValueChanged(int firstIndex, int lastIndex) { fireValueChanged(firstIndex, lastIndex, getValueIsAdjusting()); @@ -231,6 +234,7 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable, * If no such listeners exist, * this method returns an empty array. * + * @param the type of {@code EventListener} class being requested * @param listenerType the type of listeners requested; * this parameter should specify an interface * that descends from java.util.EventListener @@ -332,6 +336,8 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable, /** * Sets the value of the leadAnchorNotificationEnabled flag. + * + * @param flag boolean value for {@code leadAnchorNotificationEnabled} * @see #isLeadAnchorNotificationEnabled() */ public void setLeadAnchorNotificationEnabled(boolean flag) { diff --git a/jdk/src/share/classes/javax/swing/DefaultRowSorter.java b/jdk/src/share/classes/javax/swing/DefaultRowSorter.java index 1a723128b9e..4634b2b4d4a 100644 --- a/jdk/src/share/classes/javax/swing/DefaultRowSorter.java +++ b/jdk/src/share/classes/javax/swing/DefaultRowSorter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -712,6 +712,8 @@ public abstract class DefaultRowSorter extends RowSorter { * * @param column the index of the column to test, in terms of the * underlying model + * @return true if values are to be converted to strings before doing + * comparisons when sorting * @throws IndexOutOfBoundsException if column is not valid */ protected boolean useToString(int column) { diff --git a/jdk/src/share/classes/javax/swing/InputMap.java b/jdk/src/share/classes/javax/swing/InputMap.java index 55af730c99a..87302b0b6e2 100644 --- a/jdk/src/share/classes/javax/swing/InputMap.java +++ b/jdk/src/share/classes/javax/swing/InputMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,15 +32,12 @@ import java.util.HashMap; import java.util.Set; /** - * InputMap provides a binding between an input event - * (currently only KeyStrokes are used) - * and an Object. InputMaps - * are usually used with an ActionMap, - * to determine an Action to perform - * when a key is pressed. - * An InputMap can have a parent - * that is searched for bindings not defined in the InputMap. - *

    As with ActionMap if you create a cycle, eg: + * {@code InputMap} provides a binding between an input event (currently only + * {@code KeyStroke}s are used) and an {@code Object}. {@code InputMap}s are + * usually used with an {@code ActionMap}, to determine an {@code Action} to + * perform when a key is pressed. An {@code InputMap} can have a parent that + * is searched for bindings not defined in the {@code InputMap}. + *

    As with {@code ActionMap} if you create a cycle, eg: *

      *   InputMap am = new InputMap();
      *   InputMap bm = new InputMap():
    @@ -61,34 +58,37 @@ public class InputMap implements Serializable {
     
     
         /**
    -     * Creates an InputMap with no parent and no mappings.
    +     * Creates an {@code InputMap} with no parent and no mappings.
          */
         public InputMap() {
         }
     
         /**
    -     * Sets this InputMap's parent.
    +     * Sets this {@code InputMap}'s parent.
          *
    -     * @param map  the InputMap that is the parent of this one
    +     * @param map the {@code InputMap} that is the parent of this one
          */
         public void setParent(InputMap map) {
             this.parent = map;
         }
     
         /**
    -     * Gets this InputMap's parent.
    +     * Gets this {@code InputMap}'s parent.
          *
    -     * @return map  the InputMap that is the parent of this one,
    -     *              or null if this InputMap has no parent
    +     * @return map the {@code InputMap} that is the parent of this one,
    +     *             or null if this {@code InputMap} has no parent
          */
         public InputMap getParent() {
             return parent;
         }
     
         /**
    -     * Adds a binding for keyStroke to actionMapKey.
    -     * If actionMapKey is null, this removes the current binding
    -     * for keyStroke.
    +     * Adds a binding for {@code keyStroke} to {@code actionMapKey}.
    +     * If {@code actionMapKey} is null, this removes the current binding
    +     * for {@code keyStroke}.
    +     *
    +     * @param keyStroke a {@code KeyStroke}
    +     * @param actionMapKey an action map key
          */
         public void put(KeyStroke keyStroke, Object actionMapKey) {
             if (keyStroke == null) {
    @@ -106,8 +106,11 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Returns the binding for keyStroke, messaging the
    -     * parent InputMap if the binding is not locally defined.
    +     * Returns the binding for {@code keyStroke}, messaging the
    +     * parent {@code InputMap} if the binding is not locally defined.
    +     *
    +     * @param keyStroke the {@code KeyStroke} for which to get the binding
    +     * @return the binding for {@code keyStroke}
          */
         public Object get(KeyStroke keyStroke) {
             if (arrayTable == null) {
    @@ -131,8 +134,9 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Removes the binding for key from this
    -     * InputMap.
    +     * Removes the binding for {@code key} from this {@code InputMap}.
    +     *
    +     * @param key the {@code KeyStroke} for which to remove the binding
          */
         public void remove(KeyStroke key) {
             if (arrayTable != null) {
    @@ -141,7 +145,7 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Removes all the mappings from this InputMap.
    +     * Removes all the mappings from this {@code InputMap}.
          */
         public void clear() {
             if (arrayTable != null) {
    @@ -150,7 +154,10 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Returns the KeyStrokes that are bound in this InputMap.
    +     * Returns the {@code KeyStroke}s that are bound in this {@code InputMap}.
    +     *
    +     * @return an array of the {@code KeyStroke}s that are bound in this
    +     *         {@code InputMap}
          */
         public KeyStroke[] keys() {
             if (arrayTable == null) {
    @@ -162,7 +169,9 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Returns the number of KeyStroke bindings.
    +     * Returns the number of {@code KeyStroke} bindings.
    +     *
    +     * @return the number of {@code KeyStroke} bindings
          */
         public int size() {
             if (arrayTable == null) {
    @@ -172,9 +181,12 @@ public class InputMap implements Serializable {
         }
     
         /**
    -     * Returns an array of the KeyStrokes defined in this
    -     * InputMap and its parent. This differs from keys() in that
    -     * this method includes the keys defined in the parent.
    +     * Returns an array of the {@code KeyStroke}s defined in this
    +     * {@code InputMap} and its parent. This differs from {@code keys()}
    +     * in that this method includes the keys defined in the parent.
    +     *
    +     * @return an array of the {@code KeyStroke}s defined in this
    +     *         {@code InputMap} and its parent
          */
         public KeyStroke[] allKeys() {
             int             count = size();
    diff --git a/jdk/src/share/classes/javax/swing/JCheckBox.java b/jdk/src/share/classes/javax/swing/JCheckBox.java
    index c912a383cae..400b8efae78 100644
    --- a/jdk/src/share/classes/javax/swing/JCheckBox.java
    +++ b/jdk/src/share/classes/javax/swing/JCheckBox.java
    @@ -132,6 +132,7 @@ public class JCheckBox extends JToggleButton implements Accessible {
          * Creates a check box where properties are taken from the
          * Action supplied.
          *
    +     * @param a the {@code Action} used to specify the new check box
          * @since 1.3
          */
         public JCheckBox(Action a) {
    diff --git a/jdk/src/share/classes/javax/swing/JCheckBoxMenuItem.java b/jdk/src/share/classes/javax/swing/JCheckBoxMenuItem.java
    index 962ef73f3c0..4aaa4417caa 100644
    --- a/jdk/src/share/classes/javax/swing/JCheckBoxMenuItem.java
    +++ b/jdk/src/share/classes/javax/swing/JCheckBoxMenuItem.java
    @@ -109,7 +109,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
         /**
          * Creates an initially unselected check box menu item with an icon.
          *
    -     * @param icon the icon of the CheckBoxMenuItem.
    +     * @param icon the icon of the {@code JCheckBoxMenuItem}.
          */
         public JCheckBoxMenuItem(Icon icon) {
             this(null, icon, false);
    @@ -118,7 +118,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
         /**
          * Creates an initially unselected check box menu item with text.
          *
    -     * @param text the text of the CheckBoxMenuItem
    +     * @param text the text of the {@code JCheckBoxMenuItem}
          */
         public JCheckBoxMenuItem(String text) {
             this(text, null, false);
    @@ -128,6 +128,7 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
          * Creates a menu item whose properties are taken from the
          * Action supplied.
          *
    +     * @param a the action of the {@code JCheckBoxMenuItem}
          * @since 1.3
          */
         public JCheckBoxMenuItem(Action a) {
    @@ -138,8 +139,8 @@ public class JCheckBoxMenuItem extends JMenuItem implements SwingConstants,
         /**
          * Creates an initially unselected check box menu item with the specified text and icon.
          *
    -     * @param text the text of the CheckBoxMenuItem
    -     * @param icon the icon of the CheckBoxMenuItem
    +     * @param text the text of the {@code JCheckBoxMenuItem}
    +     * @param icon the icon of the {@code JCheckBoxMenuItem}
          */
         public JCheckBoxMenuItem(String text, Icon icon) {
             this(text, icon, false);
    diff --git a/jdk/src/share/classes/javax/swing/JEditorPane.java b/jdk/src/share/classes/javax/swing/JEditorPane.java
    index af751e9012c..d5a41d9bd66 100644
    --- a/jdk/src/share/classes/javax/swing/JEditorPane.java
    +++ b/jdk/src/share/classes/javax/swing/JEditorPane.java
    @@ -1251,11 +1251,12 @@ public class JEditorPane extends JTextComponent {
         }
     
         /**
    -     * Returns the currently registered EditorKit
    -     * class name for the type type.
    -     *
    -     * @param type  the non-null content type
    +     * Returns the currently registered {@code EditorKit} class name for the
    +     * type {@code type}.
          *
    +     * @param type  the non-{@code null} content type
    +     * @return a {@code String} containing the {@code EditorKit} class name
    +     *         for {@code type}
          * @since 1.3
          */
         public static String getEditorKitClassNameForContentType(String type) {
    diff --git a/jdk/src/share/classes/javax/swing/JFileChooser.java b/jdk/src/share/classes/javax/swing/JFileChooser.java
    index 336f57c438b..bf690ddbb5b 100644
    --- a/jdk/src/share/classes/javax/swing/JFileChooser.java
    +++ b/jdk/src/share/classes/javax/swing/JFileChooser.java
    @@ -330,6 +330,8 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Constructs a JFileChooser using the given
          * FileSystemView.
    +     *
    +     * @param fsv a {@code FileSystemView}
          */
         public JFileChooser(FileSystemView fsv) {
             this((File) null, fsv);
    @@ -339,6 +341,10 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Constructs a JFileChooser using the given current directory
          * and FileSystemView.
    +     *
    +     * @param currentDirectory a {@code File} object specifying the path to a
    +     *                         file or directory
    +     * @param fsv a {@code FileSystemView}
          */
         public JFileChooser(File currentDirectory, FileSystemView fsv) {
             setup(fsv);
    @@ -348,6 +354,10 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Constructs a JFileChooser using the given current directory
          * path and FileSystemView.
    +     *
    +     * @param currentDirectoryPath a {@code String} specifying the path to a file
    +     *                             or directory
    +     * @param fsv a {@code FileSystemView}
          */
         public JFileChooser(String currentDirectoryPath, FileSystemView fsv) {
             setup(fsv);
    @@ -360,6 +370,8 @@ public class JFileChooser extends JComponent implements Accessible {
     
         /**
          * Performs common constructor initialization and setup.
    +     *
    +     * @param view the {@code FileSystemView} used for setup
          */
         protected void setup(FileSystemView view) {
             installShowFilesListener();
    @@ -512,6 +524,8 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Returns a list of selected files if the file chooser is
          * set to allow multiple selection.
    +     *
    +     * @return an array of selected {@code File}s
          */
         public File[] getSelectedFiles() {
             if(selectedFiles == null) {
    @@ -525,6 +539,7 @@ public class JFileChooser extends JComponent implements Accessible {
          * Sets the list of selected files if the file chooser is
          * set to allow multiple selection.
          *
    +     * @param selectedFiles an array {@code File}s to be selected
          * @beaninfo
          *       bound: true
          * description: The list of selected files if the chooser is in multiple selection mode.
    @@ -971,6 +986,7 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Gets the string that goes in the JFileChooser's titlebar.
          *
    +     * @return the string from the {@code JFileChooser} window's title bar
          * @see #setDialogTitle
          */
         public String getDialogTitle() {
    @@ -1158,6 +1174,8 @@ public class JFileChooser extends JComponent implements Accessible {
          * Removes a filter from the list of user choosable file filters. Returns
          * true if the file filter was removed.
          *
    +     * @param f the file filter to be removed
    +     * @return true if the file filter was removed, false otherwise
          * @see #addChoosableFileFilter
          * @see #getChoosableFileFilters
          * @see #resetChoosableFileFilters
    @@ -1215,6 +1233,8 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Returns the AcceptAll file filter.
          * For example, on Microsoft Windows this would be All Files (*.*).
    +     *
    +     * @return the {@code AcceptAll} file filter
          */
         public FileFilter getAcceptAllFileFilter() {
             FileFilter filter = null;
    @@ -1240,8 +1260,10 @@ public class JFileChooser extends JComponent implements Accessible {
         * If false, the AcceptAll file filter is removed from
         * the list of available file filters.
         * If true, the AcceptAll file filter will become the
    -    * the actively used file filter.
    +    * actively used file filter.
         *
    +    * @param b a {@code boolean} which determines whether the {@code AcceptAll}
    +    *          file filter is an available choice in the choosable filter list
         * @beaninfo
         *   preferred: true
         *       bound: true
    @@ -1284,6 +1306,7 @@ public class JFileChooser extends JComponent implements Accessible {
          * any listeners that the accessory might have registered with the
          * file chooser.
          *
    +     * @param newAccessory the accessory component to be set
          * @beaninfo
          *   preferred: true
          *       bound: true
    @@ -1355,6 +1378,7 @@ public class JFileChooser extends JComponent implements Accessible {
          * Convenience call that determines if files are selectable based on the
          * current file selection mode.
          *
    +     * @return true if files are selectable, false otherwise
          * @see #setFileSelectionMode
          * @see #getFileSelectionMode
          */
    @@ -1366,6 +1390,7 @@ public class JFileChooser extends JComponent implements Accessible {
          * Convenience call that determines if directories are selectable based
          * on the current file selection mode.
          *
    +     * @return true if directories are selectable, false otherwise
          * @see #setFileSelectionMode
          * @see #getFileSelectionMode
          */
    @@ -1487,9 +1512,10 @@ public class JFileChooser extends JComponent implements Accessible {
         }
     
         /**
    -     * Sets the file view to used to retrieve UI information, such as
    +     * Sets the file view to be used to retrieve UI information, such as
          * the icon that represents a file or the type description of a file.
          *
    +     * @param fileView a {@code FileView} to be used to retrieve UI information
          * @beaninfo
          *   preferred: true
          *       bound: true
    @@ -1506,6 +1532,7 @@ public class JFileChooser extends JComponent implements Accessible {
         /**
          * Returns the current file view.
          *
    +     * @return the current file view
          * @see #setFileView
          */
         public FileView getFileView() {
    @@ -1765,6 +1792,8 @@ public class JFileChooser extends JComponent implements Accessible {
          * notification on this event type. The event instance
          * is lazily created using the command parameter.
          *
    +     * @param command a string that may specify a command associated with
    +     *                the event
          * @see EventListenerList
          */
         protected void fireActionPerformed(String command) {
    @@ -1973,6 +2002,9 @@ public class JFileChooser extends JComponent implements Accessible {
     // Accessibility support
     ////////////////
     
    +    /**
    +     * {@code AccessibleContext} associated with this {@code JFileChooser}
    +     */
         protected AccessibleContext accessibleContext = null;
     
         /**
    diff --git a/jdk/src/share/classes/javax/swing/JFrame.java b/jdk/src/share/classes/javax/swing/JFrame.java
    index e4a5efef662..cc3b0807f96 100644
    --- a/jdk/src/share/classes/javax/swing/JFrame.java
    +++ b/jdk/src/share/classes/javax/swing/JFrame.java
    @@ -275,6 +275,8 @@ public class JFrame  extends Frame implements WindowConstants,
         /**
          * Called by the constructor methods to create the default
          * rootPane.
    +     *
    +     * @return a new {@code JRootPane}
          */
         protected JRootPane createRootPane() {
             JRootPane rp = new JRootPane();
    @@ -874,7 +876,9 @@ public class JFrame  extends Frame implements WindowConstants,
     // Accessibility support
     ////////////////
     
    -    /** The accessible context property. */
    +    /**
    +     * The accessible context property.
    +     */
         protected AccessibleContext accessibleContext = null;
     
         /**
    diff --git a/jdk/src/share/classes/javax/swing/JMenu.java b/jdk/src/share/classes/javax/swing/JMenu.java
    index ea3b1b970d3..02285e0047f 100644
    --- a/jdk/src/share/classes/javax/swing/JMenu.java
    +++ b/jdk/src/share/classes/javax/swing/JMenu.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      *
      * This code is free software; you can redistribute it and/or modify it
    @@ -608,16 +608,18 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
          * it to the end of this menu.
          *
          * @param s the string for the menu item to be added
    +     * @return the new {@code JMenuItem}
          */
         public JMenuItem add(String s) {
             return add(new JMenuItem(s));
         }
     
         /**
    -     * Creates a new menu item attached to the specified
    -     * Action object and appends it to the end of this menu.
    +     * Creates a new menu item attached to the specified {@code Action} object
    +     * and appends it to the end of this menu.
          *
    -     * @param a the Action for the menu item to be added
    +     * @param a the {@code Action} for the menu item to be added
    +     * @return the new {@code JMenuItem}
          * @see Action
          */
         public JMenuItem add(Action a) {
    @@ -653,8 +655,11 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
         }
     
         /**
    -     * Returns a properly configured PropertyChangeListener
    -     * which updates the control as changes to the Action occur.
    +     * Returns a properly configured {@code PropertyChangeListener}
    +     * which updates the control as changes to the {@code Action} occur.
    +     *
    +     * @param b a menu item for which to create a {@code PropertyChangeListener}
    +     * @return a {@code PropertyChangeListener} for {@code b}
          */
         protected PropertyChangeListener createActionChangeListener(JMenuItem b) {
             return b.createActionPropertyChangeListener0(b.getAction());
    @@ -714,6 +719,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
          * @param a the Action object for the menu item to add
          * @param pos an integer specifying the position at which to add the
          *               new menu item
    +     * @return the new menu item
          * @exception IllegalArgumentException if the value of
          *                  pos < 0
          */
    @@ -748,16 +754,16 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
         }
     
         /**
    -     * Returns the JMenuItem at the specified position.
    -     * If the component at pos is not a menu item,
    -     * null is returned.
    +     * Returns the {@code JMenuItem} at the specified position.
    +     * If the component at {@code pos} is not a menu item,
    +     * {@code null} is returned.
          * This method is included for AWT compatibility.
          *
    -     * @param pos    an integer specifying the position
    -     * @exception   IllegalArgumentException if the value of
    -     *                       pos < 0
    +     * @param pos  an integer specifying the position
          * @return  the menu item at the specified position; or null
          *          if the item as the specified position is not a menu item
    +     * @exception  IllegalArgumentException if the value of
    +     *             {@code pos} < 0
          */
         public JMenuItem getItem(int pos) {
             if (pos < 0) {
    @@ -975,6 +981,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
         /**
          * Returns the popupmenu associated with this menu.  If there is
          * no popupmenu, it will create one.
    +     *
    +     * @return the {@code JPopupMenu} associated with this menu
          */
         public JPopupMenu getPopupMenu() {
             ensurePopupMenuCreated();
    @@ -1159,6 +1167,8 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
             JPopupMenu popupMenu;
             /**
              *  Create the window listener for the specified popup.
    +         *
    +         * @param p the popup menu for which to create a listener
              * @since 1.4
              */
             public WinListener(JPopupMenu p) {
    diff --git a/jdk/src/share/classes/javax/swing/JMenuBar.java b/jdk/src/share/classes/javax/swing/JMenuBar.java
    index 4b4f6f91643..c8fcb6673c6 100644
    --- a/jdk/src/share/classes/javax/swing/JMenuBar.java
    +++ b/jdk/src/share/classes/javax/swing/JMenuBar.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      *
      * This code is free software; you can redistribute it and/or modify it
    @@ -124,6 +124,8 @@ public class JMenuBar extends JComponent implements Accessible,MenuElement
     
         /**
          * Returns the menubar's current UI.
    +     *
    +     * @return a {@code MenuBarUI} which is the menubar's current L&F object
          * @see #setUI
          */
         public MenuBarUI getUI() {
    diff --git a/jdk/src/share/classes/javax/swing/JSlider.java b/jdk/src/share/classes/javax/swing/JSlider.java
    index 519303e569a..39e960f9a75 100644
    --- a/jdk/src/share/classes/javax/swing/JSlider.java
    +++ b/jdk/src/share/classes/javax/swing/JSlider.java
    @@ -281,6 +281,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
         /**
          * Creates a horizontal slider using the specified
          * BoundedRangeModel.
    +     *
    +     * @param brm a {@code BoundedRangeModel} for the slider
          */
         public JSlider(BoundedRangeModel brm)
         {
    @@ -363,6 +365,8 @@ public class JSlider extends JComponent implements SwingConstants, Accessible {
          * {@code fireStateChanged} method to forward {@code ChangeEvent}s
          * to the {@code ChangeListener}s that have been added directly to the
          * slider.
    +     *
    +     * @return a instance of new {@code ChangeListener}
          * @see #changeListener
          * @see #fireStateChanged
          * @see javax.swing.event.ChangeListener
    diff --git a/jdk/src/share/classes/javax/swing/JTabbedPane.java b/jdk/src/share/classes/javax/swing/JTabbedPane.java
    index c3b135ac85e..96c050529fe 100644
    --- a/jdk/src/share/classes/javax/swing/JTabbedPane.java
    +++ b/jdk/src/share/classes/javax/swing/JTabbedPane.java
    @@ -278,6 +278,7 @@ public class JTabbedPane extends JComponent
          * can override this to return a subclass of ModelListener or
          * another ChangeListener implementation.
          *
    +     * @return a {@code ChangeListener}
          * @see #fireStateChanged
          */
         protected ChangeListener createChangeListener() {
    @@ -423,6 +424,7 @@ public class JTabbedPane extends JComponent
         /**
          * Returns the model associated with this tabbedpane.
          *
    +     * @return the {@code SingleSelectionModel} associated with this tabbedpane
          * @see #setModel
          */
         public SingleSelectionModel getModel() {
    @@ -459,6 +461,8 @@ public class JTabbedPane extends JComponent
     
         /**
          * Returns the placement of the tabs for this tabbedpane.
    +     *
    +     * @return an {@code int} specifying the placement for the tabs
          * @see #setTabPlacement
          */
         public int getTabPlacement() {
    @@ -507,6 +511,8 @@ public class JTabbedPane extends JComponent
         /**
          * Returns the policy used by the tabbedpane to layout the tabs when all the
          * tabs will not fit within a single run.
    +     *
    +     * @return an {@code int} specifying the policy used to layout the tabs
          * @see #setTabLayoutPolicy
          * @since 1.4
          */
    @@ -664,6 +670,7 @@ public class JTabbedPane extends JComponent
          * will automatically set the selectedIndex to the index
          * corresponding to the specified component.
          *
    +     * @param c the selected {@code Component} for this {@code TabbedPane}
          * @exception IllegalArgumentException if component not found in tabbed
          *          pane
          * @see #getSelectedComponent
    diff --git a/jdk/src/share/classes/javax/swing/JTable.java b/jdk/src/share/classes/javax/swing/JTable.java
    index dbb57338304..a4f30ac33a5 100644
    --- a/jdk/src/share/classes/javax/swing/JTable.java
    +++ b/jdk/src/share/classes/javax/swing/JTable.java
    @@ -869,6 +869,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
         /**
          * Equivalent to new JScrollPane(aTable).
          *
    +     * @param aTable a {@code JTable} to be used for the scroll pane
    +     * @return a {@code JScrollPane} created using {@code aTable}
          * @deprecated As of Swing version 1.0.2,
          * replaced by new JScrollPane(aTable).
          */
    @@ -1965,6 +1967,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
          * JList. See the setSelectionMode method
          * in JList for details about the modes.
          *
    +     * @param selectionMode the mode used by the row and column selection models
          * @see JList#setSelectionMode
          * @beaninfo
          * description: The selection mode used by the row and column selection models.
    @@ -2325,6 +2328,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
          * Returns true if the specified index is in the valid range of rows,
          * and the row at that index is selected.
          *
    +     * @param row a row in the row model
          * @return true if row is a valid index and the row at
          *              that index is selected (where 0 is the first row)
          */
    @@ -3178,6 +3182,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
     
         /**
          * Sizes the table columns to fit the available space.
    +     *
    +     * @param lastColumnOnly determines whether to resize last column only
          * @deprecated As of Swing version 1.0.3,
          * replaced by doLayout().
          * @see #doLayout
    @@ -6696,7 +6702,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
     
         // Listeners to echo changes to the AccessiblePropertyChange mechanism
     
    -        /*
    +        /**
              * Describes a change in the accessible table model.
              */
             protected class AccessibleJTableModelChange
    @@ -6741,6 +6747,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
     
             /**
              * Track changes to the table contents
    +         *
    +         * @param e a {@code TableModelEvent} describing the event
              */
             public void tableChanged(TableModelEvent e) {
                firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
    @@ -6768,6 +6776,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
     
             /**
              * Track changes to the table contents (row insertions)
    +         *
    +         * @param e a {@code TableModelEvent} describing the event
              */
             public void tableRowsInserted(TableModelEvent e) {
                firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
    @@ -6793,6 +6803,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
     
             /**
              * Track changes to the table contents (row deletions)
    +         *
    +         * @param e a {@code TableModelEvent} describing the event
              */
             public void tableRowsDeleted(TableModelEvent e) {
                firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
    @@ -7926,6 +7938,11 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
     
                 /**
                  *  Constructs an AccessibleJTableHeaderEntry.
    +             *
    +             * @param t a {@code JTable}
    +             * @param r an {@code int} specifying a row
    +             * @param c an {@code int} specifying a column
    +             * @param i an {@code int} specifying the index to this cell
                  * @since 1.4
                  */
                 public AccessibleJTableCell(JTable t, int r, int c, int i) {
    diff --git a/jdk/src/share/classes/javax/swing/MenuElement.java b/jdk/src/share/classes/javax/swing/MenuElement.java
    index 916811e08eb..4dc310b55bc 100644
    --- a/jdk/src/share/classes/javax/swing/MenuElement.java
    +++ b/jdk/src/share/classes/javax/swing/MenuElement.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      *
      * This code is free software; you can redistribute it and/or modify it
    @@ -29,7 +29,7 @@ import java.awt.event.*;
     
     /**
      * Any component that can be placed into a menu should implement this interface.
    - * This interface is used by MenuSelectionManager
    + * This interface is used by {@code MenuSelectionManager}
      * to handle selection and navigation in menu hierarchies.
      *
      * @author Arnaud Weber
    @@ -39,46 +39,56 @@ import java.awt.event.*;
     public interface MenuElement {
     
         /**
    -     * Processes a mouse event. event is a MouseEvent
    -     * with source being the receiving element's component.
    -     * path is the path of the receiving element in the menu
    -     * hierarchy including the receiving element itself.
    -     * manager is the MenuSelectionManager
    -     * for the menu hierarchy.
    -     * This method should process the MouseEvent and change
    -     * the menu selection if necessary
    -     * by using MenuSelectionManager's API
    -     * Note: you do not have to forward the event to sub-components.
    -     * This is done automatically by the MenuSelectionManager.
    +     * Processes a mouse event. {@code event} is a {@code MouseEvent} with
    +     * source being the receiving element's component. {@code path} is the
    +     * path of the receiving element in the menu hierarchy including the
    +     * receiving element itself. {@code manager} is the
    +     * {@code MenuSelectionManager}for the menu hierarchy. This method should
    +     * process the {@code MouseEvent} and change the menu selection if necessary
    +     * by using {@code MenuSelectionManager}'s API Note: you do not have to
    +     * forward the event to sub-components. This is done automatically by the
    +     * {@code MenuSelectionManager}.
    +     *
    +     * @param event a {@code MouseEvent} to be processed
    +     * @param path the path of the receiving element in the menu hierarchy
    +     * @param manager the {@code MenuSelectionManager} for the menu hierarchy
          */
    -    public void processMouseEvent(MouseEvent event,MenuElement path[],MenuSelectionManager manager);
    +    public void processMouseEvent(MouseEvent event, MenuElement path[], MenuSelectionManager manager);
     
     
         /**
          *  Process a key event.
    +     *
    +     * @param event a {@code KeyEvent} to be processed
    +     * @param path the path of the receiving element in the menu hierarchy
    +     * @param manager the {@code MenuSelectionManager} for the menu hierarchy
          */
    -    public void processKeyEvent(KeyEvent event,MenuElement path[],MenuSelectionManager manager);
    +    public void processKeyEvent(KeyEvent event, MenuElement path[], MenuSelectionManager manager);
     
         /**
    -     * Call by the MenuSelectionManager when the
    -     * MenuElement is added or remove from
    -     * the menu selection.
    +     * Call by the {@code MenuSelectionManager} when the {@code MenuElement} is
    +     * added or removed from the menu selection.
    +     *
    +     * @param isIncluded can be used to indicate if this {@code MenuElement} is
    +     *        active (if it is a menu) or is on the part of the menu path that
    +     *        changed (if it is a menu item).
          */
         public void menuSelectionChanged(boolean isIncluded);
     
         /**
    -     * This method should return an array containing the sub-elements for the receiving menu element
    +     * This method should return an array containing the sub-elements for the
    +     * receiving menu element.
          *
    -     * @return an array of MenuElements
    +     * @return an array of {@code MenuElement}s
          */
         public MenuElement[] getSubElements();
     
         /**
    -     * This method should return the java.awt.Component used to paint the receiving element.
    -     * The returned component will be used to convert events and detect if an event is inside
    -     * a MenuElement's component.
    +     * This method should return the {@code java.awt.Component} used to paint the
    +     * receiving element. The returned component will be used to convert events
    +     * and detect if an event is inside a {@code MenuElement}'s component.
          *
    -     * @return the Component value
    +     * @return the {@code Component} value
          */
         public Component getComponent();
     }
    diff --git a/jdk/src/share/classes/javax/swing/MenuSelectionManager.java b/jdk/src/share/classes/javax/swing/MenuSelectionManager.java
    index d8df4b544c5..6df0d6701a1 100644
    --- a/jdk/src/share/classes/javax/swing/MenuSelectionManager.java
    +++ b/jdk/src/share/classes/javax/swing/MenuSelectionManager.java
    @@ -80,6 +80,7 @@ public class MenuSelectionManager {
          * generated is always "this".
          */
         protected transient ChangeEvent changeEvent = null;
    +    /** The collection of registered listeners */
         protected EventListenerList listenerList = new EventListenerList();
     
         /**
    @@ -477,7 +478,11 @@ public class MenuSelectionManager {
         }
     
         /**
    -     * Return true if c is part of the currently used menu
    +     * Return true if {@code c} is part of the currently used menu
    +     *
    +     * @param c a {@code Component}
    +     * @return true if {@code c} is part of the currently used menu,
    +     *         false otherwise
          */
         public boolean isComponentPartOfCurrentMenu(Component c) {
             if(selection.size() > 0) {
    diff --git a/jdk/src/share/classes/javax/swing/RowFilter.java b/jdk/src/share/classes/javax/swing/RowFilter.java
    index f2e0bd36816..bfa413e26f8 100644
    --- a/jdk/src/share/classes/javax/swing/RowFilter.java
    +++ b/jdk/src/share/classes/javax/swing/RowFilter.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
      * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
      *
      * This code is free software; you can redistribute it and/or modify it
    @@ -159,6 +159,8 @@ public abstract class RowFilter {
          * {@link java.util.regex.Pattern} for a complete description of
          * the supported regular-expression constructs.
          *
    +     * @param  the type of the model to which the {@code RowFilter} applies
    +     * @param  the type of the identifier passed to the {@code RowFilter}
          * @param regex the regular expression to filter on
          * @param indices the indices of the values to check.  If not supplied all
          *               values are evaluated
    @@ -185,6 +187,8 @@ public abstract class RowFilter {
          *   RowFilter.dateFilter(ComparisonType.AFTER, new Date());
          * 
    * + * @param the type of the model to which the {@code RowFilter} applies + * @param the type of the identifier passed to the {@code RowFilter} * @param type the type of comparison to perform * @param date the date to compare against * @param indices the indices of the values to check. If not supplied all @@ -213,7 +217,10 @@ public abstract class RowFilter { * RowFilter.numberFilter(ComparisonType.EQUAL, 10); * * + * @param the type of the model to which the {@code RowFilter} applies + * @param the type of the identifier passed to the {@code RowFilter} * @param type the type of comparison to perform + * @param number a {@code Number} value to compare against * @param indices the indices of the values to check. If not supplied all * values are evaluated * @return a RowFilter implementing the specified criteria @@ -240,6 +247,8 @@ public abstract class RowFilter { * RowFilter<Object,Object> fooBarFilter = RowFilter.orFilter(filters); * * + * @param the type of the model to which the {@code RowFilter} applies + * @param the type of the identifier passed to the {@code RowFilter} * @param filters the RowFilters to test * @throws IllegalArgumentException if any of the filters * are null @@ -266,6 +275,8 @@ public abstract class RowFilter { * RowFilter<Object,Object> fooBarFilter = RowFilter.andFilter(filters); * * + * @param the type of the model the {@code RowFilter} applies to + * @param the type of the identifier passed to the {@code RowFilter} * @param filters the RowFilters to test * @return a RowFilter implementing the specified criteria * @throws IllegalArgumentException if any of the filters @@ -282,6 +293,8 @@ public abstract class RowFilter { * Returns a RowFilter that includes entries if the * supplied filter does not include the entry. * + * @param the type of the model to which the {@code RowFilter} applies + * @param the type of the identifier passed to the {@code RowFilter} * @param filter the RowFilter to negate * @return a RowFilter implementing the specified criteria * @throws IllegalArgumentException if filter is diff --git a/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java b/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java index c2907a39df7..797f6f35524 100644 --- a/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java +++ b/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java @@ -133,6 +133,8 @@ public class SortingFocusTraversalPolicy /** * Constructs a SortingFocusTraversalPolicy with the specified Comparator. + * + * @param comparator the {@code Comparator} to sort by */ public SortingFocusTraversalPolicy(Comparator comparator) { this.comparator = comparator; diff --git a/jdk/src/share/classes/javax/swing/Spring.java b/jdk/src/share/classes/javax/swing/Spring.java index 75b2a510f00..366b95fec78 100644 --- a/jdk/src/share/classes/javax/swing/Spring.java +++ b/jdk/src/share/classes/javax/swing/Spring.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -547,9 +547,10 @@ public abstract class Spring { /** - * Returns -s: a spring running in the opposite direction to s. + * Returns {@code -s}: a spring running in the opposite direction to {@code s}. * - * @return -s: a spring running in the opposite direction to s + * @param s a {@code Spring} object + * @return {@code -s}: a spring running in the opposite direction to {@code s} * * @see Spring */ @@ -582,6 +583,8 @@ public abstract class Spring { * the values of s1 and s2 is exactly equal to * the value of s3. * + * @param s1 a {@code Spring} object + * @param s2 a {@code Spring} object * @return s1+s2: a spring representing s1 and s2 in series * * @see Spring @@ -591,11 +594,13 @@ public abstract class Spring { } /** - * Returns max(s1, s2): a spring whose value is always greater than (or equal to) - * the values of both s1 and s2. + * Returns {@code max(s1, s2)}: a spring whose value is always greater than (or equal to) + * the values of both {@code s1} and {@code s2}. * - * @return max(s1, s2): a spring whose value is always greater than (or equal to) - * the values of both s1 and s2 + * @param s1 a {@code Spring} object + * @param s2 a {@code Spring} object + * @return {@code max(s1, s2)}: a spring whose value is always greater than (or equal to) + * the values of both {@code s1} and {@code s2} * @see Spring */ public static Spring max(Spring s1, Spring s2) { diff --git a/jdk/src/share/classes/javax/swing/UIManager.java b/jdk/src/share/classes/javax/swing/UIManager.java index d8bcbae9488..44e9decfc26 100644 --- a/jdk/src/share/classes/javax/swing/UIManager.java +++ b/jdk/src/share/classes/javax/swing/UIManager.java @@ -1107,6 +1107,8 @@ public class UIManager implements Serializable * UI class is created or when the default look and feel is changed * on a component instance. *

    Note these are not the same as the installed look and feels. + * + * @param laf the {@code LookAndFeel} to be removed * @return true if the LookAndFeel was removed from the list * @see #removeAuxiliaryLookAndFeel * @see #getAuxiliaryLookAndFeels diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Protocol.java b/jdk/src/share/classes/sun/misc/JavaAWTFontAccess.java similarity index 73% rename from jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Protocol.java rename to jdk/src/share/classes/sun/misc/JavaAWTFontAccess.java index b0e548e63f3..079d94fb39b 100644 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Protocol.java +++ b/jdk/src/share/classes/sun/misc/JavaAWTFontAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,12 +22,18 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.apple.internal.jobjc.generator.model; -public class Protocol { +/** + * SharedSecrets interface used for the access from java.text.Bidi + */ - public Protocol(final Clazz protocol) { +package sun.misc; - } +public interface JavaAWTFontAccess { + // java.awt.font.TextAttribute constants + public Object getTextAttributeConstant(String name); + + // java.awt.font.NumericShaper + public void shape(Object shaper, char[] text, int start, int count); } diff --git a/jdk/src/share/classes/sun/misc/SharedSecrets.java b/jdk/src/share/classes/sun/misc/SharedSecrets.java index 3e268759bc7..49f06b5d39b 100644 --- a/jdk/src/share/classes/sun/misc/SharedSecrets.java +++ b/jdk/src/share/classes/sun/misc/SharedSecrets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,6 +55,7 @@ public class SharedSecrets { private static JavaSecurityAccess javaSecurityAccess; private static JavaUtilZipFileAccess javaUtilZipFileAccess; private static JavaAWTAccess javaAWTAccess; + private static JavaAWTFontAccess javaAWTFontAccess; private static JavaBeansIntrospectorAccess javaBeansIntrospectorAccess; public static JavaUtilJarAccess javaUtilJarAccess() { @@ -180,12 +181,19 @@ public class SharedSecrets { public static JavaAWTAccess getJavaAWTAccess() { // this may return null in which case calling code needs to // provision for. - if (javaAWTAccess == null) { - return null; - } return javaAWTAccess; } + public static void setJavaAWTFontAccess(JavaAWTFontAccess jafa) { + javaAWTFontAccess = jafa; + } + + public static JavaAWTFontAccess getJavaAWTFontAccess() { + // this may return null in which case calling code needs to + // provision for. + return javaAWTFontAccess; + } + public static JavaBeansIntrospectorAccess getJavaBeansIntrospectorAccess() { return javaBeansIntrospectorAccess; } diff --git a/jdk/src/share/classes/sun/security/pkcs11/P11Signature.java b/jdk/src/share/classes/sun/security/pkcs11/P11Signature.java index 4a0733d7195..1bac22ca62c 100644 --- a/jdk/src/share/classes/sun/security/pkcs11/P11Signature.java +++ b/jdk/src/share/classes/sun/security/pkcs11/P11Signature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -340,7 +340,10 @@ final class P11Signature extends SignatureSpi { } int minKeySize = (int) mechInfo.ulMinKeySize; int maxKeySize = (int) mechInfo.ulMaxKeySize; - + // need to override the MAX keysize for SHA1withDSA + if (md != null && mechanism == CKM_DSA && maxKeySize > 1024) { + maxKeySize = 1024; + } int keySize = 0; if (key instanceof P11Key) { keySize = ((P11Key) key).length(); diff --git a/jdk/src/share/classes/sun/text/bidi/BidiBase.java b/jdk/src/share/classes/sun/text/bidi/BidiBase.java index f13155d06d5..bbf1b4b6a21 100644 --- a/jdk/src/share/classes/sun/text/bidi/BidiBase.java +++ b/jdk/src/share/classes/sun/text/bidi/BidiBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,13 +54,12 @@ package sun.text.bidi; import java.io.IOException; import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; import java.text.AttributedCharacterIterator; import java.text.Bidi; import java.util.Arrays; import java.util.MissingResourceException; +import sun.misc.JavaAWTFontAccess; +import sun.misc.SharedSecrets; import sun.text.normalizer.UBiDiProps; import sun.text.normalizer.UCharacter; import sun.text.normalizer.UTF16; @@ -3446,7 +3445,13 @@ public class BidiBase { * java.awt.font.TextAttribute without creating a static dependency. */ private static class TextAttributeConstants { - private static final Class clazz = getClass("java.awt.font.TextAttribute"); + // Make sure to load the AWT's TextAttribute class before using the constants, if any. + static { + try { + Class.forName("java.awt.font.TextAttribute", true, null); + } catch (ClassNotFoundException e) {} + } + static final JavaAWTFontAccess jafa = SharedSecrets.getJavaAWTFontAccess(); /** * TextAttribute instances (or a fake Attribute type if @@ -3462,88 +3467,41 @@ public class BidiBase { /** * TextAttribute.RUN_DIRECTION_LTR */ - static final Boolean RUN_DIRECTION_LTR = (clazz == null) ? - Boolean.FALSE : (Boolean)getStaticField(clazz, "RUN_DIRECTION_LTR"); - - - private static Class getClass(String name) { - try { - return Class.forName(name, true, null); - } catch (ClassNotFoundException e) { - return null; - } - } - - private static Object getStaticField(Class clazz, String name) { - try { - Field f = clazz.getField(name); - return f.get(null); - } catch (NoSuchFieldException | IllegalAccessException x) { - throw new AssertionError(x); - } - } + static final Boolean RUN_DIRECTION_LTR = (jafa == null) ? + Boolean.FALSE : (Boolean)jafa.getTextAttributeConstant("RUN_DIRECTION_LTR"); @SuppressWarnings("serial") private static AttributedCharacterIterator.Attribute getTextAttribute(String name) { - if (clazz == null) { + if (jafa == null) { // fake attribute return new AttributedCharacterIterator.Attribute(name) { }; } else { - return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name); + return (AttributedCharacterIterator.Attribute)jafa.getTextAttributeConstant(name); } } } /** - * A class that provides access to java.awt.font.NumericShaping without + * A class that provides access to java.awt.font.NumericShaper without * creating a static dependency. */ private static class NumericShapings { - private static final Class clazz = - getClass("java.awt.font.NumericShaper"); - private static final Method shapeMethod = - getMethod(clazz, "shape", char[].class, int.class, int.class); - - private static Class getClass(String name) { + // Make sure to load the AWT's NumericShaper class before calling shape, if any. + static { try { - return Class.forName(name, true, null); - } catch (ClassNotFoundException e) { - return null; - } - } - - private static Method getMethod(Class clazz, - String name, - Class... paramTypes) - { - if (clazz != null) { - try { - return clazz.getMethod(name, paramTypes); - } catch (NoSuchMethodException e) { - throw new AssertionError(e); - } - } else { - return null; - } + Class.forName("java.awt.font.NumericShaper", true, null); + } catch (ClassNotFoundException e) {} } + static final JavaAWTFontAccess jafa = SharedSecrets.getJavaAWTFontAccess(); /** * Invokes NumericShaping shape(text,start,count) method. */ static void shape(Object shaper, char[] text, int start, int count) { - if (shapeMethod == null) - throw new AssertionError("Should not get here"); - try { - shapeMethod.invoke(shaper, text, start, count); - } catch (InvocationTargetException e) { - Throwable cause = e.getCause(); - if (cause instanceof RuntimeException) - throw (RuntimeException)cause; - throw new AssertionError(e); - } catch (IllegalAccessException iae) { - throw new AssertionError(iae); + if (jafa != null) { + jafa.shape(shaper, text, start, count); } } } diff --git a/jdk/src/share/lib/security/java.security-aix b/jdk/src/share/lib/security/java.security-aix index 2734cb43a90..77540a3e506 100644 --- a/jdk/src/share/lib/security/java.security-aix +++ b/jdk/src/share/lib/security/java.security-aix @@ -206,7 +206,6 @@ package.access=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ @@ -253,7 +252,6 @@ package.definition=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ diff --git a/jdk/src/share/lib/security/java.security-linux b/jdk/src/share/lib/security/java.security-linux index 2734cb43a90..77540a3e506 100644 --- a/jdk/src/share/lib/security/java.security-linux +++ b/jdk/src/share/lib/security/java.security-linux @@ -206,7 +206,6 @@ package.access=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ @@ -253,7 +252,6 @@ package.definition=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ diff --git a/jdk/src/share/lib/security/java.security-macosx b/jdk/src/share/lib/security/java.security-macosx index 5c3122d6420..fad693da976 100644 --- a/jdk/src/share/lib/security/java.security-macosx +++ b/jdk/src/share/lib/security/java.security-macosx @@ -207,7 +207,6 @@ package.access=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ @@ -254,7 +253,6 @@ package.definition=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ diff --git a/jdk/src/share/lib/security/java.security-solaris b/jdk/src/share/lib/security/java.security-solaris index 1d3fb6ae428..c6015fb07bf 100644 --- a/jdk/src/share/lib/security/java.security-solaris +++ b/jdk/src/share/lib/security/java.security-solaris @@ -208,7 +208,6 @@ package.access=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ @@ -254,7 +253,6 @@ package.definition=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ diff --git a/jdk/src/share/lib/security/java.security-windows b/jdk/src/share/lib/security/java.security-windows index 2566f113cc9..466a4849bad 100644 --- a/jdk/src/share/lib/security/java.security-windows +++ b/jdk/src/share/lib/security/java.security-windows @@ -207,7 +207,6 @@ package.access=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ @@ -254,7 +253,6 @@ package.definition=sun.,\ com.sun.org.glassfish.,\ com.oracle.xmlns.internal.,\ com.oracle.webservices.internal.,\ - oracle.jrockit.jfr.,\ org.jcp.xml.dsig.internal.,\ jdk.internal.,\ jdk.nashorn.internal.,\ diff --git a/jdk/src/share/native/java/util/zip/ZipFile.c b/jdk/src/share/native/java/util/zip/ZipFile.c index 5fd4936a803..4604d8ff229 100644 --- a/jdk/src/share/native/java/util/zip/ZipFile.c +++ b/jdk/src/share/native/java/util/zip/ZipFile.c @@ -272,7 +272,9 @@ Java_java_util_zip_ZipFile_getEntryBytes(JNIEnv *env, case java_util_zip_ZipFile_JZENTRY_NAME: if (ze->name != 0) { len = (int)strlen(ze->name); - if (len == 0 || (jba = (*env)->NewByteArray(env, len)) == NULL) + // Unlike for extra and comment, we never return null for + // an (extremely rarely seen) empty name + if ((jba = (*env)->NewByteArray(env, len)) == NULL) break; (*env)->SetByteArrayRegion(env, jba, 0, len, (jbyte *)ze->name); } diff --git a/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c b/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c index e14036b899c..b9bfb929830 100644 --- a/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c +++ b/jdk/src/share/native/sun/security/jgss/wrapper/GSSLibStub.c @@ -639,7 +639,7 @@ Java_sun_security_jgss_wrapper_GSSLibStub_releaseCred(JNIEnv *env, */ void inquireCred(JNIEnv *env, jobject jobj, gss_cred_id_t pCred, jint type, void *result) { - OM_uint32 minor, major=0; + OM_uint32 minor=0, major=0; OM_uint32 routineErr; gss_cred_id_t credHdl; diff --git a/jdk/src/windows/native/java/net/net_util_md.c b/jdk/src/windows/native/java/net/net_util_md.c index f9a61bf5787..ae71733d8ad 100644 --- a/jdk/src/windows/native/java/net/net_util_md.c +++ b/jdk/src/windows/native/java/net/net_util_md.c @@ -443,6 +443,13 @@ NET_GetSockOpt(int s, int level, int optname, void *optval, { int rv; + if (level == IPPROTO_IPV6 && optname == IPV6_TCLASS) { + int *intopt = (int *)optval; + *intopt = 0; + *optlen = sizeof(*intopt); + return 0; + } + rv = getsockopt(s, level, optname, optval, optlen); diff --git a/jdk/src/windows/native/sun/nio/ch/Net.c b/jdk/src/windows/native/sun/nio/ch/Net.c index fc96ea206ae..fb0faa87b84 100644 --- a/jdk/src/windows/native/sun/nio/ch/Net.c +++ b/jdk/src/windows/native/sun/nio/ch/Net.c @@ -295,9 +295,9 @@ Java_sun_nio_ch_Net_getIntOption0(JNIEnv *env, jclass clazz, jobject fdo, /** * HACK: IP_TOS is deprecated on Windows and querying the option * returns a protocol error. NET_GetSockOpt handles this and uses - * a fallback mechanism. + * a fallback mechanism. Same applies to IPV6_TCLASS */ - if (level == IPPROTO_IP && opt == IP_TOS) { + if ((level == IPPROTO_IP && opt == IP_TOS) || (level == IPPROTO_IPV6 && opt == IPV6_TCLASS)) { mayNeedConversion = JNI_TRUE; } @@ -340,6 +340,11 @@ Java_sun_nio_ch_Net_setIntOption0(JNIEnv *env, jclass clazz, jobject fdo, arglen = sizeof(arg); } + if (level == IPPROTO_IPV6 && opt == IPV6_TCLASS) { + /* No op */ + return; + } + if (mayNeedConversion) { n = NET_SetSockOpt(fdval(env, fdo), level, opt, parg, arglen); } else { diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index a8d232a71a2..254f9fe8d56 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -239,9 +239,6 @@ sun/security/tools/keytool/standard.sh solaris-all # jdk_tools -# 8028474 -sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh generic-all - # Tests take too long, on sparcs see 7143279 tools/pack200/CommandLineTests.java solaris-all, macosx-all tools/pack200/Pack200Test.java solaris-all, macosx-all diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index 9efa1bd05c3..3cd7450172e 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -362,7 +362,8 @@ needs_jdk = \ sun/reflect/CallerSensitive/CallerSensitiveFinder.java \ sun/reflect/CallerSensitive/MissingCallerSensitive.java \ sun/security/util/Resources/NewNamesFormat.java \ - vm/verifier/defaultMethods/DefaultMethodRegressionTestsRun.java + vm/verifier/defaultMethods/DefaultMethodRegressionTestsRun.java \ + javax/xml/ws/clientjar/TestWsImport.java # JRE adds further tests to compact3 # @@ -388,6 +389,7 @@ needs_jre = \ java/security/Security/ClassLoaderDeadlock/Deadlock.sh \ java/util/jar/Manifest/CreateManifest.java \ java/util/logging/TestMainAppContext.java \ + java/util/logging/TestLoggingWithMainAppContext.java \ java/util/ResourceBundle/Control/Bug6530694.java \ java/text/Bidi/BidiConformance.java \ java/text/Bidi/BidiEmbeddingTest.java \ diff --git a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestCopySafe.java b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestCopySafe.java index 20dff835f90..697da6750ad 100644 --- a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestCopySafe.java +++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestCopySafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8026943 + * @bug 8026943 8027575 * @summary Verify that same buffer can be used as input and output when * using Cipher objects. * @author Valerie Peng @@ -44,7 +44,7 @@ public class TestCopySafe { private static SecretKey KEY = new SecretKeySpec(new byte[16], "AES"); private static byte[] IV = new byte[16]; - private static int[] OFFSETS = { 1, 8, 17 }; + private static int[] OFFSETS = { 1, 8, 9, 16, 17, 32, 33 }; private static final String[] MODES = { "ECB", "CBC", "PCBC", "CTR", "CTS", diff --git a/jdk/test/com/sun/jdi/PrivateTransportTest.sh b/jdk/test/com/sun/jdi/PrivateTransportTest.sh index 7f4b0029f26..1885b6d3d4b 100644 --- a/jdk/test/com/sun/jdi/PrivateTransportTest.sh +++ b/jdk/test/com/sun/jdi/PrivateTransportTest.sh @@ -82,12 +82,7 @@ fi echo "JDK under test is: $TESTJAVA" # Get flags being sent to debuggee -DEBUGGEEFLAGS= -if [ -r $TESTCLASSES/@debuggeeVMOptions ] ; then - DEBUGGEEFLAGS=`cat $TESTCLASSES/@debuggeeVMOptions` -elif [ -r $TESTCLASSES/../@debuggeeVMOptions ] ; then - DEBUGGEEFLAGS=`cat $TESTCLASSES/../@debuggeeVMOptions` -fi +DEBUGGEEFLAGS=$TESTVMOPTS $TESTJAVAOPTS # Figure out what the libarch path is os=`uname -s` diff --git a/jdk/test/com/sun/jdi/ProcessAttachDebuggee.java b/jdk/test/com/sun/jdi/ProcessAttachDebuggee.java deleted file mode 100644 index 3208b1551ee..00000000000 --- a/jdk/test/com/sun/jdi/ProcessAttachDebuggee.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2005, 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. - */ - -/* - * - * - * The "debuggee" used by the unit tests for the ProcessAttachingConnector. - * This debuggee binds to a random TCP port and waits for a client to connect. - */ -import java.net.Socket; -import java.net.ServerSocket; -import java.nio.file.CopyOption; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.io.File; -import java.io.FileOutputStream; - -public class ProcessAttachDebuggee { - public static void main(String args[]) throws Exception { - // bind to a random port - ServerSocket ss = new ServerSocket(0); - int port = ss.getLocalPort(); - - // Write the port number to the given file - File partial = new File(args[0] + ".partial"); - File portFile = new File(args[0]); - try (FileOutputStream fos = new FileOutputStream(partial)) { - fos.write( Integer.toString(port).getBytes("UTF-8") ); - } - Files.move(partial.toPath(), portFile.toPath(), StandardCopyOption.ATOMIC_MOVE); - - System.out.println("Debuggee bound to port: " + port); - System.out.flush(); - - // wait for test harness to connect - Socket s = ss.accept(); - s.close(); - ss.close(); - - System.out.println("Debuggee shutdown."); - } -} diff --git a/jdk/test/com/sun/jdi/ProcessAttachDebugger.java b/jdk/test/com/sun/jdi/ProcessAttachDebugger.java deleted file mode 100644 index 93094032883..00000000000 --- a/jdk/test/com/sun/jdi/ProcessAttachDebugger.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2005, 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. - */ - -/* - * - * - * Unit test for ProcessAttachingConnector - this "debugger" attaches to a debuggee - * given it's pid. Usage: - * - * java ProcessAttachDebugger - */ - -import com.sun.jdi.Bootstrap; -import com.sun.jdi.VirtualMachine; -import com.sun.jdi.ThreadReference; -import com.sun.jdi.connect.Connector; -import com.sun.jdi.connect.AttachingConnector; - -import java.util.List; -import java.util.Map; - -public class ProcessAttachDebugger { - - public static void main(String main_args[]) throws Exception { - String pid = main_args[0]; - - // find ProcessAttachingConnector - - List l = - Bootstrap.virtualMachineManager().attachingConnectors(); - AttachingConnector ac = null; - for (AttachingConnector c: l) { - if (c.name().equals("com.sun.jdi.ProcessAttach")) { - ac = c; - break; - } - } - if (ac == null) { - throw new RuntimeException("Unable to locate ProcessAttachingConnector"); - } - - Map args = ac.defaultArguments(); - Connector.StringArgument arg = (Connector.StringArgument)args.get("pid"); - arg.setValue(pid); - - System.out.println("Debugger is attaching to: " + pid + " ..."); - - VirtualMachine vm = ac.attach(args); - - System.out.println("Attached! Now listing threads ..."); - - // list all threads - - for (ThreadReference thr: vm.allThreads()) { - System.out.println(thr); - } - - System.out.println("Debugger done."); - } - -} diff --git a/jdk/test/com/sun/jdi/ProcessAttachTest.java b/jdk/test/com/sun/jdi/ProcessAttachTest.java new file mode 100644 index 00000000000..972f27b04db --- /dev/null +++ b/jdk/test/com/sun/jdi/ProcessAttachTest.java @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Map; + +import jdk.testlibrary.ProcessTools; + +import com.sun.jdi.Bootstrap; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.connect.AttachingConnector; +import com.sun.jdi.connect.Connector; +import com.sun.jdi.connect.IllegalConnectorArgumentsException; + +/** + * @test + * @bug 4527279 + * @summary Unit test for ProcessAttachingConnector + * + * @library /lib/testlibrary + * @build jdk.testlibrary.* ProcessAttachTest + * @run driver ProcessAttachTest + */ + +class ProcessAttachTestTarg { + public static void main(String args[]) throws Exception { + // Write something that can be read by the driver + System.out.println("Debuggee started"); + System.out.flush(); + for (;;) { + Thread.sleep(100); + } + } +} + +public class ProcessAttachTest { + + public static final String TESTCLASSES = System.getProperty("test.classes"); + + public static void main(String[] args) throws Exception { + + System.out.println("Test 1: Debuggee start with suspend=n"); + runTest("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n"); + + System.out.println("Test 2: Debuggee start with suspend=y"); + runTest("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y"); + + } + + private static void runTest(String jdwpArg) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + jdwpArg, + "-classpath", TESTCLASSES, + "ProcessAttachTestTarg"); + Process p = null; + try { + p = pb.start(); + + // Wait for the process to start + InputStream is = p.getInputStream(); + is.read(); + + // Attach a debugger + tryDebug(p.getPid()); + } finally { + p.destroyForcibly(); + } + } + + private static void tryDebug(long pid) throws IOException, + IllegalConnectorArgumentsException { + AttachingConnector ac = Bootstrap.virtualMachineManager().attachingConnectors() + .stream() + .filter(c -> c.name().equals("com.sun.jdi.ProcessAttach")) + .findFirst() + .orElseThrow(() -> new RuntimeException("Unable to locate ProcessAttachingConnector")); + + Map args = ac.defaultArguments(); + Connector.StringArgument arg = (Connector.StringArgument) args + .get("pid"); + arg.setValue("" + pid); + + System.out.println("Debugger is attaching to: " + pid + " ..."); + VirtualMachine vm = ac.attach(args); + + // list all threads + System.out.println("Attached! Now listing threads ..."); + vm.allThreads().stream().forEach(System.out::println); + + System.out.println("Debugger done."); + vm.dispose(); + } +} diff --git a/jdk/test/com/sun/jdi/ProcessAttachTest.sh b/jdk/test/com/sun/jdi/ProcessAttachTest.sh deleted file mode 100644 index 739b53abb10..00000000000 --- a/jdk/test/com/sun/jdi/ProcessAttachTest.sh +++ /dev/null @@ -1,199 +0,0 @@ -#!/bin/sh - -# -# Copyright (c) 2005, 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 4527279 -# @summary Unit test for ProcessAttachingConnector -# -# @build ProcessAttachDebugger ProcessAttachDebuggee ShutdownDebuggee -# @run shell/timeout=120 ProcessAttachTest.sh - -if [ "${TESTJAVA}" = "" ] -then - echo "TESTJAVA not set. Test cannot execute. Failed." - exit 1 -fi - -if [ "${TESTSRC}" = "" ] -then - echo "TESTSRC not set. Test cannot execute. Failed." - exit 1 -fi - -if [ "${TESTCLASSES}" = "" ] -then - echo "TESTCLASSES not set. Test cannot execute. Failed." - exit 1 -fi - -JAVA="${TESTJAVA}/bin/java" - -OS=`uname -s` - -case "$OS" in - Windows*) - PS=";" - OS="Windows" - ;; - CYGWIN*) - PS=";" - OS="CYGWIN" - ;; - * ) - PS=":" - ;; -esac - -startDebuggee() -{ - rm -f ${OUTPUTFILE} - ${JAVA} "$@" > ${OUTPUTFILE} 2>&1 & - startpid="$!" - pid="${startpid}" - - # CYGWIN startpid is not the native windows PID we want, get the WINPID - if [ "${OS}" = "CYGWIN" ]; then - sleep 2 - ps -l -p ${startpid} - pid=`ps -l -p ${startpid} | tail -1 | awk '{print $4;}'` - fi - - # MKS creates an intermediate shell to launch ${JAVA} so - # ${startpid} is not the actual pid. We have put in a small sleep - # to give the intermediate shell process time to launch the - # "java" process. - if [ "$OS" = "Windows" ]; then - sleep 2 - pid=`ps -o pid,ppid,comm | awk '/${startpid}.+java/{ print $1 }'` - fi - - echo "Waiting for Debuggee to initialize..." - attempts=0 - while true; do - out=`tail -1 ${OUTPUTFILE}` - if [ ! -z "$out" ]; then - break - fi - sleep 1 - attempts=`expr $attempts + 1` - echo "Waiting $attempts second(s) ..." - done - - echo "Debuggee is process $pid (startpid=${startpid})" -} - -stopDebuggee() -{ - # We have to make sure the debuggee has written the portfile before - # trying to read it. - - echo "Waiting for port file to be written..." - attempts=0 - while true; do - attempts=`expr $attempts + 1` - if [ -f ${PORTFILE} ]; then - break - fi - sleep 1 - echo "Waiting $attempts second(s) ..." - done - - $JAVA -classpath "${TESTCLASSES}" ShutdownDebuggee $1 2>&1 - if [ $? != 0 ] ; then - echo "Error: ShutdownDebuggee failed: $?" - failures=`expr $failures + 1` - kill -9 ${startpid} - fi -} - -failures=0 - -######################################################### -echo "Test 1: Debuggee start with suspend=n" - -PORTFILE=shutdown1.port -OUTPUTFILE=Debuggee1.out - -DEBUGGEEFLAGS= -if [ -r $TESTCLASSES/@debuggeeVMOptions ] ; then - DEBUGGEEFLAGS=`cat $TESTCLASSES/@debuggeeVMOptions` -elif [ -r $TESTCLASSES/../@debuggeeVMOptions ] ; then - DEBUGGEEFLAGS=`cat $TESTCLASSES/../@debuggeeVMOptions` -fi - -startDebuggee \ - $DEBUGGEEFLAGS \ - -agentlib:jdwp=transport=dt_socket,server=y,suspend=n \ - -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}" - -$JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ - ProcessAttachDebugger $pid 2>&1 - -if [ $? != 0 ]; then - echo "Error: ProcessAttachDebugger failed: $?" - failures=`expr $failures + 1` -fi - -# Note that when the debugger disconnects, the debuggee picks another -# port and outputs another 'Listening for transport ... ' msg. - -stopDebuggee "${PORTFILE}" - -echo "${OUTPUTFILE}:" -cat $OUTPUTFILE -echo "-----" - -######################################################### -echo "\nTest 2: Debuggee start with suspend=y" - -PORTFILE=shutdown2.port -OUTPUTFILE=Debuggee2.out - -startDebuggee \ - $DEBUGGEEFLAGS \ - -agentlib:jdwp=transport=dt_socket,server=y,suspend=y \ - -classpath "${TESTCLASSES}" ProcessAttachDebuggee "${PORTFILE}" - -$JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ - ProcessAttachDebugger $pid 2>&1 - -if [ $? != 0 ]; then - echo "Error: ProcessAttachDebugger failed: $?" - failures=`expr $failures + 1` -fi - -stopDebuggee "${PORTFILE}" - -echo $OUTPUTFILE : -cat $OUTPUTFILE -echo ----- - -### -if [ $failures = 0 ]; - then echo "All tests passed."; - else echo "$failures test(s) failed." -fi -exit $failures diff --git a/jdk/test/com/sun/jdi/ShellScaffold.sh b/jdk/test/com/sun/jdi/ShellScaffold.sh index 193aabcb907..dec8ed4151f 100644 --- a/jdk/test/com/sun/jdi/ShellScaffold.sh +++ b/jdk/test/com/sun/jdi/ShellScaffold.sh @@ -882,15 +882,10 @@ startJdb() startDebuggee() { - args= - # Note that @debuggeeVMOptions is unique to a test run instead of - # a test in a run. It is not modified during a test run. - if [ -r $TESTCLASSES/../@debuggeeVMOptions ] ; then - args=`cat $TESTCLASSES/../@debuggeeVMOptions` - fi + args=$TESTVMOPTS $TESTJAVAOPTS if [ ! -z "$args" ] ; then - echo "--Starting debuggee with args from @debuggeeVMOptions: $args" + echo "--Starting debuggee with args from TESTVMOPTS and/or TESTJAVAOPTS: $args" else echo "--Starting debuggee" fi diff --git a/jdk/test/com/sun/jdi/ShutdownDebuggee.java b/jdk/test/com/sun/jdi/ShutdownDebuggee.java deleted file mode 100644 index b69768892a5..00000000000 --- a/jdk/test/com/sun/jdi/ShutdownDebuggee.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2005, 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. - */ - -/* - * - * - * Used by the unit tests for the ProcessAttachingConnector. This class is - * used to shutdown the debuggee by connecting to its shutdown port. - */ -import java.net.Socket; -import java.net.InetSocketAddress; -import java.io.File; -import java.io.FileInputStream; - -public class ShutdownDebuggee { - public static void main(String args[]) throws Exception { - - // read the (TCP) port number from the given file - - File f = new File(args[0]); - FileInputStream fis = new FileInputStream(f); - byte b[] = new byte[8]; - int n = fis.read(b); - if (n < 1) { - throw new RuntimeException("Empty file"); - } - fis.close(); - - String str = new String(b, 0, n, "UTF-8"); - System.out.println("Port number of debuggee is: " + str); - int port = Integer.parseInt(str); - - // Now connect to the port (which will shutdown debuggee) - - System.out.println("Connecting to port " + port + - " to shutdown Debuggee ..."); - - Socket s = new Socket(); - s.connect( new InetSocketAddress(port) ); - s.close(); - } -} diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Opaque.java b/jdk/test/com/sun/jdi/SuspendNoFlagTest.java similarity index 53% rename from jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Opaque.java rename to jdk/test/com/sun/jdi/SuspendNoFlagTest.java index 9cc4317d855..ad506f500ce 100644 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Opaque.java +++ b/jdk/test/com/sun/jdi/SuspendNoFlagTest.java @@ -1,12 +1,10 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -22,21 +20,29 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.apple.internal.jobjc.generator.model; -import java.util.List; +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.ProcessTools; -import org.w3c.dom.Node; +/* @test + * @bug 4914611 + * @summary Test for JDWP: -agentlib:jdwp=suspend=n hanging + * @library /lib/testlibrary + * @build jdk.testlibarary.* + * @compile -g HelloWorld.java + * @run driver SuspendNoFlagTest + */ +public class SuspendNoFlagTest { -import com.apple.internal.jobjc.generator.classes.OpaqueClassFile; -import com.apple.internal.jobjc.generator.classes.OutputFile; + private static final String TEST_CLASSES = System.getProperty( + "test.classes", "."); -public class Opaque extends TypeElement implements OutputFileGenerator { - public Opaque(final Node node, final Framework parent) { - super(node, getAttr(node, "name"), parent); + public static void main(String[] args) throws Throwable { + OutputAnalyzer output = ProcessTools.executeTestJvm("-classpath", + TEST_CLASSES, + "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n", + "HelloWorld"); + output.shouldHaveExitValue(0); } - public void generateClasses(final List generatedClassFiles) { - generatedClassFiles.add(new OpaqueClassFile(this)); - } } diff --git a/jdk/test/com/sun/jdi/SuspendNoFlagTest.sh b/jdk/test/com/sun/jdi/SuspendNoFlagTest.sh deleted file mode 100644 index dd4a24e4d76..00000000000 --- a/jdk/test/com/sun/jdi/SuspendNoFlagTest.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/ksh -p - -# -# Copyright (c) 2003, 2006, 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 SuspendNoFlagTest.sh -# @bug 4914611 -# @summary Test for JDWP: -agentlib:jdwp=suspend=n hanging -# @author Kelly O'Hair -# Based on test/java/awt/TEMPLATE/AutomaticShellTest.sh -# -# @run compile -g HelloWorld.java -# @run shell/timeout=60 SuspendNoFlagTest.sh -# - -# Beginning of subroutines: -status=1 - -#Call this from anywhere to fail the test with an error message -# usage: fail "reason why the test failed" -fail() - { echo "The test failed :-(" - echo "$*" 1>&2 - echo "exit status was $status" - exit $status - } #end of fail() - -#Call this from anywhere to pass the test with a message -# usage: pass "reason why the test passed if applicable" -pass() - { echo "The test passed!!!" - echo "$*" 1>&2 - exit 0 - } #end of pass() - -# end of subroutines - -# The beginning of the script proper - -TARGETCLASS="HelloWorld" -if [ -z "${TESTJAVA}" ] ; then - # TESTJAVA is not set, so the test is running stand-alone. - # TESTJAVA holds the path to the root directory of the build of the JDK - # to be tested. That is, any java files run explicitly in this shell - # should use TESTJAVA in the path to the java interpreter. - # So, we'll set this to the JDK spec'd on the command line. If none - # is given on the command line, tell the user that and use a default. - # THIS IS THE JDK BEING TESTED. - if [ -n "$1" ] ; then - TESTJAVA=$1 - else - TESTJAVA=$JAVA_HOME - fi - TESTSRC=. - TESTCLASSES=. - #Deal with .class files: - ${TESTJAVA}/bin/javac -d ${TESTCLASSES} \ - -classpath "${TESTCLASSES}" -g \ - ${TARGETCLASS}.java -fi -# -echo "JDK under test is: $TESTJAVA" -# -CP="-classpath \"${TESTCLASSES}\"" -# -DEBUGEEFLAGS= -if [ -r $TESTCLASSES/@debuggeeVMOptions ] ; then - DEBUGEEFLAGS=`cat $TESTCLASSES/@debuggeeVMOptions` -elif [ -r $TESTCLASSES/../@debuggeeVMOptions ] ; then - DEBUGEEFLAGS=`cat $TESTCLASSES/../@debuggeeVMOptions` -fi -DEBUGEEFLAGS="$DEBUGEEFLAGS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n" - -java=java -echo ${TESTJAVA}/bin/$java ${DEBUGEEFLAGS} ${CP} ${TARGETCLASS} -eval ${TESTJAVA}/bin/$java ${DEBUGEEFLAGS} ${CP} ${TARGETCLASS} -status=$? -echo "test status was: $status" -if [ $status -eq "0" ] ; - then pass "status = 0 and no timeout occured" - - else fail "unspecified test failure (timed out or hung)" -fi diff --git a/jdk/test/com/sun/jdi/VMConnection.java b/jdk/test/com/sun/jdi/VMConnection.java index 2df2e63057e..a9e5355a321 100644 --- a/jdk/test/com/sun/jdi/VMConnection.java +++ b/jdk/test/com/sun/jdi/VMConnection.java @@ -44,8 +44,7 @@ class VMConnection { /** * Return a String containing VM Options to pass to the debugee * or an empty string if there are none. - * These are read from the first non-comment line - * in file @debuggeeVMOptions in the test.classes dir + * These are read from TESTVMOPTS and/or TESTJAVAOPTS. */ static public String getDebuggeeVMOptions() { String retVal = ""; diff --git a/jdk/test/java/io/File/NulFile.java b/jdk/test/java/io/File/NulFile.java index b61b1d875cf..0b68efafd9d 100644 --- a/jdk/test/java/io/File/NulFile.java +++ b/jdk/test/java/io/File/NulFile.java @@ -602,7 +602,10 @@ public class NulFile { try { File.createTempFile(prefix, suffix, directory); } catch (IllegalArgumentException ex) { - if ("Prefix string too short".equals(ex.getMessage())) + String actual = ex.getMessage(); + String expected = "Prefix string \"" + prefix + + "\" too short: length must be at least 3"; + if (actual != null && actual.equals(expected)) exceptionThrown = true; } catch (IOException ioe) { System.err.println("IOException happens in testCreateTempFile"); diff --git a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java index a8e75896a6f..cbde18a378d 100644 --- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java +++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java @@ -80,7 +80,6 @@ public class CheckPackageAccess { "com.sun.org.glassfish.", "com.oracle.xmlns.internal.", "com.oracle.webservices.internal.", - "oracle.jrockit.jfr.", "org.jcp.xml.dsig.internal.", "jdk.internal.", "jdk.nashorn.internal.", diff --git a/jdk/test/java/text/Bidi/Bug7051769.java b/jdk/test/java/text/Bidi/Bug7051769.java index 1a96870b14f..9b1326021b5 100644 --- a/jdk/test/java/text/Bidi/Bug7051769.java +++ b/jdk/test/java/text/Bidi/Bug7051769.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,11 @@ /* * @test - * @bug 7051769 + * @bug 7051769 8038092 * @summary verify that Bidi.toString() returns the corect result. + * The second run is intended to test lazy SharedSectets init for 8038092 + * @run main Bug7051769 + * @run main/othervm -DpreloadBidi=true Bug7051769 */ import java.awt.font.*; import java.text.*; @@ -32,6 +35,18 @@ import java.util.*; public class Bug7051769 { + static { + if (System.getProperty("preloadBidi", "").equals("true")) { + // Make sure the SharedSecret is lazily initialized correctly + try { + Class.forName("sun.text.bidi.BidiBase"); + System.out.println("BidiBase class has been pre-loaded."); + } catch (ClassNotFoundException e) { + System.out.println("BidiBase class could not be pre-loaded."); + } + } + } + private static boolean err = false; public static void main(String[] args) { diff --git a/jdk/test/java/util/logging/CheckZombieLockTest.java b/jdk/test/java/util/logging/CheckZombieLockTest.java new file mode 100644 index 00000000000..f0b0a930c68 --- /dev/null +++ b/jdk/test/java/util/logging/CheckZombieLockTest.java @@ -0,0 +1,369 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8048020 + * @author Daniel Fuchs + * @summary Regression on java.util.logging.FileHandler. + * The fix is to avoid filling up the file system with zombie lock files. + * + * @run main/othervm CheckZombieLockTest WRITABLE CLOSE CLEANUP + * @run main/othervm CheckZombieLockTest CLEANUP + * @run main/othervm CheckZombieLockTest WRITABLE + * @run main/othervm CheckZombieLockTest CREATE_FIRST + * @run main/othervm CheckZombieLockTest CREATE_NEXT + * @run main/othervm CheckZombieLockTest CREATE_NEXT + * @run main/othervm CheckZombieLockTest CLEANUP + * @run main/othervm CheckZombieLockTest REUSE + * @run main/othervm CheckZombieLockTest CLEANUP + */ +import java.io.File; +import java.io.IOException; +import java.nio.channels.FileChannel; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.logging.FileHandler; +import java.util.logging.Level; +import java.util.logging.LogRecord; +public class CheckZombieLockTest { + + private static final String WRITABLE_DIR = "writable-dir"; + private static volatile boolean supportsLocking = true; + + static enum TestCase { + WRITABLE, // just verifies that we can create a file in our 'writable-dir' + CLOSE, // checks that closing a FileHandler removes its lock file + CREATE_FIRST, // verifies that 'writable-dir' contains no lock, then creates a first FileHandler. + CREATE_NEXT, // verifies that 'writable-dir' contains a single lock, then creates the next FileHandler + REUSE, // verifies that zombie lock files can be reused + CLEANUP // removes "writable-dir" + }; + + public static void main(String... args) throws IOException { + // we'll base all file creation attempts on the system temp directory, + // %t + File writableDir = setup(); + System.out.println("Writable dir is: "+writableDir.getAbsolutePath()); + // we now have one writable directory to work with: + // writableDir + if (args == null || args.length == 0) { + args = new String[] { "WRITABLE", "CLOSE", "CLEANUP" }; + } + try { + runTests(writableDir, args); + } catch (RuntimeException | IOException | Error x) { + // some error occured: cleanup + delete(writableDir); + throw x; + } + } + + /** + * @param writableDir in which log and lock file are created + * @throws SecurityException + * @throws RuntimeException + * @throws IOException + */ + private static void runTests(File writableDir, String... args) throws SecurityException, + RuntimeException, IOException { + for (String arg : args) { + switch(TestCase.valueOf(arg)) { + // Test 1: makes sure we can create FileHandler in writable directory + case WRITABLE: checkWritable(writableDir); break; + // Test 2: verifies that FileHandler.close() cleans up its lock file + case CLOSE: testFileHandlerClose(writableDir); break; + // Test 3: creates the first file handler + case CREATE_FIRST: testFileHandlerCreate(writableDir, true); break; + // Test 4, 5, ... creates the next file handler + case CREATE_NEXT: testFileHandlerCreate(writableDir, false); break; + // Checks that zombie lock files are reused appropriatly + case REUSE: testFileHandlerReuse(writableDir); break; + // Removes the writableDir + case CLEANUP: delete(writableDir); break; + default: throw new RuntimeException("No such test case: "+arg); + } + } + } + + /** + * @param writableDir in which log and lock file are created + * @throws SecurityException + * @throws RuntimeException + * @throws IOException + */ + private static void checkWritable(File writableDir) throws SecurityException, + RuntimeException, IOException { + // Test 1: make sure we can create/delete files in the writable dir. + final File file = new File(writableDir, "test.txt"); + if (!createFile(file, false)) { + throw new IOException("Can't create "+file+"\n\tUnable to run test"); + } else { + delete(file); + } + } + + + private static FileHandler createFileHandler(File writableDir) throws SecurityException, + RuntimeException, IOException { + // Test 1: make sure we can create FileHandler in writable directory + try { + FileHandler handler = new FileHandler("%t/" + WRITABLE_DIR + "/log.log"); + handler.publish(new LogRecord(Level.INFO, handler.toString())); + handler.flush(); + return handler; + } catch (IOException ex) { + throw new RuntimeException("Test failed: should have been able" + + " to create FileHandler for " + "%t/" + WRITABLE_DIR + + "/log.log in writable directory.", ex); + } + } + + private static List listLocks(File writableDir, boolean print) + throws IOException { + List locks = new ArrayList<>(); + for (File f : writableDir.listFiles()) { + if (print) { + System.out.println("Found file: " + f.getName()); + } + if (f.getName().endsWith(".lck")) { + locks.add(f); + } + } + return locks; + } + + private static void testFileHandlerClose(File writableDir) throws IOException { + File fakeLock = new File(writableDir, "log.log.lck"); + if (!createFile(fakeLock, false)) { + throw new IOException("Can't create fake lock file: "+fakeLock); + } + try { + List before = listLocks(writableDir, true); + System.out.println("before: " +before.size() + " locks found"); + FileHandler handler = createFileHandler(writableDir); + System.out.println("handler created: "+handler); + List after = listLocks(writableDir, true); + System.out.println("after creating handler: " + after.size() + " locks found"); + handler.close(); + System.out.println("handler closed: "+handler); + List afterClose = listLocks(writableDir, true); + System.out.println("after closing handler: " + afterClose.size() + " locks found"); + afterClose.removeAll(before); + if (!afterClose.isEmpty()) { + throw new RuntimeException("Zombie lock file detected: "+ afterClose); + } + } finally { + if (fakeLock.canRead()) delete(fakeLock); + } + List finalLocks = listLocks(writableDir, false); + System.out.println("After cleanup: " + finalLocks.size() + " locks found"); + } + + + private static void testFileHandlerReuse(File writableDir) throws IOException { + List before = listLocks(writableDir, true); + System.out.println("before: " +before.size() + " locks found"); + try { + if (!before.isEmpty()) { + throw new RuntimeException("Expected no lock file! Found: "+before); + } + } finally { + before.stream().forEach(CheckZombieLockTest::delete); + } + + FileHandler handler1 = createFileHandler(writableDir); + System.out.println("handler created: "+handler1); + List after = listLocks(writableDir, true); + System.out.println("after creating handler: " + after.size() + " locks found"); + if (after.size() != 1) { + throw new RuntimeException("Unexpected number of lock files found for "+handler1+": "+after); + } + final File lock = after.get(0); + after.clear(); + handler1.close(); + after = listLocks(writableDir, true); + System.out.println("after closing handler: " + after.size() + " locks found"); + if (!after.isEmpty()) { + throw new RuntimeException("Unexpected number of lock files found for "+handler1+": "+after); + } + if (!createFile(lock, false)) { + throw new IOException("Can't create fake lock file: "+lock); + } + try { + before = listLocks(writableDir, true); + System.out.println("before: " +before.size() + " locks found"); + if (before.size() != 1) { + throw new RuntimeException("Unexpected number of lock files found: "+before+" expected [" + +lock+"]."); + } + FileHandler handler2 = createFileHandler(writableDir); + System.out.println("handler created: "+handler2); + after = listLocks(writableDir, true); + System.out.println("after creating handler: " + after.size() + " locks found"); + after.removeAll(before); + if (!after.isEmpty()) { + throw new RuntimeException("Unexpected lock file found: "+after + + "\n\t" + lock + " should have been reused"); + } + handler2.close(); + System.out.println("handler closed: "+handler2); + List afterClose = listLocks(writableDir, true); + System.out.println("after closing handler: " + afterClose.size() + " locks found"); + if (!afterClose.isEmpty()) { + throw new RuntimeException("Zombie lock file detected: "+ afterClose); + } + + if (supportsLocking) { + FileChannel fc = FileChannel.open(Paths.get(lock.getAbsolutePath()), + StandardOpenOption.CREATE_NEW, StandardOpenOption.APPEND, + StandardOpenOption.WRITE); + try { + if (fc.tryLock() != null) { + System.out.println("locked: "+lock); + handler2 = createFileHandler(writableDir); + System.out.println("handler created: "+handler2); + after = listLocks(writableDir, true); + System.out.println("after creating handler: " + after.size() + " locks found"); + after.removeAll(before); + if (after.size() != 1) { + throw new RuntimeException("Unexpected lock files found: "+after + + "\n\t" + lock + " should not have been reused"); + } + } else { + throw new RuntimeException("Failed to lock: "+lock); + } + } finally { + delete(lock); + } + } + } finally { + List finalLocks = listLocks(writableDir, false); + System.out.println("end: " + finalLocks.size() + " locks found"); + delete(writableDir); + } + } + + + private static void testFileHandlerCreate(File writableDir, boolean first) + throws IOException { + List before = listLocks(writableDir, true); + System.out.println("before: " +before.size() + " locks found"); + try { + if (first && !before.isEmpty()) { + throw new RuntimeException("Expected no lock file! Found: "+before); + } else if (!first && before.size() != 1) { + throw new RuntimeException("Expected a single lock file! Found: "+before); + } + } finally { + before.stream().forEach(CheckZombieLockTest::delete); + } + FileHandler handler = createFileHandler(writableDir); + System.out.println("handler created: "+handler); + List after = listLocks(writableDir, true); + System.out.println("after creating handler: " + after.size() + " locks found"); + if (after.size() != 1) { + throw new RuntimeException("Unexpected number of lock files found for "+handler+": "+after); + } + } + + + /** + * Setup all the files and directories needed for the tests + * + * @return writable directory created that needs to be deleted when done + * @throws RuntimeException + */ + private static File setup() throws RuntimeException { + // First do some setup in the temporary directory (using same logic as + // FileHandler for %t pattern) + String tmpDir = System.getProperty("java.io.tmpdir"); // i.e. %t + if (tmpDir == null) { + tmpDir = System.getProperty("user.home"); + } + File tmpOrHomeDir = new File(tmpDir); + // Create a writable directory here (%t/writable-dir) + File writableDir = new File(tmpOrHomeDir, WRITABLE_DIR); + if (!createFile(writableDir, true)) { + throw new RuntimeException("Test setup failed: unable to create" + + " writable working directory " + + writableDir.getAbsolutePath() ); + } + + // try to determine whether file locking is supported + try { + FileChannel fc = FileChannel.open(Paths.get(writableDir.getAbsolutePath(), + UUID.randomUUID().toString()+".lck"), + StandardOpenOption.CREATE_NEW, StandardOpenOption.APPEND, + StandardOpenOption.DELETE_ON_CLOSE); + try { + fc.tryLock(); + } catch(IOException x) { + supportsLocking = false; + } finally { + fc.close(); + } + } catch(Throwable t) { + // should not happen + t.printStackTrace(); + } + return writableDir; + } + + /** + * @param newFile + * @return true if file already exists or creation succeeded + */ + private static boolean createFile(File newFile, boolean makeDirectory) { + if (newFile.exists()) { + return true; + } + if (makeDirectory) { + return newFile.mkdir(); + } else { + try { + return newFile.createNewFile(); + } catch (IOException ioex) { + ioex.printStackTrace(); + return false; + } + } + } + + /* + * Recursively delete all files starting at specified file + */ + private static void delete(File f) { + if (f != null && f.isDirectory()) { + for (File c : f.listFiles()) + delete(c); + } + if (!f.delete()) + System.err.println( + "WARNING: unable to delete/cleanup writable test directory: " + + f ); + } +} diff --git a/jdk/test/java/util/zip/ZipFile/Assortment.java b/jdk/test/java/util/zip/ZipFile/Assortment.java index d5e9d1f933d..b890b31ff1a 100644 --- a/jdk/test/java/util/zip/ZipFile/Assortment.java +++ b/jdk/test/java/util/zip/ZipFile/Assortment.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4770745 6234507 6303183 + * @bug 4770745 6234507 6303183 8048990 * @summary test a variety of zip file entries * @author Martin Buchholz */ @@ -137,8 +137,11 @@ public class Assortment { return fdata; } - void verify(ZipFile f) throws Exception { - ZipEntry e = f.getEntry(name); + void verify(ZipFile f, ZipEntry e) throws Exception { + verify(e, getData(f, e)); + } + + void verify(ZipEntry e, byte[] eData) throws Exception { byte[] data = (this.data == null) ? new byte[]{} : this.data; byte[] extra = (this.extra != null && this.extra.length == 0) ? null : this.extra; @@ -148,21 +151,23 @@ public class Assortment { && (e.getComment() == null)) || comment.equals(e.getComment())); check(equalsExtraData(extra, e.getExtra())); - check(Arrays.equals(data, getData(f, e))); + check(Arrays.equals(data, eData)); check(e.getSize() == data.length); check((method == ZipEntry.DEFLATED) || (e.getCompressedSize() == data.length)); } - void verify(JarInputStream jis) throws Exception { - // JarInputStream "automatically" reads the manifest - if (name.equals("meta-iNf/ManIfEst.Mf")) - return; - ZipEntry e = jis.getNextEntry(); + void verify(ZipFile f) throws Exception { + ZipEntry e = f.getEntry(name); + verify(e, getData(f, e)); + } + + void verifyZipInputStream(ZipInputStream s) throws Exception { + ZipEntry e = s.getNextEntry(); byte[] data = (this.data == null) ? new byte[]{} : this.data; byte[] otherData = new byte[data.length]; - jis.read(otherData); + s.read(otherData); check(Arrays.equals(data, otherData)); byte[] extra = (this.extra != null && this.extra.length == 0) ? @@ -173,7 +178,14 @@ public class Assortment { check(e.getSize() == -1 || e.getSize() == data.length); check((method == ZipEntry.DEFLATED) || (e.getCompressedSize() == data.length)); + } + void verifyJarInputStream(JarInputStream s) throws Exception { + // JarInputStream "automatically" reads the manifest + if (name.equals("meta-iNf/ManIfEst.Mf")) + return; + + verifyZipInputStream(s); } } @@ -225,7 +237,7 @@ public class Assortment { "Can manifests have comments??")); // The emptiest possible entry - entries.add(new Entry("", ZipEntry.STORED, null, null, "")); + entries.add(new Entry("", ZipEntry.STORED, null, null, "")); for (String name : names) for (int method : methods) @@ -246,30 +258,66 @@ public class Assortment { } //---------------------------------------------------------------- - // Verify zip file contents using JarFile class + // Verify zip file contents using ZipFile.getEntry() //---------------------------------------------------------------- - JarFile f = new JarFile(zipName); + try (ZipFile f = new ZipFile(zipName)) { + for (Entry e : entries) + e.verify(f); + } - check(f.getManifest() != null); + //---------------------------------------------------------------- + // Verify zip file contents using JarFile.getEntry() + //---------------------------------------------------------------- + try (JarFile f = new JarFile(zipName)) { + check(f.getManifest() != null); + for (Entry e : entries) + e.verify(f); + } - for (Entry e : entries) - e.verify(f); + //---------------------------------------------------------------- + // Verify zip file contents using ZipFile.entries() + //---------------------------------------------------------------- + try (ZipFile f = new ZipFile(zipName)) { + Enumeration en = f.entries(); + for (Entry e : entries) + e.verify(f, en.nextElement()); - f.close(); + check(!en.hasMoreElements()); + } + + //---------------------------------------------------------------- + // Verify zip file contents using JarFile.entries() + //---------------------------------------------------------------- + try (JarFile f = new JarFile(zipName)) { + Enumeration en = f.entries(); + for (Entry e : entries) + e.verify(f, en.nextElement()); + + check(!en.hasMoreElements()); + } + + //---------------------------------------------------------------- + // Verify zip file contents using ZipInputStream class + //---------------------------------------------------------------- + try (FileInputStream fis = new FileInputStream(zipName); + ZipInputStream s = new ZipInputStream(fis)) { + + for (Entry e : entries) + e.verifyZipInputStream(s); + } //---------------------------------------------------------------- // Verify zip file contents using JarInputStream class //---------------------------------------------------------------- - JarInputStream jis = new JarInputStream( - new FileInputStream(zipName)); + try (FileInputStream fis = new FileInputStream(zipName); + JarInputStream s = new JarInputStream(fis)) { - // JarInputStream "automatically" reads the manifest - check(jis.getManifest() != null); + // JarInputStream "automatically" reads the manifest + check(s.getManifest() != null); - for (Entry e : entries) - e.verify(jis); - - jis.close(); + for (Entry e : entries) + e.verifyJarInputStream(s); + } // String cmd = "unzip -t " + zipName.getPath() + " >/dev/tty"; // new ProcessBuilder(new String[]{"/bin/sh", "-c", cmd}).start().waitFor(); diff --git a/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java b/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java index 9c2f0630fb7..7d9cd4b5521 100644 --- a/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java +++ b/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,228 +21,299 @@ * questions. */ -import java.util.concurrent.CountDownLatch; -import java.util.regex.*; -import java.util.*; -import java.net.URISyntaxException; +import java.io.File; import java.io.IOException; -import sun.jvmstat.monitor.*; -import sun.jvmstat.monitor.event.*; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Semaphore; -public class MonitorVmStartTerminate { +import jdk.testlibrary.OutputBuffer; +import jdk.testlibrary.ProcessTools; +import sun.jvmstat.monitor.MonitorException; +import sun.jvmstat.monitor.MonitoredHost; +import sun.jvmstat.monitor.MonitoredVm; +import sun.jvmstat.monitor.MonitoredVmUtil; +import sun.jvmstat.monitor.VmIdentifier; +import sun.jvmstat.monitor.event.HostEvent; +import sun.jvmstat.monitor.event.HostListener; +import sun.jvmstat.monitor.event.VmStatusChangeEvent; - private static final int SLEEPERS = 10; - private static final int SLEEPTIME = 5000; // sleep time for a sleeper - private static final int EXECINTERVAL = 3000; // wait time between exec's +/* - public static void main(String args[]) throws Exception { + Test starts ten Java processes, each with a unique id. - long now = System.currentTimeMillis(); + Each process creates a file named after the id and then it waits for + the test to remove the file, at which the Java process exits. - String sleeperArgs = SLEEPTIME + " " + now; - String sleeperPattern = "Sleeper " + sleeperArgs + " \\d+$"; + The processes are monitored by the test to make sure notifications + are sent when they are started/terminated. + + To avoid Java processes being left behind, in case of an unexpected + failure, shutdown hooks are installed that remove files when the test + exits. If files are not removed, i.e. due to a JVM crash, the Java + processes will exit themselves after 1000 s. + +*/ + +/* + * @test + * @bug 4990825 + * @summary attach to external but local JVM processes + * @library /lib/testlibrary + * @build jdk.testlibrary.* + * @run main/othervm MonitorVmStartTerminate + */ +public final class MonitorVmStartTerminate { + + private static final int PROCESS_COUNT = 10; + private static final long PROCESS_TIMEOUT_IN_NS = 1000*1000_000_000L; + + public static void main(String... args) throws Exception { MonitoredHost host = MonitoredHost.getMonitoredHost("localhost"); - host.setInterval(200); + host.setInterval(1); // 1 ms - Matcher matcher = Pattern.compile(sleeperPattern).matcher(""); - SleeperListener listener = new SleeperListener(host, matcher, SLEEPERS); + String id = UUID.randomUUID().toString(); + + List javaProcesses = new ArrayList<>(); + for (int i = 0; i < PROCESS_COUNT; i++) { + javaProcesses.add(new JavaProcess(id + "_" + i)); + } + + Listener listener = new Listener(host, javaProcesses); host.addHostListener(listener); - - SleeperStarter ss = new SleeperStarter(SLEEPERS, EXECINTERVAL, - sleeperArgs); - ss.start(); - - System.out.println("Waiting for " - + SLEEPERS + " sleepers to terminate"); - try { - ss.join(); - } catch (InterruptedException e) { - throw new Exception("Timed out waiting for sleepers"); + for (JavaProcess javaProcess : javaProcesses) { + javaProcess.start(); } - listener.waitForSleepersToStart(); - listener.waitForSleepersToTerminate(); + + // Wait for all processes to start before terminating + // them, so pids are not reused within a poll interval. + System.out.println("Waiting for all processes to get started notification"); + listener.started.acquire(PROCESS_COUNT); + + for (JavaProcess javaProcess : javaProcesses) { + javaProcess.terminate(); + } + System.out.println("Waiting for all processes to get terminated notification"); + listener.terminated.acquire(PROCESS_COUNT); + + host.removeHostListener(listener); } - public static class SleeperListener implements HostListener { - - private final List targets = new ArrayList<>(); - private final CountDownLatch terminateLatch; - private final CountDownLatch startLatch; + private static final class Listener implements HostListener { + private final Semaphore started = new Semaphore(0); + private final Semaphore terminated = new Semaphore(0); private final MonitoredHost host; - private final Matcher patternMatcher; + private final List processes; - public SleeperListener(MonitoredHost host, Matcher matcher, int count) { + public Listener(MonitoredHost host, List processes) { this.host = host; - this.patternMatcher = matcher; - this.terminateLatch = new CountDownLatch(count); - this.startLatch = new CountDownLatch(count); - } - - public void waitForSleepersToTerminate() throws InterruptedException { - terminateLatch.await(); - } - - public void waitForSleepersToStart() throws InterruptedException { - startLatch.await(); - } - - private void printList(Set list, String msg) { - System.out.println(msg + ":"); - for (Integer lvmid : list) { - try { - VmIdentifier vmid = new VmIdentifier("//" + lvmid.intValue()); - MonitoredVm target = host.getMonitoredVm(vmid); - - StringMonitor cmdMonitor = - (StringMonitor)target.findByName("sun.rt.javaCommand"); - String cmd = cmdMonitor.stringValue(); - - System.out.println("\t" + lvmid.intValue() + ": " - + "\"" + cmd + "\"" + ": "); - } catch (URISyntaxException e) { - System.err.println("Unexpected URISyntaxException: " - + e.getMessage()); - } catch (MonitorException e) { - System.out.println("\t" + lvmid.intValue() - + ": error reading monitoring data: " - + " target possibly terminated?"); - } - } - } - - - private int addStarted(Set started) { - int found = 0; - for (Integer lvmid : started) { - try { - VmIdentifier vmid = new VmIdentifier("//" + lvmid.intValue()); - MonitoredVm target = host.getMonitoredVm(vmid); - - StringMonitor cmdMonitor = - (StringMonitor)target.findByName("sun.rt.javaCommand"); - String cmd = cmdMonitor.stringValue(); - - patternMatcher.reset(cmd); - System.out.print("Started: " + lvmid.intValue() - + ": " + "\"" + cmd + "\"" + ": "); - - if (patternMatcher.matches()) { - System.out.println("matches pattern - recorded"); - targets.add(lvmid); - found++; - } - else { - System.out.println("does not match pattern - ignored"); - } - } catch (URISyntaxException e) { - System.err.println("Unexpected URISyntaxException: " - + e.getMessage()); - } catch (MonitorException e) { - System.err.println("Unexpected MonitorException: " - + e.getMessage()); - } - } - return found; - } - - private int removeTerminated(Set terminated) { - int found = 0; - for (Integer lvmid : terminated) { - /* - * we don't attempt to attach to the target here as it's - * now dead and has no jvmstat share memory file. Just see - * if the process id is among those that we saved when we - * started the targets (note - duplicated allowed and somewhat - * expected on windows); - */ - System.out.print("Terminated: " + lvmid.intValue() + ": "); - if (targets.contains(lvmid)) { - System.out.println("matches pattern - termination recorded"); - targets.remove(lvmid); - found++; - } - else { - System.out.println("does not match pattern - ignored"); - } - } - return found; + this.processes = processes; + printStatus(); } + @Override @SuppressWarnings("unchecked") - public void vmStatusChanged(VmStatusChangeEvent ev) { - printList(ev.getActive(), "Active"); - printList(ev.getStarted(), "Started"); - printList(ev.getTerminated(), "Terminated"); + public void vmStatusChanged(VmStatusChangeEvent event) { + releaseStarted(event.getStarted()); + releaseTerminated(event.getTerminated()); + printStatus(); + } - int recentlyStarted = addStarted(ev.getStarted()); - int recentlyTerminated = removeTerminated(ev.getTerminated()); + private void printStatus() { + System.out.printf("started=%d, terminated=%d\n", + started.availablePermits(), terminated.availablePermits()); + } - for (int i = 0; i < recentlyTerminated; i++) { - terminateLatch.countDown(); - } - for (int i = 0; i < recentlyStarted; i++) { - startLatch.countDown(); + @Override + public void disconnected(HostEvent arg0) { + // ignore + } + + private void releaseStarted(Set ids) { + System.out.println("realeaseStarted(" + ids + ")"); + for (Integer id : ids) { + releaseStarted(id); } } - public void disconnected(HostEvent ev) { + private void releaseStarted(Integer id) { + for (JavaProcess jp : processes) { + if (hasMainArgs(id, jp.getMainArgsIdentifier())) { + // store id for terminated identification + jp.setId(id); + System.out.println("RELEASED (id=" + jp.getId() + ", args=" + jp.getMainArgsIdentifier() + ")"); + started.release(); + return; + } + } + } + + private void releaseTerminated(Set ids) { + System.out.println("releaseTerminated(" + ids + ")"); + for (Integer id : ids) { + releaseTerminated(id); + } + } + + private void releaseTerminated(Integer id) { + for (JavaProcess jp : processes) { + if (id.equals(jp.getId())) { + System.out.println("RELEASED (id=" + jp.getId() + ", args=" + jp.getMainArgsIdentifier() + ")"); + terminated.release(); + return; + } + } + } + + private boolean hasMainArgs(Integer id, String args) { + try { + VmIdentifier vmid = new VmIdentifier("//" + id.intValue()); + MonitoredVm target = host.getMonitoredVm(vmid); + String monitoredArgs = MonitoredVmUtil.mainArgs(target); + if (monitoredArgs != null && monitoredArgs.contains(args)) { + return true; + } + } catch (URISyntaxException | MonitorException e) { + // ok. process probably not running + } + return false; } } - public static class SleeperStarter extends Thread { + public final static class JavaProcess { - private final JavaProcess[] processes; - private final int execInterval; - private final String args; + private static final class ShutdownHook extends Thread { + private final JavaProcess javaProcess; - public SleeperStarter(int sleepers, int execInterval, String args) { - this.execInterval = execInterval; - this.args = args; - this.processes = new JavaProcess[sleepers]; - } - - private synchronized int active() { - int active = processes.length; - for(JavaProcess jp : processes) { - try { - jp.exitValue(); - active--; - } catch (IllegalThreadStateException e) { - // process hasn't exited yet - } + public ShutdownHook(JavaProcess javaProcess) { + this.javaProcess = javaProcess; + } + + public void run() { + javaProcess.terminate(); } - return active; } - public void run() { - System.out.println("Starting " + processes.length + " sleepers"); + public static void main(String[] args) throws InterruptedException { + try { + Path path = Paths.get(args[0]); + createFile(path); + waitForRemoval(path); + } catch (Throwable t) { + t.printStackTrace(); + System.exit(1); + } + } - String[] classpath = { - "-classpath", - System.getProperty("java.class.path") - }; + public Integer getId() { + return id; + } - for (int i = 0; i < processes.length; i++) { - try { - System.out.println("Starting Sleeper " + i); - synchronized(this) { - processes[i] = new JavaProcess("Sleeper", args + " " + i); - processes[i].addOptions(classpath); - } - processes[i].start(); - Thread.sleep(execInterval); - } catch (InterruptedException ignore) { - } catch (IOException e) { - System.err.println( - "IOException trying to start Sleeper " + i + ": " - + e.getMessage()); - } - } + public void setId(Integer id) { + this.id = id; + } - // spin waiting for the processes to terminate - while (active() > 0) ; + private static void createFile(Path path) throws IOException { + Files.write(path, new byte[0], StandardOpenOption.CREATE); + if (!Files.exists(path)) { + throw new Error("Newly created file " + path + + " does not exist!"); + } + } + + private static void waitForRemoval(Path path) { + long start = System.nanoTime(); + while (true) { + long now = System.nanoTime(); + long waited = now - start; + System.out.println("Waiting for " + path + " to be removed, " + waited + " ns"); + if (!Files.exists(path)) { + return; + } + if (waited > PROCESS_TIMEOUT_IN_NS) { + System.out.println("Start: " + start); + System.out.println("Now: " + now); + System.out.print("Process timed out after " + waited + " ns. Abort."); + System.exit(1); + } + takeNap(); + } + } + + private static void takeNap() { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // ignore + } + } + + private final String mainArgsIdentifier; + private final ShutdownHook shutdownHook; + private volatile Integer id; + + public JavaProcess(String mainArgsIdentifier) { + this.mainArgsIdentifier = mainArgsIdentifier; + this.shutdownHook = new ShutdownHook(this); + } + + /** + * Starts a Java process asynchronously. + * + * The process runs until {@link #stop()} is called. If test exits + * unexpectedly the process will be cleaned up by a shutdown hook. + * + * @throws Exception + */ + public void start() throws Exception { + Runtime.getRuntime().addShutdownHook(shutdownHook); + System.out.println("Starting " + getMainArgsIdentifier()); + + Runnable r = new Runnable() { + @Override + public void run() { + try { + executeJava(); + } catch (Throwable t) { + t.printStackTrace(); + } + } + }; + new Thread(r).start(); + } + + public void terminate() { + try { + System.out.println("Terminating " + mainArgsIdentifier); + Files.delete(Paths.get(mainArgsIdentifier)); + } catch (IOException e) { + e.printStackTrace(); + } + Runtime.getRuntime().removeShutdownHook(shutdownHook); + } + + private void executeJava() throws Exception, IOException { + String className = JavaProcess.class.getName(); + String classPath = System.getProperty("test.classes"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-cp", + classPath, className, mainArgsIdentifier); + OutputBuffer ob = ProcessTools.getOutput(pb.start()); + System.out.println("Java Process " + getMainArgsIdentifier() + " stder:" + + ob.getStderr()); + System.err.println("Java Process " + getMainArgsIdentifier() + " stdout:" + + ob.getStdout()); + } + + public String getMainArgsIdentifier() { + return mainArgsIdentifier; } } } - diff --git a/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh b/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh deleted file mode 100644 index 152ec9303a9..00000000000 --- a/jdk/test/sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright (c) 2004, 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 4990825 -# @summary attach to external but local JVM processes -# @library ../../testlibrary -# @build Sleeper -# @build JavaProcess -# @build MonitorVmStartTerminate -# @run shell MonitorVmStartTerminate.sh -# - -. ${TESTSRC-.}/../../testlibrary/utils.sh - -setup -verify_os - -JAVA="${TESTJAVA}/bin/java" -CP=${TESTJAVA}${FS}lib${FS}tools.jar${PS}${TESTCLASSES}${PS}${TESTCLASSES}${FS}..${FS}..${FS}testlibrary - -${JAVA} ${TESTVMOPTS} -classpath ${CP} MonitorVmStartTerminate diff --git a/jdk/test/sun/jvmstat/testlibrary/JavaProcess.java b/jdk/test/sun/jvmstat/testlibrary/JavaProcess.java deleted file mode 100644 index 664947b2577..00000000000 --- a/jdk/test/sun/jvmstat/testlibrary/JavaProcess.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2004, 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.io.*; - -public class JavaProcess { - - protected Process process = null; - - private String classname; - private StringBuilder classArgs; - private StringBuilder javaOptions; - - private static String java = System.getProperty("java.home") - + File.separator + "bin" - + File.separator + "java"; - - public JavaProcess(String classname) { - this(classname, "", ""); - } - - public JavaProcess(String classname, String classArgs) { - this(classname, "", classArgs); - } - - public JavaProcess(String classname, String javaOptions, String classArgs) { - this.classname = classname; - this.javaOptions = new StringBuilder(javaOptions); - this.classArgs = new StringBuilder(classArgs); - } - - /** - * add java options to the java command - */ - public void addOptions(String[] opts) { - if (javaOptions != null && javaOptions.length() > 0) { - javaOptions.append(" "); - } - - for (int i = 0; i < opts.length; i++) { - if (i != 0) { - javaOptions.append(" "); - } - javaOptions.append(opts[i]); - } - } - - /** - * add arguments to the class arguments - */ - public void addArguments(String[] args) { - if (classArgs != null && classArgs.length() > 0) { - classArgs.append(" "); - } - - for (int i = 0; i < args.length; i++) { - if (i != 0) { - classArgs.append(" "); - } - classArgs.append(args[i]); - } - } - - /** - * start the java process - */ - public void start() throws IOException { - if (process != null) { - return; - } - - String javaCommand = java + " " + javaOptions + " " - + classname + " " + classArgs; - - System.out.println("exec'ing: " + javaCommand); - - process = Runtime.getRuntime().exec(javaCommand); - } - - /** - * destroy the java process - */ - public void destroy() { - if (process != null) { - process.destroy(); - } - process = null; - } - - public int exitValue() { - if (process != null) { - return process.exitValue(); - } - throw new RuntimeException("exitValue called with process == null"); - } - - public InputStream getErrorStream() { - if (process != null) { - return process.getErrorStream(); - } - throw new RuntimeException( - "getErrorStream() called with process == null"); - } - - public InputStream getInputStream() { - if (process != null) { - return process.getInputStream(); - } - throw new RuntimeException( - "getInputStream() called with process == null"); - } - - public OutputStream getOutputStream() { - if (process != null) { - return process.getOutputStream(); - } - throw new RuntimeException( - "getOutputStream() called with process == null"); - } - - public int waitFor() throws InterruptedException { - if (process != null) { - return process.waitFor(); - } - throw new RuntimeException("waitFor() called with process == null"); - } -} diff --git a/langtools/.hgtags b/langtools/.hgtags index e701f6f47df..65e86128fc8 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -261,3 +261,5 @@ f04fccfbd880c819affc3ef33e0083aab9556409 jdk9-b11 7d67ebd3e35c3c36ad2caee482a84f8310d2f838 jdk9-b16 b64f8d5b97faa29e4d629bf4e56ebe0e26c40ecc jdk9-b17 fd8da51c5df4546995c360fc49f0b985cbf8fbd3 jdk9-b18 +a9accd7c44159f191ad09740d54493e563c39f95 jdk9-b19 +31acbc476a5251824f919df0b82bca9cbb19cf7c jdk9-b20 diff --git a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java index 44d3275f502..f546229aba4 100644 --- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java +++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java @@ -31,6 +31,7 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Target; import java.text.Collator; import java.util.*; + import javax.tools.StandardLocation; import com.sun.javadoc.*; @@ -783,9 +784,8 @@ public class Util { } /** - * A general purpose String comparator, which compares two Strings using a Collator - * strength of "SECONDARY", thus providing optimum case insensitive comparisons in - * most Locales. + * A general purpose case insensitive String comparator, which compares two Strings using a Collator + * strength of "TERTIARY". * * @param s1 first String to compare. * @param s2 second String to compare. @@ -793,14 +793,32 @@ public class Util { * argument is less than, equal to, or greater than the second. */ public static int compareStrings(String s1, String s2) { + return compareStrings(true, s1, s2); + } + /** + * A general purpose case sensitive String comparator, which compares two Strings using a Collator + * strength of "SECONDARY". + * + * @param s1 first String to compare. + * @param s2 second String to compare. + * @return a negative integer, zero, or a positive integer as the first + * argument is less than, equal to, or greater than the second. + */ + public static int compareCaseCompare(String s1, String s2) { + return compareStrings(false, s1, s2); + } + private static int compareStrings(boolean caseSensitive, String s1, String s2) { Collator collator = Collator.getInstance(); - collator.setStrength(Collator.SECONDARY); + collator.setStrength(caseSensitive ? Collator.TERTIARY : Collator.SECONDARY); return collator.compare(s1, s2); } - /** - * A comparator for index file uses, this sorts first on names, then on - * parameter types and finally on the fully qualified name. + * A comparator for index file uses, + * 1. this sorts first on simple names + * 2. if equal, case insensitive comparison of Parameter types + * 3. if equal, case sensitive comparison of Parameter types + * 4. if equal, compare the FQNs of the entities + * 5. if equal, then compare the DocKinds ex: Package, Interface etc. * @return a comparator for index file use */ public static Comparator makeComparatorForIndexUse() { @@ -816,29 +834,35 @@ public class Util { * argument is less than, equal to, or greater than the second. */ public int compare(Doc d1, Doc d2) { - int result = compareStrings(d1.name(), d2.name()); + int result = compareNames(d1, d2); if (result != 0) { return result; } if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) { - result = compareExecutableMembers( - (ExecutableMemberDoc) d1, - (ExecutableMemberDoc) d2); + Parameter[] param1 = ((ExecutableMemberDoc) d1).parameters(); + Parameter[] param2 = ((ExecutableMemberDoc) d2).parameters(); + result = compareParameters(false, param1, param2); if (result != 0) { return result; } + result = compareParameters(true, param1, param2); } - if (d1 instanceof ProgramElementDoc && d2 instanceof ProgramElementDoc) { - return compareProgramElementDoc((ProgramElementDoc)d1, (ProgramElementDoc)d2); + if (result != 0) { + return result; } - return 0; + result = compareFullyQualifiedNames(d1, d2); + if (result != 0) { + return result; + } + return compareDocKinds(d1, d2); } }; } /** * Comparator for ClassUse representations, this sorts on member names, - * fully qualified member names and then the parameter types if applicable. + * fully qualified member names and then the parameter types if applicable, + * and finally the Doc kinds ie. package, class, interface etc. * @return a comparator to sort classes and members for class use */ public static Comparator makeComparatorForClassUse() { @@ -853,46 +877,88 @@ public class Util { * argument is less than, equal to, or greater than the second. */ public int compare(Doc d1, Doc d2) { - int result = compareStrings(d1.name(), d2.name()); + int result = compareNames(d1, d2); if (result != 0) { return result; } - if (d1 instanceof ProgramElementDoc && d2 instanceof ProgramElementDoc) { - result = compareProgramElementDoc((ProgramElementDoc) d1, (ProgramElementDoc) d2); + result = compareFullyQualifiedNames(d1, d2); + if (result != 0) { + return result; + } + if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) { + Parameter[] param1 = ((ExecutableMemberDoc) d1).parameters(); + Parameter[] param2 = ((ExecutableMemberDoc) d2).parameters(); + result = compareParameters(false, param1, param2); if (result != 0) { return result; } + return compareParameters(true, param1, param2); } - if (d1 instanceof ExecutableMemberDoc && d2 instanceof ExecutableMemberDoc) { - return compareExecutableMembers((ExecutableMemberDoc)d1, (ExecutableMemberDoc)d2); - } - return 0; + return compareDocKinds(d1, d2); } }; } + /** * A general purpose comparator to sort Doc entities, basically provides the building blocks * for creating specific comparators for an use-case. * @param a Doc entity */ static abstract class DocComparator implements Comparator { + static enum DocKinds { + PACKAGE, + FIELD, + ENUM, + ANNOTATION, + INTERFACE, + CLASS, + CONSTRUCTOR, + METHOD + }; + private DocKinds getValue(Doc d) { + if (d.isAnnotationType() || d.isAnnotationTypeElement()) { + return DocKinds.ANNOTATION; + } else if (d.isEnum() || d.isEnumConstant()) { + return DocKinds.ENUM; + } else if (d.isField()) { + return DocKinds.FIELD; + } else if (d.isInterface()) { + return DocKinds.INTERFACE; + } else if (d.isClass()) { + return DocKinds.CLASS; + } else if (d.isConstructor()) { + return DocKinds.CONSTRUCTOR; + } else if (d.isMethod()) { + return DocKinds.METHOD; + } else { + return DocKinds.PACKAGE; + } + } /** - * compares two parameter arrays by comparing each Type of the parameter in the array, - * as possible, if the matched strings are identical, and have mismatched array lengths - * then compare the lengths. + * Compares two Doc entities' kinds, and these are ordered as defined in + * the DocKinds enumeration. + * @param d1 the first Doc object + * @param d2 the second Doc object + * @return a negative integer, zero, or a positive integer as the first + * argument is less than, equal to, or greater than the second. + */ + protected int compareDocKinds(Doc d1, Doc d2) { + return getValue(d1).compareTo(getValue(d2)); + } + /** + * Compares two parameter arrays by comparing each Type of the parameter in the array, + * and as many as possible, otherwise compare their lengths. + * @param ignoreCase specifies case sensitive or insensitive comparison. * @param params1 the first parameter array. * @param params2 the first parameter array. * @return a negative integer, zero, or a positive integer as the first * argument is less than, equal to, or greater than the second. */ - protected int compareParameters(Parameter[] params1, Parameter[] params2) { - if (params1.length == 0 && params2.length == 0) { - return 0; - } + protected int compareParameters(boolean ignoreCase, Parameter[] params1, Parameter[] params2) { // try to compare as many as possible for (int i = 0; i < params1.length && i < params2.length; i++) { - int result = compareStrings(params1[i].typeName(), params2[i].typeName()); + int result = compareStrings(ignoreCase, params1[i].typeName(), params2[i].typeName()); if (result != 0) { return result; } @@ -901,41 +967,32 @@ public class Util { } /** - * Compares two MemberDocs, typically the name of a method, - * field or constructor. - * @param e1 the first MemberDoc. - * @param e2 the second MemberDoc. + * Compares two Doc entities typically the simple name of a method, + * field, constructor etc. + * @param d1 the first Doc. + * @param d2 the second Doc. * @return a negative integer, zero, or a positive integer as the first * argument is less than, equal to, or greater than the second. */ - protected int compareMembers(MemberDoc e1, MemberDoc e2) { - return compareStrings(e1.name(), e2.name()); - } - - /** - * Compares two ExecutableMemberDocs such as methods and constructors, - * as well as the parameters the entity might take. - * @param m1 the first ExecutableMemberDoc. - * @param m2 the second ExecutableMemberDoc. - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - */ - protected int compareExecutableMembers(ExecutableMemberDoc m1, ExecutableMemberDoc m2) { - int result = compareMembers(m1, m2); - if (result == 0) - result = compareParameters(m1.parameters(), m2.parameters()); - return result; + protected int compareNames(Doc d1, Doc d2) { + return compareStrings(d1.name(), d2.name()); } /** * Compares the fully qualified names of the entities - * @param p1 the first ProgramElementDoc. - * @param p2 the first ProgramElementDoc. + * @param d1 the first entity + * @param d2 the second entity * @return a negative integer, zero, or a positive integer as the first * argument is less than, equal to, or greater than the second. */ - protected int compareProgramElementDoc(ProgramElementDoc p1, ProgramElementDoc p2) { - return compareStrings(p1.qualifiedName(), p2.qualifiedName()); + protected int compareFullyQualifiedNames(Doc d1, Doc d2) { + String name1 = (d1 instanceof ProgramElementDoc) + ? ((ProgramElementDoc)d1).qualifiedName() + : d1.name(); + String name2 = (d2 instanceof ProgramElementDoc) + ? ((ProgramElementDoc)d2).qualifiedName() + : d2.name(); + return compareStrings(name1, name2); } } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java index 19881065604..1b9521c05ec 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -161,7 +161,7 @@ public final class JavacTool implements JavaCompiler { } } - public static void processOptions(Context context, + private void processOptions(Context context, JavaFileManager fileManager, Iterable options) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java index 88f421c9a76..656b4f14ac2 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java @@ -277,6 +277,11 @@ public class Flags { */ public static final long LAMBDA_METHOD = 1L<<49; + /** + * Flag to control recursion in TransTypes + */ + public static final long TYPE_TRANSLATED = 1L<<50; + /** Modifier masks. */ public static final int @@ -386,7 +391,8 @@ public class Flags { BAD_OVERRIDE(Flags.BAD_OVERRIDE), SIGNATURE_POLYMORPHIC(Flags.SIGNATURE_POLYMORPHIC), THROWS(Flags.THROWS), - LAMBDA_METHOD(Flags.LAMBDA_METHOD); + LAMBDA_METHOD(Flags.LAMBDA_METHOD), + TYPE_TRANSLATED(Flags.TYPE_TRANSLATED); Flag(long flag) { this.value = flag; diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java index 35a6ea9b84a..a4d09cd8699 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java @@ -237,6 +237,9 @@ public enum Source { public boolean allowFunctionalInterfaceMostSpecific() { return compareTo(JDK1_8) >= 0; } + public boolean allowPostApplicabilityVarargsAccessCheck() { + return compareTo(JDK1_8) >= 0; + } public static SourceVersion toSourceVersion(Source source) { switch(source) { case JDK1_2: diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java index f76d7282c79..c6565f27b16 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java @@ -770,42 +770,41 @@ public abstract class Symbol extends AnnoConstruct implements Element { @Override public List getAnnotationMirrors() { - return onlyTypeVariableAnnotations(owner.getRawTypeAttributes()); - } - - private List onlyTypeVariableAnnotations( - List candidates) { - // Declaration annotations on TypeParameters are stored in type attributes + // Declaration annotations on type variables are stored in type attributes + // on the owner of the TypeVariableSymbol + List candidates = owner.getRawTypeAttributes(); + int index = owner.getTypeParameters().indexOf(this); List res = List.nil(); for (Attribute.TypeCompound a : candidates) { - if (a.position.type == TargetType.CLASS_TYPE_PARAMETER || - a.position.type == TargetType.METHOD_TYPE_PARAMETER) + if (isCurrentSymbolsAnnotation(a, index)) res = res.prepend(a); } - return res = res.reverse(); + return res.reverse(); } - - // Helper to getAnnotation[s] @Override public Attribute.Compound getAttribute(Class annoType) { - String name = annoType.getName(); // Declaration annotations on type variables are stored in type attributes // on the owner of the TypeVariableSymbol List candidates = owner.getRawTypeAttributes(); + int index = owner.getTypeParameters().indexOf(this); for (Attribute.TypeCompound anno : candidates) - if (anno.position.type == TargetType.CLASS_TYPE_PARAMETER || - anno.position.type == TargetType.METHOD_TYPE_PARAMETER) - if (name.contentEquals(anno.type.tsym.flatName())) - return anno; + if (isCurrentSymbolsAnnotation(anno, index) && + name.contentEquals(anno.type.tsym.flatName())) + return anno; return null; } - + //where: + boolean isCurrentSymbolsAnnotation(Attribute.TypeCompound anno, int index) { + return (anno.position.type == TargetType.CLASS_TYPE_PARAMETER || + anno.position.type == TargetType.METHOD_TYPE_PARAMETER) && + anno.position.parameter_index == index; + } @Override diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 8762d125115..97f123f2b45 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -92,6 +92,7 @@ public class Attr extends JCTree.Visitor { final JCDiagnostic.Factory diags; final Annotate annotate; final DeferredLintHandler deferredLintHandler; + final TypeEnvs typeEnvs; public static Attr instance(Context context) { Attr instance = context.get(attrKey); @@ -120,6 +121,7 @@ public class Attr extends JCTree.Visitor { diags = JCDiagnostic.Factory.instance(context); annotate = Annotate.instance(context); deferredLintHandler = DeferredLintHandler.instance(context); + typeEnvs = TypeEnvs.instance(context); Options options = Options.instance(context); @@ -429,7 +431,7 @@ public class Attr extends JCTree.Visitor { } public Type attribType(JCTree node, TypeSymbol sym) { - Env env = enter.typeEnvs.get(sym); + Env env = typeEnvs.get(sym); Env localEnv = env.dup(node, env.info.dup()); return attribTree(node, localEnv, unknownTypeInfo); } @@ -4252,7 +4254,7 @@ public class Attr extends JCTree.Visitor { // ... and attribute the bound class c.flags_field |= UNATTRIBUTED; Env cenv = enter.classEnv(cd, env); - enter.typeEnvs.put(c, cenv); + typeEnvs.put(c, cenv); attribClass(c); return owntype; } @@ -4398,9 +4400,9 @@ public class Attr extends JCTree.Visitor { c.flags_field &= ~UNATTRIBUTED; // Get environment current at the point of class definition. - Env env = enter.typeEnvs.get(c); + Env env = typeEnvs.get(c); - // The info.lint field in the envs stored in enter.typeEnvs is deliberately uninitialized, + // The info.lint field in the envs stored in typeEnvs is deliberately uninitialized, // because the annotations were not available at the time the env was created. Therefore, // we look up the environment chain for the first enclosing environment for which the // lint value is set. Typically, this is the parent env, but might be further if there diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java index 3f2157cdc35..ef37f097493 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java @@ -78,6 +78,7 @@ public class DeferredAttr extends JCTree.Visitor { final Flow flow; final Names names; final Annotate annotate; + final TypeEnvs typeEnvs; public static DeferredAttr instance(Context context) { DeferredAttr instance = context.get(deferredAttrKey); @@ -102,6 +103,7 @@ public class DeferredAttr extends JCTree.Visitor { names = Names.instance(context); stuckTree = make.Ident(names.empty).setType(Type.stuckType); annotate = Annotate.instance(context); + typeEnvs = TypeEnvs.instance(context); emptyDeferredAttrContext = new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) { @Override @@ -420,7 +422,7 @@ public class DeferredAttr extends JCTree.Visitor { //it is possible that nested expressions inside argument expression //are left unchecked - in such cases there's nothing to clean up. if (csym == null) return; - enter.typeEnvs.remove(csym); + typeEnvs.remove(csym); chk.compiled.remove(csym.flatname); syms.classes.remove(csym.flatname); super.visitClassDef(tree); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java index 65df77a2cc5..03448a80a9b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java @@ -103,6 +103,7 @@ public class Enter extends JCTree.Visitor { Names names; JavaFileManager fileManager; PkgInfo pkginfoOpt; + TypeEnvs typeEnvs; private final Todo todo; @@ -139,13 +140,9 @@ public class Enter extends JCTree.Visitor { Options options = Options.instance(context); pkginfoOpt = PkgInfo.get(options); + typeEnvs = TypeEnvs.instance(context); } - /** A hashtable mapping classes and packages to the environments current - * at the points of their definitions. - */ - Map> typeEnvs = new HashMap<>(); - /** Accessor for typeEnvs */ public Env getEnv(TypeSymbol sym) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 5bffdebdca7..933c790e82a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -79,6 +79,7 @@ public class Lower extends TreeTranslator { private final ConstFold cfolder; private final Target target; private final Source source; + private final TypeEnvs typeEnvs; private final boolean allowEnums; private final Name dollarAssertionsDisabled; private final Name classDollar; @@ -99,6 +100,7 @@ public class Lower extends TreeTranslator { cfolder = ConstFold.instance(context); target = Target.instance(context); source = Source.instance(context); + typeEnvs = TypeEnvs.instance(context); allowEnums = source.allowEnums(); dollarAssertionsDisabled = names. fromString(target.syntheticNameChar() + "assertionsDisabled"); @@ -2450,10 +2452,16 @@ public class Lower extends TreeTranslator { } public void visitClassDef(JCClassDecl tree) { + Env prevEnv = attrEnv; ClassSymbol currentClassPrev = currentClass; MethodSymbol currentMethodSymPrev = currentMethodSym; + currentClass = tree.sym; currentMethodSym = null; + attrEnv = typeEnvs.remove(currentClass); + if (attrEnv == null) + attrEnv = prevEnv; + classdefs.put(currentClass, tree); proxies = proxies.dup(currentClass); @@ -2525,6 +2533,7 @@ public class Lower extends TreeTranslator { // Append translated tree to `translated' queue. translated.append(tree); + attrEnv = prevEnv; currentClass = currentClassPrev; currentMethodSym = currentMethodSymPrev; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java index a1b51f6edc5..dfdcaee0acc 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java @@ -82,6 +82,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { private final Target target; private final DeferredLintHandler deferredLintHandler; private final Lint lint; + private final TypeEnvs typeEnvs; public static MemberEnter instance(Context context) { MemberEnter instance = context.get(memberEnterKey); @@ -107,6 +108,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { target = Target.instance(context); deferredLintHandler = DeferredLintHandler.instance(context); lint = Lint.instance(context); + typeEnvs = TypeEnvs.instance(context); allowTypeAnnos = source.allowTypeAnnotations(); } @@ -1000,7 +1002,7 @@ public class MemberEnter extends JCTree.Visitor implements Completer { ClassSymbol c = (ClassSymbol)sym; ClassType ct = (ClassType)c.type; - Env env = enter.typeEnvs.get(c); + Env env = typeEnvs.get(c); JCClassDecl tree = (JCClassDecl)env.tree; boolean wasFirst = isFirst; isFirst = false; diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index fffe05c55a0..f8ab3109450 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -95,6 +95,7 @@ public class Resolve { public final boolean varargsEnabled; public final boolean allowMethodHandles; public final boolean allowFunctionalInterfaceMostSpecific; + public final boolean checkVarargsAccessDuringResolution; private final boolean debugResolve; private final boolean compactMethodDiags; final EnumSet verboseResolutionMode; @@ -136,6 +137,8 @@ public class Resolve { Target target = Target.instance(context); allowMethodHandles = target.hasMethodHandles(); allowFunctionalInterfaceMostSpecific = source.allowFunctionalInterfaceMostSpecific(); + checkVarargsAccessDuringResolution = + source.allowPostApplicabilityVarargsAccessCheck(); polymorphicSignatureScope = new Scope(syms.noSymbol); inapplicableMethodException = new InapplicableMethodException(diags); @@ -833,7 +836,10 @@ public class Resolve { Warner warn) { super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn); //should we expand formals? - if (deferredAttrContext.phase.isVarargsRequired()) { + if ((!checkVarargsAccessDuringResolution || + (checkVarargsAccessDuringResolution && + deferredAttrContext.mode == AttrMode.CHECK)) && + deferredAttrContext.phase.isVarargsRequired()) { //check varargs element type accessibility varargsAccessible(env, types.elemtype(formals.last()), deferredAttrContext.inferenceContext); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java index 29f0215137c..03ab51fec48 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -966,10 +966,11 @@ public class TransTypes extends TreeTranslator { translateClass((ClassSymbol)st.tsym); } - Env myEnv = enter.typeEnvs.remove(c); - if (myEnv == null) { + Env myEnv = enter.getEnv(c); + if (myEnv == null || (c.flags_field & TYPE_TRANSLATED) != 0) { return; } + c.flags_field |= TYPE_TRANSLATED; /* The two assertions below are set for early detection of any attempt * to translate a class that: diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/TypeEnvs.java b/langtools/src/share/classes/com/sun/tools/javac/comp/TypeEnvs.java new file mode 100644 index 00000000000..01672d4ab6d --- /dev/null +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TypeEnvs.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. 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.tools.javac.comp; + +import java.util.Collection; +import java.util.HashMap; +import com.sun.tools.javac.code.Symbol.TypeSymbol; +import com.sun.tools.javac.util.Context; + +/** This class contains the type environments used by Enter, MemberEnter, + * Attr, DeferredAttr, and Lower. + * + *

    This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ +class TypeEnvs { + private static final long serialVersionUID = 571524752489954631L; + + protected static final Context.Key typeEnvsKey = new Context.Key<>(); + public static TypeEnvs instance(Context context) { + TypeEnvs instance = context.get(typeEnvsKey); + if (instance == null) + instance = new TypeEnvs(context); + return instance; + } + + private HashMap> map; + protected TypeEnvs(Context context) { + map = new HashMap<>(); + context.put(typeEnvsKey, this); + } + + Env get(TypeSymbol sym) { return map.get(sym); } + Env put(TypeSymbol sym, Env env) { return map.put(sym, env); } + Env remove(TypeSymbol sym) { return map.remove(sym); } + Collection> values() { return map.values(); } + void clear() { map.clear(); } +} diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java index 3cb2662f3a3..ec95d298964 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java +++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java @@ -384,7 +384,7 @@ public class Main { /** Programmatic interface for main function. * @param args The command line parameters. */ - public Result compile(String[] args, + protected Result compile(String[] args, Context context, List fileObjects, Iterable processors) diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java b/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java index 7fc43f8eec9..1e9bdeb6776 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java +++ b/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java @@ -354,13 +354,41 @@ public class JCDiagnostic implements Diagnostic { private final DiagnosticType type; private final DiagnosticSource source; private final DiagnosticPosition position; - private final int line; - private final int column; private final String key; protected final Object[] args; private final Set flags; private final LintCategory lintCategory; + /** source line position (set lazily) */ + private SourcePosition sourcePosition; + + /** + * This class is used to defer the line/column position fetch logic after diagnostic construction. + */ + class SourcePosition { + + private final int line; + private final int column; + + SourcePosition() { + int n = (position == null ? Position.NOPOS : position.getPreferredPosition()); + if (n == Position.NOPOS || source == null) + line = column = -1; + else { + line = source.getLineNumber(n); + column = source.getColumnNumber(n, true); + } + } + + public int getLineNumber() { + return line; + } + + public int getColumnNumber() { + return column; + } + } + /** * Create a diagnostic object. * @param formatter the formatter to use for the diagnostic @@ -390,14 +418,6 @@ public class JCDiagnostic implements Diagnostic { this.position = pos; this.key = key; this.args = args; - - int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition()); - if (n == Position.NOPOS || source == null) - line = column = -1; - else { - line = source.getLineNumber(n); - column = source.getColumnNumber(n, true); - } } /** @@ -494,7 +514,10 @@ public class JCDiagnostic implements Diagnostic { * @return the line number within the source referred to by this diagnostic */ public long getLineNumber() { - return line; + if (sourcePosition == null) { + sourcePosition = new SourcePosition(); + } + return sourcePosition.getLineNumber(); } /** @@ -502,7 +525,10 @@ public class JCDiagnostic implements Diagnostic { * @return the column number within the line of source referred to by this diagnostic */ public long getColumnNumber() { - return column; + if (sourcePosition == null) { + sourcePosition = new SourcePosition(); + } + return sourcePosition.getColumnNumber(); } /** diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java b/langtools/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java index a0eaa5268a3..2c7c5eb8eea 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/comp/Dependencies.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,10 +72,6 @@ public class Dependencies { private Dependencies(Context context) { context.put(dependenciesKey, this); log = Log.instance(context); - } - - public void reset() - { deps = new HashMap<>(); explicitPackages = new HashSet<>(); publicApiPerClass = new HashMap<>(); diff --git a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java index 3998e51b47e..c3873c3409e 100644 --- a/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java +++ b/langtools/src/share/classes/com/sun/tools/sjavac/server/CompilerThread.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,23 +39,26 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; -import java.util.Set; import java.util.Map; +import java.util.Set; import java.util.concurrent.Future; + +import javax.tools.JavaCompiler.CompilationTask; import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; +import com.sun.tools.javac.api.JavacTaskImpl; +import com.sun.tools.javac.util.BaseFileManager; import com.sun.tools.javac.util.Context; import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Log; -import com.sun.tools.javac.util.BaseFileManager; import com.sun.tools.javac.util.StringUtils; import com.sun.tools.sjavac.comp.AttrWithDeps; import com.sun.tools.sjavac.comp.Dependencies; import com.sun.tools.sjavac.comp.JavaCompilerWithDeps; -import com.sun.tools.sjavac.comp.SmartFileManager; import com.sun.tools.sjavac.comp.ResolveWithDeps; +import com.sun.tools.sjavac.comp.SmartFileManager; /** * The compiler thread maintains a JavaCompiler instance and @@ -78,7 +81,6 @@ public class CompilerThread implements Runnable { // The necessary classes to do a compilation. private com.sun.tools.javac.api.JavacTool compiler; private StandardJavaFileManager fileManager; - private BaseFileManager fileManagerBase; private SmartFileManager smartFileManager; private Context context; @@ -127,10 +129,8 @@ public class CompilerThread implements Runnable { inUse = true; compiler = com.sun.tools.javac.api.JavacTool.create(); fileManager = compiler.getStandardFileManager(null, null, null); - fileManagerBase = (BaseFileManager)fileManager; smartFileManager = new SmartFileManager(fileManager); context = new Context(); - context.put(JavaFileManager.class, smartFileManager); ResolveWithDeps.preRegister(context); AttrWithDeps.preRegister(context); JavaCompilerWithDeps.preRegister(context, this); @@ -145,7 +145,6 @@ public class CompilerThread implements Runnable { inUse = false; compiler = null; fileManager = null; - fileManagerBase = null; smartFileManager = null; context = null; subTasks = null; @@ -315,24 +314,13 @@ public class CompilerThread implements Runnable { com.sun.tools.javac.main.Main.Result rc = com.sun.tools.javac.main.Main.Result.OK; try { if (compilationUnits.size() > 0) { - // Bind the new logger to the existing context. - context.put(Log.outKey, stderr); - Log.instance(context).setWriter(Log.WriterKind.NOTICE, stdout); - Log.instance(context).setWriter(Log.WriterKind.WARNING, stderr); - Log.instance(context).setWriter(Log.WriterKind.ERROR, stderr); - // Process the options. - com.sun.tools.javac.api.JavacTool.processOptions(context, smartFileManager, the_options); - fileManagerBase.setContext(context); smartFileManager.setVisibleSources(visibleSources); smartFileManager.cleanArtifacts(); smartFileManager.setLog(stdout); - Dependencies.instance(context).reset(); - - com.sun.tools.javac.main.Main ccompiler = new com.sun.tools.javac.main.Main("javacTask", stderr); - String[] aa = the_options.toArray(new String[0]); // Do the compilation! - rc = ccompiler.compile(aa, context, compilationUnits.toList(), null); + CompilationTask task = compiler.getTask(stderr, smartFileManager, null, the_options, null, compilationUnits, context); + rc = ((JavacTaskImpl) task).doCall(); while (numActiveSubTasks()>0) { try { Thread.sleep(1000); } catch (InterruptedException e) { } diff --git a/langtools/test/com/sun/javadoc/lib/JavadocTester.java b/langtools/test/com/sun/javadoc/lib/JavadocTester.java index 3fd1bdcc1a8..aa12176b327 100644 --- a/langtools/test/com/sun/javadoc/lib/JavadocTester.java +++ b/langtools/test/com/sun/javadoc/lib/JavadocTester.java @@ -451,8 +451,12 @@ public abstract class JavadocTester { for (String s : strings) { int currentIndex = fileString.indexOf(s); checking(s + " at index " + currentIndex); - if (currentIndex >= prevIndex) { - passed(s + "is in the correct order"); + if (currentIndex == -1) { + failed(s + " not found."); + continue; + } + if (currentIndex > prevIndex) { + passed(s + " is in the correct order"); } else { failed(s + " is in the wrong order."); } diff --git a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java index 29286329ac2..98cc674525b 100644 --- a/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java +++ b/langtools/test/com/sun/javadoc/testOrdering/TestOrdering.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8039410 8042601 + * @bug 8039410 8042601 8042829 * @summary test to determine if members are ordered correctly * @author ksrini * @library ../lib/ @@ -31,6 +31,16 @@ * @run main TestOrdering */ +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static java.nio.file.StandardOpenOption.*; + public class TestOrdering extends JavadocTester { public static void main(String[] args) throws Exception { @@ -39,7 +49,7 @@ public class TestOrdering extends JavadocTester { } @Test - void testUnnamedPackages() { + void testUnnamedPackagesForClassUse() { javadoc("-d", "out", "-sourcepath", testSrc, "-use", @@ -49,16 +59,94 @@ public class TestOrdering extends JavadocTester { } @Test - void testNamedPackages() { + void testNamedPackagesForClassUse() { javadoc("-d", "out-1", "-sourcepath", testSrc, "-use", "pkg1"); checkExit(Exit.OK); checkClassUseOrdering("pkg1/class-use/UsedClass.html"); - checkIndexPathOrdering("index-all.html"); } + enum ListOrder { NONE, REVERSE, SHUFFLE }; + /* + * By default we do not shuffle the input list, in order to keep the list deterministic, + * and the test predictable. However, we can turn on the stress mode, by setting the following + * property if required. + */ + static final ListOrder STRESS_MODE = Boolean.getBoolean("TestOrder.STRESS") + ? ListOrder.SHUFFLE + : ListOrder.REVERSE; + + /* + * Controls the number of sibling packages, pkg0, pkg1, pkg2, ..... + */ + static final int MAX_PACKAGES = 4; + + /* + * Controls the number of children packages, pkg0, pkg0.pkg, pkg0.pkg.pkg, ..... + * Note: having too long a depth (> 256 chars on Windows), will likely lead to + * cause problems with automated build and test systems. + */ + static final int MAX_SUBPACKAGES_DEPTH = 4; + @Test + void testIndexOrdering() throws IOException { + final String clsname = "Add"; + List cmdArgs = new ArrayList(); + cmdArgs.add("-d"); + cmdArgs.add("out-2"); + cmdArgs.add("-sourcepath"); + cmdArgs.add("src"); + cmdArgs.add("-package"); + System.out.println("STRESS_MODE: " + STRESS_MODE); + emitFile(null, clsname, STRESS_MODE); + for (int width = 0 ; width < MAX_PACKAGES ; width++) { + String wpkgname = "add" + width; + String dpkgname = wpkgname; + emitFile(wpkgname, clsname, ListOrder.NONE); // list as-is + cmdArgs.add(wpkgname); + for (int depth = 1 ; depth < MAX_SUBPACKAGES_DEPTH ; depth++) { + dpkgname = dpkgname + ".add"; + emitFile(dpkgname, clsname, STRESS_MODE); + cmdArgs.add(dpkgname); + } + } + File srcDir = new File(new File("."), "src"); + cmdArgs.add(new File(srcDir, clsname + ".java").getPath()); + javadoc(cmdArgs.toArray(new String[cmdArgs.size()])); + checkExit(Exit.OK); + checkOrder("index-all.html", composeTestVectors()); + } + String[] composeTestVectors() { + List testList = new ArrayList<>(); + + for (String x : expectedMethodOrdering) { + testList.add(x); + for (int i = 0; i < MAX_PACKAGES; i++) { + String wpkg = "add" + i; + testList.add(wpkg + "/" + x); + String dpkg = wpkg; + for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) { + dpkg = dpkg + "/" + "add"; + testList.add(dpkg + "/" + x); + } + } + } + for (String x : expectedEnumOrdering) { + testList.add(x.replace("REPLACE_ME", "<Unnamed>")); + for (int i = 0; i < MAX_PACKAGES; i++) { + String wpkg = "add" + i; + testList.add(wpkg + "/" + x.replace("REPLACE_ME", wpkg)); + String dpkg = wpkg; + for (int j = 1; j < MAX_SUBPACKAGES_DEPTH; j++) { + dpkg = dpkg + "/" + "add"; + testList.add(dpkg + "/" + x.replace("REPLACE_ME", pathToPackage(dpkg))); + } + } + } + testList.addAll(Arrays.asList(expectedFieldOrdering)); + return testList.toArray(new String[testList.size()]); + } void checkExecutableMemberOrdering(String usePage) { String contents = readFile(usePage); // check constructors @@ -109,29 +197,125 @@ public class TestOrdering extends JavadocTester { } } - void checkIndexPathOrdering(String indexPage) { - checkOrder(indexPage, - "pkg1/UsedClass.html#add--", - "pkg1/ZZTop.html#add--", - "pkg1/UsedClass.html#add-double-", - "pkg1/UsedClass.html#add-java.lang.Double-", - "pkg1/ZZTop.html#add-double-", - "pkg1/ZZTop.html#add-java.lang.Double-", - "pkg1/UsedClass.html#add-double-byte-", - "pkg1/ZZTop.html#add-double-byte-", - "pkg1/UsedClass.html#add-double-double-", - "pkg1/UsedClass.html#add-double-java.lang.Double-", - "pkg1/ZZTop.html#add-double-double-", - "pkg1/ZZTop.html#add-double-java.lang.Double-", - "pkg1/UsedClass.html#add-float-", - "pkg1/ZZTop.html#add-float-", - "pkg1/UsedClass.html#add-float-int-", - "pkg1/ZZTop.html#add-float-int-", - "pkg1/UsedClass.html#add-int-", - "pkg1/ZZTop.html#add-int-", - "pkg1/UsedClass.html#add-int-float-", - "pkg1/ZZTop.html#add-int-float-", - "pkg1/UsedClass.html#add-java.lang.Integer-", - "pkg1/ZZTop.html#add-java.lang.Integer-"); + static String[] contents = { + "public add ADDADD;", + "public add AddAdd;", + "public add addadd;", + "public enum add {add, ADD, addd, ADDD};", + "public enum ADD {ADD, add, addd, ADDD};", + "public void add(){}", + "public void add(double d){}", + "public void add(int i, float f){}", + "public void add(float f, int i){}", + "public void add(double d, byte b){}", + "public Double add(Double d) {return (double) 22/7;}", + "public double add(double d1, double d2) {return d1 + d2;}", + "public double add(double d1, Double d2) {return d1 + d2;}", + "public Float add(float f) {return (float) 22/7;}", + "public void add(int i){}", + "public int add(Integer i) {return 0;}" + }; + + void emitFile(String pkgname, String clsname, ListOrder order) throws IOException { + File srcDir = new File("src"); + File outDir = pkgname == null + ? srcDir + : new File(srcDir, pkgname.replace(".", File.separator)); + File outFile = new File(outDir, clsname + ".java"); + outDir.mkdirs(); + List scratch = new ArrayList<>(Arrays.asList(contents)); + switch (order) { + case SHUFFLE: + Collections.shuffle(scratch); + break; + case REVERSE: + Collections.reverse(scratch); + break; + default: + // leave list as-is + } + // insert the header + scratch.add(0, "public class " + clsname + " {"); + if (pkgname != null) { + scratch.add(0, "package " + pkgname + ";"); + } + // append the footer + scratch.add("}"); + Files.write(outFile.toPath(), scratch, CREATE, TRUNCATE_EXISTING); } + + String pathToPackage(String in) { + return in.replace("/", "."); + } + + final String expectedMethodOrdering[] = { + "Add.html#add--", + "Add.html#add-double-", + "Add.html#add-java.lang.Double-", + "Add.html#add-double-byte-", + "Add.html#add-double-double-", + "Add.html#add-double-java.lang.Double-", + "Add.html#add-float-", + "Add.html#add-float-int-", + "Add.html#add-int-", + "Add.html#add-int-float-", + "Add.html#add-java.lang.Integer-" + }; + final String expectedEnumOrdering[] = { + "Add.add.html\" title=\"enum in REPLACE_ME\"", + "Add.ADD.html\" title=\"enum in REPLACE_ME\"" + }; + final String expectedFieldOrdering[] = { + "Add.html#addadd\"", + "add0/add/add/add/Add.html#addadd\"", + "add0/add/add/Add.html#addadd\"", + "add0/add/Add.html#addadd\"", + "add0/Add.html#addadd\"", + "add1/add/add/add/Add.html#addadd\"", + "add1/add/add/Add.html#addadd\"", + "add1/add/Add.html#addadd\"", + "add1/Add.html#addadd\"", + "add2/add/add/add/Add.html#addadd\"", + "add2/add/add/Add.html#addadd\"", + "add2/add/Add.html#addadd\"", + "add2/Add.html#addadd\"", + "add3/add/add/add/Add.html#addadd\"", + "add3/add/add/Add.html#addadd\"", + "add3/add/Add.html#addadd\"", + "add3/Add.html#addadd\"", + "Add.html#AddAdd\"", + "add0/add/add/add/Add.html#AddAdd\"", + "add0/add/add/Add.html#AddAdd\"", + "add0/add/Add.html#AddAdd\"", + "add0/Add.html#AddAdd\"", + "add1/add/add/add/Add.html#AddAdd\"", + "add1/add/add/Add.html#AddAdd\"", + "add1/add/Add.html#AddAdd\"", + "add1/Add.html#AddAdd\"", + "add2/add/add/add/Add.html#AddAdd\"", + "add2/add/add/Add.html#AddAdd\"", + "add2/add/Add.html#AddAdd\"", + "add2/Add.html#AddAdd\"", + "add3/add/add/add/Add.html#AddAdd\"", + "add3/add/add/Add.html#AddAdd\"", + "add3/add/Add.html#AddAdd\"", + "add3/Add.html#AddAdd\"", + "Add.html#ADDADD\"", + "add0/add/add/add/Add.html#ADDADD\"", + "add0/add/add/Add.html#ADDADD\"", + "add0/add/Add.html#ADDADD\"", + "add0/Add.html#ADDADD\"", + "add1/add/add/add/Add.html#ADDADD\"", + "add1/add/add/Add.html#ADDADD\"", + "add1/add/Add.html#ADDADD\"", + "add1/Add.html#ADDADD\"", + "add2/add/add/add/Add.html#ADDADD\"", + "add2/add/add/Add.html#ADDADD\"", + "add2/add/Add.html#ADDADD\"", + "add2/Add.html#ADDADD\"", + "add3/add/add/add/Add.html#ADDADD\"", + "add3/add/add/Add.html#ADDADD\"", + "add3/add/Add.html#ADDADD\"", + "add3/Add.html#ADDADD\"" + }; } diff --git a/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java b/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java index 020dd7bb031..ed35353e9fd 100644 --- a/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java +++ b/langtools/test/com/sun/javadoc/testOrdering/pkg1/UsedClass.java @@ -23,72 +23,6 @@ package pkg1; /** - * For index and class-use testing + * For class-use testing */ -public class UsedClass { - - /** - * just an empty param method. - */ - public void add(){} - - /** - * @param d param - */ - public void add(double d){} - - /** - * @param i param - * @param f param - */ - public void add(int i, float f){} - - /** - * @param f param - * @param i param - */ - public void add(float f, int i){} - - /** - * @param d param - * @param b param - */ - public void add(double d, byte b){} - - /** - * @param d param - * @return Double - */ - public Double add(Double d) {return (double) 22/7;} - - /** - * @param d1 param - * @param d2 param - * @return double - */ - public double add(double d1, double d2) {return d1 + d2;} - - /** - * @param d1 param - * @param d2 param - * @return double - */ - public double add(double d1, Double d2) {return d1 + d2;} - - /** - * @param f param - * @return Float - */ - public Float add(float f) {return (float) 22/7;} - - /** - * @param i param - */ - public void add(int i){} - - /** - * @param i param - * @return double - */ - public int add(Integer i) {return 0;} -} +public class UsedClass {} diff --git a/langtools/test/com/sun/javadoc/testOrdering/pkg1/ZZTop.java b/langtools/test/com/sun/javadoc/testOrdering/pkg1/ZZTop.java deleted file mode 100644 index 6ad1cb4aa84..00000000000 --- a/langtools/test/com/sun/javadoc/testOrdering/pkg1/ZZTop.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package pkg1; -/** - * For index testing only - */ -public class ZZTop { - - /** - * just an empty param method. - */ - public void add(){} - - /** - * @param d param - */ - public void add(double d){} - - /** - * @param i param - * @param f param - */ - public void add(int i, float f){} - - /** - * @param f param - * @param i param - */ - public void add(float f, int i){} - - /** - * @param d param - * @param b param - */ - public void add(double d, byte b){} - - /** - * @param d param - * @return Double - */ - public Double add(Double d) {return (double) 22/7;} - - /** - * @param d1 param - * @param d2 param - * @return double - */ - public double add(double d1, double d2) {return d1 + d2;} - - /** - * @param d1 param - * @param d2 param - * @return double - */ - public double add(double d1, Double d2) {return d1 + d2;} - - /** - * @param f param - * @return Float - */ - public Float add(float f) {return (float) 22/7;} - - /** - * @param i param - */ - public void add(int i){} - - /** - * @param i param - * @return double - */ - public int add(Integer i) {return 0;} -} diff --git a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java b/langtools/test/tools/javac/T8038975/AccessTest.java similarity index 67% rename from jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java rename to langtools/test/tools/javac/T8038975/AccessTest.java index fe6684833e0..b79a9db89ae 100644 --- a/jdk/src/macosx/native/jobjc/src/core/java/com/apple/jobjc/Opaque.java +++ b/langtools/test/tools/javac/T8038975/AccessTest.java @@ -1,12 +1,10 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -22,10 +20,20 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.apple.jobjc; +/* + * @test + * @bug 8038975 + * @summary Access control in enhanced for + * @compile AccessTest.java + */ -public class Opaque extends Pointer { - protected Opaque(long ptr) { super(ptr); } - protected Opaque(Pointer ptr) { super(ptr.ptr); } +import a.*; +public class AccessTest { + private static class Impl extends B { + public void method(Inner inner) { + for (A a : inner) + System.out.println(a); + } + } } diff --git a/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m b/langtools/test/tools/javac/T8038975/a/A.java similarity index 75% rename from jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m rename to langtools/test/tools/javac/T8038975/a/A.java index dfb5b48676a..c6573f2871c 100644 --- a/jdk/src/macosx/native/jobjc/src/core/native/JObjCRuntime.m +++ b/langtools/test/tools/javac/T8038975/a/A.java @@ -1,12 +1,10 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -23,5 +21,5 @@ * questions. */ -#include "Cocoa/Cocoa.h" - +package a; +public class A { } diff --git a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Constant.java b/langtools/test/tools/javac/T8038975/a/B.java similarity index 64% rename from jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Constant.java rename to langtools/test/tools/javac/T8038975/a/B.java index b5c0b627649..a7728e0ddb0 100644 --- a/jdk/src/macosx/native/jobjc/src/generator/java/com/apple/internal/jobjc/generator/model/Constant.java +++ b/langtools/test/tools/javac/T8038975/a/B.java @@ -1,12 +1,10 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. + * 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 @@ -22,12 +20,8 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.apple.internal.jobjc.generator.model; -import org.w3c.dom.Node; - -public class Constant extends ElementWType { - public Constant(final Node node, final Framework parent) { - super(node, parent); - } +package a; +public class B { + protected abstract class Inner implements Iterable { } } diff --git a/langtools/test/tools/javac/options/xprefer/XPreferTest.java b/langtools/test/tools/javac/options/xprefer/XPreferTest.java index 7d9c6da190e..3a95718fe36 100644 --- a/langtools/test/tools/javac/options/xprefer/XPreferTest.java +++ b/langtools/test/tools/javac/options/xprefer/XPreferTest.java @@ -26,7 +26,6 @@ * @summary Tests which path is used to represent an implicit type given * various xprefer arguments and multiple .class / .java files involved. * @bug 8028196 - * @ignore 8042839 XPreferTest fails on Windows */ import java.io.File; @@ -42,6 +41,7 @@ import java.util.List; import java.util.ListIterator; import java.util.NoSuchElementException; import java.util.Scanner; +import java.util.regex.Pattern; import javax.tools.JavaCompiler; import javax.tools.JavaCompiler.CompilationTask; @@ -180,10 +180,16 @@ public class XPreferTest { Scanner s = new Scanner(compilerOutput); while (s.hasNextLine()) { String line = s.nextLine(); - if (line.matches("\\[loading .*\\]")) - for (Dir dir : Dir.values()) - if (line.contains(dir.file.getName() + "/" + classId)) + if (line.matches("\\[loading .*\\]")) { + for (Dir dir : Dir.values()) { + // On Windows all paths are printed with '/' except + // paths inside zip-files, which are printed with '\'. + // For this reason we accept both '/' and '\' below. + String regex = dir.file.getName() + "[\\\\/]" + classId; + if (Pattern.compile(regex).matcher(line).find()) return dir; + } + } } return null; } diff --git a/langtools/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java b/langtools/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java index d0b5cc8ef7f..1b6e26f4308 100644 --- a/langtools/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java +++ b/langtools/test/tools/javac/processing/model/element/TestTypeParameterAnnotations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8011027 + * @bug 8011027 8046916 * @library /tools/javac/lib * @build JavacTestingAbstractProcessor TestTypeParameterAnnotations * @compile -processor TestTypeParameterAnnotations -proc:only TestTypeParameterAnnotations.java @@ -33,10 +33,16 @@ import java.util.*; import java.lang.annotation.*; import javax.annotation.processing.*; import javax.lang.model.element.*; -import javax.lang.model.util.*; import javax.tools.*; -public class TestTypeParameterAnnotations<@Foo @Bar @Baz T> extends JavacTestingAbstractProcessor { +@ExpectedTypeParameterAnnotations(typeParameterName="T1", + annotations={"Foo1", "Bar1", "Baz1"}) +@ExpectedTypeParameterAnnotations(typeParameterName="T2", annotations={}) +@ExpectedTypeParameterAnnotations(typeParameterName="T3", + annotations={"Foo2", "Bar2", "Baz2"}) +@ExpectedTypeParameterAnnotations(typeParameterName="T4", annotations={}) +public class TestTypeParameterAnnotations<@Foo1 @Bar1 @Baz1 T1, T2, @Foo2 @Bar2 @Baz2 T3, T4> extends + JavacTestingAbstractProcessor { int round = 0; public boolean process(Set annotations, RoundEnvironment roundEnv) { @@ -74,82 +80,69 @@ public class TestTypeParameterAnnotations<@Foo @Bar @Baz T> extends JavacTesting int check(Element e, List typarams) { if (typarams.isEmpty()) return 0; - if (typarams.size() != 1) - return 0; - for (TypeParameterElement tpe: typarams) { - boolean b1 = checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors()); - boolean b2 = checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe)); - boolean b3 = checkGetAnnotation(tpe); - boolean b4 = checkGetAnnotations(tpe); - return b1 && b2 && b3 && b4 ? 1 : 0; + for (TypeParameterElement tpe : typarams) { + ExpectedTypeParameterAnnotations expected = null; + for (ExpectedTypeParameterAnnotations a : e.getAnnotationsByType(ExpectedTypeParameterAnnotations.class)) { + if (tpe.getSimpleName().contentEquals(a.typeParameterName())) { + expected = a; + break; + } + } + if (expected == null) { + throw new IllegalStateException("Does not have expected values annotation."); + } + checkAnnotationMirrors(tpe, tpe.getAnnotationMirrors(), expected); + checkAnnotationMirrors(tpe, elements.getAllAnnotationMirrors(tpe), expected); + checkGetAnnotation(tpe, expected); + checkGetAnnotations(tpe, expected); } - return 0; + + return typarams.size(); } - boolean checkAnnotationMirrors(TypeParameterElement tpe, List l) { - if (l.size() != 3) { - error("To few annotations, got " + l.size() + - ", should be 3", tpe); - return false; + void checkAnnotationMirrors(TypeParameterElement tpe, List l, ExpectedTypeParameterAnnotations expected) { + String[] expectedAnnotations = expected.annotations(); + + if (l.size() != expectedAnnotations.length) { + error("Incorrect number of annotations, got " + l.size() + + ", should be " + expectedAnnotations.length, tpe); + return ; } - AnnotationMirror m = l.get(0); - if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Foo"))) { - error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement()); - return false; + for (int i = 0; i < expectedAnnotations.length; i++) { + AnnotationMirror m = l.get(i); + if (!m.getAnnotationType().asElement().equals(elements.getTypeElement(expectedAnnotations[i]))) { + error("Wrong type of annotation, was expecting @Foo", m.getAnnotationType().asElement()); + return ; + } } - m = l.get(1); - if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Bar"))) { - error("Wrong type of annotation, was expecting @Bar", m.getAnnotationType().asElement()); - return false; - } - m = l.get(2); - if (!m.getAnnotationType().asElement().equals(elements.getTypeElement("Baz"))) { - error("Wrong type of annotation, was expecting @Baz", m.getAnnotationType().asElement()); - return false; - } - return true; } - boolean checkGetAnnotation(TypeParameterElement tpe) { - Foo f = tpe.getAnnotation(Foo.class); - if (f == null) - error("Expecting @Foo to be present in getAnnotation()", tpe); + void checkGetAnnotation(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) { + List expectedAnnotations = Arrays.asList(expected.annotations()); - Bar b = tpe.getAnnotation(Bar.class); - if (b == null) - error("Expecting @Bar to be present in getAnnotation()", tpe); + for (Class c : ALL_ANNOTATIONS) { + Object a = tpe.getAnnotation(c); - Baz z = tpe.getAnnotation(Baz.class); - if (z == null) - error("Expecting @Baz to be present in getAnnotation()", tpe); - - return f != null && - b != null && - z != null; + if (a != null ^ expectedAnnotations.indexOf(c.getName()) != (-1)) { + error("Unexpected behavior for " + c.getName(), tpe); + return ; + } + } } - boolean checkGetAnnotations(TypeParameterElement tpe) { - Foo[] f = tpe.getAnnotationsByType(Foo.class); - if (f.length != 1) { - error("Expecting 1 @Foo to be present in getAnnotationsByType()", tpe); - return false; - } + void checkGetAnnotations(TypeParameterElement tpe, ExpectedTypeParameterAnnotations expected) { + List expectedAnnotations = Arrays.asList(expected.annotations()); - Bar[] b = tpe.getAnnotationsByType(Bar.class); - if (b.length != 1) { - error("Expecting 1 @Bar to be present in getAnnotationsByType()", tpe); - return false; - } + for (Class c : ALL_ANNOTATIONS) { + Object[] a = tpe.getAnnotationsByType(c); - Baz[] z = tpe.getAnnotationsByType(Baz.class); - if (z.length != 1) { - error("Expecting 1 @Baz to be present in getAnnotationsByType()", tpe); - return false; + if (a.length > 0 ^ expectedAnnotations.indexOf(c.getName()) != (-1)) { + error("Unexpected behavior for " + c.getName(), tpe); + return ; + } } - - return true; } void note(String msg) { @@ -168,23 +161,71 @@ public class TestTypeParameterAnnotations<@Foo @Bar @Baz T> extends JavacTesting messager.printMessage(Diagnostic.Kind.ERROR, msg); } + Class[] ALL_ANNOTATIONS = new Class[] { + Foo1.class, Bar1.class, Baz1.class, + Foo2.class, Bar2.class, Baz2.class, + }; + // additional generic elements to test - <@Foo @Bar @Baz X> X m(X x) { return x; } + @ExpectedTypeParameterAnnotations(typeParameterName="W", + annotations={"Foo1", "Bar1", "Baz1"}) + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) + @ExpectedTypeParameterAnnotations(typeParameterName="Y", + annotations={"Foo2", "Bar2", "Baz2"}) + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) + <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> X m(X x) { return x; } - interface Intf<@Foo @Bar @Baz X> { X m() ; } + @ExpectedTypeParameterAnnotations(typeParameterName="W", + annotations={"Foo1", "Bar1", "Baz1"}) + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) + @ExpectedTypeParameterAnnotations(typeParameterName="Y", + annotations={"Foo2", "Bar2", "Baz2"}) + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) + interface Intf<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> { X m() ; } - class Class<@Foo @Bar @Baz X> { - <@Foo @Bar @Baz Y> Class() { } + @ExpectedTypeParameterAnnotations(typeParameterName="W", + annotations={"Foo1", "Bar1", "Baz1"}) + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) + @ExpectedTypeParameterAnnotations(typeParameterName="Y", + annotations={"Foo2", "Bar2", "Baz2"}) + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) + class Clazz<@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> { + @ExpectedTypeParameterAnnotations(typeParameterName="W", + annotations={"Foo1", "Bar1", "Baz1"}) + @ExpectedTypeParameterAnnotations(typeParameterName="X", annotations={}) + @ExpectedTypeParameterAnnotations(typeParameterName="Y", + annotations={"Foo2", "Bar2", "Baz2"}) + @ExpectedTypeParameterAnnotations(typeParameterName="Z", annotations={}) + <@Foo1 @Bar1 @Baz1 W, X, @Foo2 @Bar2 @Baz2 Y, Z> Clazz() { } } - final int expect = 5; // top level class, plus preceding examples + final int expect = 5 * 4; // top level class, plus preceding examples, 4 type variables each } @Target(ElementType.TYPE_PARAMETER) -@interface Foo {} +@interface Foo1 {} @Target(ElementType.TYPE_PARAMETER) -@interface Bar {} +@interface Bar1 {} @Target(ElementType.TYPE_PARAMETER) -@interface Baz {} +@interface Baz1 {} + +@Target(ElementType.TYPE_PARAMETER) +@interface Foo2 {} + +@Target(ElementType.TYPE_PARAMETER) +@interface Bar2 {} + +@Target(ElementType.TYPE_PARAMETER) +@interface Baz2 {} + +@Repeatable(ExpectedTypeParameterAnnotationsCollection.class) +@interface ExpectedTypeParameterAnnotations { + public String typeParameterName(); + public String[] annotations(); +} + +@interface ExpectedTypeParameterAnnotationsCollection { + public ExpectedTypeParameterAnnotations[] value(); +} diff --git a/langtools/test/tools/javac/varargs/6313164/T6313164.java b/langtools/test/tools/javac/varargs/6313164/T6313164.java index 3e8284531d9..7df40d0f8bb 100644 --- a/langtools/test/tools/javac/varargs/6313164/T6313164.java +++ b/langtools/test/tools/javac/varargs/6313164/T6313164.java @@ -1,18 +1,26 @@ /* * @test /nodynamiccopyright/ - * @bug 6313164 + * @bug 6313164 8036953 * @author mcimadamore * @summary javac generates code that fails byte code verification for the varargs feature - * @compile/fail/ref=T6313164.out -XDrawDiagnostics T6313164.java + * @compile/fail/ref=T6313164Source7.out -source 7 -XDrawDiagnostics T6313164.java + * @compile/fail/ref=T6313164Source8AndHigher.out -XDrawDiagnostics T6313164.java */ import p1.*; class T6313164 { - { B b = new B(); - b.foo1(new B(), new B()); //error - A not accesible - b.foo2(new B(), new B()); //ok - A not accessible, but foo2(Object...) applicable - b.foo3(null, null); //error - A (inferred) not accesible - b.foo4(null, null); //error - A (inferred in 15.12.2.8 - no resolution backtrack) not accesible - b.foo4(new B(), new C()); //ok - A (inferred in 15.12.2.7) not accessible, but foo4(Object...) applicable + { + B b = new B(); + b.foo1(new B(), new B()); //error - A not accessible + /* 7 : ok - A not accessible, but foo2(Object...) applicable + * 8+ : error - A not accessible + */ + b.foo2(new B(), new B()); + b.foo3(null, null); //error - A (inferred) not accessible + b.foo4(null, null); //error - A not accesible + /* 7 : ok - A not accessible, but foo4(Object...) applicable + * 8+ : error - A not accessible + */ + b.foo4(new B(), new C()); } } diff --git a/langtools/test/tools/javac/varargs/6313164/T6313164.out b/langtools/test/tools/javac/varargs/6313164/T6313164.out deleted file mode 100644 index 7b2de27216b..00000000000 --- a/langtools/test/tools/javac/varargs/6313164/T6313164.out +++ /dev/null @@ -1,6 +0,0 @@ -T6313164.java:12:8: compiler.err.cant.apply.symbol: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) -T6313164.java:14:13: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) -T6313164.java:15:13: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) -- compiler.note.unchecked.filename: B.java -- compiler.note.unchecked.recompile -3 errors diff --git a/langtools/test/tools/javac/varargs/6313164/T6313164Source7.out b/langtools/test/tools/javac/varargs/6313164/T6313164Source7.out new file mode 100644 index 00000000000..8c12e727aa7 --- /dev/null +++ b/langtools/test/tools/javac/varargs/6313164/T6313164Source7.out @@ -0,0 +1,6 @@ +- compiler.warn.source.no.bootclasspath: 1.7 +T6313164.java:14:10: compiler.err.cant.apply.symbol: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:19:15: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:20:15: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +3 errors +1 warning diff --git a/langtools/test/tools/javac/varargs/6313164/T6313164Source8AndHigher.out b/langtools/test/tools/javac/varargs/6313164/T6313164Source8AndHigher.out new file mode 100644 index 00000000000..0257a5d5ecb --- /dev/null +++ b/langtools/test/tools/javac/varargs/6313164/T6313164Source8AndHigher.out @@ -0,0 +1,6 @@ +T6313164.java:14:15: compiler.err.cant.apply.symbol: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:18:15: compiler.err.cant.apply.symbol: kindname.method, foo2, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:19:15: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:20:15: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +T6313164.java:24:15: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) +5 errors diff --git a/langtools/test/tools/javac/varargs/6313164/T7175433.java b/langtools/test/tools/javac/varargs/6313164/T7175433.java index b4627eb7ab8..4384cf5d9b9 100644 --- a/langtools/test/tools/javac/varargs/6313164/T7175433.java +++ b/langtools/test/tools/javac/varargs/6313164/T7175433.java @@ -1,31 +1,8 @@ /* - * Copyright (c) 2012, 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 + * @test /nodynamiccopyright/ * @bug 7175433 6313164 * @summary Inference cleanup: add helper class to handle inference variables - * + * @compile/fail/ref=T7175433.out -XDrawDiagnostics T7175433.java */ import java.util.List; @@ -34,26 +11,16 @@ class Bar { private class Foo { } - List m(Object... o) { T7175433.assertTrue(true); return null; } - List m(Foo... o) { T7175433.assertTrue(false); return null; } + List m(Object... o) { return null; } + List m(Foo... o) { return null; } Foo getFoo() { return null; } } public class T7175433 { - static int assertionCount; - - static void assertTrue(boolean b) { - assertionCount++; - if (!b) { - throw new AssertionError(); - } - } - public static void main(String[] args) { Bar b = new Bar(); b.m(b.getFoo()); - assertTrue(assertionCount == 1); } } diff --git a/langtools/test/tools/javac/varargs/6313164/T7175433.out b/langtools/test/tools/javac/varargs/6313164/T7175433.out new file mode 100644 index 00000000000..598f3bb58df --- /dev/null +++ b/langtools/test/tools/javac/varargs/6313164/T7175433.out @@ -0,0 +1,2 @@ +T7175433.java:24:12: compiler.err.prob.found.req: (compiler.misc.inaccessible.varargs.type: Bar.Foo, kindname.class, T7175433) +1 error diff --git a/langtools/test/tools/javac/varargs/6313164/p1/B.java b/langtools/test/tools/javac/varargs/6313164/p1/B.java index 38ec371c5b2..ebe7ba99c20 100644 --- a/langtools/test/tools/javac/varargs/6313164/p1/B.java +++ b/langtools/test/tools/javac/varargs/6313164/p1/B.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +23,12 @@ package p1; +@SuppressWarnings("unchecked") public class B extends A { - public B() {} public void foo1(A... args) { } public void foo2(A... args) { } public void foo2(Object... args) { } public void foo3(X... args) { } public void foo4(X... args) { } public void foo4(Object... args) { } - } diff --git a/langtools/test/tools/sjavac/SJavac.java b/langtools/test/tools/sjavac/SJavac.java index 5fa47ee7d51..867643e7f98 100644 --- a/langtools/test/tools/sjavac/SJavac.java +++ b/langtools/test/tools/sjavac/SJavac.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,8 +34,12 @@ public class SJavac { public static void main(String... args) throws Exception { - SJavac s = new SJavac(); - s.test(); + try { + SJavac s = new SJavac(); + s.test(); + } finally { + System.out.println("\ntest complete\n"); + } } FileSystem defaultfs = FileSystems.getDefault(); @@ -412,7 +416,7 @@ class SJavac { } void incrementalCompileTestFullyQualifiedRef() throws Exception { - System.out.println("Verify that \"alfa.omega.A a;\" does create a proper dependency."); + System.out.println("\nVerify that \"alfa.omega.A a;\" does create a proper dependency."); System.out.println("----------------------------------------------------------------"); populate(gensrc, @@ -517,8 +521,7 @@ class SJavac { if (rc == 0) throw new Exception("Expected error during compile! Did not fail!"); } - Map collectState(Path dir) throws IOException - { + Map collectState(Path dir) throws IOException { final Map files = new HashMap<>(); Files.walkFileTree(dir, new SimpleFileVisitor() { @Override diff --git a/nashorn/.hgtags b/nashorn/.hgtags index a702f565523..1a1ec8355f0 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -252,3 +252,5 @@ be4580ae56e2ef0ce521d3f840753eaa83cacf33 jdk9-b13 fed8c83dfba4dce94d2ae1cb82f026634ff2a3e4 jdk9-b16 4a47b7cfecdf2a865811ab08a7ef49c942801d7c jdk9-b17 893c337bc95fef3885baa3e4ffc30d68f62a829f jdk9-b18 +46e36a92e37c06dea50f8c829549d9d0bfed4e3c jdk9-b19 +d703c59c556f9fcd9604272806ef7acf55c92363 jdk9-b20 diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java index 1132db98541..c8a929dc609 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MemberInfo.java @@ -412,6 +412,10 @@ public final class MemberInfo implements Cloneable { } } } + break; + + default: + break; } } @@ -450,7 +454,7 @@ public final class MemberInfo implements Cloneable { if (type.getSort() == Type.OBJECT) { try { - final Class clazz = Class.forName(type.getClassName(), false, myLoader); + final Class clazz = Class.forName(type.getClassName(), false, myLoader); return ScriptObject.class.isAssignableFrom(clazz); } catch (final ClassNotFoundException cnfe) { return false; diff --git a/nashorn/make/project.properties b/nashorn/make/project.properties index dd43dda4f2b..eb708a41320 100644 --- a/nashorn/make/project.properties +++ b/nashorn/make/project.properties @@ -283,7 +283,7 @@ run.test.jvmargs.common=\ -XX:+HeapDumpOnOutOfMemoryError # turn on assertions for tests -run.test.jvmargs.main=${run.test.jvmargs.common} -ea -Dnashorn.lazy +run.test.jvmargs.main=${run.test.jvmargs.common} -ea # extra jvmargs that might be useful for debugging # @@ -305,7 +305,7 @@ run.test.jvmargs.main=${run.test.jvmargs.common} -ea -Dnashorn.lazy # -XX:+PrintNMethods # Use best known performance options for octane -run.test.jvmargs.octane.main=${run.test.jvmargs.common} -Dnashorn.lazy -XX:+UnlockDiagnosticVMOptions -XX:+UseNewCode -XX:TypeProfileLevel=222 +run.test.jvmargs.octane.main=${run.test.jvmargs.common} -XX:+UnlockDiagnosticVMOptions -XX:+UseNewCode -XX:TypeProfileLevel=222 # Security manager args - make sure that we run with the nashorn.policy that the build creates run.test.jvmsecurityargs=-Xverify:all -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy diff --git a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java index 9214e7fad74..5c7757a1fa7 100644 --- a/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java +++ b/nashorn/src/jdk/nashorn/internal/codegen/Compiler.java @@ -47,7 +47,9 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Consumer; import java.util.logging.Level; + import jdk.internal.dynalink.support.NameCodec; import jdk.nashorn.internal.codegen.ClassEmitter.Flag; import jdk.nashorn.internal.codegen.types.Type; @@ -421,7 +423,14 @@ public final class Compiler implements Loggable { @Override public DebugLogger initLogger(final Context ctxt) { - return ctxt.getLogger(this.getClass()); + return ctxt.getLogger(this.getClass(), new Consumer() { + @Override + public void accept(final DebugLogger newLogger) { + if (!Compiler.this.getScriptEnvironment()._lazy_compilation) { + newLogger.warning("WARNING: Running with lazy compilation switched off. This is not a default setting."); + } + } + }); } ScriptEnvironment getScriptEnvironment() { diff --git a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java index face386c48f..8411e263bfa 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/BinaryNode.java @@ -45,7 +45,7 @@ import jdk.nashorn.internal.parser.TokenType; public final class BinaryNode extends Expression implements Assignment, Optimistic { // Placeholder for "undecided optimistic ADD type". Unfortunately, we can't decide the type of ADD during optimistic // type calculation as it can have local variables as its operands that will decide its ultimate type. - private static final Type OPTIMISTIC_UNDECIDED_TYPE = Type.typeFor(new Object(){}.getClass()); + private static final Type OPTIMISTIC_UNDECIDED_TYPE = Type.typeFor(new Object(){/*empty*/}.getClass()); /** Left hand side argument. */ private final Expression lhs; diff --git a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java index c9c6688c26a..282c19ed0c7 100644 --- a/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java +++ b/nashorn/src/jdk/nashorn/internal/ir/FunctionNode.java @@ -99,7 +99,7 @@ public final class FunctionNode extends LexicalContextExpression implements Flag BYTECODE_GENERATED, /** method has been installed */ BYTECODE_INSTALLED - }; + } /** Source of entity. */ private final Source source; @@ -388,10 +388,11 @@ public final class FunctionNode extends LexicalContextExpression implements Flag } /** - * static source name getter + * Static source name getter + * * @param source * @param sourceURL - * @return + * @return source name */ public static String getSourceName(final Source source, final String sourceURL) { return sourceURL != null ? sourceURL : source.getName(); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java index 0d1d6861ccf..30ffbabff9e 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java @@ -75,7 +75,10 @@ import jdk.nashorn.internal.runtime.linker.NashornBeansLinker; */ @ScriptClass("Object") public final class NativeObject { + /** Methodhandle to proto getter */ public static final MethodHandle GET__PROTO__ = findOwnMH("get__proto__", ScriptObject.class, Object.class); + + /** Methodhandle to proto setter */ public static final MethodHandle SET__PROTO__ = findOwnMH("set__proto__", Object.class, Object.class, Object.class); private static final Object TO_STRING = new Object(); diff --git a/nashorn/src/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk/nashorn/internal/parser/Parser.java index b4541de5a1a..20efafbe163 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/Parser.java +++ b/nashorn/src/jdk/nashorn/internal/parser/Parser.java @@ -680,7 +680,7 @@ loop: */ private FunctionNode program(final String scriptName, final boolean allowPropertyFunction) { // Make a pseudo-token for the script holding its start and length. - final long functionToken = Token.toDesc(FUNCTION, getProgramStartPosition(token), source.getLength()); + final long functionToken = Token.toDesc(FUNCTION, Token.descPosition(Token.withDelimiter(token)), source.getLength()); final int functionLine = line; // Set up the script to append elements. @@ -710,20 +710,6 @@ loop: return script; } - /** - * Returns the start position of the program based on its first token. Normally returns the position of the token - * itself, except in case of string tokens which report their position past their opening delimiter and thus need - * to have one subtracted from their position. - * @param firstToken the first token of the program - * @return the start position of the program - */ - private static int getProgramStartPosition(final long firstToken) { - final int start = Token.descPosition(firstToken); - switch(Token.descType(firstToken)) { - case STRING: case ESCSTRING: case EXECSTRING: return start - 1; - default: return start; - } - } /** * Directive value or null if statement is not a directive. * diff --git a/nashorn/src/jdk/nashorn/internal/parser/Token.java b/nashorn/src/jdk/nashorn/internal/parser/Token.java index 0012daa6b7e..43df83b0ebe 100644 --- a/nashorn/src/jdk/nashorn/internal/parser/Token.java +++ b/nashorn/src/jdk/nashorn/internal/parser/Token.java @@ -60,6 +60,28 @@ public class Token { return (int)(token >>> 32); } + /** + * Normally returns the token itself, except in case of string tokens + * which report their position past their opening delimiter and thus + * need to have position and length adjusted. + * + * @param token Token descriptor. + * @return same or adjusted token. + */ + public static long withDelimiter(final long token) { + final TokenType tokenType = Token.descType(token); + switch(tokenType) { + case STRING: case ESCSTRING: case EXECSTRING: { + final int start = Token.descPosition(token) - 1; + final int len = Token.descLength(token) + 2; + return toDesc(tokenType, start, len); + } + default: { + return token; + } + } + } + /** * Extract token length from a token descriptor. * @param token Token descriptor. diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index 369c4e6ebf2..d521598986a 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -1236,6 +1236,16 @@ public final class Context { * @return debuglogger associated with that class */ public DebugLogger getLogger(final Class clazz) { + return getLogger(clazz, null); + } + + /** + * Get a logger, given a loggable class + * @param clazz a Loggable class + * @param initHook an init hook - if this is the first time the logger is created in the context, run the init hook + * @return debuglogger associated with that class + */ + public DebugLogger getLogger(final Class clazz, final Consumer initHook) { final String name = getLoggerName(clazz); DebugLogger logger = loggers.get(name); if (logger == null) { @@ -1244,6 +1254,9 @@ public final class Context { } final LoggerInfo info = env._loggers.get(name); logger = new DebugLogger(name, info.getLevel(), info.isQuiet()); + if (initHook != null) { + initHook.accept(logger); + } loggers.put(name, logger); } return logger; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java index b4c0e01d80d..a9c915527b2 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java @@ -34,6 +34,8 @@ import java.lang.invoke.MethodType; */ final class FinalScriptFunctionData extends ScriptFunctionData { + private static final long serialVersionUID = -930632846167768864L; + /** * Constructor - used for bind * diff --git a/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java b/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java index de9f87c88d1..9641f522272 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/PropertyMap.java @@ -185,6 +185,7 @@ public final class PropertyMap implements Iterable, Serializable { * properties with keys that are valid array indices.

    * * @param properties Collection of initial properties. + * @param className class name * @param fieldCount Number of fields in use. * @param fieldMaximum Number of fields available. * @param spillLength Number of used spill slots. diff --git a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java index c210a69078d..78ee06e58ce 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java @@ -54,7 +54,6 @@ import jdk.nashorn.internal.parser.TokenType; import jdk.nashorn.internal.runtime.logging.DebugLogger; import jdk.nashorn.internal.runtime.logging.Loggable; import jdk.nashorn.internal.runtime.logging.Logger; -import jdk.nashorn.internal.runtime.options.Options; import jdk.nashorn.internal.scripts.JS; /** @@ -65,9 +64,6 @@ import jdk.nashorn.internal.scripts.JS; */ @Logger(name="recompile") public final class RecompilableScriptFunctionData extends ScriptFunctionData implements Loggable { - /** Is lazy compilation enabled? TODO: this should be the default */ - public static final boolean LAZY_COMPILATION = Options.getBooleanProperty("nashorn.lazy"); - /** Prefix used for all recompiled script classes */ public static final String RECOMPILATION_PREFIX = "Recompilation$"; @@ -240,6 +236,12 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp return "function " + (name == null ? "" : name) + "() { [native code] }"; } + /** + * Setter for code and source + * + * @param code map of code, class name to class + * @param source source + */ public void setCodeAndSource(final Map> code, final Source source) { this.source = source; if (methodLocator != null) { @@ -292,7 +294,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp private static long tokenFor(final FunctionNode fn) { final int position = Token.descPosition(fn.getFirstToken()); - final long lastToken = fn.getLastToken(); + final long lastToken = Token.withDelimiter(fn.getLastToken()); // EOL uses length field to store the line number final int length = Token.descPosition(lastToken) - position + (Token.descType(lastToken) == TokenType.EOL ? 0 : Token.descLength(lastToken)); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java index 1c71da43837..1e095d45905 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptObject.java @@ -2267,7 +2267,7 @@ public abstract class ScriptObject implements PropertyAccess { if (mh != null) { assert func != null; - if (scopeAccess && func != null && func.isStrict()) { + if (scopeAccess && func.isStrict()) { mh = bindTo(mh, UNDEFINED); } return new GuardedInvocation( diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Source.java b/nashorn/src/jdk/nashorn/internal/runtime/Source.java index deec95ce0e5..b9f6fd0dba4 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Source.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Source.java @@ -99,12 +99,13 @@ public final class Source implements Loggable { // Force any access errors data.checkPermissionAndClose(); return existingSource; - } else { - // All sources in cache must be fully loaded - data.load(); - CACHE.put(newSource, newSource); - return newSource; } + + // All sources in cache must be fully loaded + data.load(); + CACHE.put(newSource, newSource); + + return newSource; } catch (final RuntimeException e) { final Throwable cause = e.getCause(); if (cause instanceof IOException) { @@ -291,7 +292,9 @@ public final class Source implements Loggable { } protected void checkPermissionAndClose() throws IOException { - try (InputStream in = url.openStream()) {} + try (InputStream in = url.openStream()) { + // empty + } debug("permission checked for ", url); } @@ -366,20 +369,24 @@ public final class Source implements Loggable { } /** - * Returns an instance + * Returns a Source instance * * @param name source name * @param content contents as char array + * + * @return source instance */ public static Source sourceFor(final String name, final char[] content) { return new Source(name, baseName(name), new RawData(content)); } /** - * Returns an instance + * Returns a Source instance * * @param name source name * @param content contents as string + * + * @return source instance */ public static Source sourceFor(final String name, final String content) { return new Source(name, baseName(name), new RawData(content)); @@ -391,6 +398,8 @@ public final class Source implements Loggable { * @param name source name * @param url url from which source can be loaded * + * @return source instance + * * @throws IOException if source cannot be loaded */ public static Source sourceFor(final String name, final URL url) throws IOException { @@ -404,6 +413,8 @@ public final class Source implements Loggable { * @param url url from which source can be loaded * @param cs Charset used to convert bytes to chars * + * @return source instance + * * @throws IOException if source cannot be loaded */ public static Source sourceFor(final String name, final URL url, final Charset cs) throws IOException { @@ -416,6 +427,8 @@ public final class Source implements Loggable { * @param name source name * @param file file from which source can be loaded * + * @return source instance + * * @throws IOException if source cannot be loaded */ public static Source sourceFor(final String name, final File file) throws IOException { @@ -429,6 +442,8 @@ public final class Source implements Loggable { * @param file file from which source can be loaded * @param cs Charset used to convert bytes to chars * + * @return source instance + * * @throws IOException if source cannot be loaded */ public static Source sourceFor(final String name, final File file, final Charset cs) throws IOException { @@ -441,6 +456,9 @@ public final class Source implements Loggable { * * @param name source name * @param reader reader from which source can be loaded + * + * @return source instance + * * @throws IOException if source cannot be loaded */ public static Source sourceFor(final String name, final Reader reader) throws IOException { @@ -542,9 +560,9 @@ public final class Source implements Loggable { * @return Index of first character of line. */ private int findBOLN(final int position) { - final char[] data = data(); + final char[] d = data(); for (int i = position - 1; i > 0; i--) { - final char ch = data[i]; + final char ch = d[i]; if (ch == '\n' || ch == '\r') { return i + 1; @@ -560,10 +578,10 @@ public final class Source implements Loggable { * @return Index of last character of line. */ private int findEOLN(final int position) { - final char[] data = data(); - final int length = data.length; + final char[] d = data(); + final int length = d.length; for (int i = position; i < length; i++) { - final char ch = data[i]; + final char ch = d[i]; if (ch == '\n' || ch == '\r') { return i - 1; @@ -583,12 +601,12 @@ public final class Source implements Loggable { * @return Line number. */ public int getLine(final int position) { - final char[] data = data(); + final char[] d = data(); // Line count starts at 1. int line = 1; for (int i = 0; i < position; i++) { - final char ch = data[i]; + final char ch = d[i]; // Works for both \n and \r\n. if (ch == '\n') { line++; diff --git a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java index c09291ac0a6..be41673b2af 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java @@ -141,21 +141,6 @@ abstract class ArrayFilter extends ArrayData { return this; } - private static void printTrace(final Throwable t, final String msg) { - final java.io.StringWriter sw = new java.io.StringWriter(); - final java.io.PrintWriter pw = new java.io.PrintWriter(sw, false); - pw.println(msg); - final StackTraceElement[] trace = t.getStackTrace(); - for(final StackTraceElement e: trace) { - pw.println(" at " + e); - if(e.getClassName().startsWith("jdk.nashorn.")) { - break; - } - } - pw.flush(); - System.out.println(sw.toString()); - } - @Override public Type getOptimisticType() { return underlying.getOptimisticType(); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/logging/DebugLogger.java b/nashorn/src/jdk/nashorn/internal/runtime/logging/DebugLogger.java index b52a0b02d4f..084f7658d28 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/logging/DebugLogger.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/logging/DebugLogger.java @@ -540,7 +540,7 @@ public final class DebugLogger { /** * Shorthand for outputting a log string as log level - * {@link java.util.logging.Level#FINE} on this logger + * {@link java.util.logging.Level#SEVERE} on this logger * @param objs object array to log - use this to perform lazy concatenation to avoid unconditional toString overhead */ public void severe(final Object... objs) { diff --git a/nashorn/test/script/basic/JDK-8047035.js b/nashorn/test/script/basic/JDK-8047035.js new file mode 100644 index 00000000000..dc44921ff72 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047035.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8047035: (function() "hello")() crashes in Lexer with jdk9 + * + * @test + * @run + */ + +// should not print ")" at the end +print(function() "hello"); +print(function() ''); + +// The following should not crash inside lexer +print((function() '')()); +print((function() "hello")()); diff --git a/nashorn/test/script/basic/JDK-8047035.js.EXPECTED b/nashorn/test/script/basic/JDK-8047035.js.EXPECTED new file mode 100644 index 00000000000..0c4ab07b787 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047035.js.EXPECTED @@ -0,0 +1,4 @@ +function() "hello" +function() '' + +hello diff --git a/nashorn/test/script/basic/JDK-8047057.js b/nashorn/test/script/basic/JDK-8047057.js new file mode 100644 index 00000000000..cf1263a1243 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8047057.js @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8047057: Add a regression test for the passing test cases from JDK-8042304 + * + * @test + * @run + */ + +// commented out makeFuncAndCall calls are still result in crash +// Tests commented with //** fail only within test framework. +// Pass fine with standalone "jjs" mode. + +function makeFuncAndCall(code) { + Function(code)(); +} + +function makeFuncExpectError(code, ErrorType) { + try { + makeFuncAndCall(code); + } catch (e) { + if (! (e instanceof ErrorType)) { + fail(ErrorType.name + " expected, got " + e); + } + } +} + +// makeFuncAndCall("switch(0) { default: {break;} return }"); +// makeFuncAndCall("L: { { break L; } return; }"); +makeFuncAndCall("L: { while(0) break L; return; }"); +makeFuncExpectError("L: {while(0) break L; return [](); }", TypeError); +// makeFuncAndCall("do with({}) break ; while(0);"); +makeFuncAndCall("while(0) with({}) continue ;"); +//** makeFuncAndCall("eval([]);"); +//** makeFuncAndCall("try{} finally{[]}"); +makeFuncAndCall("try { } catch(x if 1) { try { } catch(x2) { } }"); +makeFuncAndCall("try { } catch(x if 1) { try { return; } catch(x2) { { } } }"); +makeFuncAndCall("Error() * (false)[-0]--"); +makeFuncAndCall("try { var x = 1, x = null; } finally { }"); +makeFuncAndCall("try { var x = {}, x = []; } catch(x3) { }"); +//** makeFuncAndCall("[delete this]"); +// makeFuncAndCall("if(eval('', eval('', function() {}))) { }"); +// makeFuncAndCall("if(eval('', eval('', function() {}))) { }"); +// makeFuncAndCall("eval(\"[,,];\", [11,12,13,14].some)"); +// makeFuncAndCall("eval(\"1.2e3\", ({})[ /x/ ])"); +// makeFuncAndCall("eval(\"x4\", x3);"); +makeFuncAndCall("with({5.0000000000000000000000: String()}){(false); }"); +makeFuncAndCall("try { var x = undefined, x = 5.0000000000000000000000; } catch(x) { x = undefined; }"); +makeFuncAndCall("(function (x){ x %= this}(false))"); +// makeFuncAndCall("eval.apply.apply(function(){ eval('') })"); +makeFuncAndCall("(false % !this) && 0"); +makeFuncAndCall("with({8: 'fafafa'.replace()}){ }"); +makeFuncAndCall("(function (x) '' )(true)"); +makeFuncExpectError("new eval(function(){})", TypeError); diff --git a/nashorn/test/src/UnnamedPackageTestCallback.java b/nashorn/test/src/UnnamedPackageTestCallback.java index 67ab36fc45f..3b6cdf5a2bc 100644 --- a/nashorn/test/src/UnnamedPackageTestCallback.java +++ b/nashorn/test/src/UnnamedPackageTestCallback.java @@ -23,6 +23,14 @@ * questions. */ +/** + * Interface for callbacks used by the test suite. + */ public interface UnnamedPackageTestCallback { + /** + * Call function + * @param s string argument + * @return string + */ String call(String s); }