# HG changeset patch # User ngthomas # Date 1398807607 25200 # Node ID 2061862eb57c0937b9d20b76e374e5d1f5ca94cf # Parent 1d117d2dfe9283a92162d225daf4b5c720ac8d6a# Parent 0809c9a4d36e6291f1c4384604c4bbf29e975722 Merge diff -r 1d117d2dfe92 -r 2061862eb57c .hgtags --- a/.hgtags Tue Apr 29 15:44:14 2014 -0400 +++ b/.hgtags Tue Apr 29 14:40:07 2014 -0700 @@ -250,3 +250,6 @@ dd311791ad6895a3989020dd6c6c46db87972ab8 jdk9-b05 85dbdc227c5e11429b4fc4a8ba763f50107edd6e jdk9-b06 c826d05f1fb0773f6a28caa763307dd30d90d36e jdk9-b07 +b47e021195757f8f45582124ea7cad48ccf5f872 jdk9-b08 +efe7dbc6088691757404e0c8745f894e3ca9c022 jdk9-b09 +8c0bdeecd7c0f9ce3f3762a51991f755cb3a972c jdk9-b10 diff -r 1d117d2dfe92 -r 2061862eb57c .hgtags-top-repo --- a/.hgtags-top-repo Tue Apr 29 15:44:14 2014 -0400 +++ b/.hgtags-top-repo Tue Apr 29 14:40:07 2014 -0700 @@ -250,3 +250,6 @@ 8c63f0b6ada282f27e3a80125e53c3be603f9af7 jdk9-b05 d0b525cd31b87abeb6d5b7e3516953eeb13b323c jdk9-b06 0ea015c298b201c07fa33990f2445b6d0ef3566d jdk9-b07 +db045d8faa0924b7378102d24a1a0d850c1e3834 jdk9-b08 +4a21dc7d57d1069a01f68e7182c074cb37349dfb jdk9-b09 +fa13f2b926f8426876ec03e7903f3ee0ee150f2e jdk9-b10 diff -r 1d117d2dfe92 -r 2061862eb57c README-builds.html --- a/README-builds.html Tue Apr 29 15:44:14 2014 -0400 +++ b/README-builds.html Tue Apr 29 14:40:07 2014 -0700 @@ -145,7 +145,7 @@ root repository:
- hg clone http://hg.openjdk.java.net/jdk8/jdk8
+ hg clone http://hg.openjdk.java.net/jdk9/jdk9
YourOpenJDK
cd YourOpenJDK
@@ -373,18 +373,17 @@
particular update level.
- Building JDK 8 requires use of a version
- of JDK 7 that is at Update 7 or newer. JDK 8
- developers should not use JDK 8 as the boot
- JDK, to ensure that JDK 8 dependencies are
+ Building JDK 9 requires JDK 8. JDK 9
+ developers should not use JDK 9 as the boot
+ JDK, to ensure that JDK 9 dependencies are
not introduced into the parts of the system
- that are built with JDK 7.
+ that are built with JDK 8.
- The JDK 7 binaries can be downloaded from Oracle's
+ The JDK 8 binaries can be downloaded from Oracle's
JDK 7 download site.
- For build performance reasons
+ target="_blank">JDK 8 download site.
+ For build performance reasons it
is very important that this bootstrap JDK be made available
on the local disk of the machine doing the build.
You should add its bin
directory
@@ -1454,9 +1453,7 @@
One of the top goals of the new build system is to improve the
build performance and decrease the time needed to build. This will
soon also apply to the java compilation when the Smart Javac wrapper
- is making its way into jdk8. It can be tried in the build-infra
- repository already. You are likely to find that the new build system
- is faster than the old one even without this feature.
+ is fully supported.
At the end of a successful execution of configure
,
you will get a performance summary,
diff -r 1d117d2dfe92 -r 2061862eb57c common/autoconf/boot-jdk.m4
--- a/common/autoconf/boot-jdk.m4 Tue Apr 29 15:44:14 2014 -0400
+++ b/common/autoconf/boot-jdk.m4 Tue Apr 29 14:40:07 2014 -0700
@@ -82,10 +82,10 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- [FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`]
+ [FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`]
if test "x$FOUND_CORRECT_VERSION" = x; then
AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring])
- AC_MSG_NOTICE([(Your Boot JDK must be version 7, 8 or 9)])
+ AC_MSG_NOTICE([(Your Boot JDK must be version 8 or 9)])
BOOT_JDK_FOUND=no
else
# We're done! :-)
diff -r 1d117d2dfe92 -r 2061862eb57c common/autoconf/build-performance.m4
--- a/common/autoconf/build-performance.m4 Tue Apr 29 15:44:14 2014 -0400
+++ b/common/autoconf/build-performance.m4 Tue Apr 29 14:40:07 2014 -0700
@@ -89,7 +89,7 @@
if test "x$FOUND_MEM" = xyes; then
AC_MSG_RESULT([$MEMORY_SIZE MB])
else
- AC_MSG_RESULT([could not detect memory size, defaulting to 1024 MB])
+ AC_MSG_RESULT([could not detect memory size, defaulting to $MEMORY_SIZE MB])
AC_MSG_WARN([This might seriously impact build performance!])
fi
])
diff -r 1d117d2dfe92 -r 2061862eb57c common/autoconf/flags.m4
--- a/common/autoconf/flags.m4 Tue Apr 29 15:44:14 2014 -0400
+++ b/common/autoconf/flags.m4 Tue Apr 29 14:40:07 2014 -0700
@@ -473,7 +473,8 @@
CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
;;
ppc )
- # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
+ # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
+ CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
;;
* )
CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
diff -r 1d117d2dfe92 -r 2061862eb57c common/autoconf/generated-configure.sh
--- a/common/autoconf/generated-configure.sh Tue Apr 29 15:44:14 2014 -0400
+++ b/common/autoconf/generated-configure.sh Tue Apr 29 14:40:07 2014 -0700
@@ -19906,12 +19906,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -20238,12 +20238,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -20432,12 +20432,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -20619,12 +20619,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -20805,12 +20805,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -20991,12 +20991,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -21168,12 +21168,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -21486,12 +21486,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -21814,12 +21814,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -22029,12 +22029,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -22209,12 +22209,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -22417,12 +22417,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -22597,12 +22597,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -22805,12 +22805,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -22985,12 +22985,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -23193,12 +23193,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -23373,12 +23373,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -23568,12 +23568,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -23746,12 +23746,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -23942,12 +23942,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -24120,12 +24120,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -24315,12 +24315,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -24493,12 +24493,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -24689,12 +24689,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -24867,12 +24867,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -25044,12 +25044,12 @@
BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1`
# Extra M4 quote needed to protect [] in grep expression.
- FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`
+ FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[89]\.'`
if test "x$FOUND_CORRECT_VERSION" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5
$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5
-$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 8 or 9)" >&5
+$as_echo "$as_me: (Your Boot JDK must be version 8 or 9)" >&6;}
BOOT_JDK_FOUND=no
else
# We're done! :-)
@@ -41672,7 +41672,8 @@
CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
;;
ppc )
- # on ppc we don't prevent gcc to omit frame pointer nor strict-aliasing
+ # on ppc we don't prevent gcc to omit frame pointer but do prevent strict aliasing
+ CFLAGS_JDK="${CFLAGS_JDK} -fno-strict-aliasing"
;;
* )
CCXXFLAGS_JDK="$CCXXFLAGS_JDK -fno-omit-frame-pointer"
@@ -48685,8 +48686,8 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MEMORY_SIZE MB" >&5
$as_echo "$MEMORY_SIZE MB" >&6; }
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not detect memory size, defaulting to 1024 MB" >&5
-$as_echo "could not detect memory size, defaulting to 1024 MB" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: could not detect memory size, defaulting to $MEMORY_SIZE MB" >&5
+$as_echo "could not detect memory size, defaulting to $MEMORY_SIZE MB" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: This might seriously impact build performance!" >&5
$as_echo "$as_me: WARNING: This might seriously impact build performance!" >&2;}
fi
diff -r 1d117d2dfe92 -r 2061862eb57c common/autoconf/spec.gmk.in
--- a/common/autoconf/spec.gmk.in Tue Apr 29 15:44:14 2014 -0400
+++ b/common/autoconf/spec.gmk.in Tue Apr 29 14:40:07 2014 -0700
@@ -261,6 +261,7 @@
# Information about the build system
NUM_CORES:=@NUM_CORES@
+MEMORY_SIZE:=@MEMORY_SIZE@
# Enable sjavac support = use a javac server,
# multi core javac compilation and dependency tracking.
ENABLE_SJAVAC:=@ENABLE_SJAVAC@
diff -r 1d117d2dfe92 -r 2061862eb57c common/bin/hgforest.sh
--- a/common/bin/hgforest.sh Tue Apr 29 15:44:14 2014 -0400
+++ b/common/bin/hgforest.sh Tue Apr 29 14:40:07 2014 -0700
@@ -72,12 +72,21 @@
exit 1
}
-
if [ "x" = "x$command" ] ; then
echo "ERROR: No command to hg supplied!"
usage
fi
+# Check if we can use fifos for monitoring sub-process completion.
+on_windows=`uname -s | egrep -ic -e 'cygwin|msys'`
+if [ ${on_windows} = "1" ]; then
+ # cygwin has (2014-04-18) broken (single writer only) FIFOs
+ # msys has (2014-04-18) no FIFOs.
+ have_fifos="false"
+else
+ have_fifos="true"
+fi
+
# Clean out the temporary directory that stores the pid files.
tmp=/tmp/forest.$$
rm -f -r ${tmp}
@@ -210,7 +219,19 @@
) &
else
# Run the supplied command on all repos in parallel.
+
+ # n is the number of subprocess started or which might still be running.
n=0
+ if [ $have_fifos = "true" ]; then
+ # if we have fifos use them to detect command completion.
+ mkfifo ${tmp}/fifo
+ exec 3<>${tmp}/fifo
+ if [ "${sflag}" = "true" ] ; then
+ # force sequential
+ at_a_time=1
+ fi
+ fi
+
for i in ${repos} ${repos_extra} ; do
n=`expr ${n} '+' 1`
repopidfile=`echo ${i} | sed -e 's@./@@' -e 's@/@_@g'`
@@ -221,10 +242,11 @@
pull_base="${pull_extra}"
fi
done
+ pull_base="`echo ${pull_base} | sed -e 's@[/]*$@@'`"
(
(
if [ "${command}" = "clone" -o "${command}" = "fclone" -o "${command}" = "tclone" ] ; then
- pull_newrepo="`echo ${pull_base}/${i} | sed -e 's@\([^:]/\)//*@\1@g'`"
+ pull_newrepo="${pull_base}/${i}"
path="`dirname ${i}`"
if [ "${path}" != "." ] ; then
times=0
@@ -237,7 +259,7 @@
sleep 5
done
fi
- echo "hg clone ${pull_newrepo} ${i}" > ${status_output}
+ echo "hg${global_opts} clone ${pull_newrepo} ${i}" > ${status_output}
(PYTHONUNBUFFERED=true hg${global_opts} clone ${pull_newrepo} ${i}; echo "$?" > ${tmp}/${repopidfile}.pid.rc ) 2>&1 &
else
echo "cd ${i} && hg${global_opts} ${command} ${command_args}" > ${status_output}
@@ -246,21 +268,41 @@
echo $! > ${tmp}/${repopidfile}.pid
) 2>&1 | sed -e "s@^@${reponame}: @" > ${status_output}
+ if [ $have_fifos = "true" ]; then
+ echo "${reponame}" >&3
+ fi
) &
- if [ `expr ${n} '%' ${at_a_time}` -eq 0 -a "${sflag}" = "false" ] ; then
- sleep 2
- echo "Waiting 5 secs before spawning next background command." > ${status_output}
- sleep 3
- fi
-
- if [ "${sflag}" = "true" ] ; then
+ if [ $have_fifos = "true" ]; then
+ # check on count of running subprocesses and possibly wait for completion
+ if [ ${at_a_time} -lt ${n} ] ; then
+ # read will block until there are completed subprocesses
+ while read repo_done; do
+ n=`expr ${n} '-' 1`
+ if [ ${n} -lt ${at_a_time} ] ; then
+ # we should start more subprocesses
+ break;
+ fi
+ done <&3
+ fi
+ else
+ if [ "${sflag}" = "false" ] ; then
+ # Compare completions to starts
+ completed="`(ls -1 ${tmp}/*.pid.rc 2> /dev/null | wc -l) || echo 0`"
+ while [ ${at_a_time} -lt `expr ${n} '-' ${completed}` ] ; do
+ # sleep a short time to give time for something to complete
+ sleep 1
+ completed="`(ls -1 ${tmp}/*.pid.rc 2> /dev/null | wc -l) || echo 0`"
+ done
+ else
+ # complete this task before starting another.
wait
+ fi
fi
done
fi
-# Wait for all hg commands to complete
+# Wait for all subprocesses to complete
wait
# Terminate with exit 0 only if all subprocesses were successful
@@ -270,7 +312,7 @@
exit_code=`cat ${rc} | tr -d ' \n\r'`
if [ "${exit_code}" != "0" ] ; then
repo="`echo ${rc} | sed -e s@^${tmp}@@ -e 's@/*\([^/]*\)\.pid\.rc$@\1@' -e 's@_@/@g'`"
- echo "WARNING: ${repo} exited abnormally." > ${status_output}
+ echo "WARNING: ${repo} exited abnormally ($exit_code)" > ${status_output}
ec=1
fi
done
diff -r 1d117d2dfe92 -r 2061862eb57c corba/.hgtags
--- a/corba/.hgtags Tue Apr 29 15:44:14 2014 -0400
+++ b/corba/.hgtags Tue Apr 29 14:40:07 2014 -0700
@@ -250,3 +250,6 @@
167c39eb44731a5d66770d0f00e231164653a2ff jdk9-b05
a4bf701ac316946c2e5e83138ad8e687da6a4b30 jdk9-b06
6c8563600a71394c949405189ddd66267a88d8cd jdk9-b07
+2da7fead826bc27f193c7d63048c2cf100a8809c jdk9-b08
+1a3a4f48515dbf1cff37279691b2fb74f228298d jdk9-b09
+3bd4039dfc632fd7fc8418a25a3dcc34d1cd4019 jdk9-b10
diff -r 1d117d2dfe92 -r 2061862eb57c corba/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java
--- a/corba/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java Tue Apr 29 15:44:14 2014 -0400
+++ b/corba/src/share/classes/com/sun/corba/se/impl/io/ObjectStreamClass.java Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2012, 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
@@ -52,6 +52,7 @@
import java.io.DataOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.InvalidClassException;
+import java.io.Externalizable;
import java.io.Serializable;
import java.util.Arrays;
@@ -80,15 +81,15 @@
public static final long kDefaultUID = -1;
private static Object noArgsList[] = {};
- private static Class noTypesList[] = {};
+ private static Class> noTypesList[] = {};
/** true if represents enum type */
private boolean isEnum;
private static final Bridge bridge =
- (Bridge)AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
+ AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Bridge run() {
return Bridge.get() ;
}
}
@@ -98,7 +99,7 @@
* is returned if the specified class does not implement
* java.io.Serializable or java.io.Externalizable.
*/
- static final ObjectStreamClass lookup(Class cl)
+ static final ObjectStreamClass lookup(Class> cl)
{
ObjectStreamClass desc = lookupInternal(cl);
if (desc.isSerializable() || desc.isExternalizable())
@@ -110,7 +111,7 @@
* Find the class descriptor for the specified class.
* Package access only so it can be called from ObjectIn/OutStream.
*/
- static ObjectStreamClass lookupInternal(Class cl)
+ static ObjectStreamClass lookupInternal(Class> cl)
{
/* Synchronize on the hashtable so no two threads will do
* this at the same time.
@@ -121,14 +122,14 @@
desc = findDescriptorFor(cl);
if (desc == null) {
/* Check if it's serializable */
- boolean serializable = classSerializable.isAssignableFrom(cl);
+ boolean serializable = Serializable.class.isAssignableFrom(cl);
/* If the class is only Serializable,
* lookup the descriptor for the superclass.
*/
ObjectStreamClass superdesc = null;
if (serializable) {
- Class superclass = cl.getSuperclass();
+ Class> superclass = cl.getSuperclass();
if (superclass != null)
superdesc = lookup(superclass);
}
@@ -141,7 +142,7 @@
if (serializable) {
externalizable =
((superdesc != null) && superdesc.isExternalizable()) ||
- classExternalizable.isAssignableFrom(cl);
+ Externalizable.class.isAssignableFrom(cl);
if (externalizable) {
serializable = false;
}
@@ -185,7 +186,7 @@
* that have evolved from a common root class and agree to be serialized
* and deserialized using a common format.
*/
- public static final long getSerialVersionUID( java.lang.Class clazz) {
+ public static final long getSerialVersionUID( java.lang.Class> clazz) {
ObjectStreamClass theosc = ObjectStreamClass.lookup( clazz );
if( theosc != null )
{
@@ -219,7 +220,7 @@
/**
* Return the actual (computed) serialVersionUID for this class.
*/
- public static final long getActualSerialVersionUID( java.lang.Class clazz )
+ public static final long getActualSerialVersionUID( java.lang.Class> clazz )
{
ObjectStreamClass theosc = ObjectStreamClass.lookup( clazz );
if( theosc != null )
@@ -249,7 +250,7 @@
* Return the class in the local VM that this version is mapped to.
* Null is returned if there is no corresponding local class.
*/
- public final Class forClass() {
+ public final Class> forClass() {
return ofClass;
}
@@ -349,7 +350,7 @@
* Create a new ObjectStreamClass from a loaded class.
* Don't call this directly, call lookup instead.
*/
- private ObjectStreamClass(java.lang.Class cl, ObjectStreamClass superdesc,
+ private ObjectStreamClass(java.lang.Class> cl, ObjectStreamClass superdesc,
boolean serial, boolean extern)
{
ofClass = cl; /* created from this class */
@@ -433,7 +434,7 @@
if (initialized)
return;
- final Class cl = ofClass;
+ final Class> cl = ofClass;
if (!serializable ||
externalizable ||
@@ -561,9 +562,9 @@
* will call it as necessary.
*/
writeObjectMethod = getPrivateMethod( cl, "writeObject",
- new Class[] { java.io.ObjectOutputStream.class }, Void.TYPE ) ;
+ new Class>[] { java.io.ObjectOutputStream.class }, Void.TYPE ) ;
readObjectMethod = getPrivateMethod( cl, "readObject",
- new Class[] { java.io.ObjectInputStream.class }, Void.TYPE ) ;
+ new Class>[] { java.io.ObjectInputStream.class }, Void.TYPE ) ;
}
return null;
}
@@ -589,9 +590,9 @@
* class, or null if none found. Access checks are disabled on the
* returned method (if any).
*/
- private static Method getPrivateMethod(Class cl, String name,
- Class[] argTypes,
- Class returnType)
+ private static Method getPrivateMethod(Class> cl, String name,
+ Class>[] argTypes,
+ Class> returnType)
{
try {
Method meth = cl.getDeclaredMethod(name, argTypes);
@@ -653,7 +654,7 @@
* Fill in the reflected Fields that will be used
* for reading.
*/
- final void setClass(Class cl) throws InvalidClassException {
+ final void setClass(Class> cl) throws InvalidClassException {
if (cl == null) {
localClassDesc = null;
@@ -920,9 +921,9 @@
* Access checks are disabled on the returned constructor (if any), since
* the defining class may still be non-public.
*/
- private static Constructor getExternalizableConstructor(Class cl) {
+ private static Constructor getExternalizableConstructor(Class> cl) {
try {
- Constructor cons = cl.getDeclaredConstructor(new Class[0]);
+ Constructor cons = cl.getDeclaredConstructor(new Class>[0]);
cons.setAccessible(true);
return ((cons.getModifiers() & Modifier.PUBLIC) != 0) ?
cons : null;
@@ -936,15 +937,15 @@
* superclass, or null if none found. Access checks are disabled on the
* returned constructor (if any).
*/
- private static Constructor getSerializableConstructor(Class cl) {
- Class initCl = cl;
+ private static Constructor getSerializableConstructor(Class> cl) {
+ Class> initCl = cl;
while (Serializable.class.isAssignableFrom(initCl)) {
if ((initCl = initCl.getSuperclass()) == null) {
return null;
}
}
try {
- Constructor cons = initCl.getDeclaredConstructor(new Class[0]);
+ Constructor cons = initCl.getDeclaredConstructor(new Class>[0]);
int mods = cons.getModifiers();
if ((mods & Modifier.PRIVATE) != 0 ||
((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 &&
@@ -1049,7 +1050,7 @@
* items to the hash accumulating in the digest stream.
* Fold the hash into a long. Use the SHA secure hash function.
*/
- private static long _computeSerialVersionUID(Class cl) {
+ private static long _computeSerialVersionUID(Class> cl) {
if (DEBUG_SVUID)
msg( "Computing SerialVersionUID for " + cl ) ;
ByteArrayOutputStream devnull = new ByteArrayOutputStream(512);
@@ -1103,7 +1104,7 @@
* them from its computation.
*/
- Class interfaces[] = cl.getInterfaces();
+ Class> interfaces[] = cl.getInterfaces();
Arrays.sort(interfaces, compareClassByName);
for (int i = 0; i < interfaces.length; i++) {
@@ -1233,7 +1234,7 @@
return h;
}
- private static long computeStructuralUID(com.sun.corba.se.impl.io.ObjectStreamClass osc, Class cl) {
+ private static long computeStructuralUID(com.sun.corba.se.impl.io.ObjectStreamClass osc, Class> cl) {
ByteArrayOutputStream devnull = new ByteArrayOutputStream(512);
long h = 0;
@@ -1253,7 +1254,7 @@
DataOutputStream data = new DataOutputStream(mdo);
// Get SUID of parent
- Class parent = cl.getSuperclass();
+ Class> parent = cl.getSuperclass();
if ((parent != null))
// SerialBug 1; acc. to spec the one for
// java.lang.object
@@ -1309,10 +1310,10 @@
/**
* Compute the JVM signature for the class.
*/
- static String getSignature(Class clazz) {
+ static String getSignature(Class> clazz) {
String type = null;
if (clazz.isArray()) {
- Class cl = clazz;
+ Class> cl = clazz;
int dimensions = 0;
while (cl.isArray()) {
dimensions++;
@@ -1358,7 +1359,7 @@
sb.append("(");
- Class[] params = meth.getParameterTypes(); // avoid clone
+ Class>[] params = meth.getParameterTypes(); // avoid clone
for (int j = 0; j < params.length; j++) {
sb.append(getSignature(params[j]));
}
@@ -1375,7 +1376,7 @@
sb.append("(");
- Class[] params = cons.getParameterTypes(); // avoid clone
+ Class>[] params = cons.getParameterTypes(); // avoid clone
for (int j = 0; j < params.length; j++) {
sb.append(getSignature(params[j]));
}
@@ -1395,7 +1396,7 @@
* The entries are extended from java.lang.ref.SoftReference so the
* gc will be able to free them if needed.
*/
- private static ObjectStreamClass findDescriptorFor(Class cl) {
+ private static ObjectStreamClass findDescriptorFor(Class> cl) {
int hash = cl.hashCode();
int index = (hash & 0x7FFFFFFF) % descriptorFor.length;
@@ -1442,7 +1443,7 @@
descriptorFor[index] = e;
}
- private static Field[] getDeclaredFields(final Class clz) {
+ private static Field[] getDeclaredFields(final Class> clz) {
return (Field[]) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return clz.getDeclaredFields();
@@ -1476,7 +1477,7 @@
/*
* Class that is a descriptor for in this virtual machine.
*/
- private Class ofClass;
+ private Class> ofClass;
/*
* True if descriptor for a proxy class.
@@ -1548,30 +1549,17 @@
* Returns true if the given class defines a static initializer method,
* false otherwise.
*/
- private static boolean hasStaticInitializer(Class cl) {
+ private static boolean hasStaticInitializer(Class> cl) {
if (hasStaticInitializerMethod == null) {
- Class classWithThisMethod = null;
+ Class> classWithThisMethod = null;
try {
- try {
- // When using rip-int with Merlin or when this is a Merlin
- // workspace, the method we want is in sun.misc.ClassReflector
- // and absent from java.io.ObjectStreamClass.
- //
- // When compiling rip-int with JDK 1.3.x, we have to get it
- // from java.io.ObjectStreamClass.
- classWithThisMethod = Class.forName("sun.misc.ClassReflector");
- } catch (ClassNotFoundException cnfe) {
- // Do nothing. This is either not a Merlin workspace,
- // or rip-int is being compiled with something other than
- // Merlin, probably JDK 1.3. Fall back on java.io.ObjectStreaClass.
- }
if (classWithThisMethod == null)
classWithThisMethod = java.io.ObjectStreamClass.class;
hasStaticInitializerMethod =
classWithThisMethod.getDeclaredMethod("hasStaticInitializer",
- new Class[] { Class.class });
+ new Class>[] { Class.class });
} catch (NoSuchMethodException ex) {
}
@@ -1596,22 +1584,6 @@
}
- /* The Class Object for java.io.Serializable */
- private static Class classSerializable = null;
- private static Class classExternalizable = null;
-
- /*
- * Resolve java.io.Serializable at load time.
- */
- static {
- try {
- classSerializable = Class.forName("java.io.Serializable");
- classExternalizable = Class.forName("java.io.Externalizable");
- } catch (Throwable e) {
- System.err.println("Could not load java.io.Serializable or java.io.Externalizable.");
- }
- }
-
/** use serialVersionUID from JDK 1.1. for interoperability */
private static final long serialVersionUID = -6120832682080437368L;
@@ -1649,8 +1621,8 @@
private static class CompareClassByName implements Comparator {
public int compare(Object o1, Object o2) {
- Class c1 = (Class)o1;
- Class c2 = (Class)o2;
+ Class> c1 = (Class)o1;
+ Class> c2 = (Class)o2;
return (c1.getName()).compareTo(c2.getName());
}
}
@@ -1764,12 +1736,12 @@
*
* Copied from the Merlin java.io.ObjectStreamClass.
*/
- private static Method getInheritableMethod(Class cl, String name,
- Class[] argTypes,
- Class returnType)
+ private static Method getInheritableMethod(Class> cl, String name,
+ Class>[] argTypes,
+ Class> returnType)
{
Method meth = null;
- Class defCl = cl;
+ Class> defCl = cl;
while (defCl != null) {
try {
meth = defCl.getDeclaredMethod(name, argTypes);
@@ -1801,7 +1773,7 @@
*
* Copied from the Merlin java.io.ObjectStreamClass.
*/
- private static boolean packageEquals(Class cl1, Class cl2) {
+ private static boolean packageEquals(Class> cl1, Class> cl2) {
Package pkg1 = cl1.getPackage(), pkg2 = cl2.getPackage();
return ((pkg1 == pkg2) || ((pkg1 != null) && (pkg1.equals(pkg2))));
}
diff -r 1d117d2dfe92 -r 2061862eb57c corba/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClassUtil_1_3.java
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClassUtil_1_3.java Tue Apr 29 15:44:14 2014 -0400
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClassUtil_1_3.java Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2002, 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
@@ -94,7 +94,7 @@
});
}
- public static long computeStructuralUID(boolean hasWriteObject, Class cl) {
+ public static long computeStructuralUID(boolean hasWriteObject, Class> cl) {
ByteArrayOutputStream devnull = new ByteArrayOutputStream(512);
long h = 0;
@@ -119,7 +119,7 @@
// Object method in there
// Get SUID of parent
- Class parent = cl.getSuperclass();
+ Class> parent = cl.getSuperclass();
if ((parent != null) && (parent != java.lang.Object.class)) {
boolean hasWriteObjectFlag = false;
Class [] args = {java.io.ObjectOutputStream.class};
@@ -503,19 +503,6 @@
Class classWithThisMethod = null;
try {
- try {
- // When using rip-int with Merlin or when this is a Merlin
- // workspace, the method we want is in sun.misc.ClassReflector
- // and absent from java.io.ObjectStreamClass.
- //
- // When compiling rip-int with JDK 1.3.x, we have to get it
- // from java.io.ObjectStreamClass.
- classWithThisMethod = Class.forName("sun.misc.ClassReflector");
- } catch (ClassNotFoundException cnfe) {
- // Do nothing. This is either not a Merlin workspace,
- // or rip-int is being compiled with something other than
- // Merlin, probably JDK 1.3. Fall back on java.io.ObjectStreaClass.
- }
if (classWithThisMethod == null)
classWithThisMethod = java.io.ObjectStreamClass.class;
diff -r 1d117d2dfe92 -r 2061862eb57c corba/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClass_1_3_1.java
--- a/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClass_1_3_1.java Tue Apr 29 15:44:14 2014 -0400
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ObjectStreamClass_1_3_1.java Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2012, 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
@@ -53,6 +53,7 @@
import java.io.ByteArrayOutputStream;
import java.io.InvalidClassException;
import java.io.Serializable;
+import java.io.Externalizable;
import java.util.Arrays;
import java.util.Comparator;
@@ -88,7 +89,7 @@
public static final long kDefaultUID = -1;
private static Object noArgsList[] = {};
- private static Class noTypesList[] = {};
+ private static Class> noTypesList[] = {};
private static Hashtable translatedFields;
@@ -96,7 +97,7 @@
* is returned if the specified class does not implement
* java.io.Serializable or java.io.Externalizable.
*/
- static final ObjectStreamClass_1_3_1 lookup(Class cl)
+ static final ObjectStreamClass_1_3_1 lookup(Class> cl)
{
ObjectStreamClass_1_3_1 desc = lookupInternal(cl);
if (desc.isSerializable() || desc.isExternalizable())
@@ -108,7 +109,7 @@
* Find the class descriptor for the specified class.
* Package access only so it can be called from ObjectIn/OutStream.
*/
- static ObjectStreamClass_1_3_1 lookupInternal(Class cl)
+ static ObjectStreamClass_1_3_1 lookupInternal(Class> cl)
{
/* Synchronize on the hashtable so no two threads will do
* this at the same time.
@@ -122,13 +123,13 @@
}
/* Check if it's serializable */
- boolean serializable = classSerializable.isAssignableFrom(cl);
+ boolean serializable = Serializable.class.isAssignableFrom(cl);
/* If the class is only Serializable,
* lookup the descriptor for the superclass.
*/
ObjectStreamClass_1_3_1 superdesc = null;
if (serializable) {
- Class superclass = cl.getSuperclass();
+ Class> superclass = cl.getSuperclass();
if (superclass != null)
superdesc = lookup(superclass);
}
@@ -141,7 +142,7 @@
if (serializable) {
externalizable =
((superdesc != null) && superdesc.isExternalizable()) ||
- classExternalizable.isAssignableFrom(cl);
+ Externalizable.class.isAssignableFrom(cl);
if (externalizable) {
serializable = false;
}
@@ -170,7 +171,7 @@
* that have evolved from a common root class and agree to be serialized
* and deserialized using a common format.
*/
- public static final long getSerialVersionUID( java.lang.Class clazz) {
+ public static final long getSerialVersionUID( java.lang.Class> clazz) {
ObjectStreamClass_1_3_1 theosc = ObjectStreamClass_1_3_1.lookup( clazz );
if( theosc != null )
{
@@ -204,7 +205,7 @@
/**
* Return the actual (computed) serialVersionUID for this class.
*/
- public static final long getActualSerialVersionUID( java.lang.Class clazz )
+ public static final long getActualSerialVersionUID( java.lang.Class> clazz )
{
ObjectStreamClass_1_3_1 theosc = ObjectStreamClass_1_3_1.lookup( clazz );
if( theosc != null )
@@ -234,7 +235,7 @@
* Return the class in the local VM that this version is mapped to.
* Null is returned if there is no corresponding local class.
*/
- public final Class forClass() {
+ public final Class> forClass() {
return ofClass;
}
@@ -333,7 +334,7 @@
* Create a new ObjectStreamClass_1_3_1 from a loaded class.
* Don't call this directly, call lookup instead.
*/
- private ObjectStreamClass_1_3_1(java.lang.Class cl, ObjectStreamClass_1_3_1 superdesc,
+ private ObjectStreamClass_1_3_1(java.lang.Class> cl, ObjectStreamClass_1_3_1 superdesc,
boolean serial, boolean extern)
{
ofClass = cl; /* created from this class */
@@ -376,7 +377,7 @@
private void init() {
synchronized (lock) {
- final Class cl = ofClass;
+ final Class> cl = ofClass;
if (fields != null) // already initialized
return;
@@ -558,7 +559,7 @@
* will call it as necessary.
*/
try {
- Class[] args = {java.io.ObjectOutputStream.class};
+ Class>[] args = {java.io.ObjectOutputStream.class};
writeObjectMethod = cl.getDeclaredMethod("writeObject", args);
hasWriteObjectMethod = true;
int mods = writeObjectMethod.getModifiers();
@@ -578,7 +579,7 @@
* ObjectInputStream so it can all the method directly.
*/
try {
- Class[] args = {java.io.ObjectInputStream.class};
+ Class>[] args = {java.io.ObjectInputStream.class};
readObjectMethod = cl.getDeclaredMethod("readObject", args);
int mods = readObjectMethod.getModifiers();
@@ -629,11 +630,11 @@
if (translation != null)
return translation;
else {
- Class osfClass = com.sun.corba.se.impl.orbutil.ObjectStreamField.class;
+ Class> osfClass = com.sun.corba.se.impl.orbutil.ObjectStreamField.class;
translation = (Object[])java.lang.reflect.Array.newInstance(osfClass, objs.length);
Object arg[] = new Object[2];
- Class types[] = {String.class, Class.class};
+ Class> types[] = {String.class, Class.class};
Constructor constructor = osfClass.getDeclaredConstructor(types);
for (int i = fields.length -1; i >= 0; i--){
arg[0] = fields[i].getName();
@@ -804,7 +805,7 @@
}
}
- private static long computeStructuralUID(ObjectStreamClass_1_3_1 osc, Class cl) {
+ private static long computeStructuralUID(ObjectStreamClass_1_3_1 osc, Class> cl) {
ByteArrayOutputStream devnull = new ByteArrayOutputStream(512);
long h = 0;
@@ -824,7 +825,7 @@
DataOutputStream data = new DataOutputStream(mdo);
// Get SUID of parent
- Class parent = cl.getSuperclass();
+ Class> parent = cl.getSuperclass();
if ((parent != null))
// SerialBug 1; acc. to spec the one for
// java.lang.object
@@ -910,10 +911,10 @@
/**
* Compute the JVM signature for the class.
*/
- static String getSignature(Class clazz) {
+ static String getSignature(Class> clazz) {
String type = null;
if (clazz.isArray()) {
- Class cl = clazz;
+ Class> cl = clazz;
int dimensions = 0;
while (cl.isArray()) {
dimensions++;
@@ -959,7 +960,7 @@
sb.append("(");
- Class[] params = meth.getParameterTypes(); // avoid clone
+ Class>[] params = meth.getParameterTypes(); // avoid clone
for (int j = 0; j < params.length; j++) {
sb.append(getSignature(params[j]));
}
@@ -976,7 +977,7 @@
sb.append("(");
- Class[] params = cons.getParameterTypes(); // avoid clone
+ Class>[] params = cons.getParameterTypes(); // avoid clone
for (int j = 0; j < params.length; j++) {
sb.append(getSignature(params[j]));
}
@@ -996,7 +997,7 @@
* The entries are extended from java.lang.ref.SoftReference so the
* gc will be able to free them if needed.
*/
- private static ObjectStreamClass_1_3_1 findDescriptorFor(Class cl) {
+ private static ObjectStreamClass_1_3_1 findDescriptorFor(Class> cl) {
int hash = cl.hashCode();
int index = (hash & 0x7FFFFFFF) % descriptorFor.length;
@@ -1077,7 +1078,7 @@
/*
* Class that is a descriptor for in this virtual machine.
*/
- private Class ofClass;
+ private Class> ofClass;
/*
* True if descriptor for a proxy class.
@@ -1130,22 +1131,6 @@
/* Get the private static final field for serial version UID */
// private static native long getSerialVersionUIDField(Class cl);
- /* The Class Object for java.io.Serializable */
- private static Class classSerializable = null;
- private static Class classExternalizable = null;
-
- /*
- * Resolve java.io.Serializable at load time.
- */
- static {
- try {
- classSerializable = Class.forName("java.io.Serializable");
- classExternalizable = Class.forName("java.io.Externalizable");
- } catch (Throwable e) {
- System.err.println("Could not load java.io.Serializable or java.io.Externalizable.");
- }
- }
-
/** use serialVersionUID from JDK 1.1. for interoperability */
private static final long serialVersionUID = -6120832682080437368L;
@@ -1183,8 +1168,8 @@
private static class CompareClassByName implements Comparator {
public int compare(Object o1, Object o2) {
- Class c1 = (Class)o1;
- Class c2 = (Class)o2;
+ Class> c1 = (Class)o1;
+ Class> c2 = (Class)o2;
return (c1.getName()).compareTo(c2.getName());
}
}
diff -r 1d117d2dfe92 -r 2061862eb57c corba/src/share/classes/org/omg/CORBA/ORB.java
--- a/corba/src/share/classes/org/omg/CORBA/ORB.java Tue Apr 29 15:44:14 2014 -0400
+++ b/corba/src/share/classes/org/omg/CORBA/ORB.java Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -36,6 +36,8 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
+import sun.reflect.misc.ReflectUtil;
+
/**
* A class providing APIs for the CORBA Object Request Broker
* features. The ORB
class also provides
@@ -161,6 +163,20 @@
*
* An application or applet can be initialized in one or more ORBs.
* ORB initialization is a bootstrap call into the CORBA world.
+ *
+ *
+ * @implNote
+ * As described above it is possible to specify, at runtime, an alternative ORBSingleton class and
+ * an alternative ORB implementation class, via the system properties {@code org.omg.CORBA.ORBSingletonClass}
+ * and {@code org.omg.CORBA.ORBClass} respectively.
+ * The class loading strategy is organized, such that, in the case of the ORBSingleton
+ * the system class loader is used to load the alternative singleton ORB.
+ * Thus, it is necessary that an application's CLASSPATH
+ * includes the classes for this alternative ORBSingleton, when specified.
+ *
+ * In the case of specifying an alternative ORB implementation class, the loading
+ * strategy will use the thread context class loader, as appropriate.
+ *
* @since JDK1.2
*/
abstract public class ORB {
@@ -289,20 +305,38 @@
(className.equals("com.sun.corba.se.impl.orb.ORBSingleton"))) {
singleton = new com.sun.corba.se.impl.orb.ORBSingleton();
} else {
- singleton = create_impl(className);
+ singleton = create_impl_with_systemclassloader(className);
}
}
return singleton;
}
+ private static ORB create_impl_with_systemclassloader(String className) {
+
+ try {
+ ReflectUtil.checkPackageAccess(className);
+ ClassLoader cl = ClassLoader.getSystemClassLoader();
+ Class orbBaseClass = org.omg.CORBA.ORB.class;
+ Class> singletonOrbClass = Class.forName(className, true, cl).asSubclass(orbBaseClass);
+ return (ORB)singletonOrbClass.newInstance();
+ } catch (Throwable ex) {
+ SystemException systemException = new INITIALIZE(
+ "can't instantiate default ORB implementation " + className);
+ systemException.initCause(ex);
+ throw systemException;
+ }
+ }
+
private static ORB create_impl(String className) {
-
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null)
cl = ClassLoader.getSystemClassLoader();
try {
- return (ORB) Class.forName(className, true, cl).newInstance();
+ ReflectUtil.checkPackageAccess(className);
+ Class orbBaseClass = org.omg.CORBA.ORB.class;
+ Class> orbClass = Class.forName(className, true, cl).asSubclass(orbBaseClass);
+ return (ORB)orbClass.newInstance();
} catch (Throwable ex) {
SystemException systemException = new INITIALIZE(
"can't instantiate default ORB implementation " + className);
@@ -346,7 +380,6 @@
} else {
orb = create_impl(className);
}
-
orb.set_parameters(args, props);
return orb;
}
@@ -377,7 +410,6 @@
} else {
orb = create_impl(className);
}
-
orb.set_parameters(app, props);
return orb;
}
@@ -573,7 +605,7 @@
try {
// First try to load the OperationDef class
String opDefClassName = "org.omg.CORBA.OperationDef";
- Class opDefClass = null;
+ Class> opDefClass = null;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if ( cl == null )
@@ -583,7 +615,7 @@
// OK, we loaded OperationDef. Now try to get the
// create_operation_list(OperationDef oper) method.
- Class[] argc = { opDefClass };
+ Class>[] argc = { opDefClass };
java.lang.reflect.Method meth =
this.getClass().getMethod("create_operation_list", argc);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/.hgtags
--- a/hotspot/.hgtags Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/.hgtags Tue Apr 29 14:40:07 2014 -0700
@@ -410,3 +410,6 @@
bdc5311e1db7598589b77015119b821bf8c828bd jdk9-b05
52377a30a3f87b62d6135706997b8c7a47366e37 jdk9-b06
52f7edf2589d9f9d35db3008bc5377f279de9c18 jdk9-b07
+4dedef5e51ed3a36677a8ba82949fc517ad64162 jdk9-b08
+05e8f5242c26ba45d4fa947e4f4f54c058c9b522 jdk9-b09
+ebc44d040cd149d2120d69fe183a3dae7840f4b4 jdk9-b10
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/make/jprt.properties
--- a/hotspot/make/jprt.properties Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/make/jprt.properties Tue Apr 29 14:40:07 2014 -0700
@@ -65,9 +65,6 @@
jprt.my.linux.ppcv2.jdk9=linux_ppcv2_2.6
jprt.my.linux.ppcv2=${jprt.my.linux.ppcv2.${jprt.tools.default.release}}
-jprt.my.linux.ppcsflt.jdk9=linux_ppcsflt_2.6
-jprt.my.linux.ppcsflt=${jprt.my.linux.ppcsflt.${jprt.tools.default.release}}
-
jprt.my.linux.armvfpsflt.jdk9=linux_armvfpsflt_2.6
jprt.my.linux.armvfpsflt=${jprt.my.linux.armvfpsflt.${jprt.tools.default.release}}
@@ -113,7 +110,6 @@
${jprt.my.linux.i586}-{productEmb|fastdebugEmb}, \
${jprt.my.linux.ppc}-{productEmb|fastdebugEmb}, \
${jprt.my.linux.ppcv2}-{productEmb|fastdebugEmb}, \
- ${jprt.my.linux.ppcsflt}-{productEmb|fastdebugEmb}, \
${jprt.my.linux.armvfpsflt}-{productEmb|fastdebugEmb}, \
${jprt.my.linux.armvfphflt}-{productEmb|fastdebugEmb}, \
${jprt.my.linux.armsflt}-{productEmb|fastdebugEmb}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp
--- a/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/ppc/vm/cppInterpreter_ppc.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012, 2013 SAP AG. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012, 2014 SAP AG. 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
@@ -2947,17 +2947,60 @@
istate->_last_Java_fp = last_Java_fp;
}
-int AbstractInterpreter::layout_activation(Method* method,
- int temps, // Number of slots on java expression stack in use.
- int popframe_args,
- int monitors, // Number of active monitors.
- int caller_actual_parameters,
- int callee_params,// Number of slots for callee parameters.
- int callee_locals,// Number of slots for locals.
- frame* caller,
- frame* interpreter_frame,
- bool is_top_frame,
- bool is_bottom_frame) {
+// Computes monitor_size and top_frame_size in bytes.
+static void frame_size_helper(int max_stack,
+ int monitors,
+ int& monitor_size,
+ int& top_frame_size) {
+ monitor_size = frame::interpreter_frame_monitor_size_in_bytes() * monitors;
+ top_frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
+ + monitor_size
+ + max_stack * Interpreter::stackElementSize
+ + 2 * Interpreter::stackElementSize,
+ frame::alignment_in_bytes)
+ + frame::top_ijava_frame_abi_size;
+}
+
+// Returns number of stackElementWords needed for the interpreter frame with the
+// given sections.
+int AbstractInterpreter::size_activation(int max_stack,
+ int temps,
+ int extra_args,
+ int monitors,
+ int callee_params,
+ int callee_locals,
+ bool is_top_frame) {
+ int monitor_size = 0;
+ int top_frame_size = 0;
+ frame_size_helper(max_stack, monitors, monitor_size, top_frame_size);
+
+ int frame_size;
+ if (is_top_frame) {
+ frame_size = top_frame_size;
+ } else {
+ frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
+ + monitor_size
+ + (temps - callee_params + callee_locals) * Interpreter::stackElementSize
+ + 2 * Interpreter::stackElementSize,
+ frame::alignment_in_bytes)
+ + frame::parent_ijava_frame_abi_size;
+ assert(extra_args == 0, "non-zero for top_frame only");
+ }
+
+ return frame_size / Interpreter::stackElementSize;
+}
+
+void AbstractInterpreter::layout_activation(Method* method,
+ int temps, // Number of slots on java expression stack in use.
+ int popframe_args,
+ int monitors, // Number of active monitors.
+ int caller_actual_parameters,
+ int callee_params,// Number of slots for callee parameters.
+ int callee_locals,// Number of slots for locals.
+ frame* caller,
+ frame* interpreter_frame,
+ bool is_top_frame,
+ bool is_bottom_frame) {
// NOTE this code must exactly mimic what
// InterpreterGenerator::generate_compute_interpreter_state() does
@@ -2967,86 +3010,64 @@
// both the abi scratch area and a place to hold a result from a
// callee on its way to the callers stack.
- int monitor_size = frame::interpreter_frame_monitor_size_in_bytes() * monitors;
- int frame_size;
- int top_frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
- + monitor_size
- + (method->max_stack() *Interpreter::stackElementWords * BytesPerWord)
- + 2*BytesPerWord,
- frame::alignment_in_bytes)
- + frame::top_ijava_frame_abi_size;
- if (is_top_frame) {
- frame_size = top_frame_size;
+ int monitor_size = 0;
+ int top_frame_size = 0;
+ frame_size_helper(method->max_stack(), monitors, monitor_size, top_frame_size);
+
+ intptr_t sp = (intptr_t)interpreter_frame->sp();
+ intptr_t fp = *(intptr_t *)sp;
+ assert(fp == (intptr_t)caller->sp(), "fp must match");
+ interpreterState cur_state =
+ (interpreterState)(fp - frame::interpreter_frame_cinterpreterstate_size_in_bytes());
+
+ // Now fill in the interpreterState object.
+
+ intptr_t* locals;
+ if (caller->is_interpreted_frame()) {
+ // Locals must agree with the caller because it will be used to set the
+ // caller's tos when we return.
+ interpreterState prev = caller->get_interpreterState();
+ // Calculate start of "locals" for MH calls. For MH calls, the
+ // current method() (= MH target) and prev->callee() (=
+ // MH.invoke*()) are different and especially have different
+ // signatures. To pop the argumentsof the caller, we must use
+ // the prev->callee()->size_of_arguments() because that's what
+ // the caller actually pushed. Currently, for synthetic MH
+ // calls (deoptimized from inlined MH calls), detected by
+ // is_method_handle_invoke(), we use the callee's arguments
+ // because here, the caller's and callee's signature match.
+ if (true /*!caller->is_at_mh_callsite()*/) {
+ locals = prev->stack() + method->size_of_parameters();
+ } else {
+ // Normal MH call.
+ locals = prev->stack() + prev->callee()->size_of_parameters();
+ }
} else {
- frame_size = round_to(frame::interpreter_frame_cinterpreterstate_size_in_bytes()
- + monitor_size
- + ((temps - callee_params + callee_locals) *
- Interpreter::stackElementWords * BytesPerWord)
- + 2*BytesPerWord,
- frame::alignment_in_bytes)
- + frame::parent_ijava_frame_abi_size;
- assert(popframe_args==0, "non-zero for top_frame only");
+ bool is_deopted;
+ locals = (intptr_t*) (fp + ((method->max_locals() - 1) * BytesPerWord) +
+ frame::parent_ijava_frame_abi_size);
}
- // If we actually have a frame to layout we must now fill in all the pieces.
- if (interpreter_frame != NULL) {
-
- intptr_t sp = (intptr_t)interpreter_frame->sp();
- intptr_t fp = *(intptr_t *)sp;
- assert(fp == (intptr_t)caller->sp(), "fp must match");
- interpreterState cur_state =
- (interpreterState)(fp - frame::interpreter_frame_cinterpreterstate_size_in_bytes());
-
- // Now fill in the interpreterState object.
-
- intptr_t* locals;
- if (caller->is_interpreted_frame()) {
- // Locals must agree with the caller because it will be used to set the
- // caller's tos when we return.
- interpreterState prev = caller->get_interpreterState();
- // Calculate start of "locals" for MH calls. For MH calls, the
- // current method() (= MH target) and prev->callee() (=
- // MH.invoke*()) are different and especially have different
- // signatures. To pop the argumentsof the caller, we must use
- // the prev->callee()->size_of_arguments() because that's what
- // the caller actually pushed. Currently, for synthetic MH
- // calls (deoptimized from inlined MH calls), detected by
- // is_method_handle_invoke(), we use the callee's arguments
- // because here, the caller's and callee's signature match.
- if (true /*!caller->is_at_mh_callsite()*/) {
- locals = prev->stack() + method->size_of_parameters();
- } else {
- // Normal MH call.
- locals = prev->stack() + prev->callee()->size_of_parameters();
- }
- } else {
- bool is_deopted;
- locals = (intptr_t*) (fp + ((method->max_locals() - 1) * BytesPerWord) +
- frame::parent_ijava_frame_abi_size);
- }
-
- intptr_t* monitor_base = (intptr_t*) cur_state;
- intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
-
- // Provide pop_frame capability on PPC64, add popframe_args.
- // +1 because stack is always prepushed.
- intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (temps + popframe_args + 1) * BytesPerWord);
-
- BytecodeInterpreter::layout_interpreterState(cur_state,
- caller,
- interpreter_frame,
- method,
- locals,
- stack,
- stack_base,
- monitor_base,
- (intptr_t*)(((intptr_t)fp)-top_frame_size),
- is_top_frame);
-
- BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address,
- interpreter_frame->fp());
- }
- return frame_size/BytesPerWord;
+ intptr_t* monitor_base = (intptr_t*) cur_state;
+ intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
+
+ // Provide pop_frame capability on PPC64, add popframe_args.
+ // +1 because stack is always prepushed.
+ intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (temps + popframe_args + 1) * BytesPerWord);
+
+ BytecodeInterpreter::layout_interpreterState(cur_state,
+ caller,
+ interpreter_frame,
+ method,
+ locals,
+ stack,
+ stack_base,
+ monitor_base,
+ (intptr_t*)(((intptr_t)fp) - top_frame_size),
+ is_top_frame);
+
+ BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address,
+ interpreter_frame->fp());
}
#endif // CC_INTERP
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/ppc/vm/ppc.ad
--- a/hotspot/src/cpu/ppc/vm/ppc.ad Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/ppc/vm/ppc.ad Tue Apr 29 14:40:07 2014 -0700
@@ -1,6 +1,6 @@
//
-// Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
-// Copyright 2012, 2013 SAP AG. All rights reserved.
+// Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+// Copyright 2012, 2014 SAP AG. 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
@@ -1362,8 +1362,8 @@
Compile* C = ra_->C;
MacroAssembler _masm(&cbuf);
- const long framesize = ((long)C->frame_slots()) << LogBytesPerInt;
- assert(framesize%(2*wordSize) == 0, "must preserve 2*wordSize alignment");
+ const long framesize = C->frame_size_in_bytes();
+ assert(framesize % (2 * wordSize) == 0, "must preserve 2*wordSize alignment");
const bool method_is_frameless = false /* TODO: PPC port C->is_frameless_method()*/;
@@ -1388,19 +1388,22 @@
// careful, because some VM calls (such as call site linkage) can
// use several kilobytes of stack. But the stack safety zone should
// account for that. See bugs 4446381, 4468289, 4497237.
- if (C->need_stack_bang(framesize) && UseStackBanging) {
+
+ int bangsize = C->bang_size_in_bytes();
+ assert(bangsize >= framesize || bangsize <= 0, "stack bang size incorrect");
+ if (C->need_stack_bang(bangsize) && UseStackBanging) {
// Unfortunately we cannot use the function provided in
// assembler.cpp as we have to emulate the pipes. So I had to
// insert the code of generate_stack_overflow_check(), see
// assembler.cpp for some illuminative comments.
const int page_size = os::vm_page_size();
- int bang_end = StackShadowPages*page_size;
+ int bang_end = StackShadowPages * page_size;
// This is how far the previous frame's stack banging extended.
const int bang_end_safe = bang_end;
- if (framesize > page_size) {
- bang_end += framesize;
+ if (bangsize > page_size) {
+ bang_end += bangsize;
}
int bang_offset = bang_end_safe;
@@ -1446,7 +1449,7 @@
unsigned int bytes = (unsigned int)framesize;
long offset = Assembler::align_addr(bytes, frame::alignment_in_bytes);
- ciMethod *currMethod = C -> method();
+ ciMethod *currMethod = C->method();
// Optimized version for most common case.
if (UsePower6SchedulerPPC64 &&
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/ppc/vm/templateInterpreter_ppc.cpp
--- a/hotspot/src/cpu/ppc/vm/templateInterpreter_ppc.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/ppc/vm/templateInterpreter_ppc.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1334,21 +1334,42 @@
int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
const int max_alignment_size = 2;
const int abi_scratch = frame::abi_reg_args_size;
- return method->max_locals() + method->max_stack() + frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch;
+ return method->max_locals() + method->max_stack() +
+ frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch;
}
-// Fills a sceletal interpreter frame generated during deoptimizations
-// and returns the frame size in slots.
+// Returns number of stackElementWords needed for the interpreter frame with the
+// given sections.
+// This overestimates the stack by one slot in case of alignments.
+int AbstractInterpreter::size_activation(int max_stack,
+ int temps,
+ int extra_args,
+ int monitors,
+ int callee_params,
+ int callee_locals,
+ bool is_top_frame) {
+ // Note: This calculation must exactly parallel the frame setup
+ // in AbstractInterpreterGenerator::generate_method_entry.
+ assert(Interpreter::stackElementWords == 1, "sanity");
+ const int max_alignment_space = StackAlignmentInBytes / Interpreter::stackElementSize;
+ const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
+ (frame::abi_minframe_size / Interpreter::stackElementSize);
+ const int size =
+ max_stack +
+ (callee_locals - callee_params) +
+ monitors * frame::interpreter_frame_monitor_size() +
+ max_alignment_space +
+ abi_scratch +
+ frame::ijava_state_size / Interpreter::stackElementSize;
+
+ // Fixed size of an interpreter frame, align to 16-byte.
+ return (size & -2);
+}
+
+// Fills a sceletal interpreter frame generated during deoptimizations.
//
// Parameters:
//
-// interpreter_frame == NULL:
-// Only calculate the size of an interpreter activation, no actual layout.
-// Note: This calculation must exactly parallel the frame setup
-// in TemplateInterpreter::generate_normal_entry. But it does not
-// account for the SP alignment, that might further enhance the
-// frame size, depending on FP.
-//
// interpreter_frame != NULL:
// set up the method, locals, and monitors.
// The frame interpreter_frame, if not NULL, is guaranteed to be the
@@ -1365,59 +1386,41 @@
// the arguments off advance the esp by dummy popframe_extra_args slots.
// Popping off those will establish the stack layout as it was before the call.
//
-int AbstractInterpreter::layout_activation(Method* method,
- int tempcount,
- int popframe_extra_args,
- int moncount,
- int caller_actual_parameters,
- int callee_param_count,
- int callee_locals,
- frame* caller,
- frame* interpreter_frame,
- bool is_top_frame,
- bool is_bottom_frame) {
+void AbstractInterpreter::layout_activation(Method* method,
+ int tempcount,
+ int popframe_extra_args,
+ int moncount,
+ int caller_actual_parameters,
+ int callee_param_count,
+ int callee_locals_count,
+ frame* caller,
+ frame* interpreter_frame,
+ bool is_top_frame,
+ bool is_bottom_frame) {
- const int max_alignment_space = 2;
const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) :
- (frame::abi_minframe_size / Interpreter::stackElementSize) ;
- const int conservative_framesize_in_slots =
- method->max_stack() + callee_locals - callee_param_count +
- (moncount * frame::interpreter_frame_monitor_size()) + max_alignment_space +
- abi_scratch + frame::ijava_state_size / Interpreter::stackElementSize;
-
- assert(!is_top_frame || conservative_framesize_in_slots * 8 > frame::abi_reg_args_size + frame::ijava_state_size, "frame too small");
+ (frame::abi_minframe_size / Interpreter::stackElementSize);
- if (interpreter_frame == NULL) {
- // Since we don't know the exact alignment, we return the conservative size.
- return (conservative_framesize_in_slots & -2);
- } else {
- // Now we know our caller, calc the exact frame layout and size.
- intptr_t* locals_base = (caller->is_interpreted_frame()) ?
- caller->interpreter_frame_esp() + caller_actual_parameters :
- caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize) ;
+ intptr_t* locals_base = (caller->is_interpreted_frame()) ?
+ caller->interpreter_frame_esp() + caller_actual_parameters :
+ caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize) ;
- intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize ;
- intptr_t* monitor = monitor_base - (moncount * frame::interpreter_frame_monitor_size());
- intptr_t* esp_base = monitor - 1;
- intptr_t* esp = esp_base - tempcount - popframe_extra_args;
- intptr_t* sp = (intptr_t *) (((intptr_t) (esp_base- callee_locals + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes);
- intptr_t* sender_sp = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
- intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
+ intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize ;
+ intptr_t* monitor = monitor_base - (moncount * frame::interpreter_frame_monitor_size());
+ intptr_t* esp_base = monitor - 1;
+ intptr_t* esp = esp_base - tempcount - popframe_extra_args;
+ intptr_t* sp = (intptr_t *) (((intptr_t) (esp_base - callee_locals_count + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes);
+ intptr_t* sender_sp = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
+ intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize;
- interpreter_frame->interpreter_frame_set_method(method);
- interpreter_frame->interpreter_frame_set_locals(locals_base);
- interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache());
- interpreter_frame->interpreter_frame_set_esp(esp);
- interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor);
- interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp);
- if (!is_bottom_frame) {
- interpreter_frame->interpreter_frame_set_sender_sp(sender_sp);
- }
-
- int framesize_in_slots = caller->sp() - sp;
- assert(!is_top_frame ||framesize_in_slots >= (frame::abi_reg_args_size / Interpreter::stackElementSize) + frame::ijava_state_size / Interpreter::stackElementSize, "frame too small");
- assert(framesize_in_slots <= conservative_framesize_in_slots, "exact frame size must be smaller than the convervative size!");
- return framesize_in_slots;
+ interpreter_frame->interpreter_frame_set_method(method);
+ interpreter_frame->interpreter_frame_set_locals(locals_base);
+ interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache());
+ interpreter_frame->interpreter_frame_set_esp(esp);
+ interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor);
+ interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp);
+ if (!is_bottom_frame) {
+ interpreter_frame->interpreter_frame_set_sender_sp(sender_sp);
}
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/sparc/vm/assembler_sparc.hpp
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -630,11 +630,20 @@
}
protected:
+ // Insert a nop if the previous is cbcond
+ void insert_nop_after_cbcond() {
+ if (UseCBCond && cbcond_before()) {
+ nop();
+ }
+ }
// Delay slot helpers
// cti is called when emitting control-transfer instruction,
// BEFORE doing the emitting.
// Only effective when assertion-checking is enabled.
void cti() {
+ // A cbcond instruction immediately followed by a CTI
+ // instruction introduces pipeline stalls, we need to avoid that.
+ no_cbcond_before();
#ifdef CHECK_DELAY
assert_not_delayed("cti should not be in delay slot");
#endif
@@ -658,7 +667,6 @@
void no_cbcond_before() {
assert(offset() == 0 || !cbcond_before(), "cbcond should not follow an other cbcond");
}
-
public:
bool use_cbcond(Label& L) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -54,33 +54,33 @@
inline void Assembler::add(Register s1, Register s2, Register d ) { emit_int32( op(arith_op) | rd(d) | op3(add_op3) | rs1(s1) | rs2(s2) ); }
inline void Assembler::add(Register s1, int simm13a, Register d ) { emit_int32( op(arith_op) | rd(d) | op3(add_op3) | rs1(s1) | immed(true) | simm(simm13a, 13) ); }
-inline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, address d, relocInfo::relocType rt ) { v9_only(); cti(); emit_data( op(branch_op) | annul(a) | cond(c) | op2(bpr_op2) | wdisp16(intptr_t(d), intptr_t(pc())) | predict(p) | rs1(s1), rt); has_delay_slot(); }
-inline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, Label& L) { bpr( c, a, p, s1, target(L)); }
+inline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, address d, relocInfo::relocType rt ) { v9_only(); insert_nop_after_cbcond(); cti(); emit_data( op(branch_op) | annul(a) | cond(c) | op2(bpr_op2) | wdisp16(intptr_t(d), intptr_t(pc())) | predict(p) | rs1(s1), rt); has_delay_slot(); }
+inline void Assembler::bpr( RCondition c, bool a, Predict p, Register s1, Label& L) { insert_nop_after_cbcond(); bpr( c, a, p, s1, target(L)); }
-inline void Assembler::fb( Condition c, bool a, address d, relocInfo::relocType rt ) { v9_dep(); cti(); emit_data( op(branch_op) | annul(a) | cond(c) | op2(fb_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt); has_delay_slot(); }
-inline void Assembler::fb( Condition c, bool a, Label& L ) { fb(c, a, target(L)); }
+inline void Assembler::fb( Condition c, bool a, address d, relocInfo::relocType rt ) { v9_dep(); insert_nop_after_cbcond(); cti(); emit_data( op(branch_op) | annul(a) | cond(c) | op2(fb_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt); has_delay_slot(); }
+inline void Assembler::fb( Condition c, bool a, Label& L ) { insert_nop_after_cbcond(); fb(c, a, target(L)); }
-inline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) { v9_only(); cti(); emit_data( op(branch_op) | annul(a) | cond(c) | op2(fbp_op2) | branchcc(cc) | predict(p) | wdisp(intptr_t(d), intptr_t(pc()), 19), rt); has_delay_slot(); }
-inline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, Label& L ) { fbp(c, a, cc, p, target(L)); }
+inline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) { v9_only(); insert_nop_after_cbcond(); cti(); emit_data( op(branch_op) | annul(a) | cond(c) | op2(fbp_op2) | branchcc(cc) | predict(p) | wdisp(intptr_t(d), intptr_t(pc()), 19), rt); has_delay_slot(); }
+inline void Assembler::fbp( Condition c, bool a, CC cc, Predict p, Label& L ) { insert_nop_after_cbcond(); fbp(c, a, cc, p, target(L)); }
-inline void Assembler::br( Condition c, bool a, address d, relocInfo::relocType rt ) { v9_dep(); cti(); emit_data( op(branch_op) | annul(a) | cond(c) | op2(br_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt); has_delay_slot(); }
-inline void Assembler::br( Condition c, bool a, Label& L ) { br(c, a, target(L)); }
+inline void Assembler::br( Condition c, bool a, address d, relocInfo::relocType rt ) { v9_dep(); insert_nop_after_cbcond(); cti(); emit_data( op(branch_op) | annul(a) | cond(c) | op2(br_op2) | wdisp(intptr_t(d), intptr_t(pc()), 22), rt); has_delay_slot(); }
+inline void Assembler::br( Condition c, bool a, Label& L ) { insert_nop_after_cbcond(); br(c, a, target(L)); }
-inline void Assembler::bp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) { v9_only(); cti(); emit_data( op(branch_op) | annul(a) | cond(c) | op2(bp_op2) | branchcc(cc) | predict(p) | wdisp(intptr_t(d), intptr_t(pc()), 19), rt); has_delay_slot(); }
-inline void Assembler::bp( Condition c, bool a, CC cc, Predict p, Label& L ) { bp(c, a, cc, p, target(L)); }
+inline void Assembler::bp( Condition c, bool a, CC cc, Predict p, address d, relocInfo::relocType rt ) { v9_only(); insert_nop_after_cbcond(); cti(); emit_data( op(branch_op) | annul(a) | cond(c) | op2(bp_op2) | branchcc(cc) | predict(p) | wdisp(intptr_t(d), intptr_t(pc()), 19), rt); has_delay_slot(); }
+inline void Assembler::bp( Condition c, bool a, CC cc, Predict p, Label& L ) { insert_nop_after_cbcond(); bp(c, a, cc, p, target(L)); }
// compare and branch
inline void Assembler::cbcond(Condition c, CC cc, Register s1, Register s2, Label& L) { cti(); no_cbcond_before(); emit_data(op(branch_op) | cond_cbcond(c) | op2(bpr_op2) | branchcc(cc) | wdisp10(intptr_t(target(L)), intptr_t(pc())) | rs1(s1) | rs2(s2)); }
inline void Assembler::cbcond(Condition c, CC cc, Register s1, int simm5, Label& L) { cti(); no_cbcond_before(); emit_data(op(branch_op) | cond_cbcond(c) | op2(bpr_op2) | branchcc(cc) | wdisp10(intptr_t(target(L)), intptr_t(pc())) | rs1(s1) | immed(true) | simm(simm5, 5)); }
-inline void Assembler::call( address d, relocInfo::relocType rt ) { cti(); emit_data( op(call_op) | wdisp(intptr_t(d), intptr_t(pc()), 30), rt); has_delay_slot(); assert(rt != relocInfo::virtual_call_type, "must use virtual_call_Relocation::spec"); }
-inline void Assembler::call( Label& L, relocInfo::relocType rt ) { call( target(L), rt); }
+inline void Assembler::call( address d, relocInfo::relocType rt ) { insert_nop_after_cbcond(); cti(); emit_data( op(call_op) | wdisp(intptr_t(d), intptr_t(pc()), 30), rt); has_delay_slot(); assert(rt != relocInfo::virtual_call_type, "must use virtual_call_Relocation::spec"); }
+inline void Assembler::call( Label& L, relocInfo::relocType rt ) { insert_nop_after_cbcond(); call( target(L), rt); }
inline void Assembler::flush( Register s1, Register s2) { emit_int32( op(arith_op) | op3(flush_op3) | rs1(s1) | rs2(s2)); }
inline void Assembler::flush( Register s1, int simm13a) { emit_data( op(arith_op) | op3(flush_op3) | rs1(s1) | immed(true) | simm(simm13a, 13)); }
-inline void Assembler::jmpl( Register s1, Register s2, Register d ) { cti(); emit_int32( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | rs2(s2)); has_delay_slot(); }
-inline void Assembler::jmpl( Register s1, int simm13a, Register d, RelocationHolder const& rspec ) { cti(); emit_data( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec); has_delay_slot(); }
+inline void Assembler::jmpl( Register s1, Register s2, Register d ) { insert_nop_after_cbcond(); cti(); emit_int32( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | rs2(s2)); has_delay_slot(); }
+inline void Assembler::jmpl( Register s1, int simm13a, Register d, RelocationHolder const& rspec ) { insert_nop_after_cbcond(); cti(); emit_data( op(arith_op) | rd(d) | op3(jmpl_op3) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec); has_delay_slot(); }
inline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, Register s2, FloatRegister d) { emit_int32( op(ldst_op) | fd(d, w) | alt_op3(ldf_op3, w) | rs1(s1) | rs2(s2) ); }
inline void Assembler::ldf(FloatRegisterImpl::Width w, Register s1, int simm13a, FloatRegister d, RelocationHolder const& rspec) { emit_data( op(ldst_op) | fd(d, w) | alt_op3(ldf_op3, w) | rs1(s1) | immed(true) | simm(simm13a, 13), rspec); }
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp
--- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -152,7 +152,7 @@
}
-int LIR_Assembler::initial_frame_size_in_bytes() {
+int LIR_Assembler::initial_frame_size_in_bytes() const {
return in_bytes(frame_map()->framesize_in_bytes());
}
@@ -182,7 +182,7 @@
int number_of_locks = entry_state->locks_size();
// Create a frame for the compiled activation.
- __ build_frame(initial_frame_size_in_bytes());
+ __ build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
// OSR buffer is
//
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp
--- a/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -55,9 +55,9 @@
}
-void C1_MacroAssembler::build_frame(int frame_size_in_bytes) {
-
- generate_stack_overflow_check(frame_size_in_bytes);
+void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
+ assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
+ generate_stack_overflow_check(bang_size_in_bytes);
// Create the frame.
save_frame_c1(frame_size_in_bytes);
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp
--- a/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -958,7 +958,7 @@
// reset handle block
__ ld_ptr(G2_thread, in_bytes(JavaThread::active_handles_offset()), G3_scratch);
- __ st_ptr(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
+ __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
// handle exceptions (exception handling will handle unlocking!)
@@ -2099,7 +2099,7 @@
int monitor_size = method->is_synchronized() ?
1*frame::interpreter_frame_monitor_size() : 0;
return size_activation_helper(method->max_locals(), method->max_stack(),
- monitor_size) + call_stub_size;
+ monitor_size) + call_stub_size;
}
void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill,
@@ -2183,31 +2183,31 @@
istate->_last_Java_pc = (intptr_t*) last_Java_pc;
}
-
-int AbstractInterpreter::layout_activation(Method* method,
- int tempcount, // Number of slots on java expression stack in use
- int popframe_extra_args,
- int moncount, // Number of active monitors
- int caller_actual_parameters,
- int callee_param_size,
- int callee_locals_size,
- frame* caller,
- frame* interpreter_frame,
- bool is_top_frame,
- bool is_bottom_frame) {
+static int frame_size_helper(int max_stack,
+ int moncount,
+ int callee_param_size,
+ int callee_locals_size,
+ bool is_top_frame,
+ int& monitor_size,
+ int& full_frame_words) {
+ int extra_locals_size = callee_locals_size - callee_param_size;
+ monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize;
+ full_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size);
+ int short_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size);
+ int frame_words = is_top_frame ? full_frame_words : short_frame_words;
- assert(popframe_extra_args == 0, "NEED TO FIX");
- // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
- // does as far as allocating an interpreter frame.
- // If interpreter_frame!=NULL, set up the method, locals, and monitors.
- // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
- // as determined by a previous call to this method.
- // It is also guaranteed to be walkable even though it is in a skeletal state
+ return frame_words;
+}
+
+int AbstractInterpreter::size_activation(int max_stack,
+ int tempcount,
+ int extra_args,
+ int moncount,
+ int callee_param_size,
+ int callee_locals_size,
+ bool is_top_frame) {
+ assert(extra_args == 0, "NEED TO FIX");
// NOTE: return size is in words not bytes
- // NOTE: tempcount is the current size of the java expression stack. For top most
- // frames we will allocate a full sized expression stack and not the curback
- // version that non-top frames have.
-
// Calculate the amount our frame will be adjust by the callee. For top frame
// this is zero.
@@ -2216,87 +2216,108 @@
// to it. So it ignores last_frame_adjust value. Seems suspicious as far
// as getting sender_sp correct.
- int extra_locals_size = callee_locals_size - callee_param_size;
- int monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize;
- int full_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
- int short_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
- int frame_words = is_top_frame ? full_frame_words : short_frame_words;
+ int unused_monitor_size = 0;
+ int unused_full_frame_words = 0;
+ return frame_size_helper(max_stack, moncount, callee_param_size, callee_locals_size, is_top_frame,
+ unused_monitor_size, unused_full_frame_words);
+}
+void AbstractInterpreter::layout_activation(Method* method,
+ int tempcount, // Number of slots on java expression stack in use
+ int popframe_extra_args,
+ int moncount, // Number of active monitors
+ int caller_actual_parameters,
+ int callee_param_size,
+ int callee_locals_size,
+ frame* caller,
+ frame* interpreter_frame,
+ bool is_top_frame,
+ bool is_bottom_frame) {
+ assert(popframe_extra_args == 0, "NEED TO FIX");
+ // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
+ // does as far as allocating an interpreter frame.
+ // Set up the method, locals, and monitors.
+ // The frame interpreter_frame is guaranteed to be the right size,
+ // as determined by a previous call to the size_activation() method.
+ // It is also guaranteed to be walkable even though it is in a skeletal state
+ // NOTE: tempcount is the current size of the java expression stack. For top most
+ // frames we will allocate a full sized expression stack and not the curback
+ // version that non-top frames have.
+ int monitor_size = 0;
+ int full_frame_words = 0;
+ int frame_words = frame_size_helper(method->max_stack(), moncount, callee_param_size, callee_locals_size,
+ is_top_frame, monitor_size, full_frame_words);
/*
- if we actually have a frame to layout we must now fill in all the pieces. This means both
+ We must now fill in all the pieces of the frame. This means both
the interpreterState and the registers.
*/
- if (interpreter_frame != NULL) {
- // MUCHO HACK
+ // MUCHO HACK
- intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words);
- // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode.
- assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation");
- frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS);
+ intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words);
+ // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode.
+ assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation");
+ frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS);
- /* Now fillin the interpreterState object */
+ /* Now fillin the interpreterState object */
- interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
+ interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
- intptr_t* locals;
+ intptr_t* locals;
+
+ // Calculate the postion of locals[0]. This is painful because of
+ // stack alignment (same as ia64). The problem is that we can
+ // not compute the location of locals from fp(). fp() will account
+ // for the extra locals but it also accounts for aligning the stack
+ // and we can't determine if the locals[0] was misaligned but max_locals
+ // was enough to have the
+ // calculate postion of locals. fp already accounts for extra locals.
+ // +2 for the static long no_params() issue.
- // Calculate the postion of locals[0]. This is painful because of
- // stack alignment (same as ia64). The problem is that we can
- // not compute the location of locals from fp(). fp() will account
- // for the extra locals but it also accounts for aligning the stack
- // and we can't determine if the locals[0] was misaligned but max_locals
- // was enough to have the
- // calculate postion of locals. fp already accounts for extra locals.
- // +2 for the static long no_params() issue.
+ if (caller->is_interpreted_frame()) {
+ // locals must agree with the caller because it will be used to set the
+ // caller's tos when we return.
+ interpreterState prev = caller->get_interpreterState();
+ // stack() is prepushed.
+ locals = prev->stack() + method->size_of_parameters();
+ } else {
+ // Lay out locals block in the caller adjacent to the register window save area.
+ //
+ // Compiled frames do not allocate a varargs area which is why this if
+ // statement is needed.
+ //
+ intptr_t* fp = interpreter_frame->fp();
+ int local_words = method->max_locals() * Interpreter::stackElementWords;
- if (caller->is_interpreted_frame()) {
- // locals must agree with the caller because it will be used to set the
- // caller's tos when we return.
- interpreterState prev = caller->get_interpreterState();
- // stack() is prepushed.
- locals = prev->stack() + method->size_of_parameters();
+ if (caller->is_compiled_frame()) {
+ locals = fp + frame::register_save_words + local_words - 1;
} else {
- // Lay out locals block in the caller adjacent to the register window save area.
- //
- // Compiled frames do not allocate a varargs area which is why this if
- // statement is needed.
- //
- intptr_t* fp = interpreter_frame->fp();
- int local_words = method->max_locals() * Interpreter::stackElementWords;
+ locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
+ }
- if (caller->is_compiled_frame()) {
- locals = fp + frame::register_save_words + local_words - 1;
- } else {
- locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
- }
+ }
+ // END MUCHO HACK
- }
- // END MUCHO HACK
-
- intptr_t* monitor_base = (intptr_t*) cur_state;
- intptr_t* stack_base = monitor_base - monitor_size;
- /* +1 because stack is always prepushed */
- intptr_t* stack = stack_base - (tempcount + 1);
+ intptr_t* monitor_base = (intptr_t*) cur_state;
+ intptr_t* stack_base = monitor_base - monitor_size;
+ /* +1 because stack is always prepushed */
+ intptr_t* stack = stack_base - (tempcount + 1);
- BytecodeInterpreter::layout_interpreterState(cur_state,
- caller,
- interpreter_frame,
- method,
- locals,
- stack,
- stack_base,
- monitor_base,
- frame_bottom,
- is_top_frame);
+ BytecodeInterpreter::layout_interpreterState(cur_state,
+ caller,
+ interpreter_frame,
+ method,
+ locals,
+ stack,
+ stack_base,
+ monitor_base,
+ frame_bottom,
+ is_top_frame);
- BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
-
- }
- return frame_words;
+ BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
}
#endif // CC_INTERP
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp
--- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -3531,7 +3531,7 @@
// was post-decremented.) Skip this address by starting at i=1, and
// touch a few more pages below. N.B. It is important to touch all
// the way down to and including i=StackShadowPages.
- for (int i = 1; i <= StackShadowPages; i++) {
+ for (int i = 1; i < StackShadowPages; i++) {
set((-i*offset)+STACK_BIAS, Rscratch);
st(G0, Rtsp, Rscratch);
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/sparc/vm/macroAssembler_sparc.inline.hpp
--- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.inline.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.inline.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -233,6 +233,7 @@
}
inline void MacroAssembler::br( Condition c, bool a, Predict p, Label& L ) {
+ insert_nop_after_cbcond();
br(c, a, p, target(L));
}
@@ -248,6 +249,7 @@
}
inline void MacroAssembler::brx( Condition c, bool a, Predict p, Label& L ) {
+ insert_nop_after_cbcond();
brx(c, a, p, target(L));
}
@@ -269,6 +271,7 @@
}
inline void MacroAssembler::fb( Condition c, bool a, Predict p, Label& L ) {
+ insert_nop_after_cbcond();
fb(c, a, p, target(L));
}
@@ -318,6 +321,7 @@
}
inline void MacroAssembler::call( Label& L, relocInfo::relocType rt ) {
+ insert_nop_after_cbcond();
MacroAssembler::call( target(L), rt);
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp
--- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -2687,7 +2687,7 @@
if (!is_critical_native) {
// reset handle block
__ ld_ptr(G2_thread, in_bytes(JavaThread::active_handles_offset()), L5);
- __ st_ptr(G0, L5, JNIHandleBlock::top_offset_in_bytes());
+ __ st(G0, L5, JNIHandleBlock::top_offset_in_bytes());
__ ld_ptr(G2_thread, in_bytes(Thread::pending_exception_offset()), G3_scratch);
check_forward_pending_exception(masm, G3_scratch);
@@ -3355,13 +3355,16 @@
Register O4array_size = O4;
Label loop;
- // Before we make new frames, check to see if stack is available.
- // Do this after the caller's return address is on top of stack
+#ifdef ASSERT
+ // Compilers generate code that bang the stack by as much as the
+ // interpreter would need. So this stack banging should never
+ // trigger a fault. Verify that it does not on non product builds.
if (UseStackBanging) {
// Get total frame size for interpreted frames
__ ld(O2UnrollBlock, Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes(), O4);
__ bang_stack_size(O4, O3, G3_scratch);
}
+#endif
__ ld(O2UnrollBlock, Deoptimization::UnrollBlock::number_of_frames_offset_in_bytes(), O4array_size);
__ ld_ptr(O2UnrollBlock, Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes(), G3pcs);
@@ -3409,9 +3412,11 @@
ResourceMark rm;
// setup code generation tools
int pad = VerifyThread ? 512 : 0;// Extra slop space for more verify code
+#ifdef ASSERT
if (UseStackBanging) {
pad += StackShadowPages*16 + 32;
}
+#endif
#ifdef _LP64
CodeBuffer buffer("deopt_blob", 2100+pad, 512);
#else
@@ -3632,9 +3637,11 @@
ResourceMark rm;
// setup code generation tools
int pad = VerifyThread ? 512 : 0;
+#ifdef ASSERT
if (UseStackBanging) {
pad += StackShadowPages*16 + 32;
}
+#endif
#ifdef _LP64
CodeBuffer buffer("uncommon_trap_blob", 2700+pad, 512);
#else
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/sparc/vm/sparc.ad
--- a/hotspot/src/cpu/sparc/vm/sparc.ad Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad Tue Apr 29 14:40:07 2014 -0700
@@ -1193,15 +1193,16 @@
st->print_cr("Verify_Thread"); st->print("\t");
}
- size_t framesize = C->frame_slots() << LogBytesPerInt;
+ size_t framesize = C->frame_size_in_bytes();
+ int bangsize = C->bang_size_in_bytes();
// Calls to C2R adapters often do not accept exceptional returns.
// We require that their callers must bang for them. But be careful, because
// some VM calls (such as call site linkage) can use several kilobytes of
// stack. But the stack safety zone should account for that.
// See bugs 4446381, 4468289, 4497237.
- if (C->need_stack_bang(framesize)) {
- st->print_cr("! stack bang"); st->print("\t");
+ if (C->need_stack_bang(bangsize)) {
+ st->print_cr("! stack bang (%d bytes)", bangsize); st->print("\t");
}
if (Assembler::is_simm13(-framesize)) {
@@ -1225,17 +1226,18 @@
__ verify_thread();
- size_t framesize = C->frame_slots() << LogBytesPerInt;
+ size_t framesize = C->frame_size_in_bytes();
assert(framesize >= 16*wordSize, "must have room for reg. save area");
assert(framesize%(2*wordSize) == 0, "must preserve 2*wordSize alignment");
+ int bangsize = C->bang_size_in_bytes();
// Calls to C2R adapters often do not accept exceptional returns.
// We require that their callers must bang for them. But be careful, because
// some VM calls (such as call site linkage) can use several kilobytes of
// stack. But the stack safety zone should account for that.
// See bugs 4446381, 4468289, 4497237.
- if (C->need_stack_bang(framesize)) {
- __ generate_stack_overflow_check(framesize);
+ if (C->need_stack_bang(bangsize)) {
+ __ generate_stack_overflow_check(bangsize);
}
if (Assembler::is_simm13(-framesize)) {
@@ -1268,7 +1270,7 @@
void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
Compile* C = ra_->C;
- if( do_polling() && ra_->C->is_method_compilation() ) {
+ if(do_polling() && ra_->C->is_method_compilation()) {
st->print("SETHI #PollAddr,L0\t! Load Polling address\n\t");
#ifdef _LP64
st->print("LDX [L0],G0\t!Poll for Safepointing\n\t");
@@ -1277,8 +1279,12 @@
#endif
}
- if( do_polling() )
+ if(do_polling()) {
+ if (UseCBCond && !ra_->C->is_method_compilation()) {
+ st->print("NOP\n\t");
+ }
st->print("RET\n\t");
+ }
st->print("RESTORE");
}
@@ -1291,15 +1297,20 @@
__ verify_thread();
// If this does safepoint polling, then do it here
- if( do_polling() && ra_->C->is_method_compilation() ) {
+ if(do_polling() && ra_->C->is_method_compilation()) {
AddressLiteral polling_page(os::get_polling_page());
__ sethi(polling_page, L0);
__ relocate(relocInfo::poll_return_type);
- __ ld_ptr( L0, 0, G0 );
+ __ ld_ptr(L0, 0, G0);
}
// If this is a return, then stuff the restore in the delay slot
- if( do_polling() ) {
+ if(do_polling()) {
+ if (UseCBCond && !ra_->C->is_method_compilation()) {
+ // Insert extra padding for the case when the epilogue is preceded by
+ // a cbcond jump, which can't be followed by a CTI instruction
+ __ nop();
+ }
__ ret();
__ delayed()->restore();
} else {
@@ -2538,7 +2549,7 @@
enc_class call_epilog %{
if( VerifyStackAtCalls ) {
MacroAssembler _masm(&cbuf);
- int framesize = ra_->C->frame_slots() << LogBytesPerInt;
+ int framesize = ra_->C->frame_size_in_bytes();
Register temp_reg = G3;
__ add(SP, framesize, temp_reg);
__ cmp(temp_reg, FP);
@@ -3330,7 +3341,18 @@
//----------Instruction Attributes---------------------------------------------
ins_attrib ins_cost(DEFAULT_COST); // Required cost attribute
ins_attrib ins_size(32); // Required size attribute (in bits)
-ins_attrib ins_avoid_back_to_back(0); // instruction should not be generated back to back
+
+// avoid_back_to_back attribute is an expression that must return
+// one of the following values defined in MachNode:
+// AVOID_NONE - instruction can be placed anywhere
+// AVOID_BEFORE - instruction cannot be placed after an
+// instruction with MachNode::AVOID_AFTER
+// AVOID_AFTER - the next instruction cannot be the one
+// with MachNode::AVOID_BEFORE
+// AVOID_BEFORE_AND_AFTER - BEFORE and AFTER attributes at
+// the same time
+ins_attrib ins_avoid_back_to_back(MachNode::AVOID_NONE);
+
ins_attrib ins_short_branch(0); // Required flag: is this instruction a
// non-matching short branch variant of some
// long branch?
@@ -6630,6 +6652,7 @@
ins_encode %{
__ encode_heap_oop($src$$Register, $dst$$Register);
%}
+ ins_avoid_back_to_back(Universe::narrow_oop_base() == NULL ? AVOID_NONE : AVOID_BEFORE);
ins_pipe(ialu_reg);
%}
@@ -9199,6 +9222,7 @@
__ ba(*L);
__ delayed()->nop();
%}
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br);
%}
@@ -9217,7 +9241,7 @@
__ ba_short(*L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_imm);
%}
@@ -9231,6 +9255,7 @@
format %{ "BP$cmp $icc,$labl" %}
// Prim = bits 24-22, Secnd = bits 31-30
ins_encode( enc_bp( labl, cmp, icc ) );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br_cc);
%}
@@ -9242,6 +9267,7 @@
format %{ "BP$cmp $icc,$labl" %}
// Prim = bits 24-22, Secnd = bits 31-30
ins_encode( enc_bp( labl, cmp, icc ) );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br_cc);
%}
@@ -9260,6 +9286,7 @@
__ bp( (Assembler::Condition)($cmp$$cmpcode), false, Assembler::ptr_cc, predict_taken, *L);
__ delayed()->nop();
%}
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br_cc);
%}
@@ -9278,6 +9305,7 @@
__ fbp( (Assembler::Condition)($cmp$$cmpcode), false, (Assembler::CC)($fcc$$reg), predict_taken, *L);
__ delayed()->nop();
%}
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br_fcc);
%}
@@ -9290,6 +9318,7 @@
format %{ "BP$cmp $icc,$labl\t! Loop end" %}
// Prim = bits 24-22, Secnd = bits 31-30
ins_encode( enc_bp( labl, cmp, icc ) );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br_cc);
%}
@@ -9302,6 +9331,7 @@
format %{ "BP$cmp $icc,$labl\t! Loop end" %}
// Prim = bits 24-22, Secnd = bits 31-30
ins_encode( enc_bp( labl, cmp, icc ) );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br_cc);
%}
@@ -9552,7 +9582,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$Register, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_reg);
%}
@@ -9570,7 +9600,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$constant, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_imm);
%}
@@ -9588,7 +9618,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$Register, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_reg);
%}
@@ -9606,7 +9636,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$constant, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_imm);
%}
@@ -9624,7 +9654,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::xcc, $op1$$Register, $op2$$Register, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_reg);
%}
@@ -9642,7 +9672,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::xcc, $op1$$Register, $op2$$constant, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_imm);
%}
@@ -9665,7 +9695,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::ptr_cc, $op1$$Register, $op2$$Register, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_reg);
%}
@@ -9687,7 +9717,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::ptr_cc, $op1$$Register, G0, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_reg);
%}
@@ -9705,7 +9735,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$Register, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_reg);
%}
@@ -9723,7 +9753,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, G0, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_reg);
%}
@@ -9742,7 +9772,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$Register, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_reg);
%}
@@ -9760,7 +9790,7 @@
__ cbcond((Assembler::Condition)($cmp$$cmpcode), Assembler::icc, $op1$$Register, $op2$$constant, *L);
%}
ins_short_branch(1);
- ins_avoid_back_to_back(1);
+ ins_avoid_back_to_back(AVOID_BEFORE_AND_AFTER);
ins_pipe(cbcond_reg_imm);
%}
@@ -9777,6 +9807,7 @@
ins_cost(BRANCH_COST);
format %{ "BR$cmp $op1,$labl" %}
ins_encode( enc_bpr( labl, cmp, op1 ) );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br_reg);
%}
@@ -9789,6 +9820,7 @@
ins_cost(BRANCH_COST);
format %{ "BR$cmp $op1,$labl" %}
ins_encode( enc_bpr( labl, cmp, op1 ) );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br_reg);
%}
@@ -9801,6 +9833,7 @@
ins_cost(BRANCH_COST);
format %{ "BR$cmp $op1,$labl" %}
ins_encode( enc_bpr( labl, cmp, op1 ) );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br_reg);
%}
@@ -9841,6 +9874,7 @@
__ bp( (Assembler::Condition)($cmp$$cmpcode), false, Assembler::xcc, predict_taken, *L);
__ delayed()->nop();
%}
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(br_cc);
%}
@@ -9968,6 +10002,7 @@
ins_cost(CALL_COST);
format %{ "CALL,static ; NOP ==> " %}
ins_encode( Java_Static_Call( meth ), call_epilog );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(simple_call);
%}
@@ -10004,6 +10039,7 @@
format %{ "CALL,runtime" %}
ins_encode( Java_To_Runtime( meth ),
call_epilog, adjust_long_from_native_call );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(simple_call);
%}
@@ -10016,6 +10052,7 @@
ins_encode( Java_To_Runtime( meth ),
call_epilog,
adjust_long_from_native_call );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(simple_call);
%}
@@ -10028,6 +10065,7 @@
ins_encode( Java_To_Runtime( meth ),
call_epilog,
adjust_long_from_native_call );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(simple_call);
%}
@@ -10041,6 +10079,7 @@
ins_cost(CALL_COST);
format %{ "Jmp $jump_target ; NOP \t! $method_oop holds method oop" %}
ins_encode(form_jmpl(jump_target));
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(tail_call);
%}
@@ -10072,6 +10111,7 @@
// opcode(Assembler::jmpl_op3, Assembler::arith_op);
// The hack duplicates the exception oop into G3, so that CreateEx can use it there.
// ins_encode( form3_rs1_simm13_rd( jump_target, 0x00, R_G0 ), move_return_pc_to_o1() );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(tail_call);
%}
@@ -10102,6 +10142,7 @@
// use the following format syntax
format %{ "Jmp rethrow_stub" %}
ins_encode(enc_rethrow);
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(tail_call);
%}
@@ -10130,6 +10171,7 @@
ins_cost(DEFAULT_COST*10);
format %{ "CALL PartialSubtypeCheck\n\tNOP" %}
ins_encode( enc_PartialSubtypeCheck() );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(partial_subtype_check_pipe);
%}
@@ -10139,6 +10181,7 @@
ins_cost(DEFAULT_COST*10);
format %{ "CALL PartialSubtypeCheck\n\tNOP\t# (sets condition codes)" %}
ins_encode( enc_PartialSubtypeCheck() );
+ ins_avoid_back_to_back(AVOID_BEFORE);
ins_pipe(partial_subtype_check_pipe);
%}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp
--- a/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/sparc/vm/templateInterpreter_sparc.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1147,7 +1147,7 @@
// reset handle block
__ ld_ptr(G2_thread, JavaThread::active_handles_offset(), G3_scratch);
- __ st_ptr(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
+ __ st(G0, G3_scratch, JNIHandleBlock::top_offset_in_bytes());
// If we have an oop result store it where it will be safe for any further gc
// until we return now that we've released the handle it might be protected by
@@ -1564,37 +1564,23 @@
int monitor_size = method->is_synchronized() ?
1*frame::interpreter_frame_monitor_size() : 0;
return size_activation_helper(method->max_locals(), method->max_stack(),
- monitor_size) + call_stub_size;
+ monitor_size) + call_stub_size;
}
-int AbstractInterpreter::layout_activation(Method* method,
- int tempcount,
- int popframe_extra_args,
- int moncount,
- int caller_actual_parameters,
- int callee_param_count,
- int callee_local_count,
- frame* caller,
- frame* interpreter_frame,
- bool is_top_frame,
- bool is_bottom_frame) {
+int AbstractInterpreter::size_activation(int max_stack,
+ int temps,
+ int extra_args,
+ int monitors,
+ int callee_params,
+ int callee_locals,
+ bool is_top_frame) {
// Note: This calculation must exactly parallel the frame setup
// in InterpreterGenerator::generate_fixed_frame.
- // If f!=NULL, set up the following variables:
- // - Lmethod
- // - Llocals
- // - Lmonitors (to the indicated number of monitors)
- // - Lesp (to the indicated number of temps)
- // The frame f (if not NULL) on entry is a description of the caller of the frame
- // we are about to layout. We are guaranteed that we will be able to fill in a
- // new interpreter frame as its callee (i.e. the stack space is allocated and
- // the amount was determined by an earlier call to this method with f == NULL).
- // On return f (if not NULL) while describe the interpreter frame we just layed out.
- int monitor_size = moncount * frame::interpreter_frame_monitor_size();
- int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
+ int monitor_size = monitors * frame::interpreter_frame_monitor_size();
assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align");
+
//
// Note: if you look closely this appears to be doing something much different
// than generate_fixed_frame. What is happening is this. On sparc we have to do
@@ -1619,146 +1605,171 @@
// there is no sense in messing working code.
//
- int rounded_cls = round_to((callee_local_count - callee_param_count), WordsPerLong);
+ int rounded_cls = round_to((callee_locals - callee_params), WordsPerLong);
assert(rounded_cls == round_to(rounded_cls, WordsPerLong), "must align");
- int raw_frame_size = size_activation_helper(rounded_cls, method->max_stack(),
- monitor_size);
+ int raw_frame_size = size_activation_helper(rounded_cls, max_stack, monitor_size);
- if (interpreter_frame != NULL) {
- // The skeleton frame must already look like an interpreter frame
- // even if not fully filled out.
- assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame");
-
- intptr_t* fp = interpreter_frame->fp();
+ return raw_frame_size;
+}
- JavaThread* thread = JavaThread::current();
- RegisterMap map(thread, false);
- // More verification that skeleton frame is properly walkable
- assert(fp == caller->sp(), "fp must match");
-
- intptr_t* montop = fp - rounded_vm_local_words;
+void AbstractInterpreter::layout_activation(Method* method,
+ int tempcount,
+ int popframe_extra_args,
+ int moncount,
+ int caller_actual_parameters,
+ int callee_param_count,
+ int callee_local_count,
+ frame* caller,
+ frame* interpreter_frame,
+ bool is_top_frame,
+ bool is_bottom_frame) {
+ // Set up the following variables:
+ // - Lmethod
+ // - Llocals
+ // - Lmonitors (to the indicated number of monitors)
+ // - Lesp (to the indicated number of temps)
+ // The frame caller on entry is a description of the caller of the
+ // frame we are about to layout. We are guaranteed that we will be
+ // able to fill in a new interpreter frame as its callee (i.e. the
+ // stack space is allocated and the amount was determined by an
+ // earlier call to the size_activation() method). On return caller
+ // while describe the interpreter frame we just layed out.
- // preallocate monitors (cf. __ add_monitor_to_stack)
- intptr_t* monitors = montop - monitor_size;
+ // The skeleton frame must already look like an interpreter frame
+ // even if not fully filled out.
+ assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame");
+
+ int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
+ int monitor_size = moncount * frame::interpreter_frame_monitor_size();
+ assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align");
+
+ intptr_t* fp = interpreter_frame->fp();
- // preallocate stack space
- intptr_t* esp = monitors - 1 -
- (tempcount * Interpreter::stackElementWords) -
- popframe_extra_args;
+ JavaThread* thread = JavaThread::current();
+ RegisterMap map(thread, false);
+ // More verification that skeleton frame is properly walkable
+ assert(fp == caller->sp(), "fp must match");
+
+ intptr_t* montop = fp - rounded_vm_local_words;
+
+ // preallocate monitors (cf. __ add_monitor_to_stack)
+ intptr_t* monitors = montop - monitor_size;
+
+ // preallocate stack space
+ intptr_t* esp = monitors - 1 -
+ (tempcount * Interpreter::stackElementWords) -
+ popframe_extra_args;
- int local_words = method->max_locals() * Interpreter::stackElementWords;
- NEEDS_CLEANUP;
- intptr_t* locals;
- if (caller->is_interpreted_frame()) {
- // Can force the locals area to end up properly overlapping the top of the expression stack.
- intptr_t* Lesp_ptr = caller->interpreter_frame_tos_address() - 1;
- // Note that this computation means we replace size_of_parameters() values from the caller
- // interpreter frame's expression stack with our argument locals
- int parm_words = caller_actual_parameters * Interpreter::stackElementWords;
- locals = Lesp_ptr + parm_words;
- int delta = local_words - parm_words;
- int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0;
- *interpreter_frame->register_addr(I5_savedSP) = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS;
- if (!is_bottom_frame) {
- // Llast_SP is set below for the current frame to SP (with the
- // extra space for the callee's locals). Here we adjust
- // Llast_SP for the caller's frame, removing the extra space
- // for the current method's locals.
- *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP);
- } else {
- assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP");
- }
+ int local_words = method->max_locals() * Interpreter::stackElementWords;
+ NEEDS_CLEANUP;
+ intptr_t* locals;
+ if (caller->is_interpreted_frame()) {
+ // Can force the locals area to end up properly overlapping the top of the expression stack.
+ intptr_t* Lesp_ptr = caller->interpreter_frame_tos_address() - 1;
+ // Note that this computation means we replace size_of_parameters() values from the caller
+ // interpreter frame's expression stack with our argument locals
+ int parm_words = caller_actual_parameters * Interpreter::stackElementWords;
+ locals = Lesp_ptr + parm_words;
+ int delta = local_words - parm_words;
+ int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0;
+ *interpreter_frame->register_addr(I5_savedSP) = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS;
+ if (!is_bottom_frame) {
+ // Llast_SP is set below for the current frame to SP (with the
+ // extra space for the callee's locals). Here we adjust
+ // Llast_SP for the caller's frame, removing the extra space
+ // for the current method's locals.
+ *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP);
} else {
- assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases");
- // Don't have Lesp available; lay out locals block in the caller
- // adjacent to the register window save area.
- //
- // Compiled frames do not allocate a varargs area which is why this if
- // statement is needed.
- //
- if (caller->is_compiled_frame()) {
- locals = fp + frame::register_save_words + local_words - 1;
- } else {
- locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
- }
- if (!caller->is_entry_frame()) {
- // Caller wants his own SP back
- int caller_frame_size = caller->cb()->frame_size();
- *interpreter_frame->register_addr(I5_savedSP) = (intptr_t)(caller->fp() - caller_frame_size) - STACK_BIAS;
+ assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP");
+ }
+ } else {
+ assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases");
+ // Don't have Lesp available; lay out locals block in the caller
+ // adjacent to the register window save area.
+ //
+ // Compiled frames do not allocate a varargs area which is why this if
+ // statement is needed.
+ //
+ if (caller->is_compiled_frame()) {
+ locals = fp + frame::register_save_words + local_words - 1;
+ } else {
+ locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
+ }
+ if (!caller->is_entry_frame()) {
+ // Caller wants his own SP back
+ int caller_frame_size = caller->cb()->frame_size();
+ *interpreter_frame->register_addr(I5_savedSP) = (intptr_t)(caller->fp() - caller_frame_size) - STACK_BIAS;
+ }
+ }
+ if (TraceDeoptimization) {
+ if (caller->is_entry_frame()) {
+ // make sure I5_savedSP and the entry frames notion of saved SP
+ // agree. This assertion duplicate a check in entry frame code
+ // but catches the failure earlier.
+ assert(*caller->register_addr(Lscratch) == *interpreter_frame->register_addr(I5_savedSP),
+ "would change callers SP");
+ }
+ if (caller->is_entry_frame()) {
+ tty->print("entry ");
+ }
+ if (caller->is_compiled_frame()) {
+ tty->print("compiled ");
+ if (caller->is_deoptimized_frame()) {
+ tty->print("(deopt) ");
}
}
- if (TraceDeoptimization) {
- if (caller->is_entry_frame()) {
- // make sure I5_savedSP and the entry frames notion of saved SP
- // agree. This assertion duplicate a check in entry frame code
- // but catches the failure earlier.
- assert(*caller->register_addr(Lscratch) == *interpreter_frame->register_addr(I5_savedSP),
- "would change callers SP");
- }
- if (caller->is_entry_frame()) {
- tty->print("entry ");
- }
- if (caller->is_compiled_frame()) {
- tty->print("compiled ");
- if (caller->is_deoptimized_frame()) {
- tty->print("(deopt) ");
- }
- }
- 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);
+ 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);
+ }
- if (method->max_locals() > 0) {
- assert(locals < caller->sp() || locals >= (caller->sp() + 16), "locals in save area");
- assert(locals < caller->fp() || locals > (caller->fp() + 16), "locals in save area");
- assert(locals < interpreter_frame->sp() || locals > (interpreter_frame->sp() + 16), "locals in save area");
- assert(locals < interpreter_frame->fp() || locals >= (interpreter_frame->fp() + 16), "locals in save area");
- }
+ if (method->max_locals() > 0) {
+ assert(locals < caller->sp() || locals >= (caller->sp() + 16), "locals in save area");
+ assert(locals < caller->fp() || locals > (caller->fp() + 16), "locals in save area");
+ assert(locals < interpreter_frame->sp() || locals > (interpreter_frame->sp() + 16), "locals in save area");
+ assert(locals < interpreter_frame->fp() || locals >= (interpreter_frame->fp() + 16), "locals in save area");
+ }
#ifdef _LP64
- assert(*interpreter_frame->register_addr(I5_savedSP) & 1, "must be odd");
+ assert(*interpreter_frame->register_addr(I5_savedSP) & 1, "must be odd");
#endif
- *interpreter_frame->register_addr(Lmethod) = (intptr_t) method;
- *interpreter_frame->register_addr(Llocals) = (intptr_t) locals;
- *interpreter_frame->register_addr(Lmonitors) = (intptr_t) monitors;
- *interpreter_frame->register_addr(Lesp) = (intptr_t) esp;
- // Llast_SP will be same as SP as there is no adapter space
- *interpreter_frame->register_addr(Llast_SP) = (intptr_t) interpreter_frame->sp() - STACK_BIAS;
- *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache();
+ *interpreter_frame->register_addr(Lmethod) = (intptr_t) method;
+ *interpreter_frame->register_addr(Llocals) = (intptr_t) locals;
+ *interpreter_frame->register_addr(Lmonitors) = (intptr_t) monitors;
+ *interpreter_frame->register_addr(Lesp) = (intptr_t) esp;
+ // Llast_SP will be same as SP as there is no adapter space
+ *interpreter_frame->register_addr(Llast_SP) = (intptr_t) interpreter_frame->sp() - STACK_BIAS;
+ *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache();
#ifdef FAST_DISPATCH
- *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table();
+ *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table();
#endif
#ifdef ASSERT
- BasicObjectLock* mp = (BasicObjectLock*)monitors;
-
- assert(interpreter_frame->interpreter_frame_method() == method, "method matches");
- assert(interpreter_frame->interpreter_frame_local_at(9) == (intptr_t *)((intptr_t)locals - (9 * Interpreter::stackElementSize)), "locals match");
- assert(interpreter_frame->interpreter_frame_monitor_end() == mp, "monitor_end matches");
- assert(((intptr_t *)interpreter_frame->interpreter_frame_monitor_begin()) == ((intptr_t *)mp)+monitor_size, "monitor_begin matches");
- assert(interpreter_frame->interpreter_frame_tos_address()-1 == esp, "esp matches");
+ BasicObjectLock* mp = (BasicObjectLock*)monitors;
- // check bounds
- intptr_t* lo = interpreter_frame->sp() + (frame::memory_parameter_word_sp_offset - 1);
- intptr_t* hi = interpreter_frame->fp() - rounded_vm_local_words;
- assert(lo < monitors && montop <= hi, "monitors in bounds");
- assert(lo <= esp && esp < monitors, "esp in bounds");
+ assert(interpreter_frame->interpreter_frame_method() == method, "method matches");
+ assert(interpreter_frame->interpreter_frame_local_at(9) == (intptr_t *)((intptr_t)locals - (9 * Interpreter::stackElementSize)), "locals match");
+ assert(interpreter_frame->interpreter_frame_monitor_end() == mp, "monitor_end matches");
+ assert(((intptr_t *)interpreter_frame->interpreter_frame_monitor_begin()) == ((intptr_t *)mp)+monitor_size, "monitor_begin matches");
+ assert(interpreter_frame->interpreter_frame_tos_address()-1 == esp, "esp matches");
+
+ // check bounds
+ intptr_t* lo = interpreter_frame->sp() + (frame::memory_parameter_word_sp_offset - 1);
+ intptr_t* hi = interpreter_frame->fp() - rounded_vm_local_words;
+ assert(lo < monitors && montop <= hi, "monitors in bounds");
+ assert(lo <= esp && esp < monitors, "esp in bounds");
#endif // ASSERT
- }
-
- return raw_frame_size;
}
//----------------------------------------------------------------------------------------------------
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -288,7 +288,7 @@
// build frame
ciMethod* m = compilation()->method();
- __ build_frame(initial_frame_size_in_bytes());
+ __ build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
// OSR buffer is
//
@@ -376,7 +376,7 @@
}
// This specifies the rsp decrement needed to build the frame
-int LIR_Assembler::initial_frame_size_in_bytes() {
+int LIR_Assembler::initial_frame_size_in_bytes() const {
// if rounding, must let FrameMap know!
// The frame_map records size in slots (32bit word)
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp
--- a/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -349,13 +349,14 @@
}
-void C1_MacroAssembler::build_frame(int frame_size_in_bytes) {
+void C1_MacroAssembler::build_frame(int frame_size_in_bytes, int bang_size_in_bytes) {
+ assert(bang_size_in_bytes >= frame_size_in_bytes, "stack bang size incorrect");
// Make sure there is enough stack space for this method's activation.
// Note that we do this before doing an enter(). This matches the
// ordering of C2's stack overflow check / rsp decrement and allows
// the SharedRuntime stack overflow handling to be consistent
// between the two compilers.
- generate_stack_overflow_check(frame_size_in_bytes);
+ generate_stack_overflow_check(bang_size_in_bytes);
push(rbp);
#ifdef TIERED
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp
--- a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1358,7 +1358,7 @@
// reset handle block
__ movptr(t, Address(thread, JavaThread::active_handles_offset()));
- __ movptr(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
+ __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
// If result was an oop then unbox and save it in the frame
{ Label L;
@@ -2342,29 +2342,42 @@
"Stack top out of range");
}
-int AbstractInterpreter::layout_activation(Method* method,
- int tempcount, //
- int popframe_extra_args,
- int moncount,
- int caller_actual_parameters,
- int callee_param_count,
- int callee_locals,
- frame* caller,
- frame* interpreter_frame,
- bool is_top_frame,
- bool is_bottom_frame) {
-
- assert(popframe_extra_args == 0, "FIX ME");
- // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
- // does as far as allocating an interpreter frame.
- // If interpreter_frame!=NULL, set up the method, locals, and monitors.
- // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
- // as determined by a previous call to this method.
- // It is also guaranteed to be walkable even though it is in a skeletal state
+
+static int frame_size_helper(int max_stack,
+ int tempcount,
+ int moncount,
+ int callee_param_count,
+ int callee_locals,
+ bool is_top_frame,
+ int& monitor_size,
+ int& full_frame_size) {
+ int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
+ monitor_size = sizeof(BasicObjectLock) * moncount;
+
+ // First calculate the frame size without any java expression stack
+ int short_frame_size = size_activation_helper(extra_locals_size,
+ monitor_size);
+
+ // Now with full size expression stack
+ full_frame_size = short_frame_size + max_stack * BytesPerWord;
+
+ // and now with only live portion of the expression stack
+ short_frame_size = short_frame_size + tempcount * BytesPerWord;
+
+ // the size the activation is right now. Only top frame is full size
+ int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
+ return frame_size;
+}
+
+int AbstractInterpreter::size_activation(int max_stack,
+ int tempcount,
+ int extra_args,
+ int moncount,
+ int callee_param_count,
+ int callee_locals,
+ bool is_top_frame) {
+ assert(extra_args == 0, "FIX ME");
// NOTE: return size is in words not bytes
- // NOTE: tempcount is the current size of the java expression stack. For top most
- // frames we will allocate a full sized expression stack and not the curback
- // version that non-top frames have.
// Calculate the amount our frame will be adjust by the callee. For top frame
// this is zero.
@@ -2374,87 +2387,102 @@
// to it. So it ignores last_frame_adjust value. Seems suspicious as far
// as getting sender_sp correct.
- int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
- int monitor_size = sizeof(BasicObjectLock) * moncount;
-
- // First calculate the frame size without any java expression stack
- int short_frame_size = size_activation_helper(extra_locals_size,
- monitor_size);
-
- // Now with full size expression stack
- int full_frame_size = short_frame_size + method->max_stack() * BytesPerWord;
-
- // and now with only live portion of the expression stack
- short_frame_size = short_frame_size + tempcount * BytesPerWord;
-
- // the size the activation is right now. Only top frame is full size
- int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
-
- if (interpreter_frame != NULL) {
+ int unused_monitor_size = 0;
+ int unused_full_frame_size = 0;
+ return frame_size_helper(max_stack, tempcount, moncount, callee_param_count, callee_locals,
+ is_top_frame, unused_monitor_size, unused_full_frame_size)/BytesPerWord;
+}
+
+void AbstractInterpreter::layout_activation(Method* method,
+ int tempcount, //
+ int popframe_extra_args,
+ int moncount,
+ int caller_actual_parameters,
+ int callee_param_count,
+ int callee_locals,
+ frame* caller,
+ frame* interpreter_frame,
+ bool is_top_frame,
+ bool is_bottom_frame) {
+
+ assert(popframe_extra_args == 0, "FIX ME");
+ // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
+ // does as far as allocating an interpreter frame.
+ // Set up the method, locals, and monitors.
+ // The frame interpreter_frame is guaranteed to be the right size,
+ // as determined by a previous call to the size_activation() method.
+ // It is also guaranteed to be walkable even though it is in a skeletal state
+ // NOTE: tempcount is the current size of the java expression stack. For top most
+ // frames we will allocate a full sized expression stack and not the curback
+ // version that non-top frames have.
+
+ int monitor_size = 0;
+ int full_frame_size = 0;
+ int frame_size = frame_size_helper(method->max_stack(), tempcount, moncount, callee_param_count, callee_locals,
+ is_top_frame, monitor_size, full_frame_size);
+
#ifdef ASSERT
- assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
+ assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
#endif
- // MUCHO HACK
-
- intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
-
- /* Now fillin the interpreterState object */
-
- // The state object is the first thing on the frame and easily located
-
- interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
-
-
- // Find the locals pointer. This is rather simple on x86 because there is no
- // confusing rounding at the callee to account for. We can trivially locate
- // our locals based on the current fp().
- // Note: the + 2 is for handling the "static long no_params() method" issue.
- // (too bad I don't really remember that issue well...)
-
- intptr_t* locals;
- // If the caller is interpreted we need to make sure that locals points to the first
- // argument that the caller passed and not in an area where the stack might have been extended.
- // because the stack to stack to converter needs a proper locals value in order to remove the
- // arguments from the caller and place the result in the proper location. Hmm maybe it'd be
- // simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code
- // adjust the stack?? HMMM QQQ
- //
- if (caller->is_interpreted_frame()) {
- // locals must agree with the caller because it will be used to set the
- // caller's tos when we return.
- interpreterState prev = caller->get_interpreterState();
- // stack() is prepushed.
- locals = prev->stack() + method->size_of_parameters();
- // locals = caller->unextended_sp() + (method->size_of_parameters() - 1);
- if (locals != interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2) {
- // os::breakpoint();
- }
- } else {
- // this is where a c2i would have placed locals (except for the +2)
- locals = interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2;
+ // MUCHO HACK
+
+ intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
+
+ /* Now fillin the interpreterState object */
+
+ // The state object is the first thing on the frame and easily located
+
+ interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
+
+
+ // Find the locals pointer. This is rather simple on x86 because there is no
+ // confusing rounding at the callee to account for. We can trivially locate
+ // our locals based on the current fp().
+ // Note: the + 2 is for handling the "static long no_params() method" issue.
+ // (too bad I don't really remember that issue well...)
+
+ intptr_t* locals;
+ // If the caller is interpreted we need to make sure that locals points to the first
+ // argument that the caller passed and not in an area where the stack might have been extended.
+ // because the stack to stack to converter needs a proper locals value in order to remove the
+ // arguments from the caller and place the result in the proper location. Hmm maybe it'd be
+ // simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code
+ // adjust the stack?? HMMM QQQ
+ //
+ if (caller->is_interpreted_frame()) {
+ // locals must agree with the caller because it will be used to set the
+ // caller's tos when we return.
+ interpreterState prev = caller->get_interpreterState();
+ // stack() is prepushed.
+ locals = prev->stack() + method->size_of_parameters();
+ // locals = caller->unextended_sp() + (method->size_of_parameters() - 1);
+ if (locals != interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2) {
+ // os::breakpoint();
}
-
- intptr_t* monitor_base = (intptr_t*) cur_state;
- intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
- /* +1 because stack is always prepushed */
- intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
-
-
- BytecodeInterpreter::layout_interpreterState(cur_state,
- caller,
- interpreter_frame,
- method,
- locals,
- stack,
- stack_base,
- monitor_base,
- frame_bottom,
- is_top_frame);
-
- // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
+ } else {
+ // this is where a c2i would have placed locals (except for the +2)
+ locals = interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2;
}
- return frame_size/BytesPerWord;
+
+ intptr_t* monitor_base = (intptr_t*) cur_state;
+ intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
+ /* +1 because stack is always prepushed */
+ intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
+
+
+ BytecodeInterpreter::layout_interpreterState(cur_state,
+ caller,
+ interpreter_frame,
+ method,
+ locals,
+ stack,
+ stack_base,
+ monitor_base,
+ frame_bottom,
+ is_top_frame);
+
+ // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
}
bool AbstractInterpreter::can_be_compiled(methodHandle m) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/globals_x86.hpp
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -162,7 +162,7 @@
"Number of milliseconds to wait before start calculating aborts " \
"for RTM locking") \
\
- experimental(bool, UseRTMXendForLockBusy, false, \
+ experimental(bool, UseRTMXendForLockBusy, true, \
"Use RTM Xend instead of Xabort when lock busy") \
\
/* assembler */ \
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1051,7 +1051,7 @@
// was post-decremented.) Skip this address by starting at i=1, and
// touch a few more pages below. N.B. It is important to touch all
// the way down to and including i=StackShadowPages.
- for (int i = 1; i <= StackShadowPages; i++) {
+ for (int i = 1; i < StackShadowPages; i++) {
// this could be any sized move but this is can be a debugging crumb
// so the bigger the better.
movptr(Address(tmp, (-i*os::vm_page_size())), size );
@@ -1488,11 +1488,10 @@
movl(retry_on_abort_count_Reg, RTMRetryCount); // Retry on abort
bind(L_rtm_retry);
}
- if (!UseRTMXendForLockBusy) {
- movptr(tmpReg, Address(objReg, 0));
- testptr(tmpReg, markOopDesc::monitor_value); // inflated vs stack-locked|neutral|biased
- jcc(Assembler::notZero, IsInflated);
- }
+ movptr(tmpReg, Address(objReg, 0));
+ testptr(tmpReg, markOopDesc::monitor_value); // inflated vs stack-locked|neutral|biased
+ jcc(Assembler::notZero, IsInflated);
+
if (PrintPreciseRTMLockingStatistics || profile_rtm) {
Label L_noincrement;
if (RTMTotalCountIncrRate > 1) {
@@ -1512,10 +1511,7 @@
Register abort_status_Reg = tmpReg; // status of abort is stored in RAX
if (UseRTMXendForLockBusy) {
xend();
- movptr(tmpReg, Address(objReg, 0));
- testptr(tmpReg, markOopDesc::monitor_value); // inflated vs stack-locked|neutral|biased
- jcc(Assembler::notZero, IsInflated);
- movptr(abort_status_Reg, 0x1); // Set the abort status to 1 (as xabort does)
+ movptr(abort_status_Reg, 0x2); // Set the abort status to 2 (so we can retry)
jmp(L_decrement_retry);
}
else {
@@ -6097,7 +6093,7 @@
// C2 compiled method's prolog code.
-void MacroAssembler::verified_entry(int framesize, bool stack_bang, bool fp_mode_24b) {
+void MacroAssembler::verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b) {
// WARNING: Initial instruction MUST be 5 bytes or longer so that
// NativeJump::patch_verified_entry will be able to patch out the entry
@@ -6105,18 +6101,20 @@
// the frame allocation can be either 3 or 6 bytes. So if we don't do
// stack bang then we must use the 6 byte frame allocation even if
// we have no frame. :-(
+ assert(stack_bang_size >= framesize || stack_bang_size <= 0, "stack bang size incorrect");
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
// Remove word for return addr
framesize -= wordSize;
+ stack_bang_size -= wordSize;
// Calls to C2R adapters often do not accept exceptional returns.
// We require that their callers must bang for them. But be careful, because
// some VM calls (such as call site linkage) can use several kilobytes of
// stack. But the stack safety zone should account for that.
// See bugs 4446381, 4468289, 4497237.
- if (stack_bang) {
- generate_stack_overflow_check(framesize);
+ if (stack_bang_size > 0) {
+ generate_stack_overflow_check(stack_bang_size);
// We always push rbp, so that on return to interpreter rbp, will be
// restored correctly and we can correct the stack.
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -1170,7 +1170,7 @@
void movl2ptr(Register dst, Register src) { LP64_ONLY(movslq(dst, src)) NOT_LP64(if (dst != src) movl(dst, src)); }
// C2 compiled method's prolog code.
- void verified_entry(int framesize, bool stack_bang, bool fp_mode_24b);
+ void verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b);
// clear memory of size 'cnt' qwords, starting at 'base'.
void clear_mem(Register base, Register cnt, Register rtmp);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -2266,7 +2266,7 @@
if (!is_critical_native) {
// reset handle block
__ movptr(rcx, Address(thread, JavaThread::active_handles_offset()));
- __ movptr(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
+ __ movl(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
// Any exception pending?
__ cmpptr(Address(thread, in_bytes(Thread::pending_exception_offset())), (int32_t)NULL_WORD);
@@ -3014,11 +3014,15 @@
// restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
__ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
- // Stack bang to make sure there's enough room for these interpreter frames.
+#ifdef ASSERT
+ // Compilers generate code that bang the stack by as much as the
+ // interpreter would need. So this stack banging should never
+ // trigger a fault. Verify that it does not on non product builds.
if (UseStackBanging) {
__ movl(rbx, Address(rdi ,Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
__ bang_stack_size(rbx, rcx);
}
+#endif
// Load array of frame pcs into ECX
__ movptr(rcx,Address(rdi,Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
@@ -3240,12 +3244,15 @@
// restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
__ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
- // Stack bang to make sure there's enough room for these interpreter frames.
+#ifdef ASSERT
+ // Compilers generate code that bang the stack by as much as the
+ // interpreter would need. So this stack banging should never
+ // trigger a fault. Verify that it does not on non product builds.
if (UseStackBanging) {
__ movl(rbx, Address(rdi ,Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
__ bang_stack_size(rbx, rcx);
}
-
+#endif
// Load array of frame pcs into ECX
__ movl(rcx,Address(rdi,Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -2509,7 +2509,7 @@
if (!is_critical_native) {
// reset handle block
__ movptr(rcx, Address(r15_thread, JavaThread::active_handles_offset()));
- __ movptr(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
+ __ movl(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
}
// pop our frame
@@ -3484,11 +3484,15 @@
// restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
__ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
- // Stack bang to make sure there's enough room for these interpreter frames.
+#ifdef ASSERT
+ // Compilers generate code that bang the stack by as much as the
+ // interpreter would need. So this stack banging should never
+ // trigger a fault. Verify that it does not on non product builds.
if (UseStackBanging) {
__ movl(rbx, Address(rdi, Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
__ bang_stack_size(rbx, rcx);
}
+#endif
// Load address of array of frame pcs into rcx
__ movptr(rcx, Address(rdi, Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
@@ -3682,11 +3686,15 @@
// restore rbp before stack bang because if stack overflow is thrown it needs to be pushed (and preserved)
__ movptr(rbp, Address(rdi, Deoptimization::UnrollBlock::initial_info_offset_in_bytes()));
- // Stack bang to make sure there's enough room for these interpreter frames.
+#ifdef ASSERT
+ // Compilers generate code that bang the stack by as much as the
+ // interpreter would need. So this stack banging should never
+ // trigger a fault. Verify that it does not on non product builds.
if (UseStackBanging) {
__ movl(rbx, Address(rdi ,Deoptimization::UnrollBlock::total_frame_sizes_offset_in_bytes()));
__ bang_stack_size(rbx, rcx);
}
+#endif
// Load address of array of frame pcs into rcx (address*)
__ movptr(rcx, Address(rdi, Deoptimization::UnrollBlock::frame_pcs_offset_in_bytes()));
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/templateInterpreter_x86.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,124 @@
+/*
+ * 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
+ * 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 "ci/ciMethod.hpp"
+#include "interpreter/interpreter.hpp"
+#include "runtime/frame.inline.hpp"
+
+#ifndef CC_INTERP
+
+// asm based interpreter deoptimization helpers
+int AbstractInterpreter::size_activation(int max_stack,
+ int temps,
+ int extra_args,
+ int monitors,
+ int callee_params,
+ int callee_locals,
+ bool is_top_frame) {
+ // Note: This calculation must exactly parallel the frame setup
+ // in AbstractInterpreterGenerator::generate_method_entry.
+
+ // fixed size of an interpreter frame:
+ int overhead = frame::sender_sp_offset -
+ frame::interpreter_frame_initial_sp_offset;
+ // Our locals were accounted for by the caller (or last_frame_adjust
+ // on the transistion) Since the callee parameters already account
+ // for the callee's params we only need to account for the extra
+ // locals.
+ int size = overhead +
+ (callee_locals - callee_params)*Interpreter::stackElementWords +
+ monitors * frame::interpreter_frame_monitor_size() +
+ temps* Interpreter::stackElementWords + extra_args;
+
+ return size;
+}
+
+void AbstractInterpreter::layout_activation(Method* method,
+ int tempcount,
+ int popframe_extra_args,
+ int moncount,
+ int caller_actual_parameters,
+ int callee_param_count,
+ int callee_locals,
+ frame* caller,
+ frame* interpreter_frame,
+ bool is_top_frame,
+ bool is_bottom_frame) {
+ // The frame interpreter_frame is guaranteed to be the right size,
+ // as determined by a previous call to the size_activation() method.
+ // It is also guaranteed to be walkable even though it is in a
+ // skeletal state
+
+ int max_locals = method->max_locals() * Interpreter::stackElementWords;
+ int extra_locals = (method->max_locals() - method->size_of_parameters()) *
+ Interpreter::stackElementWords;
+
+#ifdef ASSERT
+ if (!EnableInvokeDynamic) {
+ // @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences?
+ // Probably, since deoptimization doesn't work yet.
+ assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
+ }
+ assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)");
+#endif
+
+ interpreter_frame->interpreter_frame_set_method(method);
+ // NOTE the difference in using sender_sp and
+ // interpreter_frame_sender_sp interpreter_frame_sender_sp is
+ // the original sp of the caller (the unextended_sp) and
+ // sender_sp is fp+8/16 (32bit/64bit) XXX
+ intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
+
+#ifdef ASSERT
+ if (caller->is_interpreted_frame()) {
+ assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
+ }
+#endif
+
+ interpreter_frame->interpreter_frame_set_locals(locals);
+ BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
+ BasicObjectLock* monbot = montop - moncount;
+ interpreter_frame->interpreter_frame_set_monitor_end(monbot);
+
+ // Set last_sp
+ intptr_t* esp = (intptr_t*) monbot -
+ tempcount*Interpreter::stackElementWords -
+ popframe_extra_args;
+ interpreter_frame->interpreter_frame_set_last_sp(esp);
+
+ // All frames but the initial (oldest) interpreter frame we fill in have
+ // a value for sender_sp that allows walking the stack but isn't
+ // truly correct. Correct the value here.
+ if (extra_locals != 0 &&
+ interpreter_frame->sender_sp() ==
+ interpreter_frame->interpreter_frame_sender_sp()) {
+ interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +
+ extra_locals);
+ }
+ *interpreter_frame->interpreter_frame_cache_addr() =
+ method->constants()->cache();
+}
+
+#endif // CC_INTERP
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp
--- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1287,7 +1287,7 @@
// reset handle block
__ movptr(t, Address(thread, JavaThread::active_handles_offset()));
- __ movptr(Address(t, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
+ __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
// If result was an oop then unbox and save it in the frame
{ Label L;
@@ -1686,91 +1686,6 @@
return overhead_size + method_stack + stub_code;
}
-// asm based interpreter deoptimization helpers
-
-int AbstractInterpreter::layout_activation(Method* method,
- int tempcount,
- int popframe_extra_args,
- int moncount,
- int caller_actual_parameters,
- int callee_param_count,
- int callee_locals,
- frame* caller,
- frame* interpreter_frame,
- bool is_top_frame,
- bool is_bottom_frame) {
- // Note: This calculation must exactly parallel the frame setup
- // in AbstractInterpreterGenerator::generate_method_entry.
- // If interpreter_frame!=NULL, set up the method, locals, and monitors.
- // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
- // as determined by a previous call to this method.
- // It is also guaranteed to be walkable even though it is in a skeletal state
- // NOTE: return size is in words not bytes
-
- // fixed size of an interpreter frame:
- int max_locals = method->max_locals() * Interpreter::stackElementWords;
- int extra_locals = (method->max_locals() - method->size_of_parameters()) *
- Interpreter::stackElementWords;
-
- int overhead = frame::sender_sp_offset - frame::interpreter_frame_initial_sp_offset;
-
- // Our locals were accounted for by the caller (or last_frame_adjust on the transistion)
- // Since the callee parameters already account for the callee's params we only need to account for
- // the extra locals.
-
-
- int size = overhead +
- ((callee_locals - callee_param_count)*Interpreter::stackElementWords) +
- (moncount*frame::interpreter_frame_monitor_size()) +
- tempcount*Interpreter::stackElementWords + popframe_extra_args;
-
- if (interpreter_frame != NULL) {
-#ifdef ASSERT
- if (!EnableInvokeDynamic)
- // @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences?
- // Probably, since deoptimization doesn't work yet.
- assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
- assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)");
-#endif
-
- interpreter_frame->interpreter_frame_set_method(method);
- // NOTE the difference in using sender_sp and interpreter_frame_sender_sp
- // interpreter_frame_sender_sp is the original sp of the caller (the unextended_sp)
- // and sender_sp is fp+8
- intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
-
-#ifdef ASSERT
- if (caller->is_interpreted_frame()) {
- assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
- }
-#endif
-
- interpreter_frame->interpreter_frame_set_locals(locals);
- BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
- BasicObjectLock* monbot = montop - moncount;
- interpreter_frame->interpreter_frame_set_monitor_end(monbot);
-
- // Set last_sp
- intptr_t* rsp = (intptr_t*) monbot -
- tempcount*Interpreter::stackElementWords -
- popframe_extra_args;
- interpreter_frame->interpreter_frame_set_last_sp(rsp);
-
- // All frames but the initial (oldest) interpreter frame we fill in have a
- // value for sender_sp that allows walking the stack but isn't
- // truly correct. Correct the value here.
-
- if (extra_locals != 0 &&
- interpreter_frame->sender_sp() == interpreter_frame->interpreter_frame_sender_sp() ) {
- interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() + extra_locals);
- }
- *interpreter_frame->interpreter_frame_cache_addr() =
- method->constants()->cache();
- }
- return size;
-}
-
-
//------------------------------------------------------------------------------------------------------------------------
// Exceptions
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp
--- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1259,7 +1259,7 @@
// reset handle block
__ movptr(t, Address(r15_thread, JavaThread::active_handles_offset()));
- __ movptr(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
+ __ movl(Address(t, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
// If result is an oop unbox and store it in frame where gc will see it
// and result handler will pick it up
@@ -1695,87 +1695,6 @@
return (overhead_size + method_stack + stub_code);
}
-int AbstractInterpreter::layout_activation(Method* method,
- int tempcount,
- int popframe_extra_args,
- int moncount,
- int caller_actual_parameters,
- int callee_param_count,
- int callee_locals,
- frame* caller,
- frame* interpreter_frame,
- bool is_top_frame,
- bool is_bottom_frame) {
- // Note: This calculation must exactly parallel the frame setup
- // in AbstractInterpreterGenerator::generate_method_entry.
- // If interpreter_frame!=NULL, set up the method, locals, and monitors.
- // The frame interpreter_frame, if not NULL, is guaranteed to be the
- // right size, as determined by a previous call to this method.
- // It is also guaranteed to be walkable even though it is in a skeletal state
-
- // fixed size of an interpreter frame:
- int max_locals = method->max_locals() * Interpreter::stackElementWords;
- int extra_locals = (method->max_locals() - method->size_of_parameters()) *
- Interpreter::stackElementWords;
-
- int overhead = frame::sender_sp_offset -
- frame::interpreter_frame_initial_sp_offset;
- // Our locals were accounted for by the caller (or last_frame_adjust
- // on the transistion) Since the callee parameters already account
- // for the callee's params we only need to account for the extra
- // locals.
- int size = overhead +
- (callee_locals - callee_param_count)*Interpreter::stackElementWords +
- moncount * frame::interpreter_frame_monitor_size() +
- tempcount* Interpreter::stackElementWords + popframe_extra_args;
- if (interpreter_frame != NULL) {
-#ifdef ASSERT
- if (!EnableInvokeDynamic)
- // @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences?
- // Probably, since deoptimization doesn't work yet.
- assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
- assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable(2)");
-#endif
-
- interpreter_frame->interpreter_frame_set_method(method);
- // NOTE the difference in using sender_sp and
- // interpreter_frame_sender_sp interpreter_frame_sender_sp is
- // the original sp of the caller (the unextended_sp) and
- // sender_sp is fp+16 XXX
- intptr_t* locals = interpreter_frame->sender_sp() + max_locals - 1;
-
-#ifdef ASSERT
- if (caller->is_interpreted_frame()) {
- assert(locals < caller->fp() + frame::interpreter_frame_initial_sp_offset, "bad placement");
- }
-#endif
-
- interpreter_frame->interpreter_frame_set_locals(locals);
- BasicObjectLock* montop = interpreter_frame->interpreter_frame_monitor_begin();
- BasicObjectLock* monbot = montop - moncount;
- interpreter_frame->interpreter_frame_set_monitor_end(monbot);
-
- // Set last_sp
- intptr_t* esp = (intptr_t*) monbot -
- tempcount*Interpreter::stackElementWords -
- popframe_extra_args;
- interpreter_frame->interpreter_frame_set_last_sp(esp);
-
- // All frames but the initial (oldest) interpreter frame we fill in have
- // a value for sender_sp that allows walking the stack but isn't
- // truly correct. Correct the value here.
- if (extra_locals != 0 &&
- interpreter_frame->sender_sp() ==
- interpreter_frame->interpreter_frame_sender_sp()) {
- interpreter_frame->set_interpreter_frame_sender_sp(caller->sp() +
- extra_locals);
- }
- *interpreter_frame->interpreter_frame_cache_addr() =
- method->constants()->cache();
- }
- return size;
-}
-
//-----------------------------------------------------------------------------
// Exceptions
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/x86_32.ad
--- a/hotspot/src/cpu/x86/vm/x86_32.ad Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad Tue Apr 29 14:40:07 2014 -0700
@@ -512,14 +512,15 @@
void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
Compile* C = ra_->C;
- int framesize = C->frame_slots() << LogBytesPerInt;
+ int framesize = C->frame_size_in_bytes();
+ int bangsize = C->bang_size_in_bytes();
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
// Remove wordSize for return addr which is already pushed.
framesize -= wordSize;
- if (C->need_stack_bang(framesize)) {
+ if (C->need_stack_bang(bangsize)) {
framesize -= wordSize;
- st->print("# stack bang");
+ st->print("# stack bang (%d bytes)", bangsize);
st->print("\n\t");
st->print("PUSH EBP\t# Save EBP");
if (framesize) {
@@ -563,9 +564,10 @@
Compile* C = ra_->C;
MacroAssembler _masm(&cbuf);
- int framesize = C->frame_slots() << LogBytesPerInt;
-
- __ verified_entry(framesize, C->need_stack_bang(framesize), C->in_24_bit_fp_mode());
+ int framesize = C->frame_size_in_bytes();
+ int bangsize = C->bang_size_in_bytes();
+
+ __ verified_entry(framesize, C->need_stack_bang(bangsize)?bangsize:0, C->in_24_bit_fp_mode());
C->set_frame_complete(cbuf.insts_size());
@@ -589,7 +591,7 @@
#ifndef PRODUCT
void MachEpilogNode::format( PhaseRegAlloc *ra_, outputStream* st ) const {
Compile *C = ra_->C;
- int framesize = C->frame_slots() << LogBytesPerInt;
+ int framesize = C->frame_size_in_bytes();
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
// Remove two words for return addr and rbp,
framesize -= 2*wordSize;
@@ -629,7 +631,7 @@
masm.fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
}
- int framesize = C->frame_slots() << LogBytesPerInt;
+ int framesize = C->frame_size_in_bytes();
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
// Remove two words for return addr and rbp,
framesize -= 2*wordSize;
@@ -663,7 +665,7 @@
if (C->max_vector_size() > 16) size += 3; // vzeroupper
if (do_polling() && C->is_method_compilation()) size += 6;
- int framesize = C->frame_slots() << LogBytesPerInt;
+ int framesize = C->frame_size_in_bytes();
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
// Remove two words for return addr and rbp,
framesize -= 2*wordSize;
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/x86/vm/x86_64.ad
--- a/hotspot/src/cpu/x86/vm/x86_64.ad Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad Tue Apr 29 14:40:07 2014 -0700
@@ -713,14 +713,15 @@
void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
Compile* C = ra_->C;
- int framesize = C->frame_slots() << LogBytesPerInt;
+ int framesize = C->frame_size_in_bytes();
+ int bangsize = C->bang_size_in_bytes();
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
// Remove wordSize for return addr which is already pushed.
framesize -= wordSize;
- if (C->need_stack_bang(framesize)) {
+ if (C->need_stack_bang(bangsize)) {
framesize -= wordSize;
- st->print("# stack bang");
+ st->print("# stack bang (%d bytes)", bangsize);
st->print("\n\t");
st->print("pushq rbp\t# Save rbp");
if (framesize) {
@@ -751,9 +752,10 @@
Compile* C = ra_->C;
MacroAssembler _masm(&cbuf);
- int framesize = C->frame_slots() << LogBytesPerInt;
-
- __ verified_entry(framesize, C->need_stack_bang(framesize), false);
+ int framesize = C->frame_size_in_bytes();
+ int bangsize = C->bang_size_in_bytes();
+
+ __ verified_entry(framesize, C->need_stack_bang(bangsize)?bangsize:0, false);
C->set_frame_complete(cbuf.insts_size());
@@ -786,7 +788,7 @@
st->cr(); st->print("\t");
}
- int framesize = C->frame_slots() << LogBytesPerInt;
+ int framesize = C->frame_size_in_bytes();
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
// Remove word for return adr already pushed
// and RBP
@@ -822,7 +824,7 @@
__ vzeroupper();
}
- int framesize = C->frame_slots() << LogBytesPerInt;
+ int framesize = C->frame_size_in_bytes();
assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
// Remove word for return adr already pushed
// and RBP
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
--- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -916,17 +916,32 @@
return (InterpreterFrame *) fp;
}
-int AbstractInterpreter::layout_activation(Method* method,
- int tempcount,
- int popframe_extra_args,
- int moncount,
- int caller_actual_parameters,
- int callee_param_count,
- int callee_locals,
- frame* caller,
- frame* interpreter_frame,
- bool is_top_frame,
- bool is_bottom_frame) {
+int AbstractInterpreter::size_activation(int max_stack,
+ int tempcount,
+ int extra_args,
+ int moncount,
+ int callee_param_count,
+ int callee_locals,
+ bool is_top_frame) {
+ int header_words = InterpreterFrame::header_words;
+ int monitor_words = moncount * frame::interpreter_frame_monitor_size();
+ int stack_words = is_top_frame ? max_stack : tempcount;
+ int callee_extra_locals = callee_locals - callee_param_count;
+
+ return header_words + monitor_words + stack_words + callee_extra_locals;
+}
+
+void AbstractInterpreter::layout_activation(Method* method,
+ int tempcount,
+ int popframe_extra_args,
+ int moncount,
+ int caller_actual_parameters,
+ int callee_param_count,
+ int callee_locals,
+ frame* caller,
+ frame* interpreter_frame,
+ bool is_top_frame,
+ bool is_bottom_frame) {
assert(popframe_extra_args == 0, "what to do?");
assert(!is_top_frame || (!callee_locals && !callee_param_count),
"top frame should have no caller");
@@ -935,39 +950,31 @@
// does (the full InterpreterFrame::build, that is, not the
// one that creates empty frames for the deoptimizer).
//
- // If interpreter_frame is not NULL then it will be filled in.
- // It's size is determined by a previous call to this method,
- // so it should be correct.
+ // interpreter_frame will be filled in. It's size is determined by
+ // a previous call to the size_activation() method,
//
// Note that tempcount is the current size of the expression
// stack. For top most frames we will allocate a full sized
// expression stack and not the trimmed version that non-top
// frames have.
- int header_words = InterpreterFrame::header_words;
int monitor_words = moncount * frame::interpreter_frame_monitor_size();
- int stack_words = is_top_frame ? method->max_stack() : tempcount;
- int callee_extra_locals = callee_locals - callee_param_count;
-
- if (interpreter_frame) {
- intptr_t *locals = interpreter_frame->fp() + method->max_locals();
- interpreterState istate = interpreter_frame->get_interpreterState();
- intptr_t *monitor_base = (intptr_t*) istate;
- intptr_t *stack_base = monitor_base - monitor_words;
- intptr_t *stack = stack_base - tempcount - 1;
+ intptr_t *locals = interpreter_frame->fp() + method->max_locals();
+ interpreterState istate = interpreter_frame->get_interpreterState();
+ intptr_t *monitor_base = (intptr_t*) istate;
+ intptr_t *stack_base = monitor_base - monitor_words;
+ intptr_t *stack = stack_base - tempcount - 1;
- BytecodeInterpreter::layout_interpreterState(istate,
- caller,
- NULL,
- method,
- locals,
- stack,
- stack_base,
- monitor_base,
- NULL,
- is_top_frame);
- }
- return header_words + monitor_words + stack_words + callee_extra_locals;
+ BytecodeInterpreter::layout_interpreterState(istate,
+ caller,
+ NULL,
+ method,
+ locals,
+ stack,
+ stack_base,
+ monitor_base,
+ NULL,
+ is_top_frame);
}
void BytecodeInterpreter::layout_interpreterState(interpreterState istate,
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os/aix/vm/os_aix.cpp
--- a/hotspot/src/os/aix/vm/os_aix.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os/aix/vm/os_aix.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -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.
* Copyright 2012, 2014 SAP AG. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -2811,18 +2811,13 @@
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
-void os::yield_all(int attempts) {
+void os::yield_all() {
// Yields to all threads, including threads with lower priorities
// Threads on Linux are all with same priority. The Solaris style
// os::yield_all() with nanosleep(1ms) is not necessary.
sched_yield();
}
-// Called from the tight loops to possibly influence time-sharing heuristics
-void os::loop_breaker(int attempts) {
- os::yield_all(attempts);
-}
-
////////////////////////////////////////////////////////////////////////////////
// thread priority support
@@ -3079,7 +3074,7 @@
for (int n = 0; !osthread->sr.is_suspended(); n++) {
for (int i = 0; i < RANDOMLY_LARGE_INTEGER2 && !osthread->sr.is_suspended(); i++) {
- os::yield_all(i);
+ os::yield_all();
}
// timeout, try to cancel the request
@@ -3113,7 +3108,7 @@
if (sr_notify(osthread) == 0) {
for (int n = 0; n < RANDOMLY_LARGE_INTEGER && !osthread->sr.is_running(); n++) {
for (int i = 0; i < 100 && !osthread->sr.is_running(); i++) {
- os::yield_all(i);
+ os::yield_all();
}
}
} else {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os/bsd/vm/os_bsd.cpp
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -917,9 +917,20 @@
//////////////////////////////////////////////////////////////////////////////
// thread local storage
+// Restore the thread pointer if the destructor is called. This is in case
+// someone from JNI code sets up a destructor with pthread_key_create to run
+// detachCurrentThread on thread death. Unless we restore the thread pointer we
+// will hang or crash. When detachCurrentThread is called the key will be set
+// to null and we will not be called again. If detachCurrentThread is never
+// called we could loop forever depending on the pthread implementation.
+static void restore_thread_pointer(void* p) {
+ Thread* thread = (Thread*) p;
+ os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread);
+}
+
int os::allocate_thread_local_storage() {
pthread_key_t key;
- int rslt = pthread_key_create(&key, NULL);
+ int rslt = pthread_key_create(&key, restore_thread_pointer);
assert(rslt == 0, "cannot allocate thread local storage");
return (int)key;
}
@@ -2551,18 +2562,13 @@
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;}
-void os::yield_all(int attempts) {
+void os::yield_all() {
// Yields to all threads, including threads with lower priorities
// Threads on Bsd are all with same priority. The Solaris style
// os::yield_all() with nanosleep(1ms) is not necessary.
sched_yield();
}
-// Called from the tight loops to possibly influence time-sharing heuristics
-void os::loop_breaker(int attempts) {
- os::yield_all(attempts);
-}
-
////////////////////////////////////////////////////////////////////////////////
// thread priority support
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os/linux/vm/os_linux.cpp
--- a/hotspot/src/os/linux/vm/os_linux.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os/linux/vm/os_linux.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1032,9 +1032,20 @@
//////////////////////////////////////////////////////////////////////////////
// thread local storage
+// Restore the thread pointer if the destructor is called. This is in case
+// someone from JNI code sets up a destructor with pthread_key_create to run
+// detachCurrentThread on thread death. Unless we restore the thread pointer we
+// will hang or crash. When detachCurrentThread is called the key will be set
+// to null and we will not be called again. If detachCurrentThread is never
+// called we could loop forever depending on the pthread implementation.
+static void restore_thread_pointer(void* p) {
+ Thread* thread = (Thread*) p;
+ os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread);
+}
+
int os::allocate_thread_local_storage() {
pthread_key_t key;
- int rslt = pthread_key_create(&key, NULL);
+ int rslt = pthread_key_create(&key, restore_thread_pointer);
assert(rslt == 0, "cannot allocate thread local storage");
return (int)key;
}
@@ -3781,18 +3792,13 @@
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN ;}
-void os::yield_all(int attempts) {
+void os::yield_all() {
// Yields to all threads, including threads with lower priorities
// Threads on Linux are all with same priority. The Solaris style
// os::yield_all() with nanosleep(1ms) is not necessary.
sched_yield();
}
-// Called from the tight loops to possibly influence time-sharing heuristics
-void os::loop_breaker(int attempts) {
- os::yield_all(attempts);
-}
-
////////////////////////////////////////////////////////////////////////////////
// thread priority support
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os/solaris/vm/attachListener_solaris.cpp
--- a/hotspot/src/os/solaris/vm/attachListener_solaris.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os/solaris/vm/attachListener_solaris.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -29,6 +29,7 @@
#include "services/dtraceAttacher.hpp"
#include
+#include
#include
#include
#include
@@ -668,11 +669,13 @@
out->print_cr("No probe specified");
return JNI_ERR;
} else {
- int probe_typess = atoi(probe);
- if (errno) {
+ char *end;
+ long val = strtol(probe, &end, 10);
+ if (end == probe || val < 0 || val > INT_MAX) {
out->print_cr("invalid probe type");
return JNI_ERR;
} else {
+ int probe_typess = (int) val;
DTrace::enable_dprobes(probe_typess);
return JNI_OK;
}
@@ -703,8 +706,9 @@
bool flag = true;
const char* arg1;
if ((arg1 = op->arg(1)) != NULL) {
- flag = (atoi(arg1) != 0);
- if (errno) {
+ char *end;
+ flag = (strtol(arg1, &end, 10) != 0);
+ if (arg1 == end) {
out->print_cr("flag value has to be an integer");
return JNI_ERR;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os/solaris/vm/osThread_solaris.cpp
--- a/hotspot/src/os/solaris/vm/osThread_solaris.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os/solaris/vm/osThread_solaris.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -49,16 +49,6 @@
// copied from synchronizer.cpp
-void OSThread::handle_spinlock_contention(int tries) {
- if (NoYieldsInMicrolock) return;
-
- if (tries > 10) {
- os::yield_all(tries); // Yield to threads of any priority
- } else if (tries > 5) {
- os::yield(); // Yield to threads of same or higher priority
- }
-}
-
void OSThread::SR_handler(Thread* thread, ucontext_t* uc) {
os::Solaris::SR_handler(thread, uc);
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os/solaris/vm/osThread_solaris.hpp
--- a/hotspot/src/os/solaris/vm/osThread_solaris.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os/solaris/vm/osThread_solaris.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -82,8 +82,6 @@
void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; }
static void SR_handler(Thread* thread, ucontext_t* uc);
- static void handle_spinlock_contention(int tries); // Used for thread local eden locking
-
// ***************************************************************
// Platform dependent initialization and cleanup
// ***************************************************************
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os/solaris/vm/os_solaris.cpp
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -969,9 +969,6 @@
return true;
}
-// _T2_libthread is true if we believe we are running with the newer
-// SunSoft lwp/libthread.so (2.8 patch, 2.9 default)
-bool os::Solaris::_T2_libthread = false;
bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) {
// Allocate the OSThread object
@@ -1056,71 +1053,10 @@
thread->set_osthread(osthread);
// Create the Solaris thread
- // explicit THR_BOUND for T2_libthread case in case
- // that assumption is not accurate, but our alternate signal stack
- // handling is based on it which must have bound threads
thread_t tid = 0;
- long flags = (UseDetachedThreads ? THR_DETACHED : 0) | THR_SUSPENDED
- | ((UseBoundThreads || os::Solaris::T2_libthread() ||
- (thr_type == vm_thread) ||
- (thr_type == cgc_thread) ||
- (thr_type == pgc_thread) ||
- (thr_type == compiler_thread && BackgroundCompilation)) ?
- THR_BOUND : 0);
+ long flags = (UseDetachedThreads ? THR_DETACHED : 0) | THR_SUSPENDED;
int status;
- // 4376845 -- libthread/kernel don't provide enough LWPs to utilize all CPUs.
- //
- // On multiprocessors systems, libthread sometimes under-provisions our
- // process with LWPs. On a 30-way systems, for instance, we could have
- // 50 user-level threads in ready state and only 2 or 3 LWPs assigned
- // to our process. This can result in under utilization of PEs.
- // I suspect the problem is related to libthread's LWP
- // pool management and to the kernel's SIGBLOCKING "last LWP parked"
- // upcall policy.
- //
- // The following code is palliative -- it attempts to ensure that our
- // process has sufficient LWPs to take advantage of multiple PEs.
- // Proper long-term cures include using user-level threads bound to LWPs
- // (THR_BOUND) or using LWP-based synchronization. Note that there is a
- // slight timing window with respect to sampling _os_thread_count, but
- // the race is benign. Also, we should periodically recompute
- // _processors_online as the min of SC_NPROCESSORS_ONLN and the
- // the number of PEs in our partition. You might be tempted to use
- // THR_NEW_LWP here, but I'd recommend against it as that could
- // result in undesirable growth of the libthread's LWP pool.
- // The fix below isn't sufficient; for instance, it doesn't take into count
- // LWPs parked on IO. It does, however, help certain CPU-bound benchmarks.
- //
- // Some pathologies this scheme doesn't handle:
- // * Threads can block, releasing the LWPs. The LWPs can age out.
- // When a large number of threads become ready again there aren't
- // enough LWPs available to service them. This can occur when the
- // number of ready threads oscillates.
- // * LWPs/Threads park on IO, thus taking the LWP out of circulation.
- //
- // Finally, we should call thr_setconcurrency() periodically to refresh
- // the LWP pool and thwart the LWP age-out mechanism.
- // The "+3" term provides a little slop -- we want to slightly overprovision.
-
- if (AdjustConcurrency && os::Solaris::_os_thread_count < (_processors_online+3)) {
- if (!(flags & THR_BOUND)) {
- thr_setconcurrency (os::Solaris::_os_thread_count); // avoid starvation
- }
- }
- // Although this doesn't hurt, we should warn of undefined behavior
- // when using unbound T1 threads with schedctl(). This should never
- // happen, as the compiler and VM threads are always created bound
- DEBUG_ONLY(
- if ((VMThreadHintNoPreempt || CompilerThreadHintNoPreempt) &&
- (!os::Solaris::T2_libthread() && (!(flags & THR_BOUND))) &&
- ((thr_type == vm_thread) || (thr_type == cgc_thread) ||
- (thr_type == pgc_thread) || (thr_type == compiler_thread && BackgroundCompilation))) {
- warning("schedctl behavior undefined when Compiler/VM/GC Threads are Unbound");
- }
- );
-
-
// Mark that we don't have an lwp or thread id yet.
// In case we attempt to set the priority before the thread starts.
osthread->set_lwp_id(-1);
@@ -1145,13 +1081,6 @@
// Remember that we created this thread so we can set priority on it
osthread->set_vm_created();
- // Set the default thread priority. If using bound threads, setting
- // lwp priority will be delayed until thread start.
- set_native_priority(thread,
- DefaultThreadPriority == -1 ?
- java_to_os_priority[NormPriority] :
- DefaultThreadPriority);
-
// Initial thread state is INITIALIZED, not SUSPENDED
osthread->set_state(INITIALIZED);
@@ -1333,39 +1262,8 @@
jt->set_stack_size(stack_size);
}
- // 5/22/01: Right now alternate signal stacks do not handle
- // throwing stack overflow exceptions, see bug 4463178
- // Until a fix is found for this, T2 will NOT imply alternate signal
- // stacks.
- // If using T2 libthread threads, install an alternate signal stack.
- // Because alternate stacks associate with LWPs on Solaris,
- // see sigaltstack(2), if using UNBOUND threads, or if UseBoundThreads
- // we prefer to explicitly stack bang.
- // If not using T2 libthread, but using UseBoundThreads any threads
- // (primordial thread, jni_attachCurrentThread) we do not create,
- // probably are not bound, therefore they can not have an alternate
- // signal stack. Since our stack banging code is generated and
- // is shared across threads, all threads must be bound to allow
- // using alternate signal stacks. The alternative is to interpose
- // on _lwp_create to associate an alt sig stack with each LWP,
- // and this could be a problem when the JVM is embedded.
- // We would prefer to use alternate signal stacks with T2
- // Since there is currently no accurate way to detect T2
- // we do not. Assuming T2 when running T1 causes sig 11s or assertions
- // on installing alternate signal stacks
-
-
- // 05/09/03: removed alternate signal stack support for Solaris
- // The alternate signal stack mechanism is no longer needed to
- // handle stack overflow. This is now handled by allocating
- // guard pages (red zone) and stackbanging.
- // Initially the alternate signal stack mechanism was removed because
- // it did not work with T1 llibthread. Alternate
- // signal stacks MUST have all threads bound to lwps. Applications
- // can create their own threads and attach them without their being
- // bound under T1. This is frequently the case for the primordial thread.
- // If we were ever to reenable this mechanism we would need to
- // use the dynamic check for T2 libthread.
+ // With the T2 libthread (T1 is no longer supported) threads are always bound
+ // and we use stackbanging in all cases.
os::Solaris::init_thread_fpu_state();
std::set_terminate(_handle_uncaught_cxx_exception);
@@ -2092,12 +1990,7 @@
}
void os::Solaris::print_libversion_info(outputStream* st) {
- if (os::Solaris::T2_libthread()) {
- st->print(" (T2 libthread)");
- }
- else {
- st->print(" (T1 libthread)");
- }
+ st->print(" (T2 libthread)");
st->cr();
}
@@ -3323,41 +3216,10 @@
os::YieldResult os::NakedYield() { thr_yield(); return os::YIELD_UNKNOWN; }
-
-// On Solaris we found that yield_all doesn't always yield to all other threads.
-// There have been cases where there is a thread ready to execute but it doesn't
-// get an lwp as the VM thread continues to spin with sleeps of 1 millisecond.
-// The 1 millisecond wait doesn't seem long enough for the kernel to issue a
-// SIGWAITING signal which will cause a new lwp to be created. So we count the
-// number of times yield_all is called in the one loop and increase the sleep
-// time after 8 attempts. If this fails too we increase the concurrency level
-// so that the starving thread would get an lwp
-
-void os::yield_all(int attempts) {
+void os::yield_all() {
// Yields to all threads, including threads with lower priorities
- if (attempts == 0) {
- os::sleep(Thread::current(), 1, false);
- } else {
- int iterations = attempts % 30;
- if (iterations == 0 && !os::Solaris::T2_libthread()) {
- // thr_setconcurrency and _getconcurrency make sense only under T1.
- int noofLWPS = thr_getconcurrency();
- if (noofLWPS < (Threads::number_of_threads() + 2)) {
- thr_setconcurrency(thr_getconcurrency() + 1);
- }
- } else if (iterations < 25) {
- os::sleep(Thread::current(), 1, false);
- } else {
- os::sleep(Thread::current(), 10, false);
- }
- }
-}
-
-// Called from the tight loops to possibly influence time-sharing heuristics
-void os::loop_breaker(int attempts) {
- os::yield_all(attempts);
-}
-
+ os::sleep(Thread::current(), 1, false);
+}
// Interface for setting lwp priorities. If we are using T2 libthread,
// which forces the use of BoundThreads or we manually set UseBoundThreads,
@@ -3365,6 +3227,9 @@
// function is meaningless in this mode so we must adjust the real lwp's priority
// The routines below implement the getting and setting of lwp priorities.
//
+// Note: T2 is now the only supported libthread. UseBoundThreads flag is
+// being deprecated and all threads are now BoundThreads
+//
// Note: There are three priority scales used on Solaris. Java priotities
// which range from 1 to 10, libthread "thr_setprio" scale which range
// from 0 to 127, and the current scheduling class of the process we
@@ -3437,29 +3302,19 @@
if (!UseThreadPriorities) return 0;
- // We are using Bound threads, we need to determine our priority ranges
- if (os::Solaris::T2_libthread() || UseBoundThreads) {
- // If ThreadPriorityPolicy is 1, switch tables
- if (ThreadPriorityPolicy == 1) {
- for (i = 0 ; i < CriticalPriority+1; i++)
- os::java_to_os_priority[i] = prio_policy1[i];
- }
- if (UseCriticalJavaThreadPriority) {
- // MaxPriority always maps to the FX scheduling class and criticalPrio.
- // See set_native_priority() and set_lwp_class_and_priority().
- // Save original MaxPriority mapping in case attempt to
- // use critical priority fails.
- java_MaxPriority_to_os_priority = os::java_to_os_priority[MaxPriority];
- // Set negative to distinguish from other priorities
- os::java_to_os_priority[MaxPriority] = -criticalPrio;
- }
- }
- // Not using Bound Threads, set to ThreadPolicy 1
- else {
- for ( i = 0 ; i < CriticalPriority+1; i++ ) {
+ // If ThreadPriorityPolicy is 1, switch tables
+ if (ThreadPriorityPolicy == 1) {
+ for (i = 0 ; i < CriticalPriority+1; i++)
os::java_to_os_priority[i] = prio_policy1[i];
- }
- return 0;
+ }
+ if (UseCriticalJavaThreadPriority) {
+ // MaxPriority always maps to the FX scheduling class and criticalPrio.
+ // See set_native_priority() and set_lwp_class_and_priority().
+ // Save original MaxPriority mapping in case attempt to
+ // use critical priority fails.
+ java_MaxPriority_to_os_priority = os::java_to_os_priority[MaxPriority];
+ // Set negative to distinguish from other priorities
+ os::java_to_os_priority[MaxPriority] = -criticalPrio;
}
// Get IDs for a set of well-known scheduling classes.
@@ -3583,10 +3438,6 @@
// set_lwp_class_and_priority
-//
-// Set the class and priority of the lwp. This call should only
-// be made when using bound threads (T2 threads are bound by default).
-//
int set_lwp_class_and_priority(int ThreadID, int lwpid,
int newPrio, int new_class, bool scale) {
int rslt;
@@ -3812,23 +3663,20 @@
status = thr_setprio(thread->osthread()->thread_id(), newpri);
}
- if (os::Solaris::T2_libthread() ||
- (UseBoundThreads && osthread->is_vm_created())) {
- int lwp_status =
- set_lwp_class_and_priority(osthread->thread_id(),
- osthread->lwp_id(),
- newpri,
- fxcritical ? fxLimits.schedPolicy : myClass,
- !fxcritical);
- if (lwp_status != 0 && fxcritical) {
- // Try again, this time without changing the scheduling class
- newpri = java_MaxPriority_to_os_priority;
- lwp_status = set_lwp_class_and_priority(osthread->thread_id(),
- osthread->lwp_id(),
- newpri, myClass, false);
- }
- status |= lwp_status;
- }
+ int lwp_status =
+ set_lwp_class_and_priority(osthread->thread_id(),
+ osthread->lwp_id(),
+ newpri,
+ fxcritical ? fxLimits.schedPolicy : myClass,
+ !fxcritical);
+ if (lwp_status != 0 && fxcritical) {
+ // Try again, this time without changing the scheduling class
+ newpri = java_MaxPriority_to_os_priority;
+ lwp_status = set_lwp_class_and_priority(osthread->thread_id(),
+ osthread->lwp_id(),
+ newpri, myClass, false);
+ }
+ status |= lwp_status;
return (status == 0) ? OS_OK : OS_ERR;
}
@@ -4495,13 +4343,6 @@
}
}
-// (Static) wrappers for the new libthread API
-int_fnP_thread_t_iP_uP_stack_tP_gregset_t os::Solaris::_thr_getstate;
-int_fnP_thread_t_i_gregset_t os::Solaris::_thr_setstate;
-int_fnP_thread_t_i os::Solaris::_thr_setmutator;
-int_fnP_thread_t os::Solaris::_thr_suspend_mutator;
-int_fnP_thread_t os::Solaris::_thr_continue_mutator;
-
// (Static) wrapper for getisax(2) call.
os::Solaris::getisax_func_t os::Solaris::_getisax = 0;
@@ -4536,78 +4377,9 @@
return addr;
}
-
-
-// isT2_libthread()
-//
-// Routine to determine if we are currently using the new T2 libthread.
-//
-// We determine if we are using T2 by reading /proc/self/lstatus and
-// looking for a thread with the ASLWP bit set. If we find this status
-// bit set, we must assume that we are NOT using T2. The T2 team
-// has approved this algorithm.
-//
-// We need to determine if we are running with the new T2 libthread
-// since setting native thread priorities is handled differently
-// when using this library. All threads created using T2 are bound
-// threads. Calling thr_setprio is meaningless in this case.
-//
-bool isT2_libthread() {
- static prheader_t * lwpArray = NULL;
- static int lwpSize = 0;
- static int lwpFile = -1;
- lwpstatus_t * that;
- char lwpName [128];
- bool isT2 = false;
-
-#define ADR(x) ((uintptr_t)(x))
-#define LWPINDEX(ary,ix) ((lwpstatus_t *)(((ary)->pr_entsize * (ix)) + (ADR((ary) + 1))))
-
- lwpFile = ::open("/proc/self/lstatus", O_RDONLY, 0);
- if (lwpFile < 0) {
- if (ThreadPriorityVerbose) warning ("Couldn't open /proc/self/lstatus\n");
- return false;
- }
- lwpSize = 16*1024;
- for (;;) {
- ::lseek64 (lwpFile, 0, SEEK_SET);
- lwpArray = (prheader_t *)NEW_C_HEAP_ARRAY(char, lwpSize, mtInternal);
- if (::read(lwpFile, lwpArray, lwpSize) < 0) {
- if (ThreadPriorityVerbose) warning("Error reading /proc/self/lstatus\n");
- break;
- }
- if ((lwpArray->pr_nent * lwpArray->pr_entsize) <= lwpSize) {
- // We got a good snapshot - now iterate over the list.
- int aslwpcount = 0;
- for (int i = 0; i < lwpArray->pr_nent; i++ ) {
- that = LWPINDEX(lwpArray,i);
- if (that->pr_flags & PR_ASLWP) {
- aslwpcount++;
- }
- }
- if (aslwpcount == 0) isT2 = true;
- break;
- }
- lwpSize = lwpArray->pr_nent * lwpArray->pr_entsize;
- FREE_C_HEAP_ARRAY(char, lwpArray, mtInternal); // retry.
- }
-
- FREE_C_HEAP_ARRAY(char, lwpArray, mtInternal);
- ::close (lwpFile);
- if (ThreadPriorityVerbose) {
- if (isT2) tty->print_cr("We are running with a T2 libthread\n");
- else tty->print_cr("We are not running with a T2 libthread\n");
- }
- return isT2;
-}
-
-
void os::Solaris::libthread_init() {
address func = (address)dlsym(RTLD_DEFAULT, "_thr_suspend_allmutators");
- // Determine if we are running with the new T2 libthread
- os::Solaris::set_T2_libthread(isT2_libthread());
-
lwp_priocntl_init();
// RTLD_DEFAULT was not defined on some early versions of 5.5.1
@@ -4618,22 +4390,6 @@
guarantee(func != NULL, "libthread.so is too old.");
}
- // Initialize the new libthread getstate API wrappers
- func = resolve_symbol("thr_getstate");
- os::Solaris::set_thr_getstate(CAST_TO_FN_PTR(int_fnP_thread_t_iP_uP_stack_tP_gregset_t, func));
-
- func = resolve_symbol("thr_setstate");
- os::Solaris::set_thr_setstate(CAST_TO_FN_PTR(int_fnP_thread_t_i_gregset_t, func));
-
- func = resolve_symbol("thr_setmutator");
- os::Solaris::set_thr_setmutator(CAST_TO_FN_PTR(int_fnP_thread_t_i, func));
-
- func = resolve_symbol("thr_suspend_mutator");
- os::Solaris::set_thr_suspend_mutator(CAST_TO_FN_PTR(int_fnP_thread_t, func));
-
- func = resolve_symbol("thr_continue_mutator");
- os::Solaris::set_thr_continue_mutator(CAST_TO_FN_PTR(int_fnP_thread_t, func));
-
int size;
void (*handler_info_func)(address *, int *);
handler_info_func = CAST_TO_FN_PTR(void (*)(address *, int *), resolve_symbol("thr_sighndlrinfo"));
@@ -5536,11 +5292,7 @@
}
bool os::is_thread_cpu_time_supported() {
- if ( os::Solaris::T2_libthread() || UseBoundThreads ) {
- return true;
- } else {
- return false;
- }
+ return true;
}
// System loadavg support. Returns -1 if load average cannot be obtained.
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os/solaris/vm/os_solaris.hpp
--- a/hotspot/src/os/solaris/vm/os_solaris.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os/solaris/vm/os_solaris.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -41,19 +41,6 @@
#define TRS_LWPID 2
#define TRS_INVALID 3
- // _T2_libthread is true if we believe we are running with the newer
- // SunSoft lib/lwp/libthread: default Solaris 9, available Solaris 8
- // which is a lightweight libthread that also supports all T1
- static bool _T2_libthread;
- // These refer to new libthread interface functions
- // They get intialized if we dynamically detect new libthread
- static int_fnP_thread_t_iP_uP_stack_tP_gregset_t _thr_getstate;
- static int_fnP_thread_t_i_gregset_t _thr_setstate;
- static int_fnP_thread_t_i _thr_setmutator;
- static int_fnP_thread_t _thr_suspend_mutator;
- static int_fnP_thread_t _thr_continue_mutator;
- // libthread_init sets the above, if the new functionality is detected
-
// initialized to libthread or lwp synchronization primitives depending on UseLWPSychronization
static int_fnP_mutex_tP _mutex_lock;
static int_fnP_mutex_tP _mutex_trylock;
@@ -214,29 +201,6 @@
static struct sigaction *get_chained_signal_action(int sig);
static bool chained_handler(int sig, siginfo_t *siginfo, void *context);
- // The following allow us to link against both the old and new libthread (2.8)
- // and exploit the new libthread functionality if available.
-
- static bool T2_libthread() { return _T2_libthread; }
- static void set_T2_libthread(bool T2_libthread) { _T2_libthread = T2_libthread; }
-
- static int thr_getstate(thread_t tid, int *flag, unsigned *lwp, stack_t *ss, gregset_t rs)
- { return _thr_getstate(tid, flag, lwp, ss, rs); }
- static void set_thr_getstate(int_fnP_thread_t_iP_uP_stack_tP_gregset_t func)
- { _thr_getstate = func; }
-
- static int thr_setstate(thread_t tid, int flag, gregset_t rs) { return _thr_setstate(tid, flag, rs); }
- static void set_thr_setstate(int_fnP_thread_t_i_gregset_t func) { _thr_setstate = func; }
-
- static int thr_setmutator(thread_t tid, int enabled) { return _thr_setmutator(tid, enabled); }
- static void set_thr_setmutator(int_fnP_thread_t_i func) { _thr_setmutator = func; }
-
- static int thr_suspend_mutator(thread_t tid) { return _thr_suspend_mutator(tid); }
- static void set_thr_suspend_mutator(int_fnP_thread_t func) { _thr_suspend_mutator = func; }
-
- static int thr_continue_mutator(thread_t tid) { return _thr_continue_mutator(tid); }
- static void set_thr_continue_mutator(int_fnP_thread_t func) { _thr_continue_mutator = func; }
-
// Allows us to switch between lwp and thread -based synchronization
static int mutex_lock(mutex_t *mx) { return _mutex_lock(mx); }
static int mutex_trylock(mutex_t *mx) { return _mutex_trylock(mx); }
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os/windows/vm/os_windows.cpp
--- a/hotspot/src/os/windows/vm/os_windows.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os/windows/vm/os_windows.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -3518,7 +3518,7 @@
void os::yield() { os::NakedYield(); }
-void os::yield_all(int attempts) {
+void os::yield_all() {
// Yields to all threads, including threads with lower priorities
Sleep(1);
}
@@ -3864,12 +3864,6 @@
win32::setmode_streams();
init_page_sizes((size_t) win32::vm_page_size());
- // For better scalability on MP systems (must be called after initialize_system_info)
-#ifndef PRODUCT
- if (is_MP()) {
- NoYieldsInMicrolock = true;
- }
-#endif
// This may be overridden later when argument processing is done.
FLAG_SET_ERGO(bool, UseLargePagesIndividualAllocation,
os::win32::is_windows_2003());
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os/windows/vm/os_windows.inline.hpp
--- a/hotspot/src/os/windows/vm/os_windows.inline.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os/windows/vm/os_windows.inline.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -52,9 +52,6 @@
return (void*)::GetProcAddress((HMODULE)lib, name);
}
-// Used to improve time-sharing on some systems
-inline void os::loop_breaker(int attempts) {}
-
inline bool os::obsolete_option(const JavaVMOption *option) {
return false;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp
--- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -270,31 +270,6 @@
}
}
-static int threadgetstate(thread_t tid, int *flags, lwpid_t *lwp, stack_t *ss, gregset_t rs, lwpstatus_t *lwpstatus) {
- char lwpstatusfile[PROCFILE_LENGTH];
- int lwpfd, err;
-
- if (err = os::Solaris::thr_getstate(tid, flags, lwp, ss, rs))
- return (err);
- if (*flags == TRS_LWPID) {
- sprintf(lwpstatusfile, "/proc/%d/lwp/%d/lwpstatus", getpid(),
- *lwp);
- if ((lwpfd = ::open(lwpstatusfile, O_RDONLY)) < 0) {
- perror("thr_mutator_status: open lwpstatus");
- return (EINVAL);
- }
- if (pread(lwpfd, lwpstatus, sizeof (lwpstatus_t), (off_t)0) !=
- sizeof (lwpstatus_t)) {
- perror("thr_mutator_status: read lwpstatus");
- (void) ::close(lwpfd);
- return (EINVAL);
- }
- (void) ::close(lwpfd);
- }
- return (0);
-}
-
-
bool os::is_allocatable(size_t bytes) {
#ifdef _LP64
return true;
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -256,30 +256,6 @@
}
}
-static int threadgetstate(thread_t tid, int *flags, lwpid_t *lwp, stack_t *ss, gregset_t rs, lwpstatus_t *lwpstatus) {
- char lwpstatusfile[PROCFILE_LENGTH];
- int lwpfd, err;
-
- if (err = os::Solaris::thr_getstate(tid, flags, lwp, ss, rs))
- return (err);
- if (*flags == TRS_LWPID) {
- sprintf(lwpstatusfile, "/proc/%d/lwp/%d/lwpstatus", getpid(),
- *lwp);
- if ((lwpfd = open(lwpstatusfile, O_RDONLY)) < 0) {
- perror("thr_mutator_status: open lwpstatus");
- return (EINVAL);
- }
- if (pread(lwpfd, lwpstatus, sizeof (lwpstatus_t), (off_t)0) !=
- sizeof (lwpstatus_t)) {
- perror("thr_mutator_status: read lwpstatus");
- (void) close(lwpfd);
- return (EINVAL);
- }
- (void) close(lwpfd);
- }
- return (0);
-}
-
#ifndef AMD64
// Detecting SSE support by OS
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java
--- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java Tue Apr 29 14:40:07 2014 -0700
@@ -25,6 +25,7 @@
package com.sun.hotspot.tools.compiler;
import java.io.PrintStream;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
@@ -40,6 +41,7 @@
private int endNodes;
private int endLiveNodes;
private double timeStamp;
+ private long inlineId;
CallSite() {
}
@@ -94,7 +96,7 @@
public void print(PrintStream stream, int indent) {
emit(stream, indent);
- String m = getMethod().getHolder().replace('/', '.') + "::" + getMethod().getName();
+ String m = getMethod().getHolder() + "::" + getMethod().getName();
if (getReason() == null) {
stream.print(" @ " + getBci() + " " + m + " (" + getMethod().getBytes() + " bytes)");
@@ -214,4 +216,45 @@
return timeStamp;
}
+ private boolean matches(CallSite other) {
+ // Every late inline call site has a unique inline id. If the
+ // call site we're looking for has one then use it other rely
+ // on method name and bci.
+ if (other.inlineId != 0) {
+ return inlineId == other.inlineId;
+ }
+ return method.equals(other.method) && bci == other.bci;
+ }
+
+ public CallSite findCallSite(ArrayDeque sites) {
+ // Locate a late inline call site. Multiple chains of
+ // identical call sites with the same method name/bci are
+ // possible so we have to try them all until we find the late
+ // inline call site that has a matching inline id.
+ CallSite site = sites.pop();
+ for (CallSite c : calls) {
+ if (c.matches(site)) {
+ if (!sites.isEmpty()) {
+ CallSite res = c.findCallSite(sites);
+ if (res != null) {
+ sites.push(site);
+ return res;
+ }
+ } else {
+ sites.push(site);
+ return c;
+ }
+ }
+ }
+ sites.push(site);
+ return null;
+ }
+
+ public long getInlineId() {
+ return inlineId;
+ }
+
+ public void setInlineId(long inlineId) {
+ this.inlineId = inlineId;
+ }
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java
--- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java Tue Apr 29 14:40:07 2014 -0700
@@ -31,6 +31,7 @@
import java.io.FileReader;
import java.io.Reader;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -144,9 +145,12 @@
private Stack scopes = new Stack();
private Compilation compile;
private CallSite site;
+ private CallSite methodHandleSite;
private Stack phaseStack = new Stack();
private UncommonTrapEvent currentTrap;
- private Stack late_inline_scope;
+ private Stack lateInlineScope;
+ private boolean lateInlining;
+
long parseLong(String l) {
try {
@@ -330,18 +334,61 @@
}
methods.put(id, m);
} else if (qname.equals("call")) {
- site = new CallSite(bci, method(search(atts, "method")));
+ if (methodHandleSite != null) {
+ methodHandleSite = null;
+ }
+ Method m = method(search(atts, "method"));
+ if (lateInlining && scopes.size() == 0) {
+ // re-attempting already seen call site (late inlining for MH invokes)
+ if (m != site.getMethod()) {
+ if (bci != site.getBci()) {
+ System.out.println(m + " bci: " + bci);
+ System.out.println(site.getMethod() + " bci: " + site.getBci());
+ throw new InternalError("bci mismatch after late inlining");
+ }
+ site.setMethod(m);
+ }
+ } else {
+ site = new CallSite(bci, m);
+ }
site.setCount(Integer.parseInt(search(atts, "count", "0")));
String receiver = atts.getValue("receiver");
if (receiver != null) {
site.setReceiver(type(receiver));
site.setReceiver_count(Integer.parseInt(search(atts, "receiver_count")));
}
- scopes.peek().add(site);
+ int methodHandle = Integer.parseInt(search(atts, "method_handle_intrinsic", "0"));
+ if (lateInlining && scopes.size() == 0) {
+ // The call was added before this round of late inlining
+ } else if (methodHandle == 0) {
+ scopes.peek().add(site);
+ } else {
+ // method handle call site can be followed by another
+ // call (in case it is inlined). If that happens we
+ // discard the method handle call site. So we keep
+ // track of it but don't add it to the list yet.
+ methodHandleSite = site;
+ }
} else if (qname.equals("regalloc")) {
compile.setAttempts(Integer.parseInt(search(atts, "attempts")));
} else if (qname.equals("inline_fail")) {
- scopes.peek().last().setReason(search(atts, "reason"));
+ if (methodHandleSite != null) {
+ scopes.peek().add(methodHandleSite);
+ methodHandleSite = null;
+ }
+ if (lateInlining && scopes.size() == 0) {
+ site.setReason(search(atts, "reason"));
+ lateInlining = false;
+ } else {
+ scopes.peek().last().setReason(search(atts, "reason"));
+ }
+ } else if (qname.equals("inline_success")) {
+ if (methodHandleSite != null) {
+ throw new InternalError("method handle site should have been replaced");
+ }
+ if (lateInlining && scopes.size() == 0) {
+ site.setReason(null);
+ }
} else if (qname.equals("failure")) {
failureReason = search(atts, "reason");
} else if (qname.equals("task_done")) {
@@ -371,22 +418,30 @@
// ignore for now
}
} else if (qname.equals("late_inline")) {
- late_inline_scope = new Stack();
+ long inlineId = Long.parseLong(search(atts, "inline_id"));
+ lateInlineScope = new Stack();
site = new CallSite(-999, method(search(atts, "method")));
- late_inline_scope.push(site);
+ site.setInlineId(inlineId);
+ lateInlineScope.push(site);
} else if (qname.equals("jvms")) {
//
if (currentTrap != null) {
currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci")));
- } else if (late_inline_scope != null) {
+ } else if (lateInlineScope != null) {
bci = Integer.parseInt(search(atts, "bci"));
site = new CallSite(bci, method(search(atts, "method")));
- late_inline_scope.push(site);
+ lateInlineScope.push(site);
} else {
// Ignore ,
// ,
//
}
+ } else if (qname.equals("inline_id")) {
+ if (methodHandleSite != null) {
+ throw new InternalError("method handle site should have been replaced");
+ }
+ long id = Long.parseLong(search(atts, "id"));
+ site.setInlineId(id);
} else if (qname.equals("nmethod")) {
String id = makeId(atts);
NMethod nm = new NMethod(Double.parseDouble(search(atts, "stamp")),
@@ -396,8 +451,18 @@
nmethods.put(id, nm);
events.add(nm);
} else if (qname.equals("parse")) {
+ if (methodHandleSite != null) {
+ throw new InternalError("method handle site should have been replaced");
+ }
Method m = method(search(atts, "method"));
- if (scopes.size() == 0) {
+ if (lateInlining && scopes.size() == 0) {
+ if (site.getMethod() != m) {
+ System.out.println(site.getMethod());
+ System.out.println(m);
+ throw new InternalError("Unexpected method mismatch during late inlining");
+ }
+ }
+ if (scopes.size() == 0 && !lateInlining) {
compile.setMethod(m);
scopes.push(site);
} else {
@@ -427,14 +492,19 @@
if (qname.equals("parse")) {
indent -= 2;
scopes.pop();
+ if (scopes.size() == 0) {
+ lateInlining = false;
+ }
} else if (qname.equals("uncommon_trap")) {
currentTrap = null;
} else if (qname.equals("late_inline")) {
// Populate late inlining info.
-
- // late_inline scopes are specified in reverse order:
+ if (scopes.size() != 0) {
+ throw new InternalError("scopes should be empty for late inline");
+ }
+ // late inline scopes are specified in reverse order:
// compiled method should be on top of stack.
- CallSite caller = late_inline_scope.pop();
+ CallSite caller = lateInlineScope.pop();
Method m = compile.getMethod();
if (m != caller.getMethod()) {
System.out.println(m);
@@ -444,28 +514,42 @@
// late_inline contains caller+bci info, convert it
// to bci+callee info used by LogCompilation.
- site = compile.getLateInlineCall();
+ CallSite lateInlineSite = compile.getLateInlineCall();
+ ArrayDeque thisCallScopes = new ArrayDeque();
do {
bci = caller.getBci();
// Next inlined call.
- caller = late_inline_scope.pop();
+ caller = lateInlineScope.pop();
CallSite callee = new CallSite(bci, caller.getMethod());
- site.add(callee);
- site = callee;
- } while (!late_inline_scope.empty());
+ callee.setInlineId(caller.getInlineId());
+ thisCallScopes.addLast(callee);
+ lateInlineSite.add(callee);
+ lateInlineSite = callee;
+ } while (!lateInlineScope.empty());
+
+ site = compile.getCall().findCallSite(thisCallScopes);
+ if (site == null) {
+ System.out.println(caller.getMethod() + " bci: " + bci);
+ throw new InternalError("couldn't find call site");
+ }
+ lateInlining = true;
if (caller.getBci() != -999) {
System.out.println(caller.getMethod());
throw new InternalError("broken late_inline info");
}
if (site.getMethod() != caller.getMethod()) {
- System.out.println(site.getMethod());
- System.out.println(caller.getMethod());
- throw new InternalError("call site and late_inline info don't match");
+ if (site.getInlineId() == caller.getInlineId()) {
+ site.setMethod(caller.getMethod());
+ } else {
+ System.out.println(site.getMethod());
+ System.out.println(caller.getMethod());
+ throw new InternalError("call site and late_inline info don't match");
+ }
}
// late_inline is followed by parse with scopes.size() == 0,
// 'site' will be pushed to scopes.
- late_inline_scope = null;
+ lateInlineScope = null;
} else if (qname.equals("task")) {
types.clear();
methods.clear();
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.java
--- a/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.java Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Method.java Tue Apr 29 14:40:07 2014 -0700
@@ -51,15 +51,15 @@
String format(int osr_bci) {
if (osr_bci >= 0) {
- return getHolder().replace('/', '.') + "::" + getName() + " @ " + osr_bci + " (" + getBytes() + " bytes)";
+ return getHolder() + "::" + getName() + " @ " + osr_bci + " (" + getBytes() + " bytes)";
} else {
- return getHolder().replace('/', '.') + "::" + getName() + " (" + getBytes() + " bytes)";
+ return getHolder() + "::" + getName() + " (" + getBytes() + " bytes)";
}
}
@Override
public String toString() {
- return getHolder().replace('/', '.') + "::" + getName() + " (" + getBytes() + " bytes)";
+ return getHolder() + "::" + getName() + " (" + getBytes() + " bytes)";
}
public String getHolder() {
@@ -117,4 +117,14 @@
public void setFlags(String flags) {
this.flags = flags;
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof Method) {
+ Method other = (Method)o;
+ return holder.equals(other.holder) && name.equals(other.name) &&
+ arguments.equals(other.arguments) && returnType.equals(other.returnType);
+ }
+ return false;
+ }
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/adlc/output_h.cpp
--- a/hotspot/src/share/vm/adlc/output_h.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/adlc/output_h.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1613,21 +1613,20 @@
// Each instruction attribute results in a virtual call of same name.
// The ins_cost is not handled here.
Attribute *attr = instr->_attribs;
- bool avoid_back_to_back = false;
+ Attribute *avoid_back_to_back_attr = NULL;
while (attr != NULL) {
- if (strcmp (attr->_ident, "ins_cost") != 0 &&
+ if (strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") == 0) {
+ fprintf(fp, " virtual bool is_TrapBasedCheckNode() const { return %s; }\n", attr->_val);
+ } else if (strcmp (attr->_ident, "ins_cost") != 0 &&
strncmp(attr->_ident, "ins_field_", 10) != 0 &&
// Must match function in node.hpp: return type bool, no prefix "ins_".
strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") != 0 &&
strcmp (attr->_ident, "ins_short_branch") != 0) {
fprintf(fp, " virtual int %s() const { return %s; }\n", attr->_ident, attr->_val);
}
- // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag
- if (!strcmp(attr->_ident, "ins_avoid_back_to_back") != 0 && attr->int_val(*this) != 0)
- avoid_back_to_back = true;
- if (strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") == 0)
- fprintf(fp, " virtual bool is_TrapBasedCheckNode() const { return %s; }\n", attr->_val);
-
+ if (strcmp(attr->_ident, "ins_avoid_back_to_back") == 0) {
+ avoid_back_to_back_attr = attr;
+ }
attr = (Attribute *)attr->_next;
}
@@ -1799,11 +1798,11 @@
}
// flag: if this instruction should not be generated back to back.
- if ( avoid_back_to_back ) {
- if ( node_flags_set ) {
- fprintf(fp," | Flag_avoid_back_to_back");
+ if (avoid_back_to_back_attr != NULL) {
+ if (node_flags_set) {
+ fprintf(fp," | (%s)", avoid_back_to_back_attr->_val);
} else {
- fprintf(fp,"init_flags(Flag_avoid_back_to_back");
+ fprintf(fp,"init_flags((%s)", avoid_back_to_back_attr->_val);
node_flags_set = true;
}
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/asm/codeBuffer.cpp
--- a/hotspot/src/share/vm/asm/codeBuffer.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/asm/codeBuffer.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -968,6 +968,7 @@
void CodeBuffer::log_section_sizes(const char* name) {
if (xtty != NULL) {
+ ttyLocker ttyl;
// log info about buffer usage
xtty->print_cr("", name, _total_size);
for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/c1/c1_Compilation.cpp
--- a/hotspot/src/share/vm/c1/c1_Compilation.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -546,6 +546,7 @@
, _code(buffer_blob)
, _has_access_indexed(false)
, _current_instruction(NULL)
+, _interpreter_frame_size(0)
#ifndef PRODUCT
, _last_instruction_printed(NULL)
#endif // PRODUCT
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/c1/c1_Compilation.hpp
--- a/hotspot/src/share/vm/c1/c1_Compilation.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -88,6 +88,7 @@
CodeOffsets _offsets;
CodeBuffer _code;
bool _has_access_indexed;
+ int _interpreter_frame_size; // Stack space needed in case of a deoptimization
// compilation helpers
void initialize();
@@ -262,6 +263,18 @@
// Dump inlining replay data to the stream.
void dump_inline_data(outputStream* out) { /* do nothing now */ }
+
+ // How much stack space would the interpreter need in case of a
+ // deoptimization (worst case)
+ void update_interpreter_frame_size(int size) {
+ if (_interpreter_frame_size < size) {
+ _interpreter_frame_size = size;
+ }
+ }
+
+ int interpreter_frame_size() const {
+ return _interpreter_frame_size;
+ }
};
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/c1/c1_IR.cpp
--- a/hotspot/src/share/vm/c1/c1_IR.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/c1/c1_IR.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -227,8 +227,38 @@
_oop_map->set_oop(name);
}
+// Mirror the stack size calculation in the deopt code
+// How much stack space would we need at this point in the program in
+// case of deoptimization?
+int CodeEmitInfo::interpreter_frame_size() const {
+ ValueStack* state = _stack;
+ int size = 0;
+ int callee_parameters = 0;
+ int callee_locals = 0;
+ int extra_args = state->scope()->method()->max_stack() - state->stack_size();
+ while (state != NULL) {
+ int locks = state->locks_size();
+ int temps = state->stack_size();
+ bool is_top_frame = (state == _stack);
+ ciMethod* method = state->scope()->method();
+ int frame_size = BytesPerWord * Interpreter::size_activation(method->max_stack(),
+ temps + callee_parameters,
+ extra_args,
+ locks,
+ callee_parameters,
+ callee_locals,
+ is_top_frame);
+ size += frame_size;
+
+ callee_parameters = method->size_of_parameters();
+ callee_locals = method->max_locals();
+ extra_args = 0;
+ state = state->caller_state();
+ }
+ return size + Deoptimization::last_frame_adjust(0, callee_locals) * BytesPerWord;
+}
// Implementation of IR
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/c1/c1_IR.hpp
--- a/hotspot/src/share/vm/c1/c1_IR.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/c1/c1_IR.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -284,6 +284,8 @@
bool is_method_handle_invoke() const { return _is_method_handle_invoke; }
void set_is_method_handle_invoke(bool x) { _is_method_handle_invoke = x; }
+
+ int interpreter_frame_size() const;
};
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/c1/c1_LIRAssembler.cpp
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -190,6 +190,13 @@
return _masm->pc();
}
+// To bang the stack of this compiled method we use the stack size
+// that the interpreter would need in case of a deoptimization. This
+// removes the need to bang the stack in the deoptimization blob which
+// in turn simplifies stack overflow handling.
+int LIR_Assembler::bang_size_in_bytes() const {
+ return MAX2(initial_frame_size_in_bytes(), _compilation->interpreter_frame_size());
+}
void LIR_Assembler::emit_exception_entries(ExceptionInfoList* info_list) {
for (int i = 0; i < info_list->length(); i++) {
@@ -797,7 +804,7 @@
void LIR_Assembler::build_frame() {
- _masm->build_frame(initial_frame_size_in_bytes());
+ _masm->build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/c1/c1_LIRAssembler.hpp
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -132,7 +132,8 @@
int code_offset() const;
address pc() const;
- int initial_frame_size_in_bytes();
+ int initial_frame_size_in_bytes() const;
+ int bang_size_in_bytes() const;
// test for constants which can be encoded directly in instructions
static bool is_small_constant(LIR_Opr opr);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/c1/c1_LinearScan.cpp
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -2451,6 +2451,9 @@
CodeEmitInfo* info = visitor.info_at(i);
OopMap* oop_map = first_oop_map;
+ // compute worst case interpreter size in case of a deoptimization
+ _compilation->update_interpreter_frame_size(info->interpreter_frame_size());
+
if (info->stack()->locks_size() != first_info->stack()->locks_size()) {
// this info has a different number of locks then the precomputed oop map
// (possible for lock and unlock instructions) -> compute oop map with
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/c1/c1_MacroAssembler.hpp
--- a/hotspot/src/share/vm/c1/c1_MacroAssembler.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/c1/c1_MacroAssembler.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -39,7 +39,7 @@
void explicit_null_check(Register base);
void inline_cache_check(Register receiver, Register iCache);
- void build_frame(int frame_size_in_bytes);
+ void build_frame(int frame_size_in_bytes, int bang_size_in_bytes);
void remove_frame(int frame_size_in_bytes);
void unverified_entry(Register receiver, Register ic_klass);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/ci/ciKlass.cpp
--- a/hotspot/src/share/vm/ci/ciKlass.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/ci/ciKlass.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -237,3 +237,9 @@
void ciKlass::print_name_on(outputStream* st) {
name()->print_symbol_on(st);
}
+
+const char* ciKlass::external_name() const {
+ GUARDED_VM_ENTRY(
+ return get_Klass()->external_name();
+ )
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/ci/ciKlass.hpp
--- a/hotspot/src/share/vm/ci/ciKlass.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/ci/ciKlass.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -125,6 +125,8 @@
virtual ciKlass* exact_klass() = 0;
void print_name_on(outputStream* st);
+
+ const char* external_name() const;
};
#endif // SHARE_VM_CI_CIKLASS_HPP
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/ci/ciMethod.cpp
--- a/hotspot/src/share/vm/ci/ciMethod.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/ci/ciMethod.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -80,6 +80,7 @@
_code_size = h_m()->code_size();
_intrinsic_id = h_m()->intrinsic_id();
_handler_count = h_m()->exception_table_length();
+ _size_of_parameters = h_m()->size_of_parameters();
_uses_monitors = h_m()->access_flags().has_monitor_bytecodes();
_balanced_monitors = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
_is_c1_compilable = !h_m()->is_not_c1_compilable();
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/ci/ciMethod.hpp
--- a/hotspot/src/share/vm/ci/ciMethod.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/ci/ciMethod.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -71,6 +71,7 @@
int _interpreter_invocation_count;
int _interpreter_throwout_count;
int _instructions_size;
+ int _size_of_parameters;
bool _uses_monitors;
bool _balanced_monitors;
@@ -166,6 +167,7 @@
int exception_table_length() const { check_is_loaded(); return _handler_count; }
int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; }
int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; }
+ int size_of_parameters() const { check_is_loaded(); return _size_of_parameters; }
// Code size for inlining decisions.
int code_size_for_inlining();
@@ -241,7 +243,6 @@
ciField* get_field_at_bci( int bci, bool &will_link);
ciMethod* get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature);
-
// Given a certain calling environment, find the monomorphic target
// for the call. Return NULL if the call is not monomorphic in
// its calling environment.
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/ci/ciSymbol.cpp
--- a/hotspot/src/share/vm/ci/ciSymbol.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/ci/ciSymbol.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -123,6 +123,10 @@
GUARDED_VM_ENTRY(get_symbol()->print_symbol_on(st);)
}
+const char* ciSymbol::as_klass_external_name() const {
+ GUARDED_VM_ENTRY(return get_symbol()->as_klass_external_name(););
+}
+
// ------------------------------------------------------------------
// ciSymbol::make_impl
//
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/ci/ciSymbol.hpp
--- a/hotspot/src/share/vm/ci/ciSymbol.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/ci/ciSymbol.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -90,6 +90,7 @@
void print_symbol() {
print_symbol_on(tty);
}
+ const char* as_klass_external_name() const;
// Make a ciSymbol from a C string.
// Consider adding to vmSymbols.hpp instead of using this constructor.
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/classfile/classFileParser.cpp
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -2777,6 +2777,11 @@
"Short length on BootstrapMethods in class file %s",
CHECK);
+ guarantee_property(attribute_byte_length > sizeof(u2),
+ "Invalid BootstrapMethods attribute length %u in class file %s",
+ attribute_byte_length,
+ CHECK);
+
// The attribute contains a counted array of counted tuples of shorts,
// represending bootstrap specifiers:
// length*{bootstrap_method_index, argument_count*{argument_index}}
@@ -4180,8 +4185,12 @@
clear_class_metadata();
- // deallocate the klass if already created.
- MetadataFactory::free_metadata(_loader_data, _klass);
+ // deallocate the klass if already created. Don't directly deallocate, but add
+ // to the deallocate list so that the klass is removed from the CLD::_klasses list
+ // at a safepoint.
+ if (_klass != NULL) {
+ _loader_data->add_to_deallocate_list(_klass);
+ }
_klass = NULL;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/classfile/defaultMethods.cpp
--- a/hotspot/src/share/vm/classfile/defaultMethods.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/classfile/defaultMethods.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -390,20 +390,6 @@
Symbol* get_exception_message() { return _exception_message; }
Symbol* get_exception_name() { return _exception_name; }
- // Return true if the specified klass has a static method that matches
- // the name and signature of the target method.
- bool has_matching_static(InstanceKlass* root) {
- if (_members.length() > 0) {
- Pair entry = _members.at(0);
- Method* impl = root->find_method(entry.first->name(),
- entry.first->signature());
- if ((impl != NULL) && impl->is_static()) {
- return true;
- }
- }
- return false;
- }
-
// Either sets the target or the exception error message
void determine_target(InstanceKlass* root, TRAPS) {
if (has_target() || throws_exception()) {
@@ -433,21 +419,19 @@
// If the root klass has a static method with matching name and signature
// then do not generate an overpass method because it will hide the
// static method during resolution.
- if (!has_matching_static(root)) {
- if (qualified_methods.length() == 0) {
- _exception_message = generate_no_defaults_message(CHECK);
- } else {
- assert(root != NULL, "Null root class");
- _exception_message = generate_method_message(root->name(), qualified_methods.at(0), CHECK);
- }
- _exception_name = vmSymbols::java_lang_AbstractMethodError();
+ if (qualified_methods.length() == 0) {
+ _exception_message = generate_no_defaults_message(CHECK);
+ } else {
+ assert(root != NULL, "Null root class");
+ _exception_message = generate_method_message(root->name(), qualified_methods.at(0), CHECK);
}
+ _exception_name = vmSymbols::java_lang_AbstractMethodError();
// If only one qualified method is default, select that
} else if (num_defaults == 1) {
_selected_target = qualified_methods.at(default_index);
- } else if (num_defaults > 1 && !has_matching_static(root)) {
+ } else if (num_defaults > 1) {
_exception_message = generate_conflicts_message(&qualified_methods,CHECK);
_exception_name = vmSymbols::java_lang_IncompatibleClassChangeError();
if (TraceDefaultMethods) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/classfile/javaClasses.cpp
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -464,25 +464,26 @@
void java_lang_String::print(oop java_string, outputStream* st) {
assert(java_string->klass() == SystemDictionary::String_klass(), "must be java_string");
typeArrayOop value = java_lang_String::value(java_string);
- int offset = java_lang_String::offset(java_string);
- int length = java_lang_String::length(java_string);
-
- int end = MIN2(length, 100);
+
if (value == NULL) {
// This can happen if, e.g., printing a String
// object before its initializer has been called
- st->print_cr("NULL");
- } else {
- st->print("\"");
- for (int index = 0; index < length; index++) {
- st->print("%c", value->char_at(index + offset));
- }
- st->print("\"");
+ st->print("NULL");
+ return;
}
-}
-
-static void initialize_static_field(fieldDescriptor* fd, TRAPS) {
- Handle mirror (THREAD, fd->field_holder()->java_mirror());
+
+ int offset = java_lang_String::offset(java_string);
+ int length = java_lang_String::length(java_string);
+
+ st->print("\"");
+ for (int index = 0; index < length; index++) {
+ st->print("%c", value->char_at(index + offset));
+ }
+ st->print("\"");
+}
+
+
+static void initialize_static_field(fieldDescriptor* fd, Handle mirror, TRAPS) {
assert(mirror.not_null() && fd->is_static(), "just checking");
if (fd->has_initial_value()) {
BasicType t = fd->field_type();
@@ -549,21 +550,45 @@
create_mirror(k, Handle(NULL), CHECK);
}
-oop java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) {
+void java_lang_Class::initialize_mirror_fields(KlassHandle k,
+ Handle mirror,
+ Handle protection_domain,
+ TRAPS) {
+ // Allocate a simple java object for a lock.
+ // This needs to be a java object because during class initialization
+ // it can be held across a java call.
+ typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK);
+ set_init_lock(mirror(), r);
+
+ // Set protection domain also
+ set_protection_domain(mirror(), protection_domain());
+
+ // Initialize static fields
+ InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK);
+}
+
+void java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) {
assert(k->java_mirror() == NULL, "should only assign mirror once");
// Use this moment of initialization to cache modifier_flags also,
// to support Class.getModifiers(). Instance classes recalculate
// the cached flags after the class file is parsed, but before the
// class is put into the system dictionary.
- int computed_modifiers = k->compute_modifier_flags(CHECK_0);
+ int computed_modifiers = k->compute_modifier_flags(CHECK);
k->set_modifier_flags(computed_modifiers);
// Class_klass has to be loaded because it is used to allocate
// the mirror.
if (SystemDictionary::Class_klass_loaded()) {
// Allocate mirror (java.lang.Class instance)
- Handle mirror = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK_0);
+ Handle mirror = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK);
+
+ // Setup indirection from mirror->klass
+ if (!k.is_null()) {
+ java_lang_Class::set_klass(mirror(), k());
+ }
InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(mirror->klass());
+ assert(oop_size(mirror()) == mk->instance_size(k), "should have been set");
+
java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror()));
// It might also have a component mirror. This mirror must already exist.
@@ -576,29 +601,32 @@
assert(k->oop_is_objArray(), "Must be");
Klass* element_klass = ObjArrayKlass::cast(k())->element_klass();
assert(element_klass != NULL, "Must have an element klass");
- comp_mirror = element_klass->java_mirror();
+ comp_mirror = element_klass->java_mirror();
}
assert(comp_mirror.not_null(), "must have a mirror");
- // Two-way link between the array klass and its component mirror:
+ // Two-way link between the array klass and its component mirror:
ArrayKlass::cast(k())->set_component_mirror(comp_mirror());
set_array_klass(comp_mirror(), k());
} else {
assert(k->oop_is_instance(), "Must be");
- // Allocate a simple java object for a lock.
- // This needs to be a java object because during class initialization
- // it can be held across a java call.
- typeArrayOop r = oopFactory::new_typeArray(T_INT, 0, CHECK_NULL);
- set_init_lock(mirror(), r);
-
- // Set protection domain also
- set_protection_domain(mirror(), protection_domain());
-
- // Initialize static fields
- InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, CHECK_NULL);
+ initialize_mirror_fields(k, mirror, protection_domain, THREAD);
+ if (HAS_PENDING_EXCEPTION) {
+ // If any of the fields throws an exception like OOM remove the klass field
+ // from the mirror so GC doesn't follow it after the klass has been deallocated.
+ // This mirror looks like a primitive type, which logically it is because it
+ // it represents no class.
+ java_lang_Class::set_klass(mirror(), NULL);
+ return;
+ }
}
- return mirror();
+
+ // Setup indirection from klass->mirror last
+ // after any exceptions can happen during allocations.
+ if (!k.is_null()) {
+ k->set_java_mirror(mirror());
+ }
} else {
if (fixup_mirror_list() == NULL) {
GrowableArray* list =
@@ -606,12 +634,10 @@
set_fixup_mirror_list(list);
}
fixup_mirror_list()->push(k());
- return NULL;
}
}
-
int java_lang_Class::oop_size(oop java_class) {
assert(_oop_size_offset != 0, "must be set");
return java_class->int_field(_oop_size_offset);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/classfile/javaClasses.hpp
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -246,11 +246,12 @@
static void set_init_lock(oop java_class, oop init_lock);
static void set_protection_domain(oop java_class, oop protection_domain);
+ static void initialize_mirror_fields(KlassHandle k, Handle mirror, Handle protection_domain, TRAPS);
public:
static void compute_offsets();
// Instance creation
- static oop create_mirror(KlassHandle k, Handle protection_domain, TRAPS);
+ static void create_mirror(KlassHandle k, Handle protection_domain, TRAPS);
static void fixup_mirror(KlassHandle k, TRAPS);
static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
// Conversion
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/classfile/symbolTable.cpp
--- a/hotspot/src/share/vm/classfile/symbolTable.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -810,11 +810,11 @@
const int limit = the_table()->table_size();
assert(0 <= start_idx && start_idx <= limit,
- err_msg("start_idx (" INT32_FORMAT ") is out of bounds", start_idx));
+ err_msg("start_idx (%d) is out of bounds", start_idx));
assert(0 <= end_idx && end_idx <= limit,
- err_msg("end_idx (" INT32_FORMAT ") is out of bounds", end_idx));
+ err_msg("end_idx (%d) is out of bounds", end_idx));
assert(start_idx <= end_idx,
- err_msg("Index ordering: start_idx=" INT32_FORMAT", end_idx=" INT32_FORMAT,
+ err_msg("Index ordering: start_idx=%d, end_idx=%d",
start_idx, end_idx));
for (int i = start_idx; i < end_idx; i += 1) {
@@ -833,11 +833,11 @@
const int limit = the_table()->table_size();
assert(0 <= start_idx && start_idx <= limit,
- err_msg("start_idx (" INT32_FORMAT ") is out of bounds", start_idx));
+ err_msg("start_idx (%d) is out of bounds", start_idx));
assert(0 <= end_idx && end_idx <= limit,
- err_msg("end_idx (" INT32_FORMAT ") is out of bounds", end_idx));
+ err_msg("end_idx (%d) is out of bounds", end_idx));
assert(start_idx <= end_idx,
- err_msg("Index ordering: start_idx=" INT32_FORMAT", end_idx=" INT32_FORMAT,
+ err_msg("Index ordering: start_idx=%d, end_idx=%d",
start_idx, end_idx));
for (int i = start_idx; i < end_idx; ++i) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/classfile/systemDictionary.cpp
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -826,47 +826,6 @@
}
} // load_instance_class loop
- if (HAS_PENDING_EXCEPTION) {
- // An exception, such as OOM could have happened at various places inside
- // load_instance_class. We might have partially initialized a shared class
- // and need to clean it up.
- if (class_loader.is_null()) {
- // In some cases k may be null. Let's find the shared class again.
- instanceKlassHandle ik(THREAD, find_shared_class(name));
- if (ik.not_null()) {
- if (ik->class_loader_data() == NULL) {
- // We didn't go as far as Klass::restore_unshareable_info(),
- // so nothing to clean up.
- } else {
- Klass *kk;
- {
- MutexLocker mu(SystemDictionary_lock, THREAD);
- kk = find_class(d_index, d_hash, name, ik->class_loader_data());
- }
- if (kk != NULL) {
- // No clean up is needed if the shared class has been entered
- // into system dictionary, as load_shared_class() won't be called
- // again.
- } else {
- // This must be done outside of the SystemDictionary_lock to
- // avoid deadlock.
- //
- // Note that Klass::restore_unshareable_info (called via
- // load_instance_class above) is also called outside
- // of SystemDictionary_lock. Other threads are blocked from
- // loading this class because they are waiting on the
- // SystemDictionary_lock until this thread removes
- // the placeholder below.
- //
- // This need to be re-thought when parallel-capable non-boot
- // classloaders are supported by CDS (today they're not).
- clean_up_shared_class(ik, class_loader, THREAD);
- }
- }
- }
- }
- }
-
if (load_instance_added == true) {
// clean up placeholder entries for LOAD_INSTANCE success or error
// This brackets the SystemDictionary updates for both defining
@@ -1272,19 +1231,6 @@
return ik;
}
-void SystemDictionary::clean_up_shared_class(instanceKlassHandle ik, Handle class_loader, TRAPS) {
- // Updating methods must be done under a lock so multiple
- // threads don't update these in parallel
- // Shared classes are all currently loaded by the bootstrap
- // classloader, so this will never cause a deadlock on
- // a custom class loader lock.
- {
- Handle lockObject = compute_loader_lock_object(class_loader, THREAD);
- check_loader_lock_contention(lockObject, THREAD);
- ObjectLocker ol(lockObject, THREAD, true);
- ik->remove_unshareable_info();
- }
-}
instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
instanceKlassHandle nh = instanceKlassHandle(); // null Handle
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/classfile/systemDictionary.hpp
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -617,7 +617,6 @@
Handle class_loader, TRAPS);
static instanceKlassHandle load_shared_class(instanceKlassHandle ik,
Handle class_loader, TRAPS);
- static void clean_up_shared_class(instanceKlassHandle ik, Handle class_loader, TRAPS);
static instanceKlassHandle load_instance_class(Symbol* class_name, Handle class_loader, TRAPS);
static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
static void check_loader_lock_contention(Handle loader_lock, TRAPS);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/classfile/verificationType.hpp
--- a/hotspot/src/share/vm/classfile/verificationType.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/classfile/verificationType.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 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
@@ -299,7 +299,7 @@
int dimensions() const {
assert(is_array(), "Must be an array");
int index = 0;
- while (name()->byte_at(index++) == '[');
+ while (name()->byte_at(index) == '[') index++;
return index;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/classfile/verifier.cpp
--- a/hotspot/src/share/vm/classfile/verifier.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/classfile/verifier.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -1943,7 +1943,7 @@
InstanceKlass* target_instance = InstanceKlass::cast(target_class);
fieldDescriptor fd;
if (is_method) {
- Method* m = target_instance->uncached_lookup_method(field_name, field_sig);
+ Method* m = target_instance->uncached_lookup_method(field_name, field_sig, Klass::normal);
if (m != NULL && m->is_protected()) {
if (!this_class->is_same_class_package(m->method_holder())) {
return true;
@@ -2280,7 +2280,8 @@
ref_class_type.name(), CHECK_VERIFY(this));
Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method(
vmSymbols::object_initializer_name(),
- cp->signature_ref_at(bcs->get_index_u2()));
+ cp->signature_ref_at(bcs->get_index_u2()),
+ Klass::normal);
instanceKlassHandle mh(THREAD, m->method_holder());
if (m->is_protected() && !mh->is_same_class_package(_klass())) {
bool assignable = current_type().is_assignable_from(
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/compiler/compileLog.cpp
--- a/hotspot/src/share/vm/compiler/compileLog.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/compiler/compileLog.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -106,7 +106,7 @@
if (mobj->is_klass()) {
ciKlass* klass = mobj->as_klass();
begin_elem("klass id='%d'", id);
- name(klass->name());
+ name(klass);
if (!klass->is_loaded()) {
print(" unloaded='1'");
} else {
@@ -171,6 +171,15 @@
print("'");
}
+void CompileLog::name(ciKlass* k) {
+ print(" name='");
+ if (!k->is_loaded()) {
+ text()->print(k->name()->as_klass_external_name());
+ } else {
+ text()->print(k->external_name());
+ }
+ print("'");
+}
// ------------------------------------------------------------------
// CompileLog::clear_identities
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/compiler/compileLog.hpp
--- a/hotspot/src/share/vm/compiler/compileLog.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/compiler/compileLog.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -28,6 +28,7 @@
#include "utilities/xmlstream.hpp"
class ciBaseObject;
+class ciKlass;
class ciObject;
class ciMetadata;
class ciSymbol;
@@ -72,6 +73,7 @@
void name(ciSymbol* s); // name='s'
void name(Symbol* s) { xmlStream::name(s); }
+ void name(ciKlass* k);
// Output an object description, return obj->ident().
int identify(ciBaseObject* obj);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -57,10 +57,10 @@
_threads = NEW_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _n_threads, mtGC);
- int worker_id_offset = (int)DirtyCardQueueSet::num_par_ids();
+ uint worker_id_offset = DirtyCardQueueSet::num_par_ids();
ConcurrentG1RefineThread *next = NULL;
- for (int i = _n_threads - 1; i >= 0; i--) {
+ for (uint i = _n_threads - 1; i != UINT_MAX; i--) {
ConcurrentG1RefineThread* t = new ConcurrentG1RefineThread(this, next, worker_id_offset, i);
assert(t != NULL, "Conc refine should have been created");
if (t->osthread() == NULL) {
@@ -87,7 +87,7 @@
void ConcurrentG1Refine::stop() {
if (_threads != NULL) {
- for (int i = 0; i < _n_threads; i++) {
+ for (uint i = 0; i < _n_threads; i++) {
_threads[i]->stop();
}
}
@@ -96,7 +96,7 @@
void ConcurrentG1Refine::reinitialize_threads() {
reset_threshold_step();
if (_threads != NULL) {
- for (int i = 0; i < _n_threads; i++) {
+ for (uint i = 0; i < _n_threads; i++) {
_threads[i]->initialize();
}
}
@@ -104,7 +104,7 @@
ConcurrentG1Refine::~ConcurrentG1Refine() {
if (_threads != NULL) {
- for (int i = 0; i < _n_threads; i++) {
+ for (uint i = 0; i < _n_threads; i++) {
delete _threads[i];
}
FREE_C_HEAP_ARRAY(ConcurrentG1RefineThread*, _threads, mtGC);
@@ -113,7 +113,7 @@
void ConcurrentG1Refine::threads_do(ThreadClosure *tc) {
if (_threads != NULL) {
- for (int i = 0; i < _n_threads; i++) {
+ for (uint i = 0; i < _n_threads; i++) {
tc->do_thread(_threads[i]);
}
}
@@ -121,20 +121,20 @@
void ConcurrentG1Refine::worker_threads_do(ThreadClosure * tc) {
if (_threads != NULL) {
- for (int i = 0; i < worker_thread_num(); i++) {
+ for (uint i = 0; i < worker_thread_num(); i++) {
tc->do_thread(_threads[i]);
}
}
}
-int ConcurrentG1Refine::thread_num() {
- int n_threads = (G1ConcRefinementThreads > 0) ? G1ConcRefinementThreads
+uint ConcurrentG1Refine::thread_num() {
+ uint n_threads = (G1ConcRefinementThreads > 0) ? G1ConcRefinementThreads
: ParallelGCThreads;
- return MAX2(n_threads, 1);
+ return MAX2(n_threads, 1);
}
void ConcurrentG1Refine::print_worker_threads_on(outputStream* st) const {
- for (int i = 0; i < _n_threads; ++i) {
+ for (uint i = 0; i < _n_threads; ++i) {
_threads[i]->print_on(st);
st->cr();
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -39,8 +39,8 @@
class ConcurrentG1Refine: public CHeapObj {
ConcurrentG1RefineThread** _threads;
- int _n_threads;
- int _n_worker_threads;
+ uint _n_threads;
+ uint _n_worker_threads;
/*
* The value of the update buffer queue length falls into one of 3 zones:
* green, yellow, red. If the value is in [0, green) nothing is
@@ -88,7 +88,7 @@
// The RS sampling thread
ConcurrentG1RefineThread * sampling_thread() const;
- static int thread_num();
+ static uint thread_num();
void print_worker_threads_on(outputStream* st) const;
@@ -100,8 +100,8 @@
int yellow_zone() const { return _yellow_zone; }
int red_zone() const { return _red_zone; }
- int total_thread_num() const { return _n_threads; }
- int worker_thread_num() const { return _n_worker_threads; }
+ uint total_thread_num() const { return _n_threads; }
+ uint worker_thread_num() const { return _n_worker_threads; }
int thread_threshold_step() const { return _thread_threshold_step; }
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -33,7 +33,7 @@
ConcurrentG1RefineThread::
ConcurrentG1RefineThread(ConcurrentG1Refine* cg1r, ConcurrentG1RefineThread *next,
- int worker_id_offset, int worker_id) :
+ uint worker_id_offset, uint worker_id) :
ConcurrentGCThread(),
_worker_id_offset(worker_id_offset),
_worker_id(worker_id),
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1RefineThread.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -38,8 +38,8 @@
double _vtime_start; // Initial virtual time.
double _vtime_accum; // Initial virtual time.
- int _worker_id;
- int _worker_id_offset;
+ uint _worker_id;
+ uint _worker_id_offset;
// The refinement threads collection is linked list. A predecessor can activate a successor
// when the number of the rset update buffer crosses a certain threshold. A successor
@@ -71,7 +71,7 @@
virtual void run();
// Constructor
ConcurrentG1RefineThread(ConcurrentG1Refine* cg1r, ConcurrentG1RefineThread* next,
- int worker_id_offset, int worker_id);
+ uint worker_id_offset, uint worker_id);
void initialize();
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -567,8 +567,8 @@
_root_regions.init(_g1h, this);
if (ConcGCThreads > ParallelGCThreads) {
- warning("Can't have more ConcGCThreads (" UINT32_FORMAT ") "
- "than ParallelGCThreads (" UINT32_FORMAT ").",
+ warning("Can't have more ConcGCThreads (" UINTX_FORMAT ") "
+ "than ParallelGCThreads (" UINTX_FORMAT ").",
ConcGCThreads, ParallelGCThreads);
return;
}
@@ -1804,7 +1804,6 @@
class G1NoteEndOfConcMarkClosure : public HeapRegionClosure {
G1CollectedHeap* _g1;
- int _worker_num;
size_t _max_live_bytes;
uint _regions_claimed;
size_t _freed_bytes;
@@ -1817,10 +1816,9 @@
public:
G1NoteEndOfConcMarkClosure(G1CollectedHeap* g1,
- int worker_num,
FreeRegionList* local_cleanup_list,
HRRSCleanupTask* hrrs_cleanup_task) :
- _g1(g1), _worker_num(worker_num),
+ _g1(g1),
_max_live_bytes(0), _regions_claimed(0),
_freed_bytes(0),
_claimed_region_time(0.0), _max_region_time(0.0),
@@ -1893,7 +1891,7 @@
double start = os::elapsedTime();
FreeRegionList local_cleanup_list("Local Cleanup List");
HRRSCleanupTask hrrs_cleanup_task;
- G1NoteEndOfConcMarkClosure g1_note_end(_g1h, worker_id, &local_cleanup_list,
+ G1NoteEndOfConcMarkClosure g1_note_end(_g1h, &local_cleanup_list,
&hrrs_cleanup_task);
if (G1CollectedHeap::use_parallel_gc_threads()) {
_g1h->heap_region_par_iterate_chunked(&g1_note_end, worker_id,
@@ -2145,7 +2143,7 @@
G1CollectedHeap* g1h = G1CollectedHeap::heap();
- _cleanup_list.verify_list();
+ _cleanup_list.verify_optional();
FreeRegionList tmp_free_list("Tmp Free List");
if (G1ConcRegionFreeingVerbose) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -34,12 +34,12 @@
bool DirtyCardQueue::apply_closure(CardTableEntryClosure* cl,
bool consume,
- size_t worker_i) {
+ uint worker_i) {
bool res = true;
if (_buf != NULL) {
res = apply_closure_to_buffer(cl, _buf, _index, _sz,
consume,
- (int) worker_i);
+ worker_i);
if (res && consume) _index = _sz;
}
return res;
@@ -49,7 +49,7 @@
void** buf,
size_t index, size_t sz,
bool consume,
- int worker_i) {
+ uint worker_i) {
if (cl == NULL) return true;
for (size_t i = index; i < sz; i += oopSize) {
int ind = byte_index_to_index((int)i);
@@ -79,8 +79,8 @@
}
// Determines how many mutator threads can process the buffers in parallel.
-size_t DirtyCardQueueSet::num_par_ids() {
- return os::processor_count();
+uint DirtyCardQueueSet::num_par_ids() {
+ return (uint)os::processor_count();
}
void DirtyCardQueueSet::initialize(Monitor* cbl_mon, Mutex* fl_lock,
@@ -103,7 +103,7 @@
}
void DirtyCardQueueSet::iterate_closure_all_threads(bool consume,
- size_t worker_i) {
+ uint worker_i) {
assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
for(JavaThread* t = Threads::first(); t; t = t->next()) {
bool b = t->dirty_card_queue().apply_closure(_closure, consume);
@@ -126,11 +126,11 @@
// We get the the number of any par_id that this thread
// might have already claimed.
- int worker_i = thread->get_claimed_par_id();
+ uint worker_i = thread->get_claimed_par_id();
- // If worker_i is not -1 then the thread has already claimed
+ // If worker_i is not UINT_MAX then the thread has already claimed
// a par_id. We make note of it using the already_claimed value
- if (worker_i != -1) {
+ if (worker_i != UINT_MAX) {
already_claimed = true;
} else {
@@ -142,7 +142,7 @@
}
bool b = false;
- if (worker_i != -1) {
+ if (worker_i != UINT_MAX) {
b = DirtyCardQueue::apply_closure_to_buffer(_closure, buf, 0,
_sz, true, worker_i);
if (b) Atomic::inc(&_processed_buffers_mut);
@@ -154,8 +154,8 @@
// we release the id
_free_ids->release_par_id(worker_i);
- // and set the claimed_id in the thread to -1
- thread->set_claimed_par_id(-1);
+ // and set the claimed_id in the thread to UINT_MAX
+ thread->set_claimed_par_id(UINT_MAX);
}
}
return b;
@@ -186,7 +186,7 @@
bool DirtyCardQueueSet::
apply_closure_to_completed_buffer_helper(CardTableEntryClosure* cl,
- int worker_i,
+ uint worker_i,
BufferNode* nd) {
if (nd != NULL) {
void **buf = BufferNode::make_buffer_from_node(nd);
@@ -208,7 +208,7 @@
}
bool DirtyCardQueueSet::apply_closure_to_completed_buffer(CardTableEntryClosure* cl,
- int worker_i,
+ uint worker_i,
int stop_at,
bool during_pause) {
assert(!during_pause || stop_at == 0, "Should not leave any completed buffers during a pause");
@@ -218,7 +218,7 @@
return res;
}
-bool DirtyCardQueueSet::apply_closure_to_completed_buffer(int worker_i,
+bool DirtyCardQueueSet::apply_closure_to_completed_buffer(uint worker_i,
int stop_at,
bool during_pause) {
return apply_closure_to_completed_buffer(_closure, worker_i,
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/dirtyCardQueue.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -36,7 +36,7 @@
public:
// Process the card whose card table entry is "card_ptr". If returns
// "false", terminate the iteration early.
- virtual bool do_card_ptr(jbyte* card_ptr, int worker_i = 0) = 0;
+ virtual bool do_card_ptr(jbyte* card_ptr, uint worker_i = 0) = 0;
};
// A ptrQueue whose elements are "oops", pointers to object heads.
@@ -53,7 +53,7 @@
// deletes processed entries from logs.
bool apply_closure(CardTableEntryClosure* cl,
bool consume = true,
- size_t worker_i = 0);
+ uint worker_i = 0);
// Apply the closure to all elements of "buf", down to "index"
// (inclusive.) If returns "false", then a closure application returned
@@ -63,7 +63,7 @@
static bool apply_closure_to_buffer(CardTableEntryClosure* cl,
void** buf, size_t index, size_t sz,
bool consume = true,
- int worker_i = 0);
+ uint worker_i = 0);
void **get_buf() { return _buf;}
void set_buf(void **buf) {_buf = buf;}
size_t get_index() { return _index;}
@@ -98,7 +98,7 @@
// The number of parallel ids that can be claimed to allow collector or
// mutator threads to do card-processing work.
- static size_t num_par_ids();
+ static uint num_par_ids();
static void handle_zero_index_for_thread(JavaThread* t);
@@ -115,7 +115,7 @@
// change in the future.) If "consume" is true, processed entries are
// discarded.
void iterate_closure_all_threads(bool consume = true,
- size_t worker_i = 0);
+ uint worker_i = 0);
// If there exists some completed buffer, pop it, then apply the
// registered closure to all its elements, nulling out those elements
@@ -124,7 +124,7 @@
// but is only partially completed before a "yield" happens, the
// partially completed buffer (with its processed elements set to NULL)
// is returned to the completed buffer set, and this call returns false.
- bool apply_closure_to_completed_buffer(int worker_i = 0,
+ bool apply_closure_to_completed_buffer(uint worker_i = 0,
int stop_at = 0,
bool during_pause = false);
@@ -136,13 +136,13 @@
// partially completed buffer (with its processed elements set to NULL)
// is returned to the completed buffer set, and this call returns false.
bool apply_closure_to_completed_buffer(CardTableEntryClosure* cl,
- int worker_i = 0,
+ uint worker_i = 0,
int stop_at = 0,
bool during_pause = false);
// Helper routine for the above.
bool apply_closure_to_completed_buffer_helper(CardTableEntryClosure* cl,
- int worker_i,
+ uint worker_i,
BufferNode* nd);
BufferNode* get_completed_buffer(int stop_at);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -304,26 +304,26 @@
if (c - start_card > BlockOffsetArray::power_to_cards_back(1)) {
guarantee(entry > N_words,
err_msg("Should be in logarithmic region - "
- "entry: " UINT32_FORMAT ", "
- "_array->offset_array(c): " UINT32_FORMAT ", "
- "N_words: " UINT32_FORMAT,
- entry, _array->offset_array(c), N_words));
+ "entry: %u, "
+ "_array->offset_array(c): %u, "
+ "N_words: %u",
+ (uint)entry, (uint)_array->offset_array(c), (uint)N_words));
}
size_t backskip = BlockOffsetArray::entry_to_cards_back(entry);
size_t landing_card = c - backskip;
guarantee(landing_card >= (start_card - 1), "Inv");
if (landing_card >= start_card) {
guarantee(_array->offset_array(landing_card) <= entry,
- err_msg("Monotonicity - landing_card offset: " UINT32_FORMAT ", "
- "entry: " UINT32_FORMAT,
- _array->offset_array(landing_card), entry));
+ err_msg("Monotonicity - landing_card offset: %u, "
+ "entry: %u",
+ (uint)_array->offset_array(landing_card), (uint)entry));
} else {
guarantee(landing_card == start_card - 1, "Tautology");
// Note that N_words is the maximum offset value
guarantee(_array->offset_array(landing_card) <= N_words,
- err_msg("landing card offset: " UINT32_FORMAT ", "
- "N_words: " UINT32_FORMAT,
- _array->offset_array(landing_card), N_words));
+ err_msg("landing card offset: %u, "
+ "N_words: %u",
+ (uint)_array->offset_array(landing_card), (uint)N_words));
}
}
}
@@ -554,21 +554,20 @@
(_array->offset_array(orig_index) > 0 &&
_array->offset_array(orig_index) <= N_words),
err_msg("offset array should have been set - "
- "orig_index offset: " UINT32_FORMAT ", "
+ "orig_index offset: %u, "
"blk_start: " PTR_FORMAT ", "
"boundary: " PTR_FORMAT,
- _array->offset_array(orig_index),
+ (uint)_array->offset_array(orig_index),
blk_start, boundary));
for (size_t j = orig_index + 1; j <= end_index; j++) {
assert(_array->offset_array(j) > 0 &&
_array->offset_array(j) <=
(u_char) (N_words+BlockOffsetArray::N_powers-1),
err_msg("offset array should have been set - "
- UINT32_FORMAT " not > 0 OR "
- UINT32_FORMAT " not <= " UINT32_FORMAT,
- _array->offset_array(j),
- _array->offset_array(j),
- (u_char) (N_words+BlockOffsetArray::N_powers-1)));
+ "%u not > 0 OR %u not <= %u",
+ (uint) _array->offset_array(j),
+ (uint) _array->offset_array(j),
+ (uint) (N_words+BlockOffsetArray::N_powers-1)));
}
#endif
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -146,8 +146,8 @@
void check_offset(size_t offset, const char* msg) const {
assert(offset <= N_words,
err_msg("%s - "
- "offset: " UINT32_FORMAT", N_words: " UINT32_FORMAT,
- msg, offset, N_words));
+ "offset: " SIZE_FORMAT", N_words: %u",
+ msg, offset, (uint)N_words));
}
// Bounds checking accessors:
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -102,7 +102,7 @@
ConcurrentG1Refine* cg1r) :
_sts(sts), _g1rs(g1rs), _cg1r(cg1r), _concurrent(true)
{}
- bool do_card_ptr(jbyte* card_ptr, int worker_i) {
+ bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
bool oops_into_cset = _g1rs->refine_card(card_ptr, worker_i, false);
// This path is executed by the concurrent refine or mutator threads,
// concurrently, and so we do not care if card_ptr contains references
@@ -131,7 +131,7 @@
{
for (int i = 0; i < 256; i++) _histo[i] = 0;
}
- bool do_card_ptr(jbyte* card_ptr, int worker_i) {
+ bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) {
_calls++;
unsigned char* ujb = (unsigned char*)card_ptr;
@@ -160,7 +160,7 @@
RedirtyLoggedCardTableEntryClosure() :
_calls(0), _g1h(G1CollectedHeap::heap()), _ctbs(_g1h->g1_barrier_set()) {}
- bool do_card_ptr(jbyte* card_ptr, int worker_i) {
+ bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
if (_g1h->is_in_reserved(_ctbs->addr_for(card_ptr))) {
_calls++;
*card_ptr = 0;
@@ -1288,7 +1288,7 @@
print_heap_before_gc();
trace_heap_before_gc(gc_tracer);
- size_t metadata_prev_used = MetaspaceAux::allocated_used_bytes();
+ size_t metadata_prev_used = MetaspaceAux::used_bytes();
verify_region_sets_optional();
@@ -2314,7 +2314,7 @@
void G1CollectedHeap::iterate_dirty_card_closure(CardTableEntryClosure* cl,
DirtyCardQueue* into_cset_dcq,
bool concurrent,
- int worker_i) {
+ uint worker_i) {
// Clean cards in the hot card cache
G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache();
hot_card_cache->drain(worker_i, g1_rem_set(), into_cset_dcq);
@@ -2843,7 +2843,7 @@
// Given the id of a worker, obtain or calculate a suitable
// starting region for iterating over the current collection set.
-HeapRegion* G1CollectedHeap::start_cset_region_for_worker(int worker_i) {
+HeapRegion* G1CollectedHeap::start_cset_region_for_worker(uint worker_i) {
assert(get_gc_time_stamp() > 0, "should have been updated by now");
HeapRegion* result = NULL;
@@ -5103,7 +5103,7 @@
OopClosure* scan_non_heap_roots,
OopsInHeapRegionClosure* scan_rs,
G1KlassScanClosure* scan_klasses,
- int worker_i) {
+ uint worker_i) {
// First scan the strong roots
double ext_roots_start = os::elapsedTime();
@@ -5207,10 +5207,10 @@
~G1StringSymbolTableUnlinkTask() {
guarantee(!_process_strings || !_do_in_parallel || StringTable::parallel_claimed_index() >= _initial_string_table_size,
- err_msg("claim value "INT32_FORMAT" after unlink less than initial string table size "INT32_FORMAT,
+ err_msg("claim value %d after unlink less than initial string table size %d",
StringTable::parallel_claimed_index(), _initial_string_table_size));
guarantee(!_process_symbols || !_do_in_parallel || SymbolTable::parallel_claimed_index() >= _initial_symbol_table_size,
- err_msg("claim value "INT32_FORMAT" after unlink less than initial symbol table size "INT32_FORMAT,
+ err_msg("claim value %d after unlink less than initial symbol table size %d",
SymbolTable::parallel_claimed_index(), _initial_symbol_table_size));
}
@@ -5275,7 +5275,7 @@
class RedirtyLoggedCardTableEntryFastClosure : public CardTableEntryClosure {
public:
- bool do_card_ptr(jbyte* card_ptr, int worker_i) {
+ bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
*card_ptr = CardTableModRefBS::dirty_card_val();
return true;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -845,7 +845,7 @@
OopClosure* scan_non_heap_roots,
OopsInHeapRegionClosure* scan_rs,
G1KlassScanClosure* scan_klasses,
- int worker_i);
+ uint worker_i);
// Notifies all the necessary spaces that the committed space has
// been updated (either expanded or shrunk). It should be called
@@ -1139,7 +1139,7 @@
void iterate_dirty_card_closure(CardTableEntryClosure* cl,
DirtyCardQueue* into_cset_dcq,
- bool concurrent, int worker_i);
+ bool concurrent, uint worker_i);
// The shared block offset table array.
G1BlockOffsetSharedArray* bot_shared() const { return _bot_shared; }
@@ -1370,7 +1370,7 @@
// Given the id of a worker, obtain or calculate a suitable
// starting region for iterating over the current collection set.
- HeapRegion* start_cset_region_for_worker(int worker_i);
+ HeapRegion* start_cset_region_for_worker(uint worker_i);
// This is a convenience method that is used by the
// HeapRegionIterator classes to calculate the starting region for
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1204,7 +1204,7 @@
(_young_list_target_length * HeapRegion::GrainBytes) - _survivor_used_bytes_before_gc;
if (full) {
- _metaspace_used_bytes_before_gc = MetaspaceAux::allocated_used_bytes();
+ _metaspace_used_bytes_before_gc = MetaspaceAux::used_bytes();
}
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -147,7 +147,7 @@
void WorkerDataArray::verify() {
for (uint i = 0; i < _length; i++) {
assert(_data[i] != _uninitialized,
- err_msg("Invalid data for worker " UINT32_FORMAT ", data: %lf, uninitialized: %lf",
+ err_msg("Invalid data for worker %u, data: %lf, uninitialized: %lf",
i, (double)_data[i], (double)_uninitialized));
}
}
@@ -246,8 +246,8 @@
LineBuffer(level).append_and_print_cr("[%s: %.1lf ms]", str, value);
}
-void G1GCPhaseTimes::print_stats(int level, const char* str, double value, int workers) {
- LineBuffer(level).append_and_print_cr("[%s: %.1lf ms, GC Workers: %d]", str, value, workers);
+void G1GCPhaseTimes::print_stats(int level, const char* str, double value, uint workers) {
+ LineBuffer(level).append_and_print_cr("[%s: %.1lf ms, GC Workers: %u]", str, value, workers);
}
double G1GCPhaseTimes::accounted_time_ms() {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1GCPhaseTimes.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -161,7 +161,7 @@
// Helper methods for detailed logging
void print_stats(int level, const char* str, double value);
- void print_stats(int level, const char* str, double value, int workers);
+ void print_stats(int level, const char* str, double value, uint workers);
public:
G1GCPhaseTimes(uint max_gc_threads);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -44,9 +44,9 @@
_hot_cache_idx = 0;
// For refining the cards in the hot cache in parallel
- int n_workers = (ParallelGCThreads > 0 ?
+ uint n_workers = (ParallelGCThreads > 0 ?
_g1h->workers()->total_workers() : 1);
- _hot_cache_par_chunk_size = MAX2(1, _hot_cache_size / n_workers);
+ _hot_cache_par_chunk_size = MAX2(1, _hot_cache_size / (int)n_workers);
_hot_cache_par_claimed_idx = 0;
_card_counts.initialize();
@@ -89,7 +89,7 @@
return res;
}
-void G1HotCardCache::drain(int worker_i,
+void G1HotCardCache::drain(uint worker_i,
G1RemSet* g1rs,
DirtyCardQueue* into_cset_dcq) {
if (!default_use_cache()) {
@@ -122,8 +122,8 @@
// RSet updating while within an evacuation pause.
// In this case worker_i should be the id of a GC worker thread
assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint");
- assert(worker_i < (int) (ParallelGCThreads == 0 ? 1 : ParallelGCThreads),
- err_msg("incorrect worker id: "INT32_FORMAT, worker_i));
+ assert(worker_i < (ParallelGCThreads == 0 ? 1 : ParallelGCThreads),
+ err_msg("incorrect worker id: %u", worker_i));
into_cset_dcq->enqueue(card_ptr);
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1HotCardCache.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -99,7 +99,7 @@
// Refine the cards that have delayed as a result of
// being in the cache.
- void drain(int worker_i, G1RemSet* g1rs, DirtyCardQueue* into_cset_dcq);
+ void drain(uint worker_i, G1RemSet* g1rs, DirtyCardQueue* into_cset_dcq);
// Set up for parallel processing of the cards in the hot cache
void reset_hot_cache_claimed_index() {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -234,14 +234,14 @@
HeapRegion* _from;
OopsInHeapRegionClosure* _push_ref_cl;
bool _record_refs_into_cset;
- int _worker_i;
+ uint _worker_i;
public:
G1UpdateRSOrPushRefOopClosure(G1CollectedHeap* g1h,
G1RemSet* rs,
OopsInHeapRegionClosure* push_ref_cl,
bool record_refs_into_cset,
- int worker_i = 0);
+ uint worker_i = 0);
void set_from(HeapRegion* from) {
assert(from != NULL, "from region must be non-NULL");
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -113,14 +113,14 @@
G1SATBCardTableModRefBS *_ct_bs;
double _strong_code_root_scan_time_sec;
- int _worker_i;
+ uint _worker_i;
int _block_size;
bool _try_claimed;
public:
ScanRSClosure(OopsInHeapRegionClosure* oc,
CodeBlobToOopClosure* code_root_cl,
- int worker_i) :
+ uint worker_i) :
_oc(oc),
_code_root_cl(code_root_cl),
_strong_code_root_scan_time_sec(0.0),
@@ -162,7 +162,7 @@
void printCard(HeapRegion* card_region, size_t card_index,
HeapWord* card_start) {
- gclog_or_tty->print_cr("T %d Region [" PTR_FORMAT ", " PTR_FORMAT ") "
+ gclog_or_tty->print_cr("T %u Region [" PTR_FORMAT ", " PTR_FORMAT ") "
"RS names card %p: "
"[" PTR_FORMAT ", " PTR_FORMAT ")",
_worker_i,
@@ -241,7 +241,7 @@
void G1RemSet::scanRS(OopsInHeapRegionClosure* oc,
CodeBlobToOopClosure* code_root_cl,
- int worker_i) {
+ uint worker_i) {
double rs_time_start = os::elapsedTime();
HeapRegion *startRegion = _g1->start_cset_region_for_worker(worker_i);
@@ -274,13 +274,13 @@
DirtyCardQueue* into_cset_dcq) :
_g1rs(g1h->g1_rem_set()), _into_cset_dcq(into_cset_dcq)
{}
- bool do_card_ptr(jbyte* card_ptr, int worker_i) {
+ bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
// The only time we care about recording cards that
// contain references that point into the collection set
// is during RSet updating within an evacuation pause.
// In this case worker_i should be the id of a GC worker thread.
assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause");
- assert(worker_i < (int) (ParallelGCThreads == 0 ? 1 : ParallelGCThreads), "should be a GC worker");
+ assert(worker_i < (ParallelGCThreads == 0 ? 1 : ParallelGCThreads), "should be a GC worker");
if (_g1rs->refine_card(card_ptr, worker_i, true)) {
// 'card_ptr' contains references that point into the collection
@@ -295,7 +295,7 @@
}
};
-void G1RemSet::updateRS(DirtyCardQueue* into_cset_dcq, int worker_i) {
+void G1RemSet::updateRS(DirtyCardQueue* into_cset_dcq, uint worker_i) {
double start = os::elapsedTime();
// Apply the given closure to all remaining log entries.
RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq);
@@ -320,14 +320,14 @@
void G1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc,
CodeBlobToOopClosure* code_root_cl,
- int worker_i) {
+ uint worker_i) {
#if CARD_REPEAT_HISTO
ct_freq_update_histo_and_reset();
#endif
// We cache the value of 'oc' closure into the appropriate slot in the
// _cset_rs_update_cl for this worker
- assert(worker_i < (int)n_workers(), "sanity");
+ assert(worker_i < n_workers(), "sanity");
_cset_rs_update_cl[worker_i] = oc;
// A DirtyCardQueue that is used to hold cards containing references
@@ -399,7 +399,7 @@
_g1(g1), _ct_bs(bs)
{ }
- bool do_card_ptr(jbyte* card_ptr, int worker_i) {
+ bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
// Construct the region representing the card.
HeapWord* start = _ct_bs->addr_for(card_ptr);
// And find the region containing it.
@@ -543,7 +543,7 @@
G1RemSet* rs,
OopsInHeapRegionClosure* push_ref_cl,
bool record_refs_into_cset,
- int worker_i) :
+ uint worker_i) :
_g1(g1h), _g1_rem_set(rs), _from(NULL),
_record_refs_into_cset(record_refs_into_cset),
_push_ref_cl(push_ref_cl), _worker_i(worker_i) { }
@@ -552,7 +552,7 @@
// into the collection set, if we're checking for such references;
// false otherwise.
-bool G1RemSet::refine_card(jbyte* card_ptr, int worker_i,
+bool G1RemSet::refine_card(jbyte* card_ptr, uint worker_i,
bool check_for_refs_into_cset) {
// If the card is no longer dirty, nothing to do.
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -97,7 +97,7 @@
// In the sequential case this param will be ignored.
void oops_into_collection_set_do(OopsInHeapRegionClosure* blk,
CodeBlobToOopClosure* code_root_cl,
- int worker_i);
+ uint worker_i);
// Prepare for and cleanup after an oops_into_collection_set_do
// call. Must call each of these once before and after (in sequential
@@ -109,9 +109,9 @@
void scanRS(OopsInHeapRegionClosure* oc,
CodeBlobToOopClosure* code_root_cl,
- int worker_i);
+ uint worker_i);
- void updateRS(DirtyCardQueue* into_cset_dcq, int worker_i);
+ void updateRS(DirtyCardQueue* into_cset_dcq, uint worker_i);
CardTableModRefBS* ct_bs() { return _ct_bs; }
size_t cardsScanned() { return _total_cards_scanned; }
@@ -138,7 +138,7 @@
// if the given card contains oops that have references into the
// current collection set.
virtual bool refine_card(jbyte* card_ptr,
- int worker_i,
+ uint worker_i,
bool check_for_refs_into_cset);
// Print accumulated summary info from the start of the VM.
@@ -171,12 +171,12 @@
class UpdateRSOopClosure: public ExtendedOopClosure {
HeapRegion* _from;
G1RemSet* _rs;
- int _worker_i;
+ uint _worker_i;
template void do_oop_work(T* p);
public:
- UpdateRSOopClosure(G1RemSet* rs, int worker_i = 0) :
+ UpdateRSOopClosure(G1RemSet* rs, uint worker_i = 0) :
_from(NULL), _rs(rs), _worker_i(worker_i)
{}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -390,7 +390,7 @@
void FromCardCache::print(outputStream* out) {
for (uint i = 0; i < HeapRegionRemSet::num_par_rem_sets(); i++) {
for (uint j = 0; j < _max_regions; j++) {
- out->print_cr("_from_card_cache["UINT32_FORMAT"]["UINT32_FORMAT"] = "INT32_FORMAT".",
+ out->print_cr("_from_card_cache[%u][%u] = %d.",
i, j, at(i, j));
}
}
@@ -430,7 +430,7 @@
int from_card = (int)(uintptr_t(from) >> CardTableModRefBS::card_shift);
if (G1TraceHeapRegionRememberedSet) {
- gclog_or_tty->print_cr("Table for [" PTR_FORMAT "...): card %d (cache = "INT32_FORMAT")",
+ gclog_or_tty->print_cr("Table for [" PTR_FORMAT "...): card %d (cache = %d)",
hr()->bottom(), from_card,
FromCardCache::at((uint)tid, cur_hrs_ind));
}
@@ -853,13 +853,13 @@
// This can be done by either mutator threads together with the
// concurrent refinement threads or GC threads.
uint HeapRegionRemSet::num_par_rem_sets() {
- return (uint)MAX2(DirtyCardQueueSet::num_par_ids() + ConcurrentG1Refine::thread_num(), ParallelGCThreads);
+ return MAX2(DirtyCardQueueSet::num_par_ids() + ConcurrentG1Refine::thread_num(), (uint)ParallelGCThreads);
}
HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetSharedArray* bosa,
HeapRegion* hr)
: _bosa(bosa),
- _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #"UINT32_FORMAT, hr->hrs_index()), true),
+ _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrs_index()), true),
_code_roots(), _other_regions(hr, &_m) {
reset_for_par_iteration();
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -30,7 +30,7 @@
inline void HeapRegionSetBase::add(HeapRegion* hr) {
check_mt_safety();
assert(hr->containing_set() == NULL, hrs_ext_msg(this, "should not already have a containing set %u"));
- assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked"));
+ assert(hr->next() == NULL && hr->prev() == NULL, hrs_ext_msg(this, "should not already be linked"));
_count.increment(1u, hr->capacity());
hr->set_containing_set(this);
@@ -40,7 +40,7 @@
inline void HeapRegionSetBase::remove(HeapRegion* hr) {
check_mt_safety();
verify_region(hr);
- assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked"));
+ assert(hr->next() == NULL && hr->prev() == NULL, hrs_ext_msg(this, "should already be unlinked"));
hr->set_containing_set(NULL);
assert(_count.length() > 0, hrs_ext_msg(this, "pre-condition"));
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp
--- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -290,7 +290,7 @@
shared_satb_queue()->apply_closure_and_empty(_closure);
}
-void SATBMarkQueueSet::par_iterate_closure_all_threads(int worker) {
+void SATBMarkQueueSet::par_iterate_closure_all_threads(uint worker) {
SharedHeap* sh = SharedHeap::heap();
int parity = sh->strong_roots_parity();
@@ -315,7 +315,7 @@
}
bool SATBMarkQueueSet::apply_closure_to_completed_buffer_work(bool par,
- int worker) {
+ uint worker) {
BufferNode* nd = NULL;
{
MutexLockerEx x(_cbl_mon, Mutex::_no_safepoint_check_flag);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/g1/satbQueue.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -84,7 +84,7 @@
// Utility function to support sequential and parallel versions. If
// "par" is true, then "worker" is the par thread id; if "false", worker
// is ignored.
- bool apply_closure_to_completed_buffer_work(bool par, int worker);
+ bool apply_closure_to_completed_buffer_work(bool par, uint worker);
#ifdef ASSERT
void dump_active_states(bool expected_active);
@@ -124,7 +124,7 @@
// be called serially and at a safepoint.
void iterate_closure_all_threads();
// Parallel version of the above.
- void par_iterate_closure_all_threads(int worker);
+ void par_iterate_closure_all_threads(uint worker);
// If there exists some completed buffer, pop it, then apply the
// registered closure to all its elements, and return true. If no
@@ -133,7 +133,7 @@
return apply_closure_to_completed_buffer_work(false, 0);
}
// Parallel version of the above.
- bool par_apply_closure_to_completed_buffer(int worker) {
+ bool par_apply_closure_to_completed_buffer(uint worker) {
return apply_closure_to_completed_buffer_work(true, worker);
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -184,7 +184,7 @@
size_t prev_used = heap->used();
// Capture metadata size before collection for sizing.
- size_t metadata_prev_used = MetaspaceAux::allocated_used_bytes();
+ size_t metadata_prev_used = MetaspaceAux::used_bytes();
// For PrintGCDetails
size_t old_gen_prev_used = old_gen->used_in_bytes();
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -928,7 +928,7 @@
_heap_used = heap->used();
_young_gen_used = heap->young_gen()->used_in_bytes();
_old_gen_used = heap->old_gen()->used_in_bytes();
- _metadata_used = MetaspaceAux::allocated_used_bytes();
+ _metadata_used = MetaspaceAux::used_bytes();
};
size_t heap_used() const { return _heap_used; }
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/shared/gcHeapSummary.hpp
--- a/hotspot/src/share/vm/gc_implementation/shared/gcHeapSummary.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/shared/gcHeapSummary.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -62,16 +62,16 @@
};
class MetaspaceSizes : public StackObj {
- size_t _capacity;
+ size_t _committed;
size_t _used;
size_t _reserved;
public:
- MetaspaceSizes() : _capacity(0), _used(0), _reserved(0) {}
- MetaspaceSizes(size_t capacity, size_t used, size_t reserved) :
- _capacity(capacity), _used(used), _reserved(reserved) {}
+ MetaspaceSizes() : _committed(0), _used(0), _reserved(0) {}
+ MetaspaceSizes(size_t committed, size_t used, size_t reserved) :
+ _committed(committed), _used(used), _reserved(reserved) {}
- size_t capacity() const { return _capacity; }
+ size_t committed() const { return _committed; }
size_t used() const { return _used; }
size_t reserved() const { return _reserved; }
};
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_implementation/shared/gcTraceSend.cpp
--- a/hotspot/src/share/vm/gc_implementation/shared/gcTraceSend.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_implementation/shared/gcTraceSend.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -258,7 +258,7 @@
static TraceStructMetaspaceSizes to_trace_struct(const MetaspaceSizes& sizes) {
TraceStructMetaspaceSizes meta_sizes;
- meta_sizes.set_capacity(sizes.capacity());
+ meta_sizes.set_committed(sizes.committed());
meta_sizes.set_used(sizes.used());
meta_sizes.set_reserved(sizes.reserved());
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_interface/collectedHeap.cpp
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -85,16 +85,16 @@
MetaspaceSummary CollectedHeap::create_metaspace_summary() {
const MetaspaceSizes meta_space(
- MetaspaceAux::allocated_capacity_bytes(),
- MetaspaceAux::allocated_used_bytes(),
+ MetaspaceAux::committed_bytes(),
+ MetaspaceAux::used_bytes(),
MetaspaceAux::reserved_bytes());
const MetaspaceSizes data_space(
- MetaspaceAux::allocated_capacity_bytes(Metaspace::NonClassType),
- MetaspaceAux::allocated_used_bytes(Metaspace::NonClassType),
+ MetaspaceAux::committed_bytes(Metaspace::NonClassType),
+ MetaspaceAux::used_bytes(Metaspace::NonClassType),
MetaspaceAux::reserved_bytes(Metaspace::NonClassType));
const MetaspaceSizes class_space(
- MetaspaceAux::allocated_capacity_bytes(Metaspace::ClassType),
- MetaspaceAux::allocated_used_bytes(Metaspace::ClassType),
+ MetaspaceAux::committed_bytes(Metaspace::ClassType),
+ MetaspaceAux::used_bytes(Metaspace::ClassType),
MetaspaceAux::reserved_bytes(Metaspace::ClassType));
const MetaspaceChunkFreeListSummary& ms_chunk_free_list_summary =
@@ -582,36 +582,6 @@
}
}
-oop CollectedHeap::Class_obj_allocate(KlassHandle klass, int size, KlassHandle real_klass, TRAPS) {
- debug_only(check_for_valid_allocation_state());
- assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
- assert(size >= 0, "int won't convert to size_t");
- HeapWord* obj;
- assert(ScavengeRootsInCode > 0, "must be");
- obj = common_mem_allocate_init(real_klass, size, CHECK_NULL);
- post_allocation_setup_common(klass, obj);
- assert(Universe::is_bootstrapping() ||
- !((oop)obj)->is_array(), "must not be an array");
- NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
- oop mirror = (oop)obj;
-
- java_lang_Class::set_oop_size(mirror, size);
-
- // Setup indirections
- if (!real_klass.is_null()) {
- java_lang_Class::set_klass(mirror, real_klass());
- real_klass->set_java_mirror(mirror);
- }
-
- InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(mirror->klass());
- assert(size == mk->instance_size(real_klass), "should have been set");
-
- // notify jvmti and dtrace
- post_allocation_notify(klass, (oop)obj);
-
- return mirror;
-}
-
/////////////// Unit tests ///////////////
#ifndef PRODUCT
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_interface/collectedHeap.hpp
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -151,7 +151,7 @@
inline static void post_allocation_setup_no_klass_install(KlassHandle klass,
HeapWord* objPtr);
- inline static void post_allocation_setup_obj(KlassHandle klass, HeapWord* obj);
+ inline static void post_allocation_setup_obj(KlassHandle klass, HeapWord* obj, int size);
inline static void post_allocation_setup_array(KlassHandle klass,
HeapWord* obj, int length);
@@ -312,9 +312,6 @@
// May be overridden to set additional parallelism.
virtual void set_par_threads(uint t) { _n_par_threads = t; };
- // Allocate and initialize instances of Class
- static oop Class_obj_allocate(KlassHandle klass, int size, KlassHandle real_klass, TRAPS);
-
// General obj/array allocation facilities.
inline static oop obj_allocate(KlassHandle klass, int size, TRAPS);
inline static oop array_allocate(KlassHandle klass, int size, int length, TRAPS);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -70,7 +70,7 @@
}
// Support for jvmti and dtrace
-inline void post_allocation_notify(KlassHandle klass, oop obj) {
+inline void post_allocation_notify(KlassHandle klass, oop obj, int size) {
// support low memory notifications (no-op if not enabled)
LowMemoryDetector::detect_low_memory_for_collected_pools();
@@ -80,18 +80,19 @@
if (DTraceAllocProbes) {
// support for Dtrace object alloc event (no-op most of the time)
if (klass() != NULL && klass()->name() != NULL) {
- SharedRuntime::dtrace_object_alloc(obj);
+ SharedRuntime::dtrace_object_alloc(obj, size);
}
}
}
void CollectedHeap::post_allocation_setup_obj(KlassHandle klass,
- HeapWord* obj) {
+ HeapWord* obj,
+ int size) {
post_allocation_setup_common(klass, obj);
assert(Universe::is_bootstrapping() ||
!((oop)obj)->is_array(), "must not be an array");
// notify jvmti and dtrace
- post_allocation_notify(klass, (oop)obj);
+ post_allocation_notify(klass, (oop)obj, size);
}
void CollectedHeap::post_allocation_setup_array(KlassHandle klass,
@@ -103,9 +104,10 @@
assert(length >= 0, "length should be non-negative");
((arrayOop)obj)->set_length(length);
post_allocation_setup_common(klass, obj);
- assert(((oop)obj)->is_array(), "must be an array");
+ oop new_obj = (oop)obj;
+ assert(new_obj->is_array(), "must be an array");
// notify jvmti and dtrace (must be after length is set for dtrace)
- post_allocation_notify(klass, (oop)obj);
+ post_allocation_notify(klass, new_obj, new_obj->size());
}
HeapWord* CollectedHeap::common_mem_allocate_noinit(KlassHandle klass, size_t size, TRAPS) {
@@ -199,7 +201,7 @@
assert(!Universe::heap()->is_gc_active(), "Allocation during gc not allowed");
assert(size >= 0, "int won't convert to size_t");
HeapWord* obj = common_mem_allocate_init(klass, size, CHECK_NULL);
- post_allocation_setup_obj(klass, obj);
+ post_allocation_setup_obj(klass, obj, size);
NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value(obj, size));
return (oop)obj;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/interpreter/abstractInterpreter.hpp
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -181,30 +181,16 @@
// Deoptimization should reexecute this bytecode
static bool bytecode_should_reexecute(Bytecodes::Code code);
- // share implementation of size_activation and layout_activation:
- static int size_activation(Method* method,
+ // deoptimization support
+ static int size_activation(int max_stack,
int temps,
- int popframe_args,
+ int extra_args,
int monitors,
- int caller_actual_parameters,
int callee_params,
int callee_locals,
- bool is_top_frame,
- bool is_bottom_frame) {
- return layout_activation(method,
- temps,
- popframe_args,
- monitors,
- caller_actual_parameters,
- callee_params,
- callee_locals,
- (frame*)NULL,
- (frame*)NULL,
- is_top_frame,
- is_bottom_frame);
- }
+ bool is_top_frame);
- static int layout_activation(Method* method,
+ static void layout_activation(Method* method,
int temps,
int popframe_args,
int monitors,
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/interpreter/linkResolver.cpp
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -243,7 +243,8 @@
// Look up method in klasses, including static methods
// Then look up local default methods
void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, bool checkpolymorphism, bool in_imethod_resolve, TRAPS) {
- Method* result_oop = klass->uncached_lookup_method(name, signature);
+ // Ignore overpasses so statics can be found during resolution
+ Method* result_oop = klass->uncached_lookup_method(name, signature, Klass::skip_overpass);
// JDK 8, JVMS 5.4.3.4: Interface method resolution should
// ignore static and non-public methods of java.lang.Object,
@@ -256,6 +257,12 @@
result_oop = NULL;
}
+ // Before considering default methods, check for an overpass in the
+ // current class if a method has not been found.
+ if (result_oop == NULL) {
+ result_oop = InstanceKlass::cast(klass())->find_method(name, signature);
+ }
+
if (result_oop == NULL) {
Array* default_methods = InstanceKlass::cast(klass())->default_methods();
if (default_methods != NULL) {
@@ -276,11 +283,11 @@
// returns first instance method
// Looks up method in classes, then looks up local default methods
void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
- Method* result_oop = klass->uncached_lookup_method(name, signature);
+ Method* result_oop = klass->uncached_lookup_method(name, signature, Klass::normal);
result = methodHandle(THREAD, result_oop);
while (!result.is_null() && result->is_static() && result->method_holder()->super() != NULL) {
KlassHandle super_klass = KlassHandle(THREAD, result->method_holder()->super());
- result = methodHandle(THREAD, super_klass->uncached_lookup_method(name, signature));
+ result = methodHandle(THREAD, super_klass->uncached_lookup_method(name, signature, Klass::normal));
}
if (result.is_null()) {
@@ -302,7 +309,7 @@
// First check in default method array
if (!resolved_method->is_abstract() &&
(InstanceKlass::cast(klass())->default_methods() != NULL)) {
- int index = InstanceKlass::find_method_index(InstanceKlass::cast(klass())->default_methods(), name, signature);
+ int index = InstanceKlass::find_method_index(InstanceKlass::cast(klass())->default_methods(), name, signature, false);
if (index >= 0 ) {
vtable_index = InstanceKlass::cast(klass())->default_vtable_indices()->at(index);
}
@@ -322,7 +329,7 @@
// Specify 'true' in order to skip default methods when searching the
// interfaces. Function lookup_method_in_klasses() already looked for
// the method in the default methods table.
- result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name, signature, true));
+ result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name, signature, Klass::skip_defaults));
}
void LinkResolver::lookup_polymorphic_method(methodHandle& result,
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/memory/collectorPolicy.cpp
--- a/hotspot/src/share/vm/memory/collectorPolicy.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -257,6 +257,12 @@
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),
+ "Ergonomics made minimum young generation larger than minimum heap");
+ assert(_initial_gen0_size <= bound_minus_alignment(_initial_gen0_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),
+ "Ergonomics made maximum young generation lager than maximum heap");
}
void TwoGenerationCollectorPolicy::assert_size_info() {
@@ -267,6 +273,9 @@
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");
}
#endif // ASSERT
@@ -303,20 +312,26 @@
}
}
+ // Make sure NewSize allows an old generation to fit even if set on the command line
+ if (FLAG_IS_CMDLINE(NewSize) && NewSize >= _initial_heap_byte_size) {
+ warning("NewSize was set larger than initial heap size, will use initial heap size.");
+ NewSize = bound_minus_alignment(NewSize, _initial_heap_byte_size);
+ }
+
// Now take the actual NewSize into account. We will silently increase NewSize
// if the user specified a smaller or unaligned value.
- smallest_new_size = MAX2(smallest_new_size, (uintx)align_size_down(NewSize, _gen_alignment));
- if (smallest_new_size != NewSize) {
+ uintx bounded_new_size = bound_minus_alignment(NewSize, MaxHeapSize);
+ bounded_new_size = MAX2(smallest_new_size, (uintx)align_size_down(bounded_new_size, _gen_alignment));
+ if (bounded_new_size != NewSize) {
// Do not use FLAG_SET_ERGO to update NewSize here, since this will override
// if NewSize was set on the command line or not. This information is needed
// later when setting the initial and minimum young generation size.
- NewSize = smallest_new_size;
+ NewSize = bounded_new_size;
}
+ _min_gen0_size = smallest_new_size;
_initial_gen0_size = NewSize;
if (!FLAG_IS_DEFAULT(MaxNewSize)) {
- uintx min_new_size = MAX2(_gen_alignment, _min_gen0_size);
-
if (MaxNewSize >= MaxHeapSize) {
// Make sure there is room for an old generation
uintx smaller_max_new_size = MaxHeapSize - _gen_alignment;
@@ -330,8 +345,8 @@
FLAG_SET_ERGO(uintx, NewSize, MaxNewSize);
_initial_gen0_size = NewSize;
}
- } else if (MaxNewSize < min_new_size) {
- FLAG_SET_ERGO(uintx, MaxNewSize, min_new_size);
+ } else if (MaxNewSize < _initial_gen0_size) {
+ FLAG_SET_ERGO(uintx, MaxNewSize, _initial_gen0_size);
} else if (!is_size_aligned(MaxNewSize, _gen_alignment)) {
FLAG_SET_ERGO(uintx, MaxNewSize, align_size_down(MaxNewSize, _gen_alignment));
}
@@ -361,7 +376,9 @@
GenCollectorPolicy::initialize_flags();
if (!is_size_aligned(OldSize, _gen_alignment)) {
- FLAG_SET_ERGO(uintx, OldSize, align_size_down(OldSize, _gen_alignment));
+ // Setting OldSize directly to preserve information about the possible
+ // setting of OldSize on the command line.
+ OldSize = align_size_down(OldSize, _gen_alignment);
}
if (FLAG_IS_CMDLINE(OldSize) && FLAG_IS_DEFAULT(MaxHeapSize)) {
@@ -400,6 +417,20 @@
}
}
+ // Update NewSize, if possible, to avoid sizing gen0 to 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
+ // might not have been set yet.
+ if (new_size >= _min_gen0_size && new_size <= MaxNewSize) {
+ FLAG_SET_ERGO(uintx, NewSize, new_size);
+ _initial_gen0_size = NewSize;
+ }
+ }
+ }
+
always_do_update_barrier = UseConcMarkSweepGC;
DEBUG_ONLY(TwoGenerationCollectorPolicy::assert_flags();)
@@ -441,57 +472,37 @@
// Given the maximum gen0 size, determine the initial and
// minimum gen0 sizes.
- if (_max_heap_byte_size == _min_heap_byte_size) {
- // The maximum and minimum heap sizes are the same so the generations
- // minimum and initial must be the same as its maximum.
- _min_gen0_size = max_new_size;
- _initial_gen0_size = max_new_size;
- _max_gen0_size = max_new_size;
+ if (_max_heap_byte_size == _initial_heap_byte_size) {
+ // The maxium 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;
+
+ // Also update the minimum size if min == initial == max.
+ if (_max_heap_byte_size == _min_heap_byte_size) {
+ _min_gen0_size = fixed_young_size;
+ }
} else {
size_t desired_new_size = 0;
if (FLAG_IS_CMDLINE(NewSize)) {
- // If NewSize is set on the command line, we must use it as
- // the initial size and it also makes sense to use it as the
- // lower limit.
- _min_gen0_size = NewSize;
- desired_new_size = NewSize;
- max_new_size = MAX2(max_new_size, NewSize);
- } else if (FLAG_IS_ERGO(NewSize)) {
- // If NewSize is set ergonomically, we should use it as a lower
- // limit, but use NewRatio to calculate the initial size.
- _min_gen0_size = 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 =
- MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize);
- max_new_size = MAX2(max_new_size, NewSize);
+ 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);
} else {
- // For the case where NewSize is the default, use NewRatio
- // to size the minimum and initial generation sizes.
- // Use the default NewSize as the floor for these values. If
- // NewRatio is overly large, the resulting sizes can be too small.
- _min_gen0_size = MAX2(scale_by_NewRatio_aligned(_min_heap_byte_size), NewSize);
+ // 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 =
- MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize);
+ MIN2(max_new_size, MAX2(scale_by_NewRatio_aligned(_initial_heap_byte_size), NewSize));
}
-
- assert(_min_gen0_size > 0, "Sanity check");
_initial_gen0_size = desired_new_size;
_max_gen0_size = max_new_size;
-
- // At this point the desirable initial and minimum sizes have been
- // determined without regard to the maximum sizes.
-
- // Bound the sizes by the corresponding overall heap sizes.
- _min_gen0_size = bound_minus_alignment(_min_gen0_size, _min_heap_byte_size);
- _initial_gen0_size = bound_minus_alignment(_initial_gen0_size, _initial_heap_byte_size);
- _max_gen0_size = bound_minus_alignment(_max_gen0_size, _max_heap_byte_size);
-
- // At this point all three sizes have been checked against the
- // maximum sizes but have not been checked for consistency among the three.
-
- // Final check min <= initial <= max
- _min_gen0_size = MIN2(_min_gen0_size, _max_gen0_size);
- _initial_gen0_size = MAX2(MIN2(_initial_gen0_size, _max_gen0_size), _min_gen0_size);
- _min_gen0_size = MIN2(_min_gen0_size, _initial_gen0_size);
}
// Write back to flags if necessary.
@@ -512,33 +523,6 @@
DEBUG_ONLY(GenCollectorPolicy::assert_size_info();)
}
-// Call this method during the sizing of the gen1 to make
-// adjustments to gen0 because of gen1 sizing policy. gen0 initially has
-// the most freedom in sizing because it is done before the
-// policy for gen1 is applied. Once gen1 policies have been applied,
-// there may be conflicts in the shape of the heap and this method
-// is used to make the needed adjustments. The application of the
-// policies could be more sophisticated (iterative for example) but
-// keeping it simple also seems a worthwhile goal.
-bool TwoGenerationCollectorPolicy::adjust_gen0_sizes(size_t* gen0_size_ptr,
- size_t* gen1_size_ptr,
- const size_t heap_size) {
- bool result = false;
-
- if ((*gen0_size_ptr + *gen1_size_ptr) > heap_size) {
- uintx smallest_new_size = young_gen_size_lower_bound();
- if ((heap_size < (*gen0_size_ptr + _min_gen1_size)) &&
- (heap_size >= _min_gen1_size + smallest_new_size)) {
- // Adjust gen0 down to accommodate _min_gen1_size
- *gen0_size_ptr = align_size_down_bounded(heap_size - _min_gen1_size, _gen_alignment);
- result = true;
- } else {
- *gen1_size_ptr = align_size_down_bounded(heap_size - *gen0_size_ptr, _gen_alignment);
- }
- }
- return result;
-}
-
// Minimum sizes of the generations may be different than
// the initial sizes. An inconsistency is permitted here
// in the total size that can be specified explicitly by
@@ -564,57 +548,64 @@
// 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 = MAX2(_min_heap_byte_size - _min_gen0_size, _gen_alignment);
- _initial_gen1_size = MAX2(_initial_heap_byte_size - _initial_gen0_size, _gen_alignment);
+ _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);
} else {
- // OldSize has been explicitly set on the command line. Use the
- // OldSize and then determine the consequences.
- _min_gen1_size = MIN2(OldSize, _min_heap_byte_size - _min_gen0_size);
- _initial_gen1_size = OldSize;
-
+ // OldSize has been explicitly set on the command line. Use it
+ // for the initial size but make sure the minimum allow a young
+ // generation to fit as well.
// If the user has explicitly set an OldSize that is inconsistent
// with other command line flags, issue a warning.
// The generation minimums and the overall heap minimum should
// be within one generation alignment.
- if ((_min_gen1_size + _min_gen0_size + _gen_alignment) < _min_heap_byte_size) {
- warning("Inconsistency between minimum heap size and minimum "
- "generation sizes: using minimum heap = " SIZE_FORMAT,
- _min_heap_byte_size);
- }
if (OldSize > _max_gen1_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);
+ "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);
}
- // If there is an inconsistency between the OldSize and the minimum and/or
- // initial size of gen0, since OldSize was explicitly set, OldSize wins.
- if (adjust_gen0_sizes(&_min_gen0_size, &_min_gen1_size, _min_heap_byte_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);
- }
+
+ _min_gen1_size = MIN2(OldSize, _min_heap_byte_size - _min_gen0_size);
+ _initial_gen1_size = OldSize;
+ }
+
+ // 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) {
+ 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) {
+ // 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) {
+ // 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) {
+ // Need to decrease both young and old generation
+ _initial_gen0_size = _min_gen0_size;
+ _initial_gen1_size = _initial_heap_byte_size - _min_gen0_size;
+ } else {
+ // The young generation boundaries allow us to only update the
+ // young generation.
+ _initial_gen0_size = desired_gen0_size;
}
- // The same as above for the old gen initial size.
- if (adjust_gen0_sizes(&_initial_gen0_size, &_initial_gen1_size,
- _initial_heap_byte_size)) {
- if (PrintGCDetails && Verbose) {
- gclog_or_tty->print_cr("3: Minimum gen0 " SIZE_FORMAT " Initial gen0 "
- SIZE_FORMAT " Maximum gen0 " SIZE_FORMAT,
- _min_gen0_size, _initial_gen0_size, _max_gen0_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);
}
}
- _min_gen1_size = MIN2(_min_gen1_size, _max_gen1_size);
-
- // Make sure that min gen1 <= initial gen1 <= max gen1.
- _initial_gen1_size = MAX2(_initial_gen1_size, _min_gen1_size);
- _initial_gen1_size = MIN2(_initial_gen1_size, _max_gen1_size);
-
// Write back to flags if necessary
if (NewSize != _initial_gen0_size) {
FLAG_SET_ERGO(uintx, NewSize, _initial_gen0_size);
@@ -994,56 +985,88 @@
// verify that there are some basic rules for NewSize honored by the policies.
class TestGenCollectorPolicy {
public:
- static void test() {
+ static void test_new_size() {
size_t flag_value;
save_flags();
- // Set some limits that makes the math simple.
- FLAG_SET_ERGO(uintx, MaxHeapSize, 180 * M);
- FLAG_SET_ERGO(uintx, InitialHeapSize, 120 * M);
- Arguments::set_min_heap_size(40 * M);
-
// If NewSize is set on the command line, it should be used
// for both min and initial young size if less than min heap.
flag_value = 20 * M;
+ set_basic_flag_values();
FLAG_SET_CMDLINE(uintx, NewSize, flag_value);
- verify_min(flag_value);
- verify_initial(flag_value);
+ verify_gen0_min(flag_value);
+
+ set_basic_flag_values();
+ FLAG_SET_CMDLINE(uintx, NewSize, flag_value);
+ verify_gen0_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_initial(flag_value);
+ verify_gen0_initial(flag_value);
// If NewSize has been ergonomically set, the collector policy
// should use it for min but calculate the initial young size
// using NewRatio.
flag_value = 20 * M;
+ set_basic_flag_values();
FLAG_SET_ERGO(uintx, NewSize, flag_value);
- verify_min(flag_value);
- verify_scaled_initial(InitialHeapSize);
+ verify_gen0_min(flag_value);
+
+ set_basic_flag_values();
+ FLAG_SET_ERGO(uintx, NewSize, flag_value);
+ verify_scaled_gen0_initial(InitialHeapSize);
restore_flags();
+ }
+
+ static void test_old_size() {
+ size_t flag_value;
+
+ save_flags();
+
+ // If OldSize is set on the command line, it should be used
+ // for both min and initial old size if less than min heap.
+ flag_value = 20 * M;
+ set_basic_flag_values();
+ FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
+ verify_gen1_min(flag_value);
+
+ set_basic_flag_values();
+ FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
+ verify_gen1_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
+ // ergonomically.
+ flag_value = 30 * M;
+ set_basic_flag_values();
+ FLAG_SET_CMDLINE(uintx, OldSize, flag_value);
+ FLAG_SET_CMDLINE(uintx, MaxNewSize, 170*M);
+ // Calculate what we expect the flag to be.
+ flag_value = MaxHeapSize - MaxNewSize;
+ verify_gen1_initial(flag_value);
}
- static void verify_min(size_t expected) {
+ static void verify_gen0_min(size_t expected) {
MarkSweepPolicy msp;
msp.initialize_all();
assert(msp.min_gen0_size() <= expected, err_msg("%zu > %zu", msp.min_gen0_size(), expected));
}
- static void verify_initial(size_t expected) {
+ static void verify_gen0_initial(size_t expected) {
MarkSweepPolicy msp;
msp.initialize_all();
assert(msp.initial_gen0_size() == expected, err_msg("%zu != %zu", msp.initial_gen0_size(), expected));
}
- static void verify_scaled_initial(size_t initial_heap_size) {
+ static void verify_scaled_gen0_initial(size_t initial_heap_size) {
MarkSweepPolicy msp;
msp.initialize_all();
@@ -1053,6 +1076,21 @@
err_msg("NewSize should have been set ergonomically to %zu, but was %zu", expected, NewSize));
}
+ static void verify_gen1_min(size_t expected) {
+ MarkSweepPolicy msp;
+ msp.initialize_all();
+
+ assert(msp.min_gen1_size() <= expected, err_msg("%zu > %zu", msp.min_gen1_size(), expected));
+ }
+
+ static void verify_gen1_initial(size_t expected) {
+ MarkSweepPolicy msp;
+ msp.initialize_all();
+
+ assert(msp.initial_gen1_size() == expected, err_msg("%zu != %zu", msp.initial_gen1_size(), expected));
+ }
+
+
private:
static size_t original_InitialHeapSize;
static size_t original_MaxHeapSize;
@@ -1061,6 +1099,15 @@
static size_t original_NewSize;
static size_t original_OldSize;
+ static void set_basic_flag_values() {
+ FLAG_SET_ERGO(uintx, MaxHeapSize, 180 * M);
+ FLAG_SET_ERGO(uintx, InitialHeapSize, 100 * M);
+ FLAG_SET_ERGO(uintx, OldSize, 4 * M);
+ FLAG_SET_ERGO(uintx, NewSize, 1 * M);
+ FLAG_SET_ERGO(uintx, MaxNewSize, 80 * M);
+ Arguments::set_min_heap_size(40 * M);
+ }
+
static void save_flags() {
original_InitialHeapSize = InitialHeapSize;
original_MaxHeapSize = MaxHeapSize;
@@ -1088,7 +1135,11 @@
size_t TestGenCollectorPolicy::original_OldSize = 0;
void TestNewSize_test() {
- TestGenCollectorPolicy::test();
+ TestGenCollectorPolicy::test_new_size();
+}
+
+void TestOldSize_test() {
+ TestGenCollectorPolicy::test_old_size();
}
#endif
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/memory/collectorPolicy.hpp
--- a/hotspot/src/share/vm/memory/collectorPolicy.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/memory/collectorPolicy.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -248,13 +248,13 @@
// Compute max heap alignment.
size_t compute_max_alignment();
- // Scale the base_size by NewRatio according to
- // result = base_size / (NewRatio + 1)
- // and align by min_alignment()
- size_t scale_by_NewRatio_aligned(size_t base_size);
+ // Scale the base_size by NewRatio according to
+ // result = base_size / (NewRatio + 1)
+ // and align by min_alignment()
+ size_t scale_by_NewRatio_aligned(size_t base_size);
- // Bound the value by the given maximum minus the min_alignment.
- size_t bound_minus_alignment(size_t desired_size, size_t maximum_size);
+ // Bound the value by the given maximum minus the min_alignment.
+ size_t bound_minus_alignment(size_t desired_size, size_t maximum_size);
public:
GenCollectorPolicy();
@@ -335,10 +335,6 @@
virtual CollectorPolicy::Name kind() {
return CollectorPolicy::TwoGenerationCollectorPolicyKind;
}
-
- // Returns true if gen0 sizes were adjusted
- bool adjust_gen0_sizes(size_t* gen0_size_ptr, size_t* gen1_size_ptr,
- const size_t heap_size);
};
class MarkSweepPolicy : public TwoGenerationCollectorPolicy {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/memory/genCollectedHeap.cpp
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -374,7 +374,7 @@
ClearedAllSoftRefs casr(do_clear_all_soft_refs, collector_policy());
- const size_t metadata_prev_used = MetaspaceAux::allocated_used_bytes();
+ const size_t metadata_prev_used = MetaspaceAux::used_bytes();
print_heap_before_gc();
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/memory/metaspace.cpp
--- a/hotspot/src/share/vm/memory/metaspace.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/memory/metaspace.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1447,7 +1447,7 @@
uint current_shrink_factor = _shrink_factor;
_shrink_factor = 0;
- const size_t used_after_gc = MetaspaceAux::allocated_capacity_bytes();
+ const size_t used_after_gc = MetaspaceAux::capacity_bytes();
const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC();
const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0;
@@ -2538,8 +2538,8 @@
// MetaspaceAux
-size_t MetaspaceAux::_allocated_capacity_words[] = {0, 0};
-size_t MetaspaceAux::_allocated_used_words[] = {0, 0};
+size_t MetaspaceAux::_capacity_words[] = {0, 0};
+size_t MetaspaceAux::_used_words[] = {0, 0};
size_t MetaspaceAux::free_bytes(Metaspace::MetadataType mdtype) {
VirtualSpaceList* list = Metaspace::get_space_list(mdtype);
@@ -2552,38 +2552,38 @@
void MetaspaceAux::dec_capacity(Metaspace::MetadataType mdtype, size_t words) {
assert_lock_strong(SpaceManager::expand_lock());
- assert(words <= allocated_capacity_words(mdtype),
+ assert(words <= capacity_words(mdtype),
err_msg("About to decrement below 0: words " SIZE_FORMAT
- " is greater than _allocated_capacity_words[%u] " SIZE_FORMAT,
- words, mdtype, allocated_capacity_words(mdtype)));
- _allocated_capacity_words[mdtype] -= words;
+ " is greater than _capacity_words[%u] " SIZE_FORMAT,
+ words, mdtype, capacity_words(mdtype)));
+ _capacity_words[mdtype] -= words;
}
void MetaspaceAux::inc_capacity(Metaspace::MetadataType mdtype, size_t words) {
assert_lock_strong(SpaceManager::expand_lock());
// Needs to be atomic
- _allocated_capacity_words[mdtype] += words;
+ _capacity_words[mdtype] += words;
}
void MetaspaceAux::dec_used(Metaspace::MetadataType mdtype, size_t words) {
- assert(words <= allocated_used_words(mdtype),
+ assert(words <= used_words(mdtype),
err_msg("About to decrement below 0: words " SIZE_FORMAT
- " is greater than _allocated_used_words[%u] " SIZE_FORMAT,
- words, mdtype, allocated_used_words(mdtype)));
+ " is greater than _used_words[%u] " SIZE_FORMAT,
+ words, mdtype, used_words(mdtype)));
// For CMS deallocation of the Metaspaces occurs during the
// sweep which is a concurrent phase. Protection by the expand_lock()
// is not enough since allocation is on a per Metaspace basis
// and protected by the Metaspace lock.
jlong minus_words = (jlong) - (jlong) words;
- Atomic::add_ptr(minus_words, &_allocated_used_words[mdtype]);
+ Atomic::add_ptr(minus_words, &_used_words[mdtype]);
}
void MetaspaceAux::inc_used(Metaspace::MetadataType mdtype, size_t words) {
- // _allocated_used_words tracks allocations for
+ // _used_words tracks allocations for
// each piece of metadata. Those allocations are
// generally done concurrently by different application
// threads so must be done atomically.
- Atomic::add_ptr(words, &_allocated_used_words[mdtype]);
+ Atomic::add_ptr(words, &_used_words[mdtype]);
}
size_t MetaspaceAux::used_bytes_slow(Metaspace::MetadataType mdtype) {
@@ -2630,16 +2630,16 @@
size_t MetaspaceAux::capacity_bytes_slow() {
#ifdef PRODUCT
- // Use allocated_capacity_bytes() in PRODUCT instead of this function.
+ // Use capacity_bytes() in PRODUCT instead of this function.
guarantee(false, "Should not call capacity_bytes_slow() in the PRODUCT");
#endif
size_t class_capacity = capacity_bytes_slow(Metaspace::ClassType);
size_t non_class_capacity = capacity_bytes_slow(Metaspace::NonClassType);
- assert(allocated_capacity_bytes() == class_capacity + non_class_capacity,
- err_msg("bad accounting: allocated_capacity_bytes() " SIZE_FORMAT
+ assert(capacity_bytes() == class_capacity + non_class_capacity,
+ err_msg("bad accounting: capacity_bytes() " SIZE_FORMAT
" class_capacity + non_class_capacity " SIZE_FORMAT
" class_capacity " SIZE_FORMAT " non_class_capacity " SIZE_FORMAT,
- allocated_capacity_bytes(), class_capacity + non_class_capacity,
+ capacity_bytes(), class_capacity + non_class_capacity,
class_capacity, non_class_capacity));
return class_capacity + non_class_capacity;
@@ -2699,14 +2699,14 @@
"->" SIZE_FORMAT
"(" SIZE_FORMAT ")",
prev_metadata_used,
- allocated_used_bytes(),
+ used_bytes(),
reserved_bytes());
} else {
gclog_or_tty->print(" " SIZE_FORMAT "K"
"->" SIZE_FORMAT "K"
"(" SIZE_FORMAT "K)",
prev_metadata_used/K,
- allocated_used_bytes()/K,
+ used_bytes()/K,
reserved_bytes()/K);
}
@@ -2722,8 +2722,8 @@
"capacity " SIZE_FORMAT "K, "
"committed " SIZE_FORMAT "K, "
"reserved " SIZE_FORMAT "K",
- allocated_used_bytes()/K,
- allocated_capacity_bytes()/K,
+ used_bytes()/K,
+ capacity_bytes()/K,
committed_bytes()/K,
reserved_bytes()/K);
@@ -2734,8 +2734,8 @@
"capacity " SIZE_FORMAT "K, "
"committed " SIZE_FORMAT "K, "
"reserved " SIZE_FORMAT "K",
- allocated_used_bytes(ct)/K,
- allocated_capacity_bytes(ct)/K,
+ used_bytes(ct)/K,
+ capacity_bytes(ct)/K,
committed_bytes(ct)/K,
reserved_bytes(ct)/K);
}
@@ -2837,42 +2837,42 @@
void MetaspaceAux::verify_capacity() {
#ifdef ASSERT
- size_t running_sum_capacity_bytes = allocated_capacity_bytes();
+ size_t running_sum_capacity_bytes = capacity_bytes();
// For purposes of the running sum of capacity, verify against capacity
size_t capacity_in_use_bytes = capacity_bytes_slow();
assert(running_sum_capacity_bytes == capacity_in_use_bytes,
- err_msg("allocated_capacity_words() * BytesPerWord " SIZE_FORMAT
+ err_msg("capacity_words() * BytesPerWord " SIZE_FORMAT
" capacity_bytes_slow()" SIZE_FORMAT,
running_sum_capacity_bytes, capacity_in_use_bytes));
for (Metaspace::MetadataType i = Metaspace::ClassType;
i < Metaspace:: MetadataTypeCount;
i = (Metaspace::MetadataType)(i + 1)) {
size_t capacity_in_use_bytes = capacity_bytes_slow(i);
- assert(allocated_capacity_bytes(i) == capacity_in_use_bytes,
- err_msg("allocated_capacity_bytes(%u) " SIZE_FORMAT
+ assert(capacity_bytes(i) == capacity_in_use_bytes,
+ err_msg("capacity_bytes(%u) " SIZE_FORMAT
" capacity_bytes_slow(%u)" SIZE_FORMAT,
- i, allocated_capacity_bytes(i), i, capacity_in_use_bytes));
+ i, capacity_bytes(i), i, capacity_in_use_bytes));
}
#endif
}
void MetaspaceAux::verify_used() {
#ifdef ASSERT
- size_t running_sum_used_bytes = allocated_used_bytes();
+ size_t running_sum_used_bytes = used_bytes();
// For purposes of the running sum of used, verify against used
size_t used_in_use_bytes = used_bytes_slow();
- assert(allocated_used_bytes() == used_in_use_bytes,
- err_msg("allocated_used_bytes() " SIZE_FORMAT
+ assert(used_bytes() == used_in_use_bytes,
+ err_msg("used_bytes() " SIZE_FORMAT
" used_bytes_slow()" SIZE_FORMAT,
- allocated_used_bytes(), used_in_use_bytes));
+ used_bytes(), used_in_use_bytes));
for (Metaspace::MetadataType i = Metaspace::ClassType;
i < Metaspace:: MetadataTypeCount;
i = (Metaspace::MetadataType)(i + 1)) {
size_t used_in_use_bytes = used_bytes_slow(i);
- assert(allocated_used_bytes(i) == used_in_use_bytes,
- err_msg("allocated_used_bytes(%u) " SIZE_FORMAT
+ assert(used_bytes(i) == used_in_use_bytes,
+ err_msg("used_bytes(%u) " SIZE_FORMAT
" used_bytes_slow(%u)" SIZE_FORMAT,
- i, allocated_used_bytes(i), i, used_in_use_bytes));
+ i, used_bytes(i), i, used_in_use_bytes));
}
#endif
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/memory/metaspace.hpp
--- a/hotspot/src/share/vm/memory/metaspace.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/memory/metaspace.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -280,11 +280,11 @@
// allocated to a Metaspace. This is used instead of
// iterating over all the classloaders. One for each
// type of Metadata
- static size_t _allocated_capacity_words[Metaspace:: MetadataTypeCount];
- // Running sum of space in all Metachunks that have
+ static size_t _capacity_words[Metaspace:: MetadataTypeCount];
+ // Running sum of space in all Metachunks that
// are being used for metadata. One for each
// type of Metadata.
- static size_t _allocated_used_words[Metaspace:: MetadataTypeCount];
+ static size_t _used_words[Metaspace:: MetadataTypeCount];
public:
// Decrement and increment _allocated_capacity_words
@@ -308,32 +308,32 @@
static size_t free_chunks_total_bytes();
static size_t free_chunks_total_bytes(Metaspace::MetadataType mdtype);
- static size_t allocated_capacity_words(Metaspace::MetadataType mdtype) {
- return _allocated_capacity_words[mdtype];
+ static size_t capacity_words(Metaspace::MetadataType mdtype) {
+ return _capacity_words[mdtype];
}
- static size_t allocated_capacity_words() {
- return allocated_capacity_words(Metaspace::NonClassType) +
- allocated_capacity_words(Metaspace::ClassType);
+ static size_t capacity_words() {
+ return capacity_words(Metaspace::NonClassType) +
+ capacity_words(Metaspace::ClassType);
}
- static size_t allocated_capacity_bytes(Metaspace::MetadataType mdtype) {
- return allocated_capacity_words(mdtype) * BytesPerWord;
+ static size_t capacity_bytes(Metaspace::MetadataType mdtype) {
+ return capacity_words(mdtype) * BytesPerWord;
}
- static size_t allocated_capacity_bytes() {
- return allocated_capacity_words() * BytesPerWord;
+ static size_t capacity_bytes() {
+ return capacity_words() * BytesPerWord;
}
- static size_t allocated_used_words(Metaspace::MetadataType mdtype) {
- return _allocated_used_words[mdtype];
+ static size_t used_words(Metaspace::MetadataType mdtype) {
+ return _used_words[mdtype];
}
- static size_t allocated_used_words() {
- return allocated_used_words(Metaspace::NonClassType) +
- allocated_used_words(Metaspace::ClassType);
+ static size_t used_words() {
+ return used_words(Metaspace::NonClassType) +
+ used_words(Metaspace::ClassType);
}
- static size_t allocated_used_bytes(Metaspace::MetadataType mdtype) {
- return allocated_used_words(mdtype) * BytesPerWord;
+ static size_t used_bytes(Metaspace::MetadataType mdtype) {
+ return used_words(mdtype) * BytesPerWord;
}
- static size_t allocated_used_bytes() {
- return allocated_used_words() * BytesPerWord;
+ static size_t used_bytes() {
+ return used_words() * BytesPerWord;
}
static size_t free_bytes();
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/memory/metaspaceCounters.cpp
--- a/hotspot/src/share/vm/memory/metaspaceCounters.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/memory/metaspaceCounters.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -66,7 +66,7 @@
MetaspacePerfCounters* MetaspaceCounters::_perf_counters = NULL;
size_t MetaspaceCounters::used() {
- return MetaspaceAux::allocated_used_bytes();
+ return MetaspaceAux::used_bytes();
}
size_t MetaspaceCounters::capacity() {
@@ -98,7 +98,7 @@
MetaspacePerfCounters* CompressedClassSpaceCounters::_perf_counters = NULL;
size_t CompressedClassSpaceCounters::used() {
- return MetaspaceAux::allocated_used_bytes(Metaspace::ClassType);
+ return MetaspaceAux::used_bytes(Metaspace::ClassType);
}
size_t CompressedClassSpaceCounters::capacity() {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/arrayKlass.cpp
--- a/hotspot/src/share/vm/oops/arrayKlass.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/arrayKlass.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -64,10 +64,10 @@
return NULL;
}
-Method* ArrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
+Method* ArrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const {
// There are no methods in an array klass but the super class (Object) has some
assert(super(), "super klass must be present");
- return super()->uncached_lookup_method(name, signature);
+ return super()->uncached_lookup_method(name, signature, mode);
}
ArrayKlass::ArrayKlass(Symbol* name) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/arrayKlass.hpp
--- a/hotspot/src/share/vm/oops/arrayKlass.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/arrayKlass.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -86,7 +86,7 @@
objArrayOop allocate_arrayArray(int n, int length, TRAPS);
// Lookup operations
- Method* uncached_lookup_method(Symbol* name, Symbol* signature) const;
+ Method* uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const;
// Casting from Klass*
static ArrayKlass* cast(Klass* k) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/constantPool.cpp
--- a/hotspot/src/share/vm/oops/constantPool.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/constantPool.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -144,6 +144,10 @@
// CDS support. Create a new resolved_references array.
void ConstantPool::restore_unshareable_info(TRAPS) {
+ // Only create the new resolved references array and lock if it hasn't been
+ // attempted before
+ if (resolved_references() != NULL) return;
+
// restore the C++ vtable from the shared archive
restore_vtable();
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/instanceKlass.cpp
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1289,17 +1289,18 @@
}
-void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, TRAPS), TRAPS) {
+void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle mirror, TRAPS) {
instanceKlassHandle h_this(THREAD, this);
- do_local_static_fields_impl(h_this, f, CHECK);
+ do_local_static_fields_impl(h_this, f, mirror, CHECK);
}
-void InstanceKlass::do_local_static_fields_impl(instanceKlassHandle this_k, void f(fieldDescriptor* fd, TRAPS), TRAPS) {
+void InstanceKlass::do_local_static_fields_impl(instanceKlassHandle this_k,
+ void f(fieldDescriptor* fd, Handle, TRAPS), Handle mirror, TRAPS) {
for (JavaFieldStream fs(this_k()); !fs.done(); fs.next()) {
if (fs.access_flags().is_static()) {
fieldDescriptor& fd = fs.field_descriptor();
- f(&fd, CHECK);
+ f(&fd, mirror, CHECK);
}
}
}
@@ -1388,7 +1389,11 @@
// find_method looks up the name/signature in the local methods array
Method* InstanceKlass::find_method(Symbol* name, Symbol* signature) const {
- return InstanceKlass::find_method(methods(), name, signature);
+ return find_method_impl(name, signature, false);
+}
+
+Method* InstanceKlass::find_method_impl(Symbol* name, Symbol* signature, bool skipping_overpass) const {
+ return InstanceKlass::find_method_impl(methods(), name, signature, skipping_overpass);
}
// find_instance_method looks up the name/signature in the local methods array
@@ -1405,40 +1410,49 @@
// find_method looks up the name/signature in the local methods array
Method* InstanceKlass::find_method(
Array* methods, Symbol* name, Symbol* signature) {
- int hit = find_method_index(methods, name, signature);
+ return InstanceKlass::find_method_impl(methods, name, signature, false);
+}
+
+Method* InstanceKlass::find_method_impl(
+ Array* methods, Symbol* name, Symbol* signature, bool skipping_overpass) {
+ int hit = find_method_index(methods, name, signature, skipping_overpass);
return hit >= 0 ? methods->at(hit): NULL;
}
// Used directly for default_methods to find the index into the
// default_vtable_indices, and indirectly by find_method
// find_method_index looks in the local methods array to return the index
-// of the matching name/signature
+// of the matching name/signature. If, overpass methods are being ignored,
+// the search continues to find a potential non-overpass match. This capability
+// is important during method resolution to prefer a static method, for example,
+// over an overpass method.
int InstanceKlass::find_method_index(
- Array* methods, Symbol* name, Symbol* signature) {
+ Array* methods, Symbol* name, Symbol* signature, bool skipping_overpass) {
int hit = binary_search(methods, name);
if (hit != -1) {
Method* m = methods->at(hit);
// Do linear search to find matching signature. First, quick check
- // for common case
- if (m->signature() == signature) return hit;
+ // for common case, ignoring overpasses if requested.
+ if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return hit;
+
// search downwards through overloaded methods
int i;
for (i = hit - 1; i >= 0; --i) {
Method* m = methods->at(i);
assert(m->is_method(), "must be method");
if (m->name() != name) break;
- if (m->signature() == signature) return i;
+ if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return i;
}
// search upwards
for (i = hit + 1; i < methods->length(); ++i) {
Method* m = methods->at(i);
assert(m->is_method(), "must be method");
if (m->name() != name) break;
- if (m->signature() == signature) return i;
+ if ((m->signature() == signature) && (!skipping_overpass || !m->is_overpass())) return i;
}
// not found
#ifdef ASSERT
- int index = linear_search(methods, name, signature);
+ int index = skipping_overpass ? -1 : linear_search(methods, name, signature);
assert(index == -1, err_msg("binary search should have found entry %d", index));
#endif
}
@@ -1464,16 +1478,16 @@
// uncached_lookup_method searches both the local class methods array and all
// superclasses methods arrays, skipping any overpass methods in superclasses.
-Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
+Method* InstanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const {
+ MethodLookupMode lookup_mode = mode;
Klass* klass = const_cast(this);
- bool dont_ignore_overpasses = true; // For the class being searched, find its overpasses.
while (klass != NULL) {
- Method* method = InstanceKlass::cast(klass)->find_method(name, signature);
- if ((method != NULL) && (dont_ignore_overpasses || !method->is_overpass())) {
+ Method* method = InstanceKlass::cast(klass)->find_method_impl(name, signature, (lookup_mode == skip_overpass));
+ if (method != NULL) {
return method;
}
klass = InstanceKlass::cast(klass)->super();
- dont_ignore_overpasses = false; // Ignore overpass methods in all superclasses.
+ lookup_mode = skip_overpass; // Always ignore overpass methods in superclasses
}
return NULL;
}
@@ -1488,7 +1502,7 @@
}
// Look up interfaces
if (m == NULL) {
- m = lookup_method_in_all_interfaces(name, signature, false);
+ m = lookup_method_in_all_interfaces(name, signature, normal);
}
return m;
}
@@ -1498,7 +1512,7 @@
// They should only be found in the initial InterfaceMethodRef
Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name,
Symbol* signature,
- bool skip_default_methods) const {
+ MethodLookupMode mode) const {
Array* all_ifs = transitive_interfaces();
int num_ifs = all_ifs->length();
InstanceKlass *ik = NULL;
@@ -1506,7 +1520,7 @@
ik = InstanceKlass::cast(all_ifs->at(i));
Method* m = ik->lookup_method(name, signature);
if (m != NULL && m->is_public() && !m->is_static() &&
- (!skip_default_methods || !m->is_default_method())) {
+ ((mode != skip_defaults) || !m->is_default_method())) {
return m;
}
}
@@ -2240,9 +2254,7 @@
int num_methods = methods->length();
for (int index2 = 0; index2 < num_methods; ++index2) {
methodHandle m(THREAD, methods->at(index2));
- m()->link_method(m, CHECK);
- // restore method's vtable by calling a virtual function
- m->restore_vtable();
+ m->restore_unshareable_info(CHECK);
}
if (JvmtiExport::has_redefined_a_class()) {
// Reinitialize vtable because RedefineClasses may have changed some
@@ -3409,6 +3421,10 @@
("purge: %s(%s): prev method @%d in version @%d is alive",
method->name()->as_C_string(),
method->signature()->as_C_string(), j, i));
+ if (method->method_data() != NULL) {
+ // Clean out any weak method links
+ method->method_data()->clean_weak_method_links();
+ }
}
}
}
@@ -3418,6 +3434,14 @@
("purge: previous version stats: live=%d, deleted=%d", live_count,
deleted_count));
}
+
+ Array* methods = ik->methods();
+ int num_methods = methods->length();
+ for (int index2 = 0; index2 < num_methods; ++index2) {
+ if (methods->at(index2)->method_data() != NULL) {
+ methods->at(index2)->method_data()->clean_weak_method_links();
+ }
+ }
}
// External interface for use during class unloading.
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/instanceKlass.hpp
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -490,14 +490,14 @@
static Method* find_instance_method(Array* methods, Symbol* name, Symbol* signature);
// find a local method index in default_methods (returns -1 if not found)
- static int find_method_index(Array* methods, Symbol* name, Symbol* signature);
+ static int find_method_index(Array* methods, Symbol* name, Symbol* signature, bool skipping_overpass);
// lookup operation (returns NULL if not found)
- Method* uncached_lookup_method(Symbol* name, Symbol* signature) const;
+ Method* uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const;
// lookup a method in all the interfaces that this class implements
// (returns NULL if not found)
- Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, bool skip_default_methods) const;
+ Method* lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, MethodLookupMode mode) const;
// lookup a method in local defaults then in all interfaces
// (returns NULL if not found)
@@ -802,7 +802,7 @@
// Iterators
void do_local_static_fields(FieldClosure* cl);
void do_nonstatic_fields(FieldClosure* cl); // including inherited fields
- void do_local_static_fields(void f(fieldDescriptor*, TRAPS), TRAPS);
+ void do_local_static_fields(void f(fieldDescriptor*, Handle, TRAPS), Handle, TRAPS);
void methods_do(void f(Method* method));
void array_klasses_do(void f(Klass* k));
@@ -1010,7 +1010,7 @@
static void set_initialization_state_and_notify_impl (instanceKlassHandle this_k, ClassState state, TRAPS);
static void call_class_initializer_impl (instanceKlassHandle this_k, TRAPS);
static Klass* array_klass_impl (instanceKlassHandle this_k, bool or_null, int n, TRAPS);
- static void do_local_static_fields_impl (instanceKlassHandle this_k, void f(fieldDescriptor* fd, TRAPS), TRAPS);
+ static void do_local_static_fields_impl (instanceKlassHandle this_k, void f(fieldDescriptor* fd, Handle, TRAPS), Handle, TRAPS);
/* jni_id_for_impl for jfieldID only */
static JNIid* jni_id_for_impl (instanceKlassHandle this_k, int offset);
@@ -1020,6 +1020,10 @@
// Returns the array class with this class as element type
Klass* array_klass_impl(bool or_null, TRAPS);
+ // find a local method (returns NULL if not found)
+ Method* find_method_impl(Symbol* name, Symbol* signature, bool skipping_overpass) const;
+ static Method* find_method_impl(Array* methods, Symbol* name, Symbol* signature, bool skipping_overpass);
+
// Free CHeap allocated fields.
void release_C_heap_structures();
public:
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/instanceMirrorKlass.cpp
--- a/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, 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
@@ -367,7 +367,12 @@
// Query before forming handle.
int size = instance_size(k);
KlassHandle h_k(THREAD, this);
- instanceOop i = (instanceOop) CollectedHeap::Class_obj_allocate(h_k, size, k, CHECK_NULL);
+ instanceOop i = (instanceOop)CollectedHeap::obj_allocate(h_k, size, CHECK_NULL);
+
+ // Since mirrors can be variable sized because of the static fields, store
+ // the size in the mirror itself.
+ java_lang_Class::set_oop_size(i, size);
+
return i;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/klass.cpp
--- a/hotspot/src/share/vm/oops/klass.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/klass.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -129,7 +129,7 @@
}
-Method* Klass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
+Method* Klass::uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const {
#ifdef ASSERT
tty->print_cr("Error: uncached_lookup_method called on a klass oop."
" Likely error: reflection method does not correctly"
@@ -475,12 +475,8 @@
}
void Klass::remove_unshareable_info() {
- if (!DumpSharedSpaces) {
- // Clean up after OOM during class loading
- if (class_loader_data() != NULL) {
- class_loader_data()->remove_class(this);
- }
- }
+ assert (DumpSharedSpaces, "only called for DumpSharedSpaces");
+
set_subklass(NULL);
set_next_sibling(NULL);
// Clear the java mirror
@@ -492,17 +488,26 @@
}
void Klass::restore_unshareable_info(TRAPS) {
- ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
- // Restore class_loader_data to the null class loader data
- set_class_loader_data(loader_data);
+ // If an exception happened during CDS restore, some of these fields may already be
+ // set. We leave the class on the CLD list, even if incomplete so that we don't
+ // modify the CLD list outside a safepoint.
+ if (class_loader_data() == NULL) {
+ ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data();
+ // Restore class_loader_data to the null class loader data
+ set_class_loader_data(loader_data);
- // Add to null class loader list first before creating the mirror
- // (same order as class file parsing)
- loader_data->add_class(this);
+ // Add to null class loader list first before creating the mirror
+ // (same order as class file parsing)
+ loader_data->add_class(this);
+ }
// Recreate the class mirror. The protection_domain is always null for
// boot loader, for now.
- java_lang_Class::create_mirror(this, Handle(NULL), CHECK);
+ // Only recreate it if not present. A previous attempt to restore may have
+ // gotten an OOM later but keep the mirror if it was created.
+ if (java_mirror() == NULL) {
+ java_lang_Class::create_mirror(this, Handle(NULL), CHECK);
+ }
}
Klass* Klass::array_klass_or_null(int rank) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/klass.hpp
--- a/hotspot/src/share/vm/oops/klass.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/klass.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -154,6 +154,8 @@
void* operator new(size_t size, ClassLoaderData* loader_data, size_t word_size, TRAPS) throw();
public:
+ enum MethodLookupMode { normal, skip_overpass, skip_defaults };
+
bool is_klass() const volatile { return true; }
// super
@@ -391,10 +393,10 @@
virtual void initialize(TRAPS);
// lookup operation for MethodLookupCache
friend class MethodLookupCache;
- virtual Method* uncached_lookup_method(Symbol* name, Symbol* signature) const;
+ virtual Method* uncached_lookup_method(Symbol* name, Symbol* signature, MethodLookupMode mode) const;
public:
Method* lookup_method(Symbol* name, Symbol* signature) const {
- return uncached_lookup_method(name, signature);
+ return uncached_lookup_method(name, signature, normal);
}
// array class with specific rank
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/klassVtable.cpp
--- a/hotspot/src/share/vm/oops/klassVtable.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/klassVtable.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -622,7 +622,7 @@
// this check for all access permissions.
InstanceKlass *sk = InstanceKlass::cast(super);
if (sk->has_miranda_methods()) {
- if (sk->lookup_method_in_all_interfaces(name, signature, false) != NULL) {
+ if (sk->lookup_method_in_all_interfaces(name, signature, Klass::normal) != NULL) {
return false; // found a matching miranda; we do not need a new entry
}
}
@@ -698,7 +698,7 @@
&& mo->method_holder() != NULL
&& mo->method_holder()->super() != NULL)
{
- mo = mo->method_holder()->super()->uncached_lookup_method(name, signature);
+ mo = mo->method_holder()->super()->uncached_lookup_method(name, signature, Klass::normal);
}
if (mo == NULL || mo->access_flags().is_private() ) {
// super class hierarchy does not implement it or protection is different
@@ -743,7 +743,7 @@
if (is_miranda(im, class_methods, default_methods, super)) { // is it a miranda at all?
InstanceKlass *sk = InstanceKlass::cast(super);
// check if it is a duplicate of a super's miranda
- if (sk->lookup_method_in_all_interfaces(im->name(), im->signature(), false) == NULL) {
+ if (sk->lookup_method_in_all_interfaces(im->name(), im->signature(), Klass::normal) == NULL) {
new_mirandas->append(im);
}
if (all_mirandas != NULL) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/method.cpp
--- a/hotspot/src/share/vm/oops/method.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/method.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -903,6 +903,19 @@
return adapter->get_c2i_entry();
}
+void Method::restore_unshareable_info(TRAPS) {
+ // Since restore_unshareable_info can be called more than once for a method, don't
+ // redo any work. If this field is restored, there is nothing to do.
+ if (_from_compiled_entry == NULL) {
+ // restore method's vtable by calling a virtual function
+ restore_vtable();
+
+ methodHandle mh(THREAD, this);
+ link_method(mh, CHECK);
+ }
+}
+
+
// The verified_code_entry() must be called when a invoke is resolved
// on this method.
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/method.hpp
--- a/hotspot/src/share/vm/oops/method.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/method.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -123,6 +123,8 @@
void restore_vtable() { guarantee(is_method(), "vtable restored by this call"); }
bool is_method() const volatile { return true; }
+ void restore_unshareable_info(TRAPS);
+
// accessors for instance variables
ConstMethod* constMethod() const { return _constMethod; }
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/methodData.cpp
--- a/hotspot/src/share/vm/oops/methodData.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/methodData.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1531,9 +1531,35 @@
}
}
-// Remove SpeculativeTrapData entries that reference an unloaded
-// method
-void MethodData::clean_extra_data(BoolObjectClosure* is_alive) {
+class CleanExtraDataClosure : public StackObj {
+public:
+ virtual bool is_live(Method* m) = 0;
+};
+
+// Check for entries that reference an unloaded method
+class CleanExtraDataKlassClosure : public CleanExtraDataClosure {
+private:
+ BoolObjectClosure* _is_alive;
+public:
+ CleanExtraDataKlassClosure(BoolObjectClosure* is_alive) : _is_alive(is_alive) {}
+ bool is_live(Method* m) {
+ return m->method_holder()->is_loader_alive(_is_alive);
+ }
+};
+
+// Check for entries that reference a redefined method
+class CleanExtraDataMethodClosure : public CleanExtraDataClosure {
+public:
+ CleanExtraDataMethodClosure() {}
+ bool is_live(Method* m) {
+ return m->on_stack();
+ }
+};
+
+
+// Remove SpeculativeTrapData entries that reference an unloaded or
+// redefined method
+void MethodData::clean_extra_data(CleanExtraDataClosure* cl) {
DataLayout* dp = extra_data_base();
DataLayout* end = extra_data_limit();
@@ -1544,7 +1570,7 @@
SpeculativeTrapData* data = new SpeculativeTrapData(dp);
Method* m = data->method();
assert(m != NULL, "should have a method");
- if (!m->method_holder()->is_loader_alive(is_alive)) {
+ if (!cl->is_live(m)) {
// "shift" accumulates the number of cells for dead
// SpeculativeTrapData entries that have been seen so
// far. Following entries must be shifted left by that many
@@ -1575,9 +1601,9 @@
}
}
-// Verify there's no unloaded method referenced by a
+// Verify there's no unloaded or redefined method referenced by a
// SpeculativeTrapData entry
-void MethodData::verify_extra_data_clean(BoolObjectClosure* is_alive) {
+void MethodData::verify_extra_data_clean(CleanExtraDataClosure* cl) {
#ifdef ASSERT
DataLayout* dp = extra_data_base();
DataLayout* end = extra_data_limit();
@@ -1587,7 +1613,7 @@
case DataLayout::speculative_trap_data_tag: {
SpeculativeTrapData* data = new SpeculativeTrapData(dp);
Method* m = data->method();
- assert(m != NULL && m->method_holder()->is_loader_alive(is_alive), "Method should exist");
+ assert(m != NULL && cl->is_live(m), "Method should exist");
break;
}
case DataLayout::bit_data_tag:
@@ -1613,6 +1639,19 @@
parameters->clean_weak_klass_links(is_alive);
}
- clean_extra_data(is_alive);
- verify_extra_data_clean(is_alive);
+ CleanExtraDataKlassClosure cl(is_alive);
+ clean_extra_data(&cl);
+ verify_extra_data_clean(&cl);
}
+
+void MethodData::clean_weak_method_links() {
+ for (ProfileData* data = first_data();
+ is_valid(data);
+ data = next_data(data)) {
+ data->clean_weak_method_links();
+ }
+
+ CleanExtraDataMethodClosure cl;
+ clean_extra_data(&cl);
+ verify_extra_data_clean(&cl);
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/methodData.hpp
--- a/hotspot/src/share/vm/oops/methodData.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/methodData.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -251,6 +251,9 @@
// GC support
void clean_weak_klass_links(BoolObjectClosure* cl);
+
+ // Redefinition support
+ void clean_weak_method_links();
};
@@ -506,6 +509,9 @@
// GC support
virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) {}
+ // Redefinition support
+ virtual void clean_weak_method_links() {}
+
// CI translation: ProfileData can represent both MethodDataOop data
// as well as CIMethodData data. This function is provided for translating
// an oop in a ProfileData to the ci equivalent. Generally speaking,
@@ -1989,6 +1995,7 @@
//
CC_INTERP_ONLY(class BytecodeInterpreter;)
+class CleanExtraDataClosure;
class MethodData : public Metadata {
friend class VMStructs;
@@ -2146,9 +2153,9 @@
static bool profile_parameters_jsr292_only();
static bool profile_all_parameters();
- void clean_extra_data(BoolObjectClosure* is_alive);
+ void clean_extra_data(CleanExtraDataClosure* cl);
void clean_extra_data_helper(DataLayout* dp, int shift, bool reset = false);
- void verify_extra_data_clean(BoolObjectClosure* is_alive);
+ void verify_extra_data_clean(CleanExtraDataClosure* cl);
public:
static int header_size() {
@@ -2440,6 +2447,8 @@
static bool profile_return_jsr292_only();
void clean_method_data(BoolObjectClosure* is_alive);
+
+ void clean_weak_method_links();
};
#endif // SHARE_VM_OOPS_METHODDATAOOP_HPP
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/oops/objArrayKlass.cpp
--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -269,7 +269,7 @@
if (element_is_null ||
(new_val->klass())->is_subtype_of(bound)) {
bs->write_ref_field_pre(p, new_val);
- *p = *from;
+ *p = element;
} else {
// We must do a barrier to cover the partial copy.
const size_t pd = pointer_delta(p, dst, (size_t)heapOopSize);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/callGenerator.cpp
--- a/hotspot/src/share/vm/opto/callGenerator.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/callGenerator.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -70,6 +70,7 @@
JVMState* ParseGenerator::generate(JVMState* jvms, Parse* parent_parser) {
Compile* C = Compile::current();
+ C->print_inlining_update(this);
if (is_osr()) {
// The JVMS for a OSR has a single argument (see its TypeFunc).
@@ -126,6 +127,7 @@
JVMState* DirectCallGenerator::generate(JVMState* jvms, Parse* parent_parser) {
GraphKit kit(jvms);
+ kit.C->print_inlining_update(this);
bool is_static = method()->is_static();
address target = is_static ? SharedRuntime::get_resolve_static_call_stub()
: SharedRuntime::get_resolve_opt_virtual_call_stub();
@@ -178,6 +180,8 @@
GraphKit kit(jvms);
Node* receiver = kit.argument(0);
+ kit.C->print_inlining_update(this);
+
if (kit.C->log() != NULL) {
kit.C->log()->elem("virtual_call bci='%d'", jvms->bci());
}
@@ -262,23 +266,27 @@
// Allow inlining decisions to be delayed
class LateInlineCallGenerator : public DirectCallGenerator {
+ private:
+ // unique id for log compilation
+ jlong _unique_id;
+
protected:
CallGenerator* _inline_cg;
-
virtual bool do_late_inline_check(JVMState* jvms) { return true; }
public:
LateInlineCallGenerator(ciMethod* method, CallGenerator* inline_cg) :
- DirectCallGenerator(method, true), _inline_cg(inline_cg) {}
+ DirectCallGenerator(method, true), _inline_cg(inline_cg), _unique_id(0) {}
- virtual bool is_late_inline() const { return true; }
+ virtual bool is_late_inline() const { return true; }
// Convert the CallStaticJava into an inline
virtual void do_late_inline();
virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
Compile *C = Compile::current();
- C->print_inlining_skip(this);
+
+ C->log_inline_id(this);
// Record that this call site should be revisited once the main
// parse is finished.
@@ -296,10 +304,19 @@
virtual void print_inlining_late(const char* msg) {
CallNode* call = call_node();
Compile* C = Compile::current();
- C->print_inlining_insert(this);
+ C->print_inlining_assert_ready();
C->print_inlining(method(), call->jvms()->depth()-1, call->jvms()->bci(), msg);
+ C->print_inlining_move_to(this);
+ C->print_inlining_update_delayed(this);
}
+ virtual void set_unique_id(jlong id) {
+ _unique_id = id;
+ }
+
+ virtual jlong unique_id() const {
+ return _unique_id;
+ }
};
void LateInlineCallGenerator::do_late_inline() {
@@ -360,6 +377,12 @@
map->set_argument(jvms, i1, call->in(TypeFunc::Parms + i1));
}
+ C->print_inlining_assert_ready();
+
+ C->print_inlining_move_to(this);
+
+ C->log_late_inline(this);
+
// This check is done here because for_method_handle_inline() method
// needs jvms for inlined state.
if (!do_late_inline_check(jvms)) {
@@ -367,19 +390,6 @@
return;
}
- C->print_inlining_insert(this);
-
- CompileLog* log = C->log();
- if (log != NULL) {
- log->head("late_inline method='%d'", log->identify(method()));
- JVMState* p = jvms;
- while (p != NULL) {
- log->elem("jvms bci='%d' method='%d'", p->bci(), log->identify(p->method()));
- p = p->caller();
- }
- log->tail("late_inline");
- }
-
// Setup default node notes to be picked up by the inlining
Node_Notes* old_nn = C->default_node_notes();
if (old_nn != NULL) {
@@ -388,7 +398,7 @@
C->set_default_node_notes(entry_nn);
}
- // Now perform the inling using the synthesized JVMState
+ // Now perform the inlining using the synthesized JVMState
JVMState* new_jvms = _inline_cg->generate(jvms, NULL);
if (new_jvms == NULL) return; // no change
if (C->failing()) return;
@@ -431,25 +441,24 @@
virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
JVMState* new_jvms = LateInlineCallGenerator::generate(jvms, parent_parser);
+
+ Compile* C = Compile::current();
if (_input_not_const) {
// inlining won't be possible so no need to enqueue right now.
call_node()->set_generator(this);
} else {
- Compile::current()->add_late_inline(this);
+ C->add_late_inline(this);
}
return new_jvms;
}
-
- virtual void print_inlining_late(const char* msg) {
- if (!_input_not_const) return;
- LateInlineCallGenerator::print_inlining_late(msg);
- }
};
bool LateInlineMHCallGenerator::do_late_inline_check(JVMState* jvms) {
CallGenerator* cg = for_method_handle_inline(jvms, _caller, method(), _input_not_const);
+ Compile::current()->print_inlining_update_delayed(this);
+
if (!_input_not_const) {
_attempt++;
}
@@ -479,7 +488,8 @@
virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
Compile *C = Compile::current();
- C->print_inlining_skip(this);
+
+ C->log_inline_id(this);
C->add_string_late_inline(this);
@@ -502,7 +512,8 @@
virtual JVMState* generate(JVMState* jvms, Parse* parent_parser) {
Compile *C = Compile::current();
- C->print_inlining_skip(this);
+
+ C->log_inline_id(this);
C->add_boxing_late_inline(this);
@@ -554,6 +565,8 @@
JVMState* WarmCallGenerator::generate(JVMState* jvms, Parse* parent_parser) {
Compile* C = Compile::current();
+ C->print_inlining_update(this);
+
if (C->log() != NULL) {
C->log()->elem("warm_call bci='%d'", jvms->bci());
}
@@ -632,6 +645,7 @@
JVMState* PredictedCallGenerator::generate(JVMState* jvms, Parse* parent_parser) {
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.
@@ -779,6 +793,10 @@
assert(cg == NULL || !cg->is_late_inline() || cg->is_mh_late_inline(), "no late inline here");
if (cg != NULL && cg->is_inline())
return cg;
+ } else {
+ const char* msg = "receiver not constant";
+ if (PrintInlining) C->print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
+ C->log_inline_failure(msg);
}
}
break;
@@ -844,11 +862,14 @@
// provide us with a type
speculative_receiver_type = receiver_type->speculative_type();
}
-
CallGenerator* cg = C->call_generator(target, vtable_index, call_does_dispatch, jvms, true, PROB_ALWAYS, speculative_receiver_type, true, true);
assert(cg == NULL || !cg->is_late_inline() || cg->is_mh_late_inline(), "no late inline here");
if (cg != NULL && cg->is_inline())
return cg;
+ } else {
+ const char* msg = "member_name not constant";
+ if (PrintInlining) C->print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
+ C->log_inline_failure(msg);
}
}
break;
@@ -904,6 +925,7 @@
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) {
@@ -1017,6 +1039,7 @@
JVMState* UncommonTrapCallGenerator::generate(JVMState* jvms, Parse* parent_parser) {
GraphKit kit(jvms);
+ kit.C->print_inlining_update(this);
// Take the trap with arguments pushed on the stack. (Cf. null_check_receiver).
int nargs = method()->arg_size();
kit.inc_sp(nargs);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/callGenerator.hpp
--- a/hotspot/src/share/vm/opto/callGenerator.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/callGenerator.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -84,6 +84,9 @@
virtual CallStaticJavaNode* call_node() const { ShouldNotReachHere(); return NULL; }
+ virtual void set_unique_id(jlong id) { fatal("unique id only for late inlines"); };
+ virtual jlong unique_id() const { fatal("unique id only for late inlines"); return 0; };
+
// Note: It is possible for a CG to be both inline and virtual.
// (The hashCode intrinsic does a vtable check and an inlined fast path.)
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/callnode.cpp
--- a/hotspot/src/share/vm/opto/callnode.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/callnode.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -608,6 +608,39 @@
}
}
+// Mirror the stack size calculation in the deopt code
+// How much stack space would we need at this point in the program in
+// case of deoptimization?
+int JVMState::interpreter_frame_size() const {
+ const JVMState* jvms = this;
+ int size = 0;
+ int callee_parameters = 0;
+ int callee_locals = 0;
+ int extra_args = method()->max_stack() - stk_size();
+
+ while (jvms != NULL) {
+ int locks = jvms->nof_monitors();
+ int temps = jvms->stk_size();
+ bool is_top_frame = (jvms == this);
+ ciMethod* method = jvms->method();
+
+ int frame_size = BytesPerWord * Interpreter::size_activation(method->max_stack(),
+ temps + callee_parameters,
+ extra_args,
+ locks,
+ callee_parameters,
+ callee_locals,
+ is_top_frame);
+ size += frame_size;
+
+ callee_parameters = method->size_of_parameters();
+ callee_locals = method->max_locals();
+ extra_args = 0;
+ jvms = jvms->caller();
+ }
+ return size + Deoptimization::last_frame_adjust(0, callee_locals) * BytesPerWord;
+}
+
//=============================================================================
uint CallNode::cmp( const Node &n ) const
{ return _tf == ((CallNode&)n)._tf && _jvms == ((CallNode&)n)._jvms; }
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/callnode.hpp
--- a/hotspot/src/share/vm/opto/callnode.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/callnode.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -300,6 +300,7 @@
JVMState* clone_shallow(Compile* C) const; // retains uncloned caller
void set_map_deep(SafePointNode *map);// reset map for all callers
void adapt_position(int delta); // Adapt offsets in in-array after adding an edge.
+ int interpreter_frame_size() const;
#ifndef PRODUCT
void format(PhaseRegAlloc *regalloc, const Node *n, outputStream* st) const;
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/compile.cpp
--- a/hotspot/src/share/vm/opto/compile.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/compile.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -440,6 +440,14 @@
return words;
}
+// To bang the stack of this compiled method we use the stack size
+// that the interpreter would need in case of a deoptimization. This
+// removes the need to bang the stack in the deoptimization blob which
+// in turn simplifies stack overflow handling.
+int Compile::bang_size_in_bytes() const {
+ return MAX2(_interpreter_frame_size, frame_size_in_bytes());
+}
+
// ============================================================================
//------------------------------CompileWrapper---------------------------------
class CompileWrapper : public StackObj {
@@ -662,8 +670,10 @@
_inlining_progress(false),
_inlining_incrementally(false),
_print_inlining_list(NULL),
+ _print_inlining_stream(NULL),
_print_inlining_idx(0),
- _preserve_jvm_state(0) {
+ _preserve_jvm_state(0),
+ _interpreter_frame_size(0) {
C = this;
CompileWrapper cw(this);
@@ -723,9 +733,7 @@
PhaseGVN gvn(node_arena(), estimated_size);
set_initial_gvn(&gvn);
- if (print_inlining() || print_intrinsics()) {
- _print_inlining_list = new (comp_arena())GrowableArray(comp_arena(), 1, 1, PrintInliningBuffer());
- }
+ print_inlining_init();
{ // Scope for timing the parser
TracePhase t3("parse", &_t_parser, true);
@@ -967,9 +975,11 @@
_inlining_progress(false),
_inlining_incrementally(false),
_print_inlining_list(NULL),
+ _print_inlining_stream(NULL),
_print_inlining_idx(0),
_preserve_jvm_state(0),
- _allowed_reasons(0) {
+ _allowed_reasons(0),
+ _interpreter_frame_size(0) {
C = this;
#ifndef PRODUCT
@@ -2023,6 +2033,8 @@
ResourceMark rm;
int loop_opts_cnt;
+ print_inlining_reinit();
+
NOT_PRODUCT( verify_graph_edges(); )
print_method(PHASE_AFTER_PARSING);
@@ -3076,8 +3088,12 @@
Node* m = n->in(i);
++i;
if (m != NULL && !frc._visited.test_set(m->_idx)) {
- if (m->is_SafePoint() && m->as_SafePoint()->jvms() != NULL)
+ if (m->is_SafePoint() && m->as_SafePoint()->jvms() != NULL) {
+ // compute worst case interpreter size in case of a deoptimization
+ update_interpreter_frame_size(m->as_SafePoint()->jvms()->interpreter_frame_size());
+
sfpt.push(m);
+ }
cnt = m->req();
nstack.push(n, i); // put on stack parent and next input's index
n = m;
@@ -3755,36 +3771,163 @@
}
}
-void Compile::dump_inlining() {
+// The message about the current inlining is accumulated in
+// _print_inlining_stream and transfered into the _print_inlining_list
+// once we know whether inlining succeeds or not. For regular
+// inlining, messages are appended to the buffer pointed by
+// _print_inlining_idx in the _print_inlining_list. For late inlining,
+// a new buffer is added after _print_inlining_idx in the list. This
+// way we can update the inlining message for late inlining call site
+// when the inlining is attempted again.
+void Compile::print_inlining_init() {
+ if (print_inlining() || print_intrinsics()) {
+ _print_inlining_stream = new stringStream();
+ _print_inlining_list = new (comp_arena())GrowableArray(comp_arena(), 1, 1, PrintInliningBuffer());
+ }
+}
+
+void Compile::print_inlining_reinit() {
+ if (print_inlining() || print_intrinsics()) {
+ // Re allocate buffer when we change ResourceMark
+ _print_inlining_stream = new stringStream();
+ }
+}
+
+void Compile::print_inlining_reset() {
+ _print_inlining_stream->reset();
+}
+
+void Compile::print_inlining_commit() {
+ assert(print_inlining() || print_intrinsics(), "PrintInlining off?");
+ // Transfer the message from _print_inlining_stream to the current
+ // _print_inlining_list buffer and clear _print_inlining_stream.
+ _print_inlining_list->at(_print_inlining_idx).ss()->write(_print_inlining_stream->as_string(), _print_inlining_stream->size());
+ print_inlining_reset();
+}
+
+void Compile::print_inlining_push() {
+ // Add new buffer to the _print_inlining_list at current position
+ _print_inlining_idx++;
+ _print_inlining_list->insert_before(_print_inlining_idx, PrintInliningBuffer());
+}
+
+Compile::PrintInliningBuffer& Compile::print_inlining_current() {
+ return _print_inlining_list->at(_print_inlining_idx);
+}
+
+void Compile::print_inlining_update(CallGenerator* cg) {
if (print_inlining() || print_intrinsics()) {
+ if (!cg->is_late_inline()) {
+ if (print_inlining_current().cg() != NULL) {
+ print_inlining_push();
+ }
+ print_inlining_commit();
+ } else {
+ if (print_inlining_current().cg() != cg &&
+ (print_inlining_current().cg() != NULL ||
+ print_inlining_current().ss()->size() != 0)) {
+ print_inlining_push();
+ }
+ print_inlining_commit();
+ print_inlining_current().set_cg(cg);
+ }
+ }
+}
+
+void Compile::print_inlining_move_to(CallGenerator* cg) {
+ // We resume inlining at a late inlining call site. Locate the
+ // corresponding inlining buffer so that we can update it.
+ if (print_inlining()) {
+ for (int i = 0; i < _print_inlining_list->length(); i++) {
+ if (_print_inlining_list->adr_at(i)->cg() == cg) {
+ _print_inlining_idx = i;
+ return;
+ }
+ }
+ ShouldNotReachHere();
+ }
+}
+
+void Compile::print_inlining_update_delayed(CallGenerator* cg) {
+ if (print_inlining()) {
+ assert(_print_inlining_stream->size() > 0, "missing inlining msg");
+ assert(print_inlining_current().cg() == cg, "wrong entry");
+ // replace message with new message
+ _print_inlining_list->at_put(_print_inlining_idx, PrintInliningBuffer());
+ print_inlining_commit();
+ print_inlining_current().set_cg(cg);
+ }
+}
+
+void Compile::print_inlining_assert_ready() {
+ assert(!_print_inlining || _print_inlining_stream->size() == 0, "loosing data");
+}
+
+void Compile::dump_inlining() {
+ bool do_print_inlining = print_inlining() || print_intrinsics();
+ if (do_print_inlining || log() != NULL) {
// Print inlining message for candidates that we couldn't inline
- // for lack of space or non constant receiver
+ // for lack of space
for (int i = 0; i < _late_inlines.length(); i++) {
CallGenerator* cg = _late_inlines.at(i);
- cg->print_inlining_late("live nodes > LiveNodeCountInliningCutoff");
- }
- Unique_Node_List useful;
- useful.push(root());
- for (uint next = 0; next < useful.size(); ++next) {
- Node* n = useful.at(next);
- if (n->is_Call() && n->as_Call()->generator() != NULL && n->as_Call()->generator()->call_node() == n) {
- CallNode* call = n->as_Call();
- CallGenerator* cg = call->generator();
- cg->print_inlining_late("receiver not constant");
- }
- uint max = n->len();
- for ( uint i = 0; i < max; ++i ) {
- Node *m = n->in(i);
- if ( m == NULL ) continue;
- useful.push(m);
+ if (!cg->is_mh_late_inline()) {
+ const char* msg = "live nodes > LiveNodeCountInliningCutoff";
+ if (do_print_inlining) {
+ cg->print_inlining_late(msg);
+ }
+ log_late_inline_failure(cg, msg);
}
}
+ }
+ if (do_print_inlining) {
for (int i = 0; i < _print_inlining_list->length(); i++) {
tty->print(_print_inlining_list->adr_at(i)->ss()->as_string());
}
}
}
+void Compile::log_late_inline(CallGenerator* cg) {
+ if (log() != NULL) {
+ log()->head("late_inline method='%d' inline_id='" JLONG_FORMAT "'", log()->identify(cg->method()),
+ cg->unique_id());
+ JVMState* p = cg->call_node()->jvms();
+ while (p != NULL) {
+ log()->elem("jvms bci='%d' method='%d'", p->bci(), log()->identify(p->method()));
+ p = p->caller();
+ }
+ log()->tail("late_inline");
+ }
+}
+
+void Compile::log_late_inline_failure(CallGenerator* cg, const char* msg) {
+ log_late_inline(cg);
+ if (log() != NULL) {
+ log()->inline_fail(msg);
+ }
+}
+
+void Compile::log_inline_id(CallGenerator* cg) {
+ if (log() != NULL) {
+ // The LogCompilation tool needs a unique way to identify late
+ // inline call sites. This id must be unique for this call site in
+ // this compilation. Try to have it unique across compilations as
+ // well because it can be convenient when grepping through the log
+ // file.
+ // Distinguish OSR compilations from others in case CICountOSR is
+ // on.
+ jlong id = ((jlong)unique()) + (((jlong)compile_id()) << 33) + (CICountOSR && is_osr_compilation() ? ((jlong)1) << 32 : 0);
+ cg->set_unique_id(id);
+ log()->elem("inline_id id='" JLONG_FORMAT "'", id);
+ }
+}
+
+void Compile::log_inline_failure(const char* msg) {
+ if (C->log() != NULL) {
+ C->log()->inline_fail(msg);
+ }
+}
+
+
// Dump inlining replay data to the stream.
// Don't change thread state and acquire any locks.
void Compile::dump_inline_data(outputStream* out) {
@@ -3962,8 +4105,8 @@
worklist.push(root());
for (uint next = 0; next < worklist.size(); ++next) {
Node *n = worklist.at(next);
- const Type* t = igvn.type(n);
- assert(t == t->remove_speculative(), "no more speculative types");
+ const Type* t = igvn.type_or_null(n);
+ assert((t == NULL) || (t == t->remove_speculative()), "no more speculative types");
if (n->is_Type()) {
t = n->as_Type()->type();
assert(t == t->remove_speculative(), "no more speculative types");
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/compile.hpp
--- a/hotspot/src/share/vm/opto/compile.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/compile.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -416,6 +416,7 @@
void set_cg(CallGenerator* cg) { _cg = cg; }
};
+ stringStream* _print_inlining_stream;
GrowableArray* _print_inlining_list;
int _print_inlining_idx;
@@ -433,33 +434,26 @@
void* _replay_inline_data; // Pointer to data loaded from file
+ void print_inlining_init();
+ void print_inlining_reinit();
+ void print_inlining_commit();
+ void print_inlining_push();
+ PrintInliningBuffer& print_inlining_current();
+
+ void log_late_inline_failure(CallGenerator* cg, const char* msg);
+
public:
outputStream* print_inlining_stream() const {
- return _print_inlining_list->adr_at(_print_inlining_idx)->ss();
- }
-
- void print_inlining_skip(CallGenerator* cg) {
- if (_print_inlining) {
- _print_inlining_list->adr_at(_print_inlining_idx)->set_cg(cg);
- _print_inlining_idx++;
- _print_inlining_list->insert_before(_print_inlining_idx, PrintInliningBuffer());
- }
+ assert(print_inlining() || print_intrinsics(), "PrintInlining off?");
+ return _print_inlining_stream;
}
- void print_inlining_insert(CallGenerator* cg) {
- if (_print_inlining) {
- for (int i = 0; i < _print_inlining_list->length(); i++) {
- if (_print_inlining_list->adr_at(i)->cg() == cg) {
- _print_inlining_list->insert_before(i+1, PrintInliningBuffer());
- _print_inlining_idx = i+1;
- _print_inlining_list->adr_at(i)->set_cg(NULL);
- return;
- }
- }
- ShouldNotReachHere();
- }
- }
+ void print_inlining_update(CallGenerator* cg);
+ void print_inlining_update_delayed(CallGenerator* cg);
+ void print_inlining_move_to(CallGenerator* cg);
+ void print_inlining_assert_ready();
+ void print_inlining_reset();
void print_inlining(ciMethod* method, int inline_level, int bci, const char* msg = NULL) {
stringStream ss;
@@ -467,6 +461,10 @@
print_inlining_stream()->print(ss.as_string());
}
+ void log_late_inline(CallGenerator* cg);
+ void log_inline_id(CallGenerator* cg);
+ void log_inline_failure(const char* msg);
+
void* replay_inline_data() const { return _replay_inline_data; }
// Dump inlining replay data to the stream.
@@ -486,6 +484,7 @@
RegMask _FIRST_STACK_mask; // All stack slots usable for spills (depends on frame layout)
Arena* _indexSet_arena; // control IndexSet allocation within PhaseChaitin
void* _indexSet_free_block_list; // free list of IndexSet bit blocks
+ int _interpreter_frame_size;
uint _node_bundling_limit;
Bundle* _node_bundling_base; // Information for instruction bundling
@@ -943,6 +942,7 @@
PhaseRegAlloc* regalloc() { return _regalloc; }
int frame_slots() const { return _frame_slots; }
int frame_size_in_words() const; // frame_slots in units of the polymorphic 'words'
+ int frame_size_in_bytes() const { return _frame_slots << LogBytesPerInt; }
RegMask& FIRST_STACK_mask() { return _FIRST_STACK_mask; }
Arena* indexSet_arena() { return _indexSet_arena; }
void* indexSet_free_block_list() { return _indexSet_free_block_list; }
@@ -954,6 +954,13 @@
bool need_stack_bang(int frame_size_in_bytes) const;
bool need_register_stack_bang() const;
+ void update_interpreter_frame_size(int size) {
+ if (_interpreter_frame_size < size) {
+ _interpreter_frame_size = size;
+ }
+ }
+ int bang_size_in_bytes() const;
+
void set_matcher(Matcher* m) { _matcher = m; }
//void set_regalloc(PhaseRegAlloc* ra) { _regalloc = ra; }
void set_indexSet_arena(Arena* a) { _indexSet_arena = a; }
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/doCall.cpp
--- a/hotspot/src/share/vm/opto/doCall.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/doCall.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -104,6 +104,9 @@
log->print(" receiver2='%d' receiver2_count='%d'", r2id, profile.receiver_count(1));
}
}
+ if (callee->is_method_handle_intrinsic()) {
+ log->print(" method_handle_intrinsic='1'");
+ }
log->end_elem();
}
@@ -294,6 +297,9 @@
// There was no special inlining tactic, or it bailed out.
// Use a more generic tactic, like a simple call.
if (call_does_dispatch) {
+ const char* msg = "virtual call";
+ if (PrintInlining) print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
+ C->log_inline_failure(msg);
return CallGenerator::for_virtual_call(callee, vtable_index);
} else {
// Class Hierarchy Analysis or Type Profile reveals a unique target,
@@ -396,6 +402,8 @@
// our contribution to it is cleaned up right here.
kill_dead_locals();
+ C->print_inlining_assert_ready();
+
// Set frequently used booleans
const bool is_virtual = bc() == Bytecodes::_invokevirtual;
const bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface;
@@ -531,7 +539,8 @@
// 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);
- if ((new_jvms = cg->generate(jvms, this)) == NULL) {
+ new_jvms = cg->generate(jvms, this);
+ if (new_jvms == NULL) {
guarantee(failing(), "call failed to generate: calls should work");
return;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/escape.cpp
--- a/hotspot/src/share/vm/opto/escape.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/escape.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -711,7 +711,7 @@
Node *val = n->in(MemNode::ValueIn);
PointsToNode* ptn = ptnode_adr(val->_idx);
assert(ptn != NULL, "node should be registered");
- ptn->set_escape_state(PointsToNode::GlobalEscape);
+ set_escape_state(ptn, PointsToNode::GlobalEscape);
// Add edge to object for unsafe access with offset.
PointsToNode* adr_ptn = ptnode_adr(adr->_idx);
assert(adr_ptn != NULL, "node should be registered");
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/library_call.cpp
--- a/hotspot/src/share/vm/opto/library_call.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/library_call.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -620,6 +620,7 @@
}
// Push the result from the inlined method onto the stack.
kit.push_result();
+ C->print_inlining_update(this);
return kit.transfer_exceptions_into_jvms();
}
@@ -637,6 +638,7 @@
}
}
C->gather_intrinsic_statistics(intrinsic_id(), is_virtual(), Compile::_intrinsic_failed);
+ C->print_inlining_update(this);
return NULL;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/loopTransform.cpp
--- a/hotspot/src/share/vm/opto/loopTransform.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1150,6 +1150,7 @@
// Now force out all loop-invariant dominating tests. The optimizer
// finds some, but we _know_ they are all useless.
peeled_dom_test_elim(loop,old_new);
+ loop->record_for_igvn();
}
//------------------------------is_invariant-----------------------------
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/loopnode.cpp
--- a/hotspot/src/share/vm/opto/loopnode.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/loopnode.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -3172,17 +3172,16 @@
bool had_error = false;
#ifdef ASSERT
if (early != C->root()) {
- // Make sure that there's a dominance path from use to LCA
- Node* d = use;
- while (d != LCA) {
- d = idom(d);
+ // Make sure that there's a dominance path from LCA to early
+ Node* d = LCA;
+ while (d != early) {
if (d == C->root()) {
- tty->print_cr("*** Use %d isn't dominated by def %s", use->_idx, n->_idx);
- n->dump();
- use->dump();
+ dump_bad_graph("Bad graph detected in compute_lca_of_uses", n, early, LCA);
+ tty->print_cr("*** Use %d isn't dominated by def %d ***", use->_idx, n->_idx);
had_error = true;
break;
}
+ d = idom(d);
}
}
#endif
@@ -3435,6 +3434,13 @@
_igvn._worklist.push(n); // Maybe we'll normalize it, if no more loops.
}
+#ifdef ASSERT
+ if (_verify_only && !n->is_CFG()) {
+ // Check def-use domination.
+ compute_lca_of_uses(n, get_ctrl(n), true /* verify */);
+ }
+#endif
+
// CFG and pinned nodes already handled
if( n->in(0) ) {
if( n->in(0)->is_top() ) return; // Dead?
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/loopopts.cpp
--- a/hotspot/src/share/vm/opto/loopopts.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/loopopts.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -2700,6 +2700,7 @@
// Inhibit more partial peeling on this loop
new_head_clone->set_partial_peel_loop();
C->set_major_progress();
+ loop->record_for_igvn();
#if !defined(PRODUCT)
if (TracePartialPeeling) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/machnode.hpp
--- a/hotspot/src/share/vm/opto/machnode.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/machnode.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -210,7 +210,14 @@
bool may_be_short_branch() const { return (flags() & Flag_may_be_short_branch) != 0; }
// Avoid back to back some instructions on some CPUs.
- bool avoid_back_to_back() const { return (flags() & Flag_avoid_back_to_back) != 0; }
+ enum AvoidBackToBackFlag { AVOID_NONE = 0,
+ AVOID_BEFORE = Flag_avoid_back_to_back_before,
+ AVOID_AFTER = Flag_avoid_back_to_back_after,
+ AVOID_BEFORE_AND_AFTER = AVOID_BEFORE | AVOID_AFTER };
+
+ bool avoid_back_to_back(AvoidBackToBackFlag flag_value) const {
+ return (flags() & flag_value) == flag_value;
+ }
// instruction implemented with a call
bool has_call() const { return (flags() & Flag_has_call) != 0; }
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/node.hpp
--- a/hotspot/src/share/vm/opto/node.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/node.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -645,17 +645,18 @@
// Flags are sorted by usage frequency.
enum NodeFlags {
- Flag_is_Copy = 0x01, // should be first bit to avoid shift
- Flag_rematerialize = Flag_is_Copy << 1,
+ Flag_is_Copy = 0x01, // should be first bit to avoid shift
+ Flag_rematerialize = Flag_is_Copy << 1,
Flag_needs_anti_dependence_check = Flag_rematerialize << 1,
- Flag_is_macro = Flag_needs_anti_dependence_check << 1,
- Flag_is_Con = Flag_is_macro << 1,
- Flag_is_cisc_alternate = Flag_is_Con << 1,
- Flag_is_dead_loop_safe = Flag_is_cisc_alternate << 1,
- Flag_may_be_short_branch = Flag_is_dead_loop_safe << 1,
- Flag_avoid_back_to_back = Flag_may_be_short_branch << 1,
- Flag_has_call = Flag_avoid_back_to_back << 1,
- Flag_is_expensive = Flag_has_call << 1,
+ Flag_is_macro = Flag_needs_anti_dependence_check << 1,
+ Flag_is_Con = Flag_is_macro << 1,
+ Flag_is_cisc_alternate = Flag_is_Con << 1,
+ Flag_is_dead_loop_safe = Flag_is_cisc_alternate << 1,
+ Flag_may_be_short_branch = Flag_is_dead_loop_safe << 1,
+ Flag_avoid_back_to_back_before = Flag_may_be_short_branch << 1,
+ Flag_avoid_back_to_back_after = Flag_avoid_back_to_back_before << 1,
+ Flag_has_call = Flag_avoid_back_to_back_after << 1,
+ Flag_is_expensive = Flag_has_call << 1,
_max_flags = (Flag_is_expensive << 1) - 1 // allow flags combination
};
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/output.cpp
--- a/hotspot/src/share/vm/opto/output.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/output.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -165,8 +165,13 @@
// Determine if we need to generate a stack overflow check.
// Do it if the method is not a stub function and
// has java calls or has frame size > vm_page_size/8.
+ // The debug VM checks that deoptimization doesn't trigger an
+ // unexpected stack overflow (compiled method stack banging should
+ // guarantee it doesn't happen) so we always need the stack bang in
+ // a debug VM.
return (UseStackBanging && stub_function() == NULL &&
- (has_java_calls() || frame_size_in_bytes > os::vm_page_size()>>3));
+ (has_java_calls() || frame_size_in_bytes > os::vm_page_size()>>3
+ DEBUG_ONLY(|| true)));
}
bool Compile::need_register_stack_bang() const {
@@ -411,7 +416,7 @@
blk_size += nop_size;
}
}
- if (mach->avoid_back_to_back()) {
+ if (mach->avoid_back_to_back(MachNode::AVOID_BEFORE)) {
// Nop is inserted between "avoid back to back" instructions.
// ScheduleAndBundle() can rearrange nodes in a block,
// check for all offsets inside this block.
@@ -439,7 +444,7 @@
last_call_adr = blk_starts[i]+blk_size;
}
// Remember end of avoid_back_to_back offset
- if (nj->is_Mach() && nj->as_Mach()->avoid_back_to_back()) {
+ if (nj->is_Mach() && nj->as_Mach()->avoid_back_to_back(MachNode::AVOID_AFTER)) {
last_avoid_back_to_back_adr = blk_starts[i]+blk_size;
}
}
@@ -525,11 +530,11 @@
int new_size = replacement->size(_regalloc);
int diff = br_size - new_size;
assert(diff >= (int)nop_size, "short_branch size should be smaller");
- // Conservatively take into accound padding between
+ // Conservatively take into account padding between
// avoid_back_to_back branches. Previous branch could be
// converted into avoid_back_to_back branch during next
// rounds.
- if (needs_padding && replacement->avoid_back_to_back()) {
+ if (needs_padding && replacement->avoid_back_to_back(MachNode::AVOID_BEFORE)) {
jmp_offset[i] += nop_size;
diff -= nop_size;
}
@@ -548,7 +553,7 @@
}
} // (mach->may_be_short_branch())
if (mach != NULL && (mach->may_be_short_branch() ||
- mach->avoid_back_to_back())) {
+ mach->avoid_back_to_back(MachNode::AVOID_AFTER))) {
last_may_be_short_branch_adr = blk_starts[i] + jmp_offset[i] + jmp_size[i];
}
blk_starts[i+1] -= adjust_block_start;
@@ -1313,7 +1318,7 @@
if (is_sfn && !is_mcall && padding == 0 && current_offset == last_call_offset) {
padding = nop_size;
}
- if (padding == 0 && mach->avoid_back_to_back() &&
+ if (padding == 0 && mach->avoid_back_to_back(MachNode::AVOID_BEFORE) &&
current_offset == last_avoid_back_to_back_offset) {
// Avoid back to back some instructions.
padding = nop_size;
@@ -1407,7 +1412,7 @@
int new_size = replacement->size(_regalloc);
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()) {
+ if (needs_padding && replacement->avoid_back_to_back(MachNode::AVOID_BEFORE)) {
MachNode *nop = new (this) MachNopNode();
block->insert_node(nop, j++);
_cfg->map_node_to_block(nop, block);
@@ -1515,7 +1520,7 @@
last_call_offset = current_offset;
}
- if (n->is_Mach() && n->as_Mach()->avoid_back_to_back()) {
+ if (n->is_Mach() && n->as_Mach()->avoid_back_to_back(MachNode::AVOID_AFTER)) {
// Avoid back to back some instructions.
last_avoid_back_to_back_offset = current_offset;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/phaseX.cpp
--- a/hotspot/src/share/vm/opto/phaseX.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/phaseX.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -831,154 +831,111 @@
}
}
+/**
+ * Initialize worklist for each node.
+ */
+void PhaseIterGVN::init_worklist(Node* first) {
+ Unique_Node_List to_process;
+ to_process.push(first);
+
+ while (to_process.size() > 0) {
+ Node* n = to_process.pop();
+ if (!_worklist.member(n)) {
+ _worklist.push(n);
+
+ uint cnt = n->req();
+ for(uint i = 0; i < cnt; i++) {
+ Node* m = n->in(i);
+ if (m != NULL) {
+ to_process.push(m);
+ }
+ }
+ }
+ }
+}
#ifndef PRODUCT
void PhaseIterGVN::verify_step(Node* n) {
- _verify_window[_verify_counter % _verify_window_size] = n;
- ++_verify_counter;
- ResourceMark rm;
- ResourceArea *area = Thread::current()->resource_area();
- VectorSet old_space(area), new_space(area);
- if (C->unique() < 1000 ||
- 0 == _verify_counter % (C->unique() < 10000 ? 10 : 100)) {
- ++_verify_full_passes;
- Node::verify_recur(C->root(), -1, old_space, new_space);
- }
- const int verify_depth = 4;
- for ( int i = 0; i < _verify_window_size; i++ ) {
- Node* n = _verify_window[i];
- if ( n == NULL ) continue;
- if( n->in(0) == NodeSentinel ) { // xform_idom
- _verify_window[i] = n->in(1);
- --i; continue;
+ if (VerifyIterativeGVN) {
+ _verify_window[_verify_counter % _verify_window_size] = n;
+ ++_verify_counter;
+ ResourceMark rm;
+ ResourceArea* area = Thread::current()->resource_area();
+ VectorSet old_space(area), new_space(area);
+ if (C->unique() < 1000 ||
+ 0 == _verify_counter % (C->unique() < 10000 ? 10 : 100)) {
+ ++_verify_full_passes;
+ Node::verify_recur(C->root(), -1, old_space, new_space);
}
- // Typical fanout is 1-2, so this call visits about 6 nodes.
- Node::verify_recur(n, verify_depth, old_space, new_space);
- }
-}
-#endif
-
-
-//------------------------------init_worklist----------------------------------
-// Initialize worklist for each node.
-void PhaseIterGVN::init_worklist( Node *n ) {
- if( _worklist.member(n) ) return;
- _worklist.push(n);
- uint cnt = n->req();
- for( uint i =0 ; i < cnt; i++ ) {
- Node *m = n->in(i);
- if( m ) init_worklist(m);
+ const int verify_depth = 4;
+ for ( int i = 0; i < _verify_window_size; i++ ) {
+ Node* n = _verify_window[i];
+ if ( n == NULL ) continue;
+ if( n->in(0) == NodeSentinel ) { // xform_idom
+ _verify_window[i] = n->in(1);
+ --i; continue;
+ }
+ // Typical fanout is 1-2, so this call visits about 6 nodes.
+ Node::verify_recur(n, verify_depth, old_space, new_space);
+ }
}
}
-//------------------------------optimize---------------------------------------
-void PhaseIterGVN::optimize() {
- debug_only(uint num_processed = 0;);
-#ifndef PRODUCT
- {
- _verify_counter = 0;
- _verify_full_passes = 0;
- for ( int i = 0; i < _verify_window_size; i++ ) {
- _verify_window[i] = NULL;
+void PhaseIterGVN::trace_PhaseIterGVN(Node* n, Node* nn, const Type* oldtype) {
+ if (TraceIterativeGVN) {
+ uint wlsize = _worklist.size();
+ const Type* newtype = type_or_null(n);
+ if (nn != n) {
+ // print old node
+ tty->print("< ");
+ if (oldtype != newtype && oldtype != NULL) {
+ oldtype->dump();
+ }
+ do { tty->print("\t"); } while (tty->position() < 16);
+ tty->print("<");
+ n->dump();
+ }
+ if (oldtype != newtype || nn != n) {
+ // print new node and/or new type
+ if (oldtype == NULL) {
+ tty->print("* ");
+ } else if (nn != n) {
+ tty->print("> ");
+ } else {
+ tty->print("= ");
+ }
+ if (newtype == NULL) {
+ tty->print("null");
+ } else {
+ newtype->dump();
+ }
+ do { tty->print("\t"); } while (tty->position() < 16);
+ nn->dump();
+ }
+ if (Verbose && wlsize < _worklist.size()) {
+ tty->print(" Push {");
+ while (wlsize != _worklist.size()) {
+ Node* pushed = _worklist.at(wlsize++);
+ tty->print(" %d", pushed->_idx);
+ }
+ tty->print_cr(" }");
+ }
+ if (nn != n) {
+ // ignore n, it might be subsumed
+ verify_step((Node*) NULL);
}
}
-#endif
-
-#ifdef ASSERT
- Node* prev = NULL;
- uint rep_cnt = 0;
-#endif
- uint loop_count = 0;
-
- // Pull from worklist; transform node;
- // If node has changed: update edge info and put uses on worklist.
- while( _worklist.size() ) {
- if (C->check_node_count(NodeLimitFudgeFactor * 2,
- "out of nodes optimizing method")) {
- return;
- }
- Node *n = _worklist.pop();
- if (++loop_count >= K * C->live_nodes()) {
- debug_only(n->dump(4);)
- assert(false, "infinite loop in PhaseIterGVN::optimize");
- C->record_method_not_compilable("infinite loop in PhaseIterGVN::optimize");
- return;
- }
-#ifdef ASSERT
- if (n == prev) {
- if (++rep_cnt > 3) {
- n->dump(4);
- assert(false, "loop in Ideal transformation");
- }
- } else {
- rep_cnt = 0;
- }
- prev = n;
-#endif
- if (TraceIterativeGVN && Verbose) {
- tty->print(" Pop ");
- NOT_PRODUCT( n->dump(); )
- debug_only(if( (num_processed++ % 100) == 0 ) _worklist.print_set();)
- }
-
- if (n->outcnt() != 0) {
-
-#ifndef PRODUCT
- uint wlsize = _worklist.size();
- const Type* oldtype = type_or_null(n);
-#endif //PRODUCT
-
- Node *nn = transform_old(n);
+}
-#ifndef PRODUCT
- if (TraceIterativeGVN) {
- const Type* newtype = type_or_null(n);
- if (nn != n) {
- // print old node
- tty->print("< ");
- if (oldtype != newtype && oldtype != NULL) {
- oldtype->dump();
- }
- do { tty->print("\t"); } while (tty->position() < 16);
- tty->print("<");
- n->dump();
- }
- if (oldtype != newtype || nn != n) {
- // print new node and/or new type
- if (oldtype == NULL) {
- tty->print("* ");
- } else if (nn != n) {
- tty->print("> ");
- } else {
- tty->print("= ");
- }
- if (newtype == NULL) {
- tty->print("null");
- } else {
- newtype->dump();
- }
- do { tty->print("\t"); } while (tty->position() < 16);
- nn->dump();
- }
- if (Verbose && wlsize < _worklist.size()) {
- tty->print(" Push {");
- while (wlsize != _worklist.size()) {
- Node* pushed = _worklist.at(wlsize++);
- tty->print(" %d", pushed->_idx);
- }
- tty->print_cr(" }");
- }
- }
- if( VerifyIterativeGVN && nn != n ) {
- verify_step((Node*) NULL); // ignore n, it might be subsumed
- }
-#endif
- } else if (!n->is_top()) {
- remove_dead_node(n);
- }
+void PhaseIterGVN::init_verifyPhaseIterGVN() {
+ _verify_counter = 0;
+ _verify_full_passes = 0;
+ for (int i = 0; i < _verify_window_size; i++) {
+ _verify_window[i] = NULL;
}
+}
-#ifndef PRODUCT
+void PhaseIterGVN::verify_PhaseIterGVN() {
C->verify_graph_edges();
if( VerifyOpto && allow_progress() ) {
// Must turn off allow_progress to enable assert and break recursion
@@ -998,21 +955,78 @@
igvn2.set_allow_progress(true);
}
}
- if ( VerifyIterativeGVN && PrintOpto ) {
- if ( _verify_counter == _verify_full_passes )
+ if (VerifyIterativeGVN && PrintOpto) {
+ if (_verify_counter == _verify_full_passes) {
tty->print_cr("VerifyIterativeGVN: %d transforms and verify passes",
_verify_full_passes);
- else
+ } else {
tty->print_cr("VerifyIterativeGVN: %d transforms, %d full verify passes",
_verify_counter, _verify_full_passes);
+ }
}
-#endif
+}
+#endif /* PRODUCT */
+
+#ifdef ASSERT
+/**
+ * Dumps information that can help to debug the problem. A debug
+ * build fails with an assert.
+ */
+void PhaseIterGVN::dump_infinite_loop_info(Node* n) {
+ n->dump(4);
+ _worklist.dump();
+ assert(false, "infinite loop in PhaseIterGVN::optimize");
+}
+
+/**
+ * Prints out information about IGVN if the 'verbose' option is used.
+ */
+void PhaseIterGVN::trace_PhaseIterGVN_verbose(Node* n, int num_processed) {
+ if (TraceIterativeGVN && Verbose) {
+ tty->print(" Pop ");
+ n->dump();
+ if ((num_processed % 100) == 0) {
+ _worklist.print_set();
+ }
+ }
+}
+#endif /* ASSERT */
+
+void PhaseIterGVN::optimize() {
+ DEBUG_ONLY(uint num_processed = 0;)
+ NOT_PRODUCT(init_verifyPhaseIterGVN();)
+
+ uint loop_count = 0;
+ // Pull from worklist and transform the node. If the node has changed,
+ // update edge info and put uses on worklist.
+ while(_worklist.size()) {
+ if (C->check_node_count(NodeLimitFudgeFactor * 2, "Out of nodes")) {
+ return;
+ }
+ Node* n = _worklist.pop();
+ if (++loop_count >= K * C->live_nodes()) {
+ DEBUG_ONLY(dump_infinite_loop_info(n);)
+ C->record_method_not_compilable("infinite loop in PhaseIterGVN::optimize");
+ return;
+ }
+ DEBUG_ONLY(trace_PhaseIterGVN_verbose(n, num_processed++);)
+ if (n->outcnt() != 0) {
+ NOT_PRODUCT(const Type* oldtype = type_or_null(n));
+ // Do the transformation
+ Node* nn = transform_old(n);
+ NOT_PRODUCT(trace_PhaseIterGVN(n, nn, oldtype);)
+ } else if (!n->is_top()) {
+ remove_dead_node(n);
+ }
+ }
+ NOT_PRODUCT(verify_PhaseIterGVN();)
}
-//------------------register_new_node_with_optimizer---------------------------
-// Register a new node with the optimizer. Update the types array, the def-use
-// info. Put on worklist.
+/**
+ * Register a new node with the optimizer. Update the types array, the def-use
+ * info. Put on worklist.
+ */
Node* PhaseIterGVN::register_new_node_with_optimizer(Node* n, Node* orig) {
set_type_bottom(n);
_worklist.push(n);
@@ -1038,32 +1052,29 @@
return transform_old(n);
}
-//------------------------------transform_old----------------------------------
-Node *PhaseIterGVN::transform_old( Node *n ) {
-#ifndef PRODUCT
- debug_only(uint loop_count = 0;);
- set_transforms();
-#endif
+Node *PhaseIterGVN::transform_old(Node* n) {
+ DEBUG_ONLY(uint loop_count = 0;);
+ NOT_PRODUCT(set_transforms());
+
// Remove 'n' from hash table in case it gets modified
_table.hash_delete(n);
- if( VerifyIterativeGVN ) {
- assert( !_table.find_index(n->_idx), "found duplicate entry in table");
+ if (VerifyIterativeGVN) {
+ assert(!_table.find_index(n->_idx), "found duplicate entry in table");
}
// Apply the Ideal call in a loop until it no longer applies
- Node *k = n;
+ Node* k = n;
DEBUG_ONLY(dead_loop_check(k);)
DEBUG_ONLY(bool is_new = (k->outcnt() == 0);)
- Node *i = k->Ideal(this, /*can_reshape=*/true);
+ Node* i = k->Ideal(this, /*can_reshape=*/true);
assert(i != k || is_new || i->outcnt() > 0, "don't return dead nodes");
#ifndef PRODUCT
- if( VerifyIterativeGVN )
- verify_step(k);
- if( i && VerifyOpto ) {
- if( !allow_progress() ) {
- if (i->is_Add() && i->outcnt() == 1) {
+ verify_step(k);
+ if (i && VerifyOpto ) {
+ if (!allow_progress()) {
+ if (i->is_Add() && (i->outcnt() == 1)) {
// Switched input to left side because this is the only use
- } else if( i->is_If() && (i->in(0) == NULL) ) {
+ } else if (i->is_If() && (i->in(0) == NULL)) {
// This IF is dead because it is dominated by an equivalent IF When
// dominating if changed, info is not propagated sparsely to 'this'
// Propagating this info further will spuriously identify other
@@ -1071,35 +1082,38 @@
return i;
} else
set_progress();
- } else
+ } else {
set_progress();
+ }
}
#endif
- while( i ) {
+ while (i != NULL) {
#ifndef PRODUCT
- debug_only( if( loop_count >= K ) i->dump(4); )
- assert(loop_count < K, "infinite loop in PhaseIterGVN::transform");
- debug_only( loop_count++; )
+ if (loop_count >= K) {
+ dump_infinite_loop_info(i);
+ }
+ loop_count++;
#endif
assert((i->_idx >= k->_idx) || i->is_top(), "Idealize should return new nodes, use Identity to return old nodes");
// Made a change; put users of original Node on worklist
- add_users_to_worklist( k );
+ add_users_to_worklist(k);
// Replacing root of transform tree?
- if( k != i ) {
+ if (k != i) {
// Make users of old Node now use new.
- subsume_node( k, i );
+ subsume_node(k, i);
k = i;
}
DEBUG_ONLY(dead_loop_check(k);)
// Try idealizing again
DEBUG_ONLY(is_new = (k->outcnt() == 0);)
i = k->Ideal(this, /*can_reshape=*/true);
- assert(i != k || is_new || i->outcnt() > 0, "don't return dead nodes");
+ assert(i != k || is_new || (i->outcnt() > 0), "don't return dead nodes");
#ifndef PRODUCT
- if( VerifyIterativeGVN )
- verify_step(k);
- if( i && VerifyOpto ) set_progress();
+ verify_step(k);
+ if (i && VerifyOpto) {
+ set_progress();
+ }
#endif
}
@@ -1107,48 +1121,49 @@
ensure_type_or_null(k);
// See what kind of values 'k' takes on at runtime
- const Type *t = k->Value(this);
+ const Type* t = k->Value(this);
assert(t != NULL, "value sanity");
// Since I just called 'Value' to compute the set of run-time values
// for this Node, and 'Value' is non-local (and therefore expensive) I'll
// cache Value. Later requests for the local phase->type of this Node can
// use the cached Value instead of suffering with 'bottom_type'.
- if (t != type_or_null(k)) {
- NOT_PRODUCT( set_progress(); )
- NOT_PRODUCT( inc_new_values();)
+ if (type_or_null(k) != t) {
+#ifndef PRODUCT
+ inc_new_values();
+ set_progress();
+#endif
set_type(k, t);
// If k is a TypeNode, capture any more-precise type permanently into Node
k->raise_bottom_type(t);
// Move users of node to worklist
- add_users_to_worklist( k );
+ add_users_to_worklist(k);
}
-
// If 'k' computes a constant, replace it with a constant
- if( t->singleton() && !k->is_Con() ) {
- NOT_PRODUCT( set_progress(); )
- Node *con = makecon(t); // Make a constant
- add_users_to_worklist( k );
- subsume_node( k, con ); // Everybody using k now uses con
+ if (t->singleton() && !k->is_Con()) {
+ NOT_PRODUCT(set_progress();)
+ Node* con = makecon(t); // Make a constant
+ add_users_to_worklist(k);
+ subsume_node(k, con); // Everybody using k now uses con
return con;
}
// Now check for Identities
- i = k->Identity(this); // Look for a nearby replacement
- if( i != k ) { // Found? Return replacement!
- NOT_PRODUCT( set_progress(); )
- add_users_to_worklist( k );
- subsume_node( k, i ); // Everybody using k now uses i
+ i = k->Identity(this); // Look for a nearby replacement
+ if (i != k) { // Found? Return replacement!
+ NOT_PRODUCT(set_progress();)
+ add_users_to_worklist(k);
+ subsume_node(k, i); // Everybody using k now uses i
return i;
}
// Global Value Numbering
i = hash_find_insert(k); // Check for pre-existing node
- if( i && (i != k) ) {
+ if (i && (i != k)) {
// Return the pre-existing node if it isn't dead
- NOT_PRODUCT( set_progress(); )
- add_users_to_worklist( k );
- subsume_node( k, i ); // Everybody using k now uses i
+ NOT_PRODUCT(set_progress();)
+ add_users_to_worklist(k);
+ subsume_node(k, i); // Everybody using k now uses i
return i;
}
@@ -1514,6 +1529,21 @@
C->set_root( transform(C->root())->as_Root() );
assert( C->top(), "missing TOP node" );
assert( C->root(), "missing root" );
+
+ // Eagerly remove castPP nodes here. CastPP nodes might not be
+ // removed in the subsequent IGVN phase if a node that changes
+ // in(1) of a castPP is processed prior to the castPP node.
+ for (uint i = 0; i < _worklist.size(); i++) {
+ Node* n = _worklist.at(i);
+
+ if (n->is_ConstraintCast()) {
+ Node* nn = n->Identity(this);
+ if (nn != n) {
+ replace_node(n, nn);
+ --i;
+ }
+ }
+ }
}
//------------------------------transform--------------------------------------
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/opto/phaseX.hpp
--- a/hotspot/src/share/vm/opto/phaseX.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/opto/phaseX.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -440,6 +440,17 @@
// and dominator info to a fixed point.
void optimize();
+#ifndef PRODUCT
+ void trace_PhaseIterGVN(Node* n, Node* nn, const Type* old_type);
+ void init_verifyPhaseIterGVN();
+ void verify_PhaseIterGVN();
+#endif
+
+#ifdef ASSERT
+ void dump_infinite_loop_info(Node* n);
+ void trace_PhaseIterGVN_verbose(Node* n, int num_processed);
+#endif
+
// Register a new node with the iter GVN pass without transforming it.
// Used when we need to restructure a Region/Phi area and all the Regions
// and Phis need to complete this one big transform before any other
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/prims/jni.cpp
--- a/hotspot/src/share/vm/prims/jni.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/prims/jni.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -2420,7 +2420,7 @@
DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z
, HOTSPOT_JNI_SETSTATICBOOLEANFIELD_ENTRY(env, clazz, (uintptr_t)fieldID, value),
- HOTSPOT_JNI_SETBOOLEANFIELD_RETURN())
+ HOTSPOT_JNI_SETSTATICBOOLEANFIELD_RETURN())
DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b
, HOTSPOT_JNI_SETSTATICBYTEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value),
HOTSPOT_JNI_SETSTATICBYTEFIELD_RETURN())
@@ -3877,6 +3877,7 @@
void TestMetachunk_test();
void TestVirtualSpaceNode_test();
void TestNewSize_test();
+void TestOldSize_test();
void TestKlass_test();
void TestBitMap_test();
#if INCLUDE_ALL_GCS
@@ -3903,6 +3904,7 @@
run_unit_test(AltHashing::test_alt_hash());
run_unit_test(test_loggc_filename());
run_unit_test(TestNewSize_test());
+ run_unit_test(TestOldSize_test());
run_unit_test(TestKlass_test());
run_unit_test(TestBitMap_test());
#if INCLUDE_VM_STRUCTS
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/prims/jvm.cpp
--- a/hotspot/src/share/vm/prims/jvm.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/prims/jvm.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1215,7 +1215,8 @@
// get run() method
Method* m_oop = object->klass()->uncached_lookup_method(
vmSymbols::run_method_name(),
- vmSymbols::void_object_signature());
+ vmSymbols::void_object_signature(),
+ Klass::normal);
methodHandle m (THREAD, m_oop);
if (m.is_null() || !m->is_method() || !m()->is_public() || m()->is_static()) {
THROW_MSG_0(vmSymbols::java_lang_InternalError(), "No run method");
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/prims/nativeLookup.cpp
--- a/hotspot/src/share/vm/prims/nativeLookup.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/prims/nativeLookup.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -408,7 +408,7 @@
// Find method and invoke standard lookup
methodHandle method (THREAD,
- klass->uncached_lookup_method(m_name, s_name));
+ klass->uncached_lookup_method(m_name, s_name, Klass::normal));
address result = lookup(method, in_base_library, CATCH);
assert(in_base_library, "must be in basic library");
guarantee(result != NULL, "must be non NULL");
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/prims/whitebox.cpp
--- a/hotspot/src/share/vm/prims/whitebox.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/prims/whitebox.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -438,6 +438,30 @@
return (mh->queued_for_compilation() || nm != NULL);
WB_END
+class VM_WhiteBoxOperation : public VM_Operation {
+ public:
+ VM_WhiteBoxOperation() { }
+ VMOp_Type type() const { return VMOp_WhiteBoxOperation; }
+ bool allow_nested_vm_operations() const { return true; }
+};
+
+class AlwaysFalseClosure : public BoolObjectClosure {
+ public:
+ bool do_object_b(oop p) { return false; }
+};
+
+static AlwaysFalseClosure always_false;
+
+class VM_WhiteBoxCleanMethodData : public VM_WhiteBoxOperation {
+ public:
+ VM_WhiteBoxCleanMethodData(MethodData* mdo) : _mdo(mdo) { }
+ void doit() {
+ _mdo->clean_method_data(&always_false);
+ }
+ private:
+ MethodData* _mdo;
+};
+
WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
CHECK_JNI_EXCEPTION(env);
@@ -453,6 +477,8 @@
for (int i = 0; i < arg_count; i++) {
mdo->set_arg_modified(i, 0);
}
+ VM_WhiteBoxCleanMethodData op(mdo);
+ VMThread::execute(&op);
}
mh->clear_not_c1_compilable();
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp
--- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -53,7 +53,8 @@
}
set_c1_count(MAX2(count / 3, 1));
- set_c2_count(MAX2(count - count / 3, 1));
+ set_c2_count(MAX2(count - c1_count(), 1));
+ FLAG_SET_ERGO(intx, CICompilerCount, c1_count() + c2_count());
// Some inlining tuning
#ifdef X86
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/arguments.cpp
--- a/hotspot/src/share/vm/runtime/arguments.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -307,6 +307,9 @@
JDK_Version::jdk_update(7, 2), JDK_Version::jdk(8) },
#endif // PRODUCT
{ "UseVMInterruptibleIO", JDK_Version::jdk(8), JDK_Version::jdk(9) },
+ { "UseBoundThreads", JDK_Version::jdk(9), JDK_Version::jdk(10) },
+ { "DefaultThreadPriority", JDK_Version::jdk(9), JDK_Version::jdk(10) },
+ { "NoYieldsInMicrolock", JDK_Version::jdk(9), JDK_Version::jdk(10) },
{ NULL, JDK_Version(0), JDK_Version(0) }
};
@@ -2078,17 +2081,6 @@
// Note: Needs platform-dependent factoring.
bool status = true;
- // Allow both -XX:-UseStackBanging and -XX:-UseBoundThreads in non-product
- // builds so the cost of stack banging can be measured.
-#if (defined(PRODUCT) && defined(SOLARIS))
- if (!UseBoundThreads && !UseStackBanging) {
- jio_fprintf(defaultStream::error_stream(),
- "-UseStackBanging conflicts with -UseBoundThreads\n");
-
- status = false;
- }
-#endif
-
if (TLABRefillWasteFraction == 0) {
jio_fprintf(defaultStream::error_stream(),
"TLABRefillWasteFraction should be a denominator, "
@@ -2410,6 +2402,10 @@
const int num_min_compiler_threads = (TieredCompilation && (TieredStopAtLevel >= CompLevel_full_optimization)) ? 2 : 1;
status &=verify_min_value(CICompilerCount, num_min_compiler_threads, "CICompilerCount");
+ if (!FLAG_IS_DEFAULT(CICompilerCount) && !FLAG_IS_DEFAULT(CICompilerCountPerCPU) && CICompilerCountPerCPU) {
+ warning("The VM option CICompilerCountPerCPU overrides CICompilerCount.");
+ }
+
return status;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/compilationPolicy.cpp
--- a/hotspot/src/share/vm/runtime/compilationPolicy.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/compilationPolicy.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -182,6 +182,7 @@
// max(log2(8)-1,1) = 2 compiler threads on an 8-way machine.
// May help big-app startup time.
_compiler_count = MAX2(log2_intptr(os::active_processor_count())-1,1);
+ FLAG_SET_ERGO(intx, CICompilerCount, _compiler_count);
} else {
_compiler_count = CICompilerCount;
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/deoptimization.cpp
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -420,15 +420,9 @@
// frame[number_of_frames - 1 ] = on_stack_size(youngest)
// frame[number_of_frames - 2 ] = on_stack_size(sender(youngest))
// frame[number_of_frames - 3 ] = on_stack_size(sender(sender(youngest)))
- int caller_parms = callee_parameters;
- if ((index == array->frames() - 1) && caller_was_method_handle) {
- caller_parms = 0;
- }
- frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(caller_parms,
- callee_parameters,
+ frame_sizes[number_of_frames - 1 - index] = BytesPerWord * array->element(index)->on_stack_size(callee_parameters,
callee_locals,
index == 0,
- index == array->frames() - 1,
popframe_extra_args);
// This pc doesn't have to be perfect just good enough to identify the frame
// as interpreted so the skeleton frame will be walkable
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/os.cpp
--- a/hotspot/src/share/vm/runtime/os.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/os.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -929,6 +929,10 @@
}
void os::print_date_and_time(outputStream *st) {
+ const int secs_per_day = 86400;
+ const int secs_per_hour = 3600;
+ const int secs_per_min = 60;
+
time_t tloc;
(void)time(&tloc);
st->print("time: %s", ctime(&tloc)); // ctime adds newline.
@@ -937,7 +941,17 @@
// NOTE: It tends to crash after a SEGV if we want to printf("%f",...) in
// Linux. Must be a bug in glibc ? Workaround is to round "t" to int
// before printf. We lost some precision, but who cares?
- st->print_cr("elapsed time: %d seconds", (int)t);
+ int eltime = (int)t; // elapsed time in seconds
+
+ // print elapsed time in a human-readable format:
+ int eldays = eltime / secs_per_day;
+ int day_secs = eldays * secs_per_day;
+ int elhours = (eltime - day_secs) / secs_per_hour;
+ int hour_secs = elhours * secs_per_hour;
+ int elmins = (eltime - day_secs - hour_secs) / secs_per_min;
+ int minute_secs = elmins * secs_per_min;
+ int elsecs = (eltime - day_secs - hour_secs - minute_secs);
+ st->print_cr("elapsed time: %d seconds (%dd %dh %dm %ds)", eltime, eldays, elhours, elmins, elsecs);
}
// moved from debug.cpp (used to be find()) but still called from there
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/os.hpp
--- a/hotspot/src/share/vm/runtime/os.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/os.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -450,8 +450,8 @@
// yield that can be used in lieu of blocking.
} ;
static YieldResult NakedYield () ;
- static void yield_all(int attempts = 0); // Yields to all other threads including lower priority
- static void loop_breaker(int attempts); // called from within tight loops to possibly influence time-sharing
+ static void yield_all(); // Yields to all other threads including lower priority
+ // (for the default scheduling policy)
static OSReturn set_priority(Thread* thread, ThreadPriority priority);
static OSReturn get_priority(const Thread* const thread, ThreadPriority& priority);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/safepoint.cpp
--- a/hotspot/src/share/vm/runtime/safepoint.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -319,7 +319,7 @@
if (steps < DeferThrSuspendLoopCount) {
os::NakedYield() ;
} else {
- os::yield_all(steps) ;
+ os::yield_all() ;
// Alternately, the VM thread could transiently depress its scheduling priority or
// transiently increase the priority of the tardy mutator(s).
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/sharedRuntime.cpp
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -775,10 +775,13 @@
// going to be unwound. Dispatch to a shared runtime stub
// which will cause the StackOverflowError to be fabricated
// and processed.
- // For stack overflow in deoptimization blob, cleanup thread.
- if (thread->deopt_mark() != NULL) {
- Deoptimization::cleanup_deopt_info(thread, NULL);
- }
+ // Stack overflow should never occur during deoptimization:
+ // the compiled method bangs the stack by as much as the
+ // interpreter would need in case of a deoptimization. The
+ // deoptimization blob and uncommon trap blob bang the stack
+ // in a debug VM to verify the correctness of the compiled
+ // method stack banging.
+ assert(thread->deopt_mark() == NULL, "no stack overflow from deopt blob/uncommon trap");
Events::log_exception(thread, "StackOverflowError at " INTPTR_FORMAT, pc);
return StubRoutines::throw_StackOverflowError_entry();
}
@@ -924,12 +927,6 @@
JRT_END
#endif // !PRODUCT
-
-JRT_ENTRY(void, SharedRuntime::yield_all(JavaThread* thread, int attempts))
- os::yield_all(attempts);
-JRT_END
-
-
JRT_ENTRY_NO_ASYNC(void, SharedRuntime::register_finalizer(JavaThread* thread, oopDesc* obj))
assert(obj->is_oop(), "must be a valid oop");
assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
@@ -952,14 +949,13 @@
* it gets turned into a tail-call on sparc, which runs into dtrace bug
* 6254741. Once that is fixed we can remove the dummy return value.
*/
-int SharedRuntime::dtrace_object_alloc(oopDesc* o) {
- return dtrace_object_alloc_base(Thread::current(), o);
+int SharedRuntime::dtrace_object_alloc(oopDesc* o, int size) {
+ return dtrace_object_alloc_base(Thread::current(), o, size);
}
-int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o) {
+int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o, int size) {
assert(DTraceAllocProbes, "wrong call");
Klass* klass = o->klass();
- int size = o->size();
Symbol* name = klass->name();
HOTSPOT_OBJECT_ALLOC(
get_java_tid(thread),
@@ -1268,8 +1264,6 @@
}
#endif
if (is_virtual) {
- nmethod* nm = callee_nm;
- if (nm == NULL) CodeCache::find_blob(caller_frame.pc());
CompiledIC* inline_cache = CompiledIC_before(caller_nm, caller_frame.pc());
if (inline_cache->is_clean()) {
inline_cache->set_to_monomorphic(virtual_call_info);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/sharedRuntime.hpp
--- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -253,16 +253,13 @@
// bytecode tracing is only used by the TraceBytecodes
static intptr_t trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2) PRODUCT_RETURN0;
- // Used to back off a spin lock that is under heavy contention
- static void yield_all(JavaThread* thread, int attempts = 0);
-
static oop retrieve_receiver( Symbol* sig, frame caller );
static void register_finalizer(JavaThread* thread, oopDesc* obj);
// dtrace notifications
- static int dtrace_object_alloc(oopDesc* o);
- static int dtrace_object_alloc_base(Thread* thread, oopDesc* o);
+ static int dtrace_object_alloc(oopDesc* o, int size);
+ static int dtrace_object_alloc_base(Thread* thread, oopDesc* o, int size);
static int dtrace_method_entry(JavaThread* thread, Method* m);
static int dtrace_method_exit(JavaThread* thread, Method* m);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp
--- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -142,7 +142,8 @@
count = MAX2(log2_intptr(os::active_processor_count()), 1) * 3 / 2;
}
set_c1_count(MAX2(count / 3, 1));
- set_c2_count(MAX2(count - count / 3, 1));
+ set_c2_count(MAX2(count - c1_count(), 1));
+ FLAG_SET_ERGO(intx, CICompilerCount, c1_count() + c2_count());
}
void SimpleThresholdPolicy::set_carry_if_necessary(InvocationCounter *counter) {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/thread.cpp
--- a/hotspot/src/share/vm/runtime/thread.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/thread.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -1394,8 +1394,8 @@
void JavaThread::initialize() {
// Initialize fields
- // Set the claimed par_id to -1 (ie not claiming any par_ids)
- set_claimed_par_id(-1);
+ // Set the claimed par_id to UINT_MAX (ie not claiming any par_ids)
+ set_claimed_par_id(UINT_MAX);
set_saved_exception_pc(NULL);
set_threadObj(NULL);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/thread.hpp
--- a/hotspot/src/share/vm/runtime/thread.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/thread.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -1778,12 +1778,12 @@
void set_done_attaching_via_jni() { _jni_attach_state = _attached_via_jni; OrderAccess::fence(); }
private:
// This field is used to determine if a thread has claimed
- // a par_id: it is -1 if the thread has not claimed a par_id;
+ // a par_id: it is UINT_MAX if the thread has not claimed a par_id;
// otherwise its value is the par_id that has been claimed.
- int _claimed_par_id;
+ uint _claimed_par_id;
public:
- int get_claimed_par_id() { return _claimed_par_id; }
- void set_claimed_par_id(int id) { _claimed_par_id = id;}
+ uint get_claimed_par_id() { return _claimed_par_id; }
+ void set_claimed_par_id(uint id) { _claimed_par_id = id;}
};
// Inline implementation of JavaThread::current
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/vframe.cpp
--- a/hotspot/src/share/vm/runtime/vframe.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/vframe.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -321,24 +321,38 @@
}
}
-StackValueCollection* interpretedVFrame::expressions() const {
- int length = fr().interpreter_frame_expression_stack_size();
- if (method()->is_native()) {
- // If the method is native, there is no expression stack
- length = 0;
+StackValueCollection* interpretedVFrame::expressions() const {
+
+ InterpreterOopMap oop_mask;
+
+ if (!method()->is_native()) {
+ // Get oopmap describing oops and int for current bci
+ if (TraceDeoptimization && Verbose) {
+ methodHandle m_h(method());
+ OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask);
+ } else {
+ method()->mask_for(bci(), &oop_mask);
+ }
+ }
+
+ // If the bci is a call instruction, i.e. any of the invoke* instructions,
+ // the InterpreterOopMap does not include expression/operand stack liveness
+ // info in the oop_mask/bit_mask. This can lead to a discrepancy of what
+ // is actually on the expression stack compared to what is given by the
+ // oop_map. We need to use the length reported in the oop_map.
+ int length = oop_mask.expression_stack_size();
+
+ assert(fr().interpreter_frame_expression_stack_size() >= length,
+ "error in expression stack!");
+
+ StackValueCollection* result = new StackValueCollection(length);
+
+ if (0 == length) {
+ return result;
}
int nof_locals = method()->max_locals();
- StackValueCollection* result = new StackValueCollection(length);
- InterpreterOopMap oop_mask;
- // Get oopmap describing oops and int for current bci
- if (TraceDeoptimization && Verbose) {
- methodHandle m_h(method());
- OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask);
- } else {
- method()->mask_for(bci(), &oop_mask);
- }
// handle expressions
for(int i=0; i < length; i++) {
// Find stack location
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/vframeArray.cpp
--- a/hotspot/src/share/vm/runtime/vframeArray.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/vframeArray.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -418,24 +418,20 @@
}
-int vframeArrayElement::on_stack_size(int caller_actual_parameters,
- int callee_parameters,
+int vframeArrayElement::on_stack_size(int callee_parameters,
int callee_locals,
bool is_top_frame,
- bool is_bottom_frame,
int popframe_extra_stack_expression_els) const {
assert(method()->max_locals() == locals()->size(), "just checking");
int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors();
int temps = expressions()->size();
- return Interpreter::size_activation(method(),
+ return Interpreter::size_activation(method()->max_stack(),
temps + callee_parameters,
popframe_extra_stack_expression_els,
locks,
- caller_actual_parameters,
callee_parameters,
callee_locals,
- is_top_frame,
- is_bottom_frame);
+ is_top_frame);
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/vframeArray.hpp
--- a/hotspot/src/share/vm/runtime/vframeArray.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/vframeArray.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -85,10 +85,8 @@
// Returns the on stack word size for this frame
// callee_parameters is the number of callee locals residing inside this frame
- int on_stack_size(int caller_actual_parameters,
- int callee_parameters,
+ int on_stack_size(int callee_parameters,
int callee_locals,
- bool is_bottom_frame,
bool is_top_frame,
int popframe_extra_stack_expression_els) const;
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/vmThread.cpp
--- a/hotspot/src/share/vm/runtime/vmThread.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/vmThread.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -305,6 +305,9 @@
_terminate_lock->notify();
}
+ // Thread destructor usually does this.
+ ThreadLocalStorage::set_thread(NULL);
+
// Deletion must be done synchronously by the JNI DestroyJavaVM thread
// so that the VMThread deletion completes before the main thread frees
// up the CodeHeap.
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/runtime/vm_operations.hpp
--- a/hotspot/src/share/vm/runtime/vm_operations.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/runtime/vm_operations.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -97,6 +97,7 @@
template(Exit) \
template(LinuxDllLoad) \
template(RotateGCLog) \
+ template(WhiteBoxOperation) \
class VM_Operation: public CHeapObj {
public:
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/services/memoryPool.cpp
--- a/hotspot/src/share/vm/services/memoryPool.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/services/memoryPool.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -268,7 +268,7 @@
}
size_t MetaspacePool::used_in_bytes() {
- return MetaspaceAux::allocated_used_bytes();
+ return MetaspaceAux::used_bytes();
}
size_t MetaspacePool::calculate_max_size() const {
@@ -280,7 +280,7 @@
MemoryPool("Compressed Class Space", NonHeap, 0, CompressedClassSpaceSize, true, false) { }
size_t CompressedKlassSpacePool::used_in_bytes() {
- return MetaspaceAux::allocated_used_bytes(Metaspace::ClassType);
+ return MetaspaceAux::used_bytes(Metaspace::ClassType);
}
MemoryUsage CompressedKlassSpacePool::get_memory_usage() {
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/trace/trace.xml
--- a/hotspot/src/share/vm/trace/trace.xml Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/trace/trace.xml Tue Apr 29 14:40:07 2014 -0700
@@ -185,7 +185,7 @@
-
+
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/utilities/growableArray.hpp
--- a/hotspot/src/share/vm/utilities/growableArray.hpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/utilities/growableArray.hpp Tue Apr 29 14:40:07 2014 -0700
@@ -147,6 +147,9 @@
}
};
+template class GrowableArrayIterator;
+template class GrowableArrayFilterIterator;
+
template class GrowableArray : public GenericGrowableArray {
friend class VMStructs;
@@ -243,6 +246,14 @@
return _data[_len-1];
}
+ GrowableArrayIterator begin() const {
+ return GrowableArrayIterator(this, 0);
+ }
+
+ GrowableArrayIterator end() const {
+ return GrowableArrayIterator(this, length());
+ }
+
void push(const E& elem) { append(elem); }
E pop() {
@@ -412,4 +423,83 @@
tty->print("}\n");
}
+// Custom STL-style iterator to iterate over GrowableArrays
+// It is constructed by invoking GrowableArray::begin() and GrowableArray::end()
+template class GrowableArrayIterator : public StackObj {
+ friend class GrowableArray;
+ template friend class GrowableArrayFilterIterator;
+
+ private:
+ const GrowableArray* _array; // GrowableArray we iterate over
+ int _position; // The current position in the GrowableArray
+
+ // Private constructor used in GrowableArray::begin() and GrowableArray::end()
+ GrowableArrayIterator(const GrowableArray* array, int position) : _array(array), _position(position) {
+ assert(0 <= position && position <= _array->length(), "illegal position");
+ }
+
+ public:
+ GrowableArrayIterator& operator++() { ++_position; return *this; }
+ E operator*() { return _array->at(_position); }
+
+ bool operator==(const GrowableArrayIterator& rhs) {
+ assert(_array == rhs._array, "iterator belongs to different array");
+ return _position == rhs._position;
+ }
+
+ bool operator!=(const GrowableArrayIterator& rhs) {
+ assert(_array == rhs._array, "iterator belongs to different array");
+ return _position != rhs._position;
+ }
+};
+
+// Custom STL-style iterator to iterate over elements of a GrowableArray that satisfy a given predicate
+template class GrowableArrayFilterIterator : public StackObj {
+ friend class GrowableArray;
+
+ private:
+ const GrowableArray* _array; // GrowableArray we iterate over
+ int _position; // Current position in the GrowableArray
+ UnaryPredicate _predicate; // Unary predicate the elements of the GrowableArray should satisfy
+
+ public:
+ GrowableArrayFilterIterator(const GrowableArrayIterator& begin, UnaryPredicate filter_predicate)
+ : _array(begin._array), _position(begin._position), _predicate(filter_predicate) {
+ // Advance to first element satisfying the predicate
+ while(_position != _array->length() && !_predicate(_array->at(_position))) {
+ ++_position;
+ }
+ }
+
+ GrowableArrayFilterIterator& operator++() {
+ do {
+ // Advance to next element satisfying the predicate
+ ++_position;
+ } while(_position != _array->length() && !_predicate(_array->at(_position)));
+ return *this;
+ }
+
+ E operator*() { return _array->at(_position); }
+
+ bool operator==(const GrowableArrayIterator& rhs) {
+ assert(_array == rhs._array, "iterator belongs to different array");
+ return _position == rhs._position;
+ }
+
+ bool operator!=(const GrowableArrayIterator& rhs) {
+ assert(_array == rhs._array, "iterator belongs to different array");
+ return _position != rhs._position;
+ }
+
+ bool operator==(const GrowableArrayFilterIterator& rhs) {
+ assert(_array == rhs._array, "iterator belongs to different array");
+ return _position == rhs._position;
+ }
+
+ bool operator!=(const GrowableArrayFilterIterator& rhs) {
+ assert(_array == rhs._array, "iterator belongs to different array");
+ return _position != rhs._position;
+ }
+};
+
#endif // SHARE_VM_UTILITIES_GROWABLEARRAY_HPP
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/utilities/taskqueue.cpp
--- a/hotspot/src/share/vm/utilities/taskqueue.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/utilities/taskqueue.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -239,8 +239,8 @@
#ifdef TRACESPINNING
void ParallelTaskTerminator::print_termination_counts() {
- gclog_or_tty->print_cr("ParallelTaskTerminator Total yields: " UINT32_FORMAT
- " Total spins: " UINT32_FORMAT " Total peeks: " UINT32_FORMAT,
+ gclog_or_tty->print_cr("ParallelTaskTerminator Total yields: %u"
+ " Total spins: %u Total peeks: %u",
total_yields(),
total_spins(),
total_peeks());
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/src/share/vm/utilities/xmlstream.cpp
--- a/hotspot/src/share/vm/utilities/xmlstream.cpp Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/src/share/vm/utilities/xmlstream.cpp Tue Apr 29 14:40:07 2014 -0700
@@ -396,10 +396,10 @@
}
void xmlStream::method_text(methodHandle method) {
+ ResourceMark rm;
assert_if_no_error(inside_attrs(), "printing attributes");
if (method.is_null()) return;
- //method->print_short_name(text());
- method->method_holder()->name()->print_symbol_on(text());
+ text()->print(method->method_holder()->external_name());
print_raw(" "); // " " is easier for tools to parse than "::"
method->name()->print_symbol_on(text());
print_raw(" "); // separator
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/TEST.groups
--- a/hotspot/test/TEST.groups Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/TEST.groups Tue Apr 29 14:40:07 2014 -0700
@@ -134,7 +134,8 @@
runtime/InternalApi/ThreadCpuTimesDeadlock.java \
serviceability/threads/TestFalseDeadLock.java \
compiler/tiered/NonTieredLevelsTest.java \
- compiler/tiered/TieredLevelsTest.java
+ compiler/tiered/TieredLevelsTest.java \
+ compiler/intrinsics/bmi/verifycode
# Compact 2 adds full VM tests
compact2 = \
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/EscapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/EscapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2014 SAP AG. 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 8038048
+ * @summary assert(null_obj->escape_state() == PointsToNode::NoEscape,etc)
+ * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+DoEscapeAnalysis -XX:-TieredCompilation -Xbatch TestUnsafePutAddressNullObjMustNotEscape
+ * @author Richard Reingruber richard DOT reingruber AT sap DOT com
+ */
+
+import java.lang.reflect.Field;
+import sun.misc.Unsafe;
+
+public class TestUnsafePutAddressNullObjMustNotEscape {
+
+ public static Unsafe usafe;
+ public static long mem;
+ public static long checksum;
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("EXECUTING test.");
+
+ {
+ System.out.println("Acquiring sun.misc.Unsafe.theUnsafe using reflection.");
+ getUnsafe();
+ System.out.println("Allocating raw memory.");
+ mem = (usafe.allocateMemory(1024) + 8L) & ~7L;
+ System.out.println("Triggering JIT compilation of the test method");
+ triggerJitCompilationOfTestMethod();
+ }
+
+ System.out.println("SUCCESSFULLY passed test.");
+ }
+
+ public static void triggerJitCompilationOfTestMethod() {
+ long sum = 0;
+ for (int ii = 50000; ii >= 0; ii--) {
+ sum = testMethod();
+ }
+ checksum = sum;
+ }
+
+ public static class IDGen {
+ private static long id;
+ public long nextId() {
+ return id++;
+ }
+ }
+
+ public static long testMethod() {
+ // dummy alloc to trigger escape analysis
+ IDGen gen = new IDGen();
+ // StoreP of null_obj to raw mem triggers assertion in escape analysis
+ usafe.putAddress(mem, 0L);
+ return gen.nextId();
+ }
+
+ private static void getUnsafe() throws Exception {
+ Field field = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
+ field.setAccessible(true);
+ usafe = (sun.misc.Unsafe) field.get(null);
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestI.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestI.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,57 @@
+/*
+ * 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 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build AddnTestI
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions AddnTestI
+ */
+
+import java.lang.reflect.Method;
+
+public class AddnTestI extends BmiIntrinsicBase.BmiTestCase {
+
+ protected AddnTestI(Method method) {
+ super(method);
+ // from intel manual VEX.NDS.LZ.0F38.W0 F2 /r, example c4e260f2c2
+ instrMask = new byte[]{
+ (byte) 0xFF,
+ (byte) 0x1F,
+ (byte) 0x00,
+ (byte) 0xFF};
+ instrPattern = new byte[]{
+ (byte) 0xC4, // prefix for 3-byte VEX instruction
+ (byte) 0x02, // 00010 implied 0F 38 leading opcode bytes
+ (byte) 0x00,
+ (byte) 0xF2};
+ }
+
+ public static void main(String[] args) throws Exception {
+ BmiIntrinsicBase.verifyTestCase(AddnTestI::new, TestAndnI.AndnIExpr.class.getDeclaredMethods());
+ BmiIntrinsicBase.verifyTestCase(AddnTestI::new, TestAndnI.AndnICommutativeExpr.class.getDeclaredMethods());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestL.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/AddnTestL.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
+ * @bug 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build AddnTestL
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions AddnTestL
+ */
+
+import java.lang.reflect.Method;
+
+public class AddnTestL extends AddnTestI {
+
+ protected AddnTestL(Method method) {
+ super(method);
+ isLongOperation = true;
+ }
+
+ public static void main(String[] args) throws Exception {
+ BmiIntrinsicBase.verifyTestCase(AddnTestL::new, TestAndnL.AndnLExpr.class.getDeclaredMethods());
+ BmiIntrinsicBase.verifyTestCase(AddnTestL::new, TestAndnL.AndnLCommutativeExpr.class.getDeclaredMethods());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestI.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestI.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,59 @@
+/*
+ * 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 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build BlsiTestI
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions BlsiTestI
+ */
+
+import java.lang.reflect.Method;
+
+public class BlsiTestI extends BmiIntrinsicBase.BmiTestCase {
+
+ protected BlsiTestI(Method method) {
+ super(method);
+ //from intel manual VEX.NDD.LZ.0F38.W0 F3 /3
+ instrMask = new byte[]{
+ (byte) 0xFF,
+ (byte) 0x1F,
+ (byte) 0x00,
+ (byte) 0xFF,
+ (byte) 0b0011_1000};
+ instrPattern = new byte[]{
+ (byte) 0xC4, // prefix for 3-byte VEX instruction
+ (byte) 0x02, // 00010 implied 0F 38 leading opcode bytes
+ (byte) 0x00,
+ (byte) 0xF3,
+ (byte) 0b0001_1000}; // bits 543 == 011 (3)
+ }
+
+ public static void main(String[] args) throws Exception {
+ BmiIntrinsicBase.verifyTestCase(BlsiTestI::new, TestBlsiI.BlsiIExpr.class.getDeclaredMethods());
+ BmiIntrinsicBase.verifyTestCase(BlsiTestI::new, TestBlsiI.BlsiICommutativeExpr.class.getDeclaredMethods());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestL.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsiTestL.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
+ * @bug 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build BlsiTestL
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions BlsiTestL
+ */
+
+import java.lang.reflect.Method;
+
+public class BlsiTestL extends BlsiTestI {
+
+ protected BlsiTestL(Method method) {
+ super(method);
+ isLongOperation = true;
+ }
+
+ public static void main(String[] args) throws Exception {
+ BmiIntrinsicBase.verifyTestCase(BlsiTestL::new, TestBlsiL.BlsiLExpr.class.getDeclaredMethods());
+ BmiIntrinsicBase.verifyTestCase(BlsiTestL::new, TestBlsiL.BlsiLCommutativeExpr.class.getDeclaredMethods());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestI.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,59 @@
+/*
+ * 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 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build BlsmskTestI
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions BlsmskTestI
+ */
+
+import java.lang.reflect.Method;
+
+public class BlsmskTestI extends BmiIntrinsicBase.BmiTestCase {
+
+ protected BlsmskTestI(Method method) {
+ super(method);
+ //from intel manual VEX.NDD.LZ.0F38.W0 F3 /2
+ instrMask = new byte[]{
+ (byte) 0xFF,
+ (byte) 0x1F,
+ (byte) 0x00,
+ (byte) 0xFF,
+ (byte) 0b0011_1000};
+ instrPattern = new byte[]{
+ (byte) 0xC4, // prefix for 3-byte VEX instruction
+ (byte) 0x02, // 00010 implied 0F 38 leading opcode bytes
+ (byte) 0x00,
+ (byte) 0xF3,
+ (byte) 0b0001_0000}; // bits 543 == 011 (3)
+ }
+
+ public static void main(String[] args) throws Exception {
+ BmiIntrinsicBase.verifyTestCase(BlsmskTestI::new, TestBlsmskI.BlsmskIExpr.class.getDeclaredMethods());
+ BmiIntrinsicBase.verifyTestCase(BlsmskTestI::new, TestBlsmskI.BlsmskICommutativeExpr.class.getDeclaredMethods());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsmskTestL.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
+ * @bug 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build BlsmskTestL
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions BlsmskTestL
+ */
+
+import java.lang.reflect.Method;
+
+public class BlsmskTestL extends BlsmskTestI {
+
+ protected BlsmskTestL(Method method) {
+ super(method);
+ isLongOperation = true;
+ }
+
+ public static void main(String[] args) throws Exception {
+ BmiIntrinsicBase.verifyTestCase(BlsmskTestL::new, TestBlsmskL.BlsmskLExpr.class.getDeclaredMethods());
+ BmiIntrinsicBase.verifyTestCase(BlsmskTestL::new, TestBlsmskL.BlsmskLCommutativeExpr.class.getDeclaredMethods());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestI.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestI.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,59 @@
+/*
+ * 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 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build BlsrTestI
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions BlsrTestI
+ */
+
+import java.lang.reflect.Method;
+
+public class BlsrTestI extends BmiIntrinsicBase.BmiTestCase {
+
+ protected BlsrTestI(Method method) {
+ super(method);
+ //from intel manual VEX.NDD.LZ.0F38.W0 F3 /1
+ instrMask = new byte[]{
+ (byte) 0xFF,
+ (byte) 0x1F,
+ (byte) 0x00,
+ (byte) 0xFF,
+ (byte) 0b0011_1000};
+ instrPattern = new byte[]{
+ (byte) 0xC4, // prefix for 3-byte VEX instruction
+ (byte) 0x02, // 00010 implied 0F 38 leading opcode bytes
+ (byte) 0x00,
+ (byte) 0xF3,
+ (byte) 0b0000_1000}; // bits 543 == 011 (3)
+ }
+
+ public static void main(String[] args) throws Exception {
+ BmiIntrinsicBase.verifyTestCase(BlsrTestI::new, TestBlsrI.BlsrIExpr.class.getDeclaredMethods());
+ BmiIntrinsicBase.verifyTestCase(BlsrTestI::new, TestBlsrI.BlsrICommutativeExpr.class.getDeclaredMethods());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestL.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BlsrTestL.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
+ * @bug 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build BlsrTestL
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions BlsrTestL
+ */
+
+import java.lang.reflect.Method;
+
+public class BlsrTestL extends BlsrTestI {
+
+ protected BlsrTestL(Method method) {
+ super(method);
+ isLongOperation = true;
+ }
+
+ public static void main(String[] args) throws Exception {
+ BmiIntrinsicBase.verifyTestCase(BlsrTestL::new, TestBlsrL.BlsrLExpr.class.getDeclaredMethods());
+ BmiIntrinsicBase.verifyTestCase(BlsrTestL::new, TestBlsrL.BlsrLCommutativeExpr.class.getDeclaredMethods());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/BmiIntrinsicBase.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,186 @@
+/*
+ * 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 com.oracle.java.testlibrary.Asserts;
+import com.oracle.java.testlibrary.Platform;
+import com.oracle.java.testlibrary.Utils;
+import sun.hotspot.code.NMethod;
+import sun.hotspot.cpuinfo.CPUInfo;
+
+import java.lang.reflect.Executable;
+import java.lang.reflect.Method;
+import java.util.concurrent.Callable;
+import java.util.function.Function;
+
+public class BmiIntrinsicBase extends CompilerWhiteBoxTest {
+
+ protected BmiIntrinsicBase(BmiTestCase testCase) {
+ super(testCase);
+ }
+
+ public static void verifyTestCase(Function constructor, Method... methods) throws Exception {
+ for (Method method : methods) {
+ new BmiIntrinsicBase(constructor.apply(method)).test();
+ }
+ }
+
+ @Override
+ protected void test() throws Exception {
+ BmiTestCase bmiTestCase = (BmiTestCase) testCase;
+
+ if (!(Platform.isX86() || Platform.isX64())) {
+ System.out.println("Unsupported platform, test SKIPPED");
+ return;
+ }
+
+ if (!Platform.isServer()) {
+ System.out.println("Not server VM, test SKIPPED");
+ return;
+ }
+
+ if (!CPUInfo.hasFeature(bmiTestCase.getCpuFlag())) {
+ System.out.println("Unsupported hardware, no required CPU flag " + bmiTestCase.getCpuFlag() + " , test SKIPPED");
+ return;
+ }
+
+ if (!Boolean.valueOf(getVMOption(bmiTestCase.getVMFlag()))) {
+ System.out.println("VM flag " + bmiTestCase.getVMFlag() + " disabled, test SKIPPED");
+ return;
+ }
+
+ System.out.println(testCase.name());
+
+ switch (MODE) {
+ case "compiled mode":
+ case "mixed mode":
+ if (TIERED_COMPILATION && TIERED_STOP_AT_LEVEL != CompilerWhiteBoxTest.COMP_LEVEL_MAX) {
+ System.out.println("TieredStopAtLevel value (" + TIERED_STOP_AT_LEVEL + ") is too low, test SKIPPED");
+ return;
+ }
+ deoptimize();
+ compileAtLevelAndCheck(CompilerWhiteBoxTest.COMP_LEVEL_MAX);
+ break;
+ case "interpreted mode": // test is not applicable in this mode;
+ System.err.println("Warning: This test is not applicable in mode: " + MODE);
+ break;
+ default:
+ throw new AssertionError("Test bug, unknown VM mode: " + MODE);
+ }
+ }
+
+ protected void compileAtLevelAndCheck(int level) {
+ WHITE_BOX.enqueueMethodForCompilation(method, level);
+ waitBackgroundCompilation();
+ checkCompilation(method, level);
+ checkEmittedCode(method);
+ }
+
+ protected void checkCompilation(Executable executable, int level) {
+ if (!WHITE_BOX.isMethodCompiled(executable)) {
+ throw new AssertionError("Test bug, expected compilation (level): " + level + ", but not compiled" + WHITE_BOX.isMethodCompilable(executable, level));
+ }
+ final int compilationLevel = WHITE_BOX.getMethodCompilationLevel(executable);
+ if (compilationLevel != level) {
+ throw new AssertionError("Test bug, expected compilation (level): " + level + ", but level: " + compilationLevel);
+ }
+ }
+
+ protected void checkEmittedCode(Executable executable) {
+ final byte[] nativeCode = NMethod.get(executable, false).insts;
+ if (!((BmiTestCase) testCase).verifyPositive(nativeCode)) {
+ throw new AssertionError(testCase.name() + "CPU instructions expected not found: " + Utils.toHexString(nativeCode));
+ } else {
+ System.out.println("CPU instructions found, PASSED");
+ }
+ }
+
+ abstract static class BmiTestCase implements CompilerWhiteBoxTest.TestCase {
+ private final Method method;
+ protected byte[] instrMask;
+ protected byte[] instrPattern;
+ protected boolean isLongOperation;
+
+ public BmiTestCase(Method method) {
+ this.method = method;
+ }
+
+ @Override
+ public String name() {
+ return method.toGenericString();
+ }
+
+ @Override
+ public Executable getExecutable() {
+ return method;
+ }
+
+ @Override
+ public Callable getCallable() {
+ return null;
+ }
+
+ @Override
+ public boolean isOsr() {
+ return false;
+ }
+
+ protected int countCpuInstructions(byte[] nativeCode) {
+ int count = 0;
+ int patternSize = Math.min(instrMask.length, instrPattern.length);
+ boolean found;
+ Asserts.assertGreaterThan(patternSize, 0);
+ for (int i = 0, n = nativeCode.length - patternSize; i < n; i++) {
+ found = true;
+ for (int j = 0; j < patternSize; j++) {
+ if ((nativeCode[i + j] & instrMask[j]) != instrPattern[j]) {
+ found = false;
+ break;
+ }
+ }
+ if (found) {
+ ++count;
+ i += patternSize - 1;
+ }
+ }
+ return count;
+ }
+
+ public boolean verifyPositive(byte[] nativeCode) {
+ final int cnt = countCpuInstructions(nativeCode);
+ if (Platform.isX86()) {
+ return cnt >= (isLongOperation ? 2 : 1);
+ } else {
+ return Platform.isX64() && cnt >= 1;
+ }
+ }
+
+ protected String getCpuFlag() {
+ return "bmi1";
+ }
+
+ protected String getVMFlag() {
+ return "UseBMI1Instructions";
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestI.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestI.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,59 @@
+/*
+ * 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 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build LZcntTestI
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCountLeadingZerosInstruction LZcntTestI
+ */
+
+import java.lang.reflect.Method;
+
+public class LZcntTestI extends BmiIntrinsicBase.BmiTestCase {
+
+ protected LZcntTestI(Method method) {
+ super(method);
+ instrMask = new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
+ instrPattern = new byte[]{(byte) 0xF3, (byte) 0x0F, (byte) 0xBD};
+ }
+
+ public static void main(String[] args) throws Exception {
+ // j.l.Integer and Long should be loaded to allow a compilation of the methods that use their methods
+ System.out.println("class java.lang.Integer should be loaded. Proof: " + Integer.class);
+ BmiIntrinsicBase.verifyTestCase(LZcntTestI::new, TestLzcntI.LzcntIExpr.class.getDeclaredMethods());
+ }
+
+ @Override
+ protected String getVMFlag() {
+ return "UseCountLeadingZerosInstruction";
+ }
+
+ @Override
+ protected String getCpuFlag() {
+ return "lzcnt";
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestL.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/LZcntTestL.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build LZcntTestL
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCountLeadingZerosInstruction LZcntTestL
+ */
+
+import com.oracle.java.testlibrary.Platform;
+
+import java.lang.reflect.Method;
+
+public class LZcntTestL extends LZcntTestI {
+
+ protected LZcntTestL(Method method) {
+ super(method);
+ isLongOperation = true;
+ if (Platform.isX64()) {
+ instrMask = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF};
+ instrPattern = new byte[]{(byte) 0xF3, (byte) 0x00, (byte) 0x0F, (byte) 0xBD};
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ // j.l.Integer and Long should be loaded to allow a compilation of the methods that use their methods
+ System.out.println("classes java.lang.Long should be loaded. Proof: " + Long.class);
+ BmiIntrinsicBase.verifyTestCase(LZcntTestL::new, TestLzcntL.LzcntLExpr.class.getDeclaredMethods());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestI.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestI.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build TZcntTestI
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCountTrailingZerosInstruction TZcntTestI
+ */
+
+import java.lang.reflect.Method;
+
+public class TZcntTestI extends BmiIntrinsicBase.BmiTestCase {
+
+ protected TZcntTestI(Method method) {
+ super(method);
+ instrMask = new byte[]{(byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
+ instrPattern = new byte[]{(byte) 0xF3, (byte) 0x0F, (byte) 0xBC};
+ }
+
+ public static void main(String[] args) throws Exception {
+ // j.l.Integer and Long should be loaded to allow a compilation of the methods that use their methods
+ System.out.println("class java.lang.Integer should be loaded. Proof: " + Integer.class);
+ BmiIntrinsicBase.verifyTestCase(TZcntTestI::new, TestTzcntI.TzcntIExpr.class.getDeclaredMethods());
+ }
+
+ @Override
+ protected String getVMFlag() {
+ return "UseCountTrailingZerosInstruction";
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestL.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/TZcntTestL.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,55 @@
+/*
+ * 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 8031321
+ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox ..
+ * @build TZcntTestL
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseCountTrailingZerosInstruction TZcntTestL
+ */
+
+import com.oracle.java.testlibrary.Platform;
+
+import java.lang.reflect.Method;
+
+public class TZcntTestL extends TZcntTestI {
+
+ protected TZcntTestL(Method method) {
+ super(method);
+ isLongOperation = true;
+ if (Platform.isX64()) {
+ instrMask = new byte[]{(byte) 0xFF, (byte) 0x00, (byte) 0xFF, (byte) 0xFF};
+ instrPattern = new byte[]{(byte) 0xF3, (byte) 0x00, (byte) 0x0F, (byte) 0xBC};
+ }
+ isLongOperation = true;
+ }
+
+ public static void main(String[] args) throws Exception {
+ // j.l.Integer and Long should be loaded to allow a compilation of the methods that use their methods
+ System.out.println("classes java.lang.Long should be loaded. Proof: " + Long.class);
+ BmiIntrinsicBase.verifyTestCase(TZcntTestL::new, TestTzcntL.TzcntLExpr.class.getDeclaredMethods());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/profiling/spectrapredefineclass/Agent.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass/Agent.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,142 @@
+/*
+ * 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.security.*;
+import java.lang.instrument.*;
+import java.lang.reflect.*;
+import java.lang.management.ManagementFactory;
+import com.sun.tools.attach.VirtualMachine;
+
+class A {
+ void m() {
+ }
+}
+
+class B extends A {
+ void m() {
+ }
+}
+
+class C extends A {
+ void m() {
+ }
+}
+
+class Test {
+
+ static public void m() throws Exception {
+ for (int i = 0; i < 20000; i++) {
+ m1(a);
+ }
+ for (int i = 0; i < 4; i++) {
+ m1(b);
+ }
+ }
+
+ static boolean m1(A a) {
+ boolean res = Agent.m2(a);
+ return res;
+ }
+
+ static public A a = new A();
+ static public B b = new B();
+ static public C c = new C();
+}
+
+public class Agent implements ClassFileTransformer {
+
+
+ static class MemoryChunk {
+ MemoryChunk other;
+ long[] array;
+ MemoryChunk(MemoryChunk other) {
+ other = other;
+ array = new long[1024 * 1024 * 1024];
+ }
+ }
+
+ static public boolean m2(A a) {
+ boolean res = false;
+ if (a.getClass() == B.class) {
+ a.m();
+ } else {
+ res = true;
+ }
+ return res;
+ }
+
+ static public void main(String[] args) throws Exception {
+ // Create speculative trap entries
+ Test.m();
+
+ String nameOfRunningVM = ManagementFactory.getRuntimeMXBean().getName();
+ int p = nameOfRunningVM.indexOf('@');
+ String pid = nameOfRunningVM.substring(0, p);
+
+ // Make the nmethod go away
+ for (int i = 0; i < 10; i++) {
+ System.gc();
+ }
+
+ // Redefine class
+ try {
+ VirtualMachine vm = VirtualMachine.attach(pid);
+ vm.loadAgent(System.getProperty("test.classes",".") + "/agent.jar", "");
+ vm.detach();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ Test.m();
+ // GC will hit dead method pointer
+ for (int i = 0; i < 10; i++) {
+ System.gc();
+ }
+ }
+
+ public synchronized byte[] transform(final ClassLoader classLoader,
+ final String className,
+ Class> classBeingRedefined,
+ ProtectionDomain protectionDomain,
+ byte[] classfileBuffer) {
+ System.out.println("Transforming class " + className);
+ return classfileBuffer;
+ }
+
+ public static void redefine(String agentArgs, Instrumentation instrumentation, Class to_redefine) {
+
+ try {
+ instrumentation.retransformClasses(to_redefine);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ public static void agentmain(String agentArgs, Instrumentation instrumentation) throws Exception {
+ Agent transformer = new Agent();
+ instrumentation.addTransformer(transformer, true);
+
+ redefine(agentArgs, instrumentation, Test.class);
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/profiling/spectrapredefineclass/Launcher.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass/Launcher.java Tue Apr 29 14:40:07 2014 -0700
@@ -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.
+ */
+import java.io.PrintWriter;
+import com.oracle.java.testlibrary.*;
+
+/*
+ * @test
+ * @bug 8038636
+ * @library /testlibrary
+ * @build Agent
+ * @run main ClassFileInstaller Agent
+ * @run main Launcher
+ * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222 -Xmx1M -XX:ReservedCodeCacheSize=3M Agent
+ */
+public class Launcher {
+ public static void main(String[] args) throws Exception {
+
+ PrintWriter pw = new PrintWriter("MANIFEST.MF");
+ pw.println("Agent-Class: Agent");
+ pw.println("Can-Retransform-Classes: true");
+ pw.close();
+
+ ProcessBuilder pb = new ProcessBuilder();
+ pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", System.getProperty("test.classes",".") + "/agent.jar", "Agent.class"});
+ pb.start().waitFor();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/RTMGenericCommandLineOptionTest.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,198 @@
+/*
+ * 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 com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.*;
+
+import java.util.function.BooleanSupplier;
+
+/**
+ * Base for all RTM-related CLI tests.
+ */
+public abstract class RTMGenericCommandLineOptionTest
+ extends CommandLineOptionTest {
+ protected static final String RTM_INSTR_ERROR
+ = "RTM instructions are not available on this CPU";
+ protected static final String RTM_UNSUPPORTED_VM_ERROR
+ = "RTM locking optimization is not supported in this VM";
+ protected static final String RTM_ABORT_RATIO_WARNING
+ = "RTMAbortRatio must be in the range 0 to 100, resetting it to 50";
+ protected static final String RTM_FOR_STACK_LOCKS_WARNING
+ = "UseRTMForStackLocks flag should be off when UseRTMLocking "
+ + "flag is off";
+ protected static final String RTM_COUNT_INCR_WARNING
+ = "RTMTotalCountIncrRate must be a power of 2, resetting it to 64";
+ protected static final String RTM_BIASED_LOCKING_WARNING
+ = "Biased locking is not supported with RTM locking; "
+ + "ignoring UseBiasedLocking flag";
+
+ protected final String optionName;
+ protected final String errorMessage;
+ protected final String experimentalOptionError;
+ protected final boolean isExperimental;
+ protected final boolean isBoolean;
+ protected final String defaultValue;
+ protected final String[] optionValues;
+
+ /**
+ * Constructs new genetic RTM CLI test, for option {@code optionName} which
+ * has default value {@code defaultValue}. Test cases will use option's
+ * values passed via {@code optionValues} for verification of correct
+ * option processing.
+ *
+ * Test constructed using this ctor will be started on any cpu regardless
+ * it's architecture and supported/unsupported features.
+ *
+ * @param predicate predicate responsible for test's preconditions check
+ * @param optionName name of option to be tested
+ * @param isBoolean {@code true} if option is binary
+ * @param isExperimental {@code true} if option is experimental
+ * @param defaultValue default value of tested option
+ * @param optionValues different option values
+ */
+ public RTMGenericCommandLineOptionTest(BooleanSupplier predicate,
+ String optionName, boolean isBoolean, boolean isExperimental,
+ String defaultValue, String... optionValues) {
+ super(predicate);
+ this.optionName = optionName;
+ this.isExperimental = isExperimental;
+ this.isBoolean = isBoolean;
+ this.defaultValue = defaultValue;
+ this.optionValues = optionValues;
+ this.errorMessage = CommandLineOptionTest.
+ getUnrecognizedOptionErrorMessage(optionName);
+ this.experimentalOptionError = CommandLineOptionTest.
+ getExperimentalOptionErrorMessage(optionName);
+ }
+
+ @Override
+ public void runTestCases() throws Throwable {
+ if (Platform.isX86() || Platform.isX64()) {
+ if (Platform.isServer() && !Platform.isEmbedded()) {
+ runX86SupportedVMTestCases();
+ } else {
+ runX86UnsupportedVMTestCases();
+ }
+ } else {
+ runNonX86TestCases();
+ }
+ }
+
+ /**
+ * Runs test cases on X86 CPU if VM supports RTM locking.
+ * @throws Throwable
+ */
+ protected void runX86SupportedVMTestCases() throws Throwable {
+ runGenericX86TestCases();
+ }
+
+ /**
+ * Runs test cases on non-X86 CPU if VM does not support RTM locking.
+ * @throws Throwable
+ */
+ protected void runX86UnsupportedVMTestCases() throws Throwable {
+ runGenericX86TestCases();
+ }
+
+ /**
+ * Runs test cases on non-X86 CPU.
+ * @throws Throwable
+ */
+ protected void runNonX86TestCases() throws Throwable {
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { errorMessage }, null, ExitCode.FAIL,
+ prepareOptionValue(defaultValue));
+ }
+
+ /**
+ * Runs generic X86 test cases.
+ * @throws Throwable
+ */
+ protected void runGenericX86TestCases() throws Throwable {
+ verifyJVMStartup();
+ verifyOptionValues();
+ }
+
+ protected void verifyJVMStartup() throws Throwable {
+ String optionValue = prepareOptionValue(defaultValue);
+ if (isExperimental) {
+ // verify that option is experimental
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { experimentalOptionError },
+ new String[] { errorMessage }, ExitCode.FAIL,
+ optionValue);
+ // verify that it could be passed if experimental options
+ // are unlocked
+ CommandLineOptionTest.verifySameJVMStartup(null,
+ new String[] {
+ experimentalOptionError,
+ errorMessage
+ },
+ ExitCode.OK,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+ optionValue);
+ } else {
+ // verify that option could be passed
+ CommandLineOptionTest.verifySameJVMStartup(null,
+ new String[]{errorMessage}, ExitCode.OK, optionValue);
+ }
+ }
+
+ protected void verifyOptionValues() throws Throwable {
+ // verify default value
+ if (isExperimental) {
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ defaultValue,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
+ } else {
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ defaultValue);
+ }
+ // verify other specified option values
+ if (optionValues == null) {
+ return;
+ }
+
+ for (String value : optionValues) {
+ if (isExperimental) {
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ value,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+ prepareOptionValue(value));
+ } else {
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ value, prepareOptionValue(value));
+ }
+ }
+ }
+
+ protected String prepareOptionValue(String value) {
+ if (isBoolean) {
+ return CommandLineOptionTest.prepareBooleanFlag(optionName,
+ Boolean.valueOf(value));
+ } else {
+ return String.format("-XX:%s=%s", optionName, value);
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/RTMLockingAwareTest.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,154 @@
+/*
+ * 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.List;
+import java.util.LinkedList;
+
+import com.oracle.java.testlibrary.ExitCode;
+import com.oracle.java.testlibrary.cli.*;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Base for all RTM-related CLI tests on options whose processing depends
+ * on UseRTMLocking value.
+ *
+ * Since UseRTMLocking option could be used when both CPU and VM supports RTM
+ * locking, this test will be skipped on all unsupported configurations.
+ */
+public abstract class RTMLockingAwareTest
+ extends RTMGenericCommandLineOptionTest {
+ protected final String warningMessage;
+ protected final String[] correctValues;
+ protected final String[] incorrectValues;
+ /**
+ * Constructs new test for option {@code optionName} that should be executed
+ * only on CPU with RTM support.
+ * Test will be executed using set of correct values from
+ * {@code correctValues} and set of incorrect values from
+ * {@code incorrectValues}.
+ *
+ * @param optionName name of option to be tested
+ * @param isBoolean {@code true} if tested option is binary
+ * @param isExperimental {@code true} if tested option is experimental
+ * @param defaultValue default value of tested option
+ * @param correctValues array with correct values, that should not emit
+ * {@code warningMessage} to VM output
+ * @param incorrectValues array with incorrect values, that should emit
+ * {@code waningMessage} to VM output
+ * @param warningMessage warning message associated with tested option
+ */
+ protected RTMLockingAwareTest(String optionName, boolean isBoolean,
+ boolean isExperimental, String defaultValue,
+ String[] correctValues, String[] incorrectValues,
+ String warningMessage) {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()),
+ optionName, isBoolean, isExperimental, defaultValue);
+ this.correctValues = correctValues;
+ this.incorrectValues = incorrectValues;
+ this.warningMessage = warningMessage;
+ }
+
+ @Override
+ protected void verifyJVMStartup() throws Throwable {
+ // Run generic sanity checks
+ super.verifyJVMStartup();
+ // Verify how option values will be processed depending on
+ // UseRTMLocking value.
+ if (correctValues != null) {
+ for (String correctValue : correctValues) {
+ // For correct values it is expected to see no warnings
+ // regardless to UseRTMLocking
+ verifyStartupWarning(correctValue, true, false);
+ verifyStartupWarning(correctValue, false, false);
+ }
+ }
+
+ if (incorrectValues != null) {
+ for (String incorrectValue : incorrectValues) {
+ // For incorrect values it is expected to see warning
+ // only with -XX:+UseRTMLocking
+ verifyStartupWarning(incorrectValue, true, true);
+ verifyStartupWarning(incorrectValue, false, false);
+ }
+ }
+ }
+
+ @Override
+ protected void verifyOptionValues() throws Throwable {
+ super.verifyOptionValues();
+ // Verify how option values will be setup after processing
+ // depending on UseRTMLocking value
+ if (correctValues != null) {
+ for (String correctValue : correctValues) {
+ // Correct value could be set up regardless to UseRTMLocking
+ verifyOptionValues(correctValue, false, correctValue);
+ verifyOptionValues(correctValue, true, correctValue);
+ }
+ }
+
+ if (incorrectValues != null) {
+ for (String incorrectValue : incorrectValues) {
+ // With -XX:+UseRTMLocking, incorrect value will be changed to
+ // default value.
+ verifyOptionValues(incorrectValue, false, incorrectValue);
+ verifyOptionValues(incorrectValue, true, defaultValue);
+ }
+ }
+ }
+
+ private void verifyStartupWarning(String value, boolean useRTMLocking,
+ boolean isWarningExpected) throws Throwable {
+ String warnings[] = new String[] { warningMessage };
+ List options = new LinkedList<>();
+ options.add(CommandLineOptionTest.prepareBooleanFlag("UseRTMLocking",
+ useRTMLocking));
+
+ if (isExperimental) {
+ options.add(CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
+ }
+ options.add(prepareOptionValue(value));
+
+ CommandLineOptionTest.verifySameJVMStartup(
+ (isWarningExpected ? warnings : null),
+ (isWarningExpected ? null : warnings),
+ ExitCode.OK, options.toArray(new String[options.size()]));
+ }
+
+ private void verifyOptionValues(String value, boolean useRTMLocking,
+ String expectedValue) throws Throwable {
+ List options = new LinkedList<>();
+ options.add(CommandLineOptionTest.prepareBooleanFlag("UseRTMLocking",
+ useRTMLocking));
+
+ if (isExperimental) {
+ options.add(CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
+ }
+ options.add(prepareOptionValue(value));
+
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ expectedValue, options.toArray(new String[options.size()]));
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsBase.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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 com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.*;
+
+import java.util.function.BooleanSupplier;
+
+public abstract class TestPrintPreciseRTMLockingStatisticsBase
+ extends RTMGenericCommandLineOptionTest {
+ protected static final String DEFAULT_VALUE = "false";
+
+ protected TestPrintPreciseRTMLockingStatisticsBase(
+ BooleanSupplier predicate) {
+ super(predicate, "PrintPreciseRTMLockingStatistics", true, false,
+ TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE);
+ }
+
+ @Override
+ protected void runNonX86TestCases() throws Throwable {
+ verifyJVMStartup();
+ verifyOptionValues();
+ }
+
+ @Override
+ protected void verifyJVMStartup() throws Throwable {
+ if (Platform.isServer()) {
+ if (!Platform.isDebugBuild()) {
+ String errorMessage = CommandLineOptionTest.
+ getDiagnosticOptionErrorMessage(optionName);
+ // verify that option is actually diagnostic
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { errorMessage }, null, ExitCode.FAIL,
+ prepareOptionValue("true"));
+
+ CommandLineOptionTest.verifySameJVMStartup(null,
+ new String[] { errorMessage }, ExitCode.OK,
+ CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
+ prepareOptionValue("true"));
+ } else {
+ CommandLineOptionTest.verifySameJVMStartup(
+ null, null, ExitCode.OK, prepareOptionValue("true"));
+ }
+ } else {
+ String errorMessage = CommandLineOptionTest.
+ getUnrecognizedOptionErrorMessage(optionName);
+
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[]{errorMessage}, null, ExitCode.FAIL,
+ CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
+ prepareOptionValue("true"));
+ }
+ }
+
+ @Override
+ protected void verifyOptionValues() throws Throwable {
+ if (Platform.isServer()) {
+ // Verify default value
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE,
+ CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS);
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -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 8031320
+ * @summary Verify PrintPreciseRTMLockingStatistics on CPUs with
+ * rtm support and on VM with rtm locking support,
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI
+ * TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig
+ */
+
+import com.oracle.java.testlibrary.cli.*;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig
+ extends TestPrintPreciseRTMLockingStatisticsBase {
+ private TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig() {
+ super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ }
+
+ @Override
+ protected void verifyOptionValues() throws Throwable {
+ super.verifyOptionValues();
+ // verify default value
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE,
+ CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
+ "-XX:+UseRTMLocking");
+
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ TestPrintPreciseRTMLockingStatisticsBase.DEFAULT_VALUE,
+ CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
+ "-XX:-UseRTMLocking", prepareOptionValue("true"));
+
+ // verify that option could be turned on
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true",
+ CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
+ "-XX:+UseRTMLocking", prepareOptionValue("true"));
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestPrintPreciseRTMLockingStatisticsOptionOnSupportedConfig()
+ .test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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 8031320
+ * @summary Verify PrintPreciseRTMLockingStatistics on CPUs without
+ * rtm support and/or unsupported VM.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI
+ * TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig
+ */
+
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import com.oracle.java.testlibrary.cli.predicate.NotPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig
+ extends TestPrintPreciseRTMLockingStatisticsBase {
+ private TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig() {
+ super(new NotPredicate(new AndPredicate(new SupportedCPU(),
+ new SupportedVM())));
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestPrintPreciseRTMLockingStatisticsOptionOnUnsupportedConfig()
+ .test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnSupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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 8031320
+ * @summary Verify RTMAbortRatio option processing on CPU with rtm
+ * support and on VM with rtm locking support.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMAbortRatioOptionOnSupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMAbortRatioOptionOnSupportedConfig
+ */
+
+public class TestRTMAbortRatioOptionOnSupportedConfig
+ extends RTMLockingAwareTest {
+ private static final String DEFAULT_VALUE = "50";
+
+ private TestRTMAbortRatioOptionOnSupportedConfig() {
+ super("RTMAbortRatio", false, true,
+ TestRTMAbortRatioOptionOnSupportedConfig.DEFAULT_VALUE,
+ /* correct values */
+ new String[] { "0", "20", "100" },
+ /* incorrect values */
+ new String[] { "-1", "101" },
+ RTMGenericCommandLineOptionTest.RTM_ABORT_RATIO_WARNING);
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMAbortRatioOptionOnSupportedConfig().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortRatioOptionOnUnsupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,57 @@
+/*
+ * 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 8031320
+ * @summary Verify RTMAbortRatio option processing on CPU without rtm
+ * support or on VM that does not support rtm locking.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMAbortRatioOptionOnUnsupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMAbortRatioOptionOnUnsupportedConfig
+ */
+
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import com.oracle.java.testlibrary.cli.predicate.NotPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestRTMAbortRatioOptionOnUnsupportedConfig
+ extends RTMGenericCommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "50";
+
+ private TestRTMAbortRatioOptionOnUnsupportedConfig() {
+ super(new NotPredicate(new AndPredicate(new SupportedVM(),
+ new SupportedCPU())),
+ "RTMAbortRatio", false, true,
+ TestRTMAbortRatioOptionOnUnsupportedConfig.DEFAULT_VALUE,
+ "0", "10", "100", "200");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMAbortRatioOptionOnUnsupportedConfig().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestRTMAbortThresholdOption.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMAbortThresholdOption.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
+ * @bug 8031320
+ * @summary Verify processing of RTMAbortThreshold option.
+ * @library /testlibrary
+ * @build TestRTMAbortThresholdOption
+ * @run main/othervm TestRTMAbortThresholdOption
+ */
+
+public class TestRTMAbortThresholdOption
+ extends RTMGenericCommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "1000";
+
+ private TestRTMAbortThresholdOption() {
+ super(Boolean.TRUE::booleanValue, "RTMAbortThreshold", false, true,
+ TestRTMAbortThresholdOption.DEFAULT_VALUE,
+ "0", "42", "100", "10000");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMAbortThresholdOption().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestRTMLockingCalculationDelayOption.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMLockingCalculationDelayOption.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
+ * @bug 8031320
+ * @summary Verify processing of RTMLockingCalculationDelay option.
+ * @library /testlibrary
+ * @build TestRTMLockingCalculationDelayOption
+ * @run main/othervm TestRTMLockingCalculationDelayOption
+ */
+
+public class TestRTMLockingCalculationDelayOption
+ extends RTMGenericCommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "0";
+
+ private TestRTMLockingCalculationDelayOption() {
+ super(Boolean.TRUE::booleanValue, "RTMLockingCalculationDelay", false,
+ true, TestRTMLockingCalculationDelayOption.DEFAULT_VALUE);
+ }
+
+ public static void main(String agrs[]) throws Throwable {
+ new TestRTMLockingCalculationDelayOption().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestRTMLockingThresholdOption.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMLockingThresholdOption.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
+ * @bug 8031320
+ * @summary Verify processing of RTMLockingThreshold option.
+ * @library /testlibrary
+ * @build TestRTMLockingThresholdOption
+ * @run main/othervm TestRTMLockingThresholdOption
+ */
+
+public class TestRTMLockingThresholdOption
+ extends RTMGenericCommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "10000";
+
+ private TestRTMLockingThresholdOption() {
+ super(Boolean.TRUE::booleanValue, "RTMLockingThreshold", false, true,
+ TestRTMLockingThresholdOption.DEFAULT_VALUE);
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMLockingThresholdOption().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestRTMRetryCountOption.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMRetryCountOption.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
+ * @bug 8031320
+ * @summary Verify processing of RTMRetryCount option.
+ * @library /testlibrary
+ * @build TestRTMRetryCountOption
+ * @run main/othervm TestRTMRetryCountOption
+ */
+
+public class TestRTMRetryCountOption extends RTMGenericCommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "5";
+
+ private TestRTMRetryCountOption() {
+ super(Boolean.TRUE::booleanValue, "RTMRetryCount", false, false,
+ TestRTMRetryCountOption.DEFAULT_VALUE,
+ "0", "10", "100", "1000");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMRetryCountOption().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestRTMSpinLoopCountOption.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMSpinLoopCountOption.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
+ * @bug 8031320
+ * @summary Verify processing of RTMSpinLoopCount option.
+ * @library /testlibrary
+ * @build TestRTMSpinLoopCountOption
+ * @run main/othervm TestRTMSpinLoopCountOption
+ */
+
+public class TestRTMSpinLoopCountOption
+ extends RTMGenericCommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "100";
+
+ private TestRTMSpinLoopCountOption() {
+ super(Boolean.TRUE::booleanValue, "RTMSpinLoopCount", false, true,
+ TestRTMSpinLoopCountOption.DEFAULT_VALUE,
+ "0", "10", "42", "1000");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMSpinLoopCountOption().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnSupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,55 @@
+/*
+ * 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 8031320
+ * @summary Verify RTMTotalCountIncrRate option processing on CPU with
+ * rtm support and on VM with rtm locking support.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMTotalCountIncrRateOptionOnSupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI
+ * TestRTMTotalCountIncrRateOptionOnSupportedConfig
+ */
+
+public class TestRTMTotalCountIncrRateOptionOnSupportedConfig
+ extends RTMLockingAwareTest {
+ private static final String DEFAULT_VALUE = "64";
+
+ private TestRTMTotalCountIncrRateOptionOnSupportedConfig() {
+ super("RTMTotalCountIncrRate", false, true,
+ TestRTMTotalCountIncrRateOptionOnSupportedConfig.DEFAULT_VALUE,
+ /* correct values */
+ new String[] { "1", "2", "128", "1024" },
+ /* incorrect values */
+ new String[] { "-1", "0", "3", "42" },
+ RTMGenericCommandLineOptionTest.RTM_COUNT_INCR_WARNING);
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMTotalCountIncrRateOptionOnSupportedConfig().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestRTMTotalCountIncrRateOptionOnUnsupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,59 @@
+/*
+ * 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 com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import com.oracle.java.testlibrary.cli.predicate.NotPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * @test
+ * @bug 8031320
+ * @summary Verify RTMTotalCountIncrRate option processing on CPU without
+ * rtm support and/or on VM without rtm locking support.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMTotalCountIncrRateOptionOnUnsupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI
+ * TestRTMTotalCountIncrRateOptionOnUnsupportedConfig
+ */
+
+public class TestRTMTotalCountIncrRateOptionOnUnsupportedConfig
+ extends RTMGenericCommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "64";
+
+ private TestRTMTotalCountIncrRateOptionOnUnsupportedConfig() {
+ super(new NotPredicate(new AndPredicate(new SupportedCPU(),
+ new SupportedVM())),
+ "RTMTotalCountIncrRate", false, true,
+ TestRTMTotalCountIncrRateOptionOnUnsupportedConfig
+ .DEFAULT_VALUE,
+ "-1", "0", "42", "128");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMTotalCountIncrRateOptionOnUnsupportedConfig().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnSupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,77 @@
+/*
+ * 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 8031320
+ * @summary Verify UseRTMDeopt option processing on CPUs with rtm support
+ * when rtm locking is supported by VM.
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestUseRTMDeoptOptionOnSupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMDeoptOptionOnSupportedConfig
+ */
+
+import com.oracle.java.testlibrary.ExitCode;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestUseRTMDeoptOptionOnSupportedConfig
+ extends CommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "false";
+
+ private TestUseRTMDeoptOptionOnSupportedConfig() {
+ super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ }
+
+ @Override
+ public void runTestCases() throws Throwable {
+ // verify that option could be turned on
+ CommandLineOptionTest.verifySameJVMStartup(
+ null, null, ExitCode.OK, "-XX:+UseRTMDeopt");
+ // verify that option could be turned off
+ CommandLineOptionTest.verifySameJVMStartup(
+ null, null, ExitCode.OK, "-XX:-UseRTMDeopt");
+ // verify default value
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt",
+ TestUseRTMDeoptOptionOnSupportedConfig.DEFAULT_VALUE);
+ // verify default value
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt",
+ TestUseRTMDeoptOptionOnSupportedConfig.DEFAULT_VALUE,
+ "-XX:+UseRTMLocking");
+ // verify that option is off when UseRTMLocking is off
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt",
+ "false", "-XX:-UseRTMLocking", "-XX:+UseRTMDeopt");
+ // verify that option could be turned on
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMDeopt",
+ "true", "-XX:+UseRTMLocking", "-XX:+UseRTMDeopt");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMDeoptOptionOnSupportedConfig().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMDeoptOptionOnUnsupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,70 @@
+/*
+ * 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 8031320
+ * @summary Verify UseRTMDeopt option processing on CPUs without rtm support
+ * or on VMs without rtm locking support.
+ * @library /testlibrary /testlibrary/whitebox
+ * @build TestUseRTMDeoptOptionOnUnsupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMDeoptOptionOnUnsupportedConfig
+ */
+
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import com.oracle.java.testlibrary.cli.predicate.NotPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestUseRTMDeoptOptionOnUnsupportedConfig
+ extends RTMGenericCommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "false";
+
+ private TestUseRTMDeoptOptionOnUnsupportedConfig() {
+ super(new NotPredicate(new AndPredicate(new SupportedCPU(),
+ new SupportedVM())),
+ "UseRTMDeopt", true, false,
+ TestUseRTMDeoptOptionOnUnsupportedConfig.DEFAULT_VALUE, "true");
+ }
+
+ @Override
+ protected void runX86SupportedVMTestCases() throws Throwable {
+ super.verifyJVMStartup();
+ // verify default value
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ defaultValue);
+ // verify that until RTMLocking is not used, value
+ // will be set to default false.
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ defaultValue, "-XX:+UseRTMDeopt");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMDeoptOptionOnUnsupportedConfig().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnSupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,102 @@
+/*
+ * 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 8031320
+ * @summary Verify UseRTMForStackLocks option processing on CPU with
+ * rtm support when VM supports rtm locking.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMForStackLocksOptionOnSupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI
+ * TestUseRTMForStackLocksOptionOnSupportedConfig
+ */
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.*;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestUseRTMForStackLocksOptionOnSupportedConfig
+ extends CommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "false";
+
+ private TestUseRTMForStackLocksOptionOnSupportedConfig() {
+ super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ }
+
+ @Override
+ public void runTestCases() throws Throwable {
+ String errorMessage
+ = CommandLineOptionTest.getExperimentalOptionErrorMessage(
+ "UseRTMForStackLocks");
+ String warningMessage
+ = RTMGenericCommandLineOptionTest.RTM_FOR_STACK_LOCKS_WARNING;
+
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { errorMessage }, null, ExitCode.FAIL,
+ "-XX:+UseRTMForStackLocks");
+ // verify that we get a warning when trying to use rtm for stack
+ // lock, but not using rtm locking.
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { warningMessage }, null, ExitCode.OK,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+ "-XX:+UseRTMForStackLocks",
+ "-XX:-UseRTMLocking");
+ // verify that we don't get a warning when no using rtm for stack
+ // lock and not using rtm locking.
+ CommandLineOptionTest.verifySameJVMStartup(null,
+ new String[] { warningMessage }, ExitCode.OK,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+ "-XX:-UseRTMForStackLocks",
+ "-XX:-UseRTMLocking");
+ // verify that we don't get a warning when using rtm for stack
+ // lock and using rtm locking.
+ CommandLineOptionTest.verifySameJVMStartup(null,
+ new String[] { warningMessage }, ExitCode.OK,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+ "-XX:+UseRTMForStackLocks",
+ "-XX:+UseRTMLocking");
+ // verify that default value if false
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks",
+ TestUseRTMForStackLocksOptionOnSupportedConfig.DEFAULT_VALUE,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
+ // verify that default value is false even with +UseRTMLocking
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks",
+ TestUseRTMForStackLocksOptionOnSupportedConfig.DEFAULT_VALUE,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+ "-XX:+UseRTMLocking");
+ // verify that we can turn the option on
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMForStackLocks",
+ "true", CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+ "-XX:+UseRTMLocking", "-XX:+UseRTMForStackLocks");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMForStackLocksOptionOnSupportedConfig().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMForStackLocksOptionOnUnsupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,93 @@
+/*
+ * 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 8031320
+ * @summary Verify UseRTMForStackLocks option processing on CPUs without
+ * rtm support and/or on VMs without rtm locking support.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMForStackLocksOptionOnUnsupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI
+ * TestUseRTMForStackLocksOptionOnUnsupportedConfig
+ */
+
+import com.oracle.java.testlibrary.ExitCode;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import com.oracle.java.testlibrary.cli.predicate.NotPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestUseRTMForStackLocksOptionOnUnsupportedConfig
+ extends RTMGenericCommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "false";
+
+ private TestUseRTMForStackLocksOptionOnUnsupportedConfig() {
+ super(new NotPredicate(new AndPredicate(new SupportedCPU(),
+ new SupportedVM())),
+ "UseRTMForStackLocks", true, true,
+ TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
+ "true");
+ }
+
+ @Override
+ protected void runX86SupportedVMTestCases() throws Throwable {
+ // verify that option is experimental
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[]{ experimentalOptionError },
+ null, ExitCode.FAIL, prepareOptionValue("true"));
+
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[]{ experimentalOptionError },
+ null, ExitCode.FAIL, prepareOptionValue("false"));
+
+ // verify that if we turn it on, then VM output will contain
+ // warning saying that this option could be turned on only
+ // when we use rtm locking
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[]{
+ RTMGenericCommandLineOptionTest.RTM_FOR_STACK_LOCKS_WARNING
+ },
+ null, ExitCode.OK,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+ prepareOptionValue("true")
+ );
+ // verify that options is turned off by default
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
+ // verify that it could not be turned on without rtm locking
+ CommandLineOptionTest.verifyOptionValueForSameVM(optionName,
+ TestUseRTMForStackLocksOptionOnUnsupportedConfig.DEFAULT_VALUE,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS,
+ prepareOptionValue("true"));
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMForStackLocksOptionOnUnsupportedConfig().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnSupportedConfig.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,84 @@
+/*
+ * 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 8031320
+ * @summary Verify UseRTMLocking option processing on CPU with rtm support and
+ * on VM with rtm-locking support.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMLockingOptionOnSupportedConfig
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMLockingOptionOnSupportedConfig
+ */
+
+import com.oracle.java.testlibrary.ExitCode;
+import com.oracle.java.testlibrary.cli.*;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestUseRTMLockingOptionOnSupportedConfig
+ extends CommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "false";
+
+ private TestUseRTMLockingOptionOnSupportedConfig() {
+ super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ }
+
+ @Override
+ public void runTestCases() throws Throwable {
+ String unrecongnizedOption
+ = CommandLineOptionTest.getUnrecognizedOptionErrorMessage(
+ "UseRTMLocking");
+ // verify that there are no warning or error in VM output
+ CommandLineOptionTest.verifySameJVMStartup(null,
+ new String[]{
+ RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR,
+ unrecongnizedOption
+ }, ExitCode.OK, "-XX:+UseRTMLocking"
+ );
+
+ CommandLineOptionTest.verifySameJVMStartup(null,
+ new String[]{
+ RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR,
+ unrecongnizedOption
+ }, ExitCode.OK, "-XX:-UseRTMLocking"
+ );
+ // verify that UseRTMLocking is of by default
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
+ TestUseRTMLockingOptionOnSupportedConfig.DEFAULT_VALUE);
+ // verify that we can change UseRTMLocking value
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
+ TestUseRTMLockingOptionOnSupportedConfig.DEFAULT_VALUE,
+ "-XX:-UseRTMLocking");
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
+ "true", "-XX:+UseRTMLocking");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMLockingOptionOnSupportedConfig().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedCPU.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,94 @@
+/*
+ * 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 8031320
+ * @summary Verify UseRTMLocking option processing on CPU without
+ * rtm support.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMLockingOptionOnUnsupportedCPU
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMLockingOptionOnUnsupportedCPU
+ */
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.*;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import com.oracle.java.testlibrary.cli.predicate.NotPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestUseRTMLockingOptionOnUnsupportedCPU
+ extends CommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "false";
+
+ private TestUseRTMLockingOptionOnUnsupportedCPU() {
+ super(new AndPredicate(new NotPredicate(new SupportedCPU()),
+ new SupportedVM()));
+ }
+
+ @Override
+ public void runTestCases() throws Throwable {
+ String unrecongnizedOption
+ = CommandLineOptionTest.getUnrecognizedOptionErrorMessage(
+ "UseRTMLocking");
+ String errorMessage = RTMGenericCommandLineOptionTest.RTM_INSTR_ERROR;
+
+ if (Platform.isX86() || Platform.isX64()) {
+ // verify that we get an error when use +UseRTMLocking
+ // on unsupported CPU
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { errorMessage },
+ new String[] { unrecongnizedOption },
+ ExitCode.FAIL, "-XX:+UseRTMLocking");
+ // verify that we can pass -UseRTMLocking without
+ // getting any error messages
+ CommandLineOptionTest.verifySameJVMStartup(
+ null,
+ new String[]{
+ errorMessage,
+ unrecongnizedOption
+ }, ExitCode.OK, "-XX:-UseRTMLocking");
+
+ // verify that UseRTMLocking is false by default
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
+ TestUseRTMLockingOptionOnUnsupportedCPU.DEFAULT_VALUE);
+ } else {
+ // verify that on non-x86 CPUs RTMLocking could not be used
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { unrecongnizedOption },
+ null, ExitCode.FAIL, "-XX:+UseRTMLocking");
+
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { unrecongnizedOption },
+ null, ExitCode.FAIL, "-XX:-UseRTMLocking");
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMLockingOptionOnUnsupportedCPU().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionOnUnsupportedVM.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,72 @@
+/*
+ * 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 8031320
+ * @summary Verify UseRTMLocking option processing on CPU with rtm support
+ * in case when VM should not support this option.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMLockingOptionOnUnsupportedVM
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMLockingOptionOnUnsupportedVM
+ */
+
+import com.oracle.java.testlibrary.ExitCode;
+import com.oracle.java.testlibrary.cli.*;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import com.oracle.java.testlibrary.cli.predicate.NotPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestUseRTMLockingOptionOnUnsupportedVM
+ extends CommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "false";
+
+ private TestUseRTMLockingOptionOnUnsupportedVM() {
+ super(new AndPredicate(new SupportedCPU(),
+ new NotPredicate(new SupportedVM())));
+ }
+ @Override
+ public void runTestCases() throws Throwable {
+ String errorMessage
+ = RTMGenericCommandLineOptionTest.RTM_UNSUPPORTED_VM_ERROR;
+ // verify that we can't use +UseRTMLocking
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { errorMessage }, null, ExitCode.FAIL,
+ "-XX:+UseRTMLocking");
+ // verify that we can turn it off
+ CommandLineOptionTest.verifySameJVMStartup(null,
+ new String[] { errorMessage }, ExitCode.OK,
+ "-XX:-UseRTMLocking");
+ // verify that it is off by default
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseRTMLocking",
+ TestUseRTMLockingOptionOnUnsupportedVM.DEFAULT_VALUE);
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMLockingOptionOnUnsupportedVM().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMLockingOptionWithBiasedLocking.java Tue Apr 29 14:40:07 2014 -0700
@@ -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 8031320
+ * @summary Verify processing of UseRTMLocking and UseBiasedLocking
+ * options combination on CPU and VM with rtm support.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMLockingOptionWithBiasedLocking
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMLockingOptionWithBiasedLocking
+ */
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.*;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+public class TestUseRTMLockingOptionWithBiasedLocking
+ extends CommandLineOptionTest {
+ private TestUseRTMLockingOptionWithBiasedLocking() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ public void runTestCases() throws Throwable {
+ String warningMessage
+ = RTMGenericCommandLineOptionTest.RTM_BIASED_LOCKING_WARNING;
+ // verify that we will not get a warning
+ CommandLineOptionTest.verifySameJVMStartup(null,
+ new String[] { warningMessage }, ExitCode.OK,
+ "-XX:+UseRTMLocking", "-XX:-UseBiasedLocking");
+ // verify that we will get a warning
+ CommandLineOptionTest.verifySameJVMStartup(
+ new String[] { warningMessage }, null, ExitCode.OK,
+ "-XX:+UseRTMLocking", "-XX:+UseBiasedLocking");
+ // verify that UseBiasedLocking is false when we use rtm locking
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseBiasedLocking",
+ "false", "-XX:+UseRTMLocking");
+ // verify that we can't turn on biased locking when
+ // using rtm locking
+ CommandLineOptionTest.verifyOptionValueForSameVM("UseBiasedLocking",
+ "false", "-XX:+UseRTMLocking", "-XX:+UseBiasedLocking");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMLockingOptionWithBiasedLocking().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/cli/TestUseRTMXendForLockBusyOption.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/cli/TestUseRTMXendForLockBusyOption.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
+ * @bug 8031320
+ * @summary Verify processing of UseRTMXendForLockBusy option.
+ * @library /testlibrary
+ * @build TestUseRTMXendForLockBusyOption
+ * @run main/othervm TestUseRTMXendForLockBusyOption
+ */
+
+public class TestUseRTMXendForLockBusyOption
+ extends RTMGenericCommandLineOptionTest {
+ private static final String DEFAULT_VALUE = "true";
+
+ public TestUseRTMXendForLockBusyOption() {
+ super(Boolean.TRUE::booleanValue, "UseRTMXendForLockBusy", true, true,
+ TestUseRTMXendForLockBusyOption.DEFAULT_VALUE, "true");
+ }
+
+ public static void main(String agrs[]) throws Throwable {
+ new TestUseRTMXendForLockBusyOption().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,163 @@
+/*
+ * 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 8031320
+ * @summary Verify that RTMAbortRatio affects amount of aborts before
+ * deoptimization.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMAbortRatio
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMAbortRatio
+ */
+
+import java.util.List;
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+import sun.misc.Unsafe;
+
+/**
+ * Test verifies that method will be deoptimized on high abort ratio
+ * as soon as abort ratio reaches RTMAbortRatio's value.
+ */
+public class TestRTMAbortRatio extends CommandLineOptionTest {
+ private TestRTMAbortRatio() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ verifyAbortRatio(0, false);
+ verifyAbortRatio(10, false);
+ verifyAbortRatio(50, false);
+ verifyAbortRatio(100, false);
+
+ verifyAbortRatio(0, true);
+ verifyAbortRatio(10, true);
+ verifyAbortRatio(50, true);
+ verifyAbortRatio(100, true);
+ }
+
+ private void verifyAbortRatio(int abortRatio, boolean useStackLock)
+ throws Throwable {
+ CompilableTest test = new Test();
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ test,
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
+ useStackLock),
+ "-XX:+UseRTMDeopt",
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:RTMAbortThreshold=0",
+ CommandLineOptionTest.prepareNumericFlag("RTMLockingThreshold",
+ 10 * Test.TOTAL_ITERATIONS),
+ CommandLineOptionTest.prepareNumericFlag("RTMAbortRatio",
+ abortRatio),
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ test.getClass().getName(),
+ Boolean.toString(!useStackLock));
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ test.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 1, "VM output should contain "
+ + "exactly one RTM locking statistics entry.");
+
+ RTMLockingStatistics lock = statistics.get(0);
+ int actualRatio;
+
+ if (lock.getTotalAborts() == 1L) {
+ actualRatio = 0;
+ } else {
+ actualRatio = (int) (lock.getTotalLocks()
+ / (lock.getTotalAborts() - 1L));
+ }
+
+ Asserts.assertLTE(actualRatio, abortRatio, String.format(
+ "Actual abort ratio (%d) should lower or equal to "
+ + "specified (%d).", actualRatio, abortRatio));
+ }
+
+ /**
+ * Force abort after {@code Test.WARMUP_ITERATIONS} is done.
+ */
+ public static class Test implements CompilableTest {
+ private static final int TOTAL_ITERATIONS = 10000;
+ private static final int WARMUP_ITERATIONS = 1000;
+ private static final Unsafe UNSAFE = Utils.getUnsafe();
+ private final Object monitor = new Object();
+ // Following field have to be static in order to avoid escape analysis.
+ @SuppressWarnings("UnsuedDeclaration")
+ private static int field = 0;
+
+ @Override
+ public String getMethodWithLockName() {
+ return this.getClass().getName() + "::lock";
+ }
+
+ @Override
+ public String[] getMethodsToCompileNames() {
+ return new String[] {
+ getMethodWithLockName(),
+ Unsafe.class.getName() + "::addressSize"
+ };
+ }
+
+ public void lock(boolean abort) {
+ synchronized(monitor) {
+ if (abort) {
+ Test.UNSAFE.addressSize();
+ }
+ }
+ }
+
+ /**
+ * Usage:
+ * Test <inflate monitor>
+ */
+ public static void main(String args[]) throws Throwable {
+ Asserts.assertGTE(args.length, 1, "One argument required.");
+ Test t = new Test();
+ if (Boolean.valueOf(args[0])) {
+ AbortProvoker.inflateMonitor(t.monitor);
+ }
+ for (int i = 0; i < Test.TOTAL_ITERATIONS; i++) {
+ t.lock(i >= Test.WARMUP_ITERATIONS);
+ }
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMAbortRatio().test();
+ }
+}
+
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortThreshold.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,102 @@
+/*
+ * 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 8031320
+ * @summary Verify that RTMAbortThreshold option affects
+ * amount of aborts after which abort ratio is calculated.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMAbortThreshold
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMAbortThreshold
+ */
+
+import java.util.List;
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that on RTMAbortThreshold option actually affects how soon
+ * method will be deoptimized on high abort ratio.
+ */
+public class TestRTMAbortThreshold extends CommandLineOptionTest {
+ private TestRTMAbortThreshold() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ verifyAbortThreshold(false, 1);
+ verifyAbortThreshold(false, 10);
+ verifyAbortThreshold(false, 1000);
+
+ verifyAbortThreshold(true, 1);
+ verifyAbortThreshold(true, 10);
+ verifyAbortThreshold(true, 1000);
+ }
+
+ private void verifyAbortThreshold(boolean useStackLock,
+ long abortThreshold) throws Throwable {
+ AbortProvoker provoker = AbortType.XABORT.provoker();
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ provoker,
+ "-XX:+UseRTMDeopt",
+ "-XX:RTMAbortRatio=0",
+ CommandLineOptionTest.prepareNumericFlag("RTMAbortThreshold",
+ abortThreshold),
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
+ useStackLock),
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ AbortProvoker.class.getName(),
+ AbortType.XABORT.toString(),
+ Boolean.toString(!useStackLock));
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 1, "VM output should contain "
+ + "exactly one RTM locking statistics entry for method "
+ + provoker.getMethodWithLockName());
+
+ Asserts.assertEQ(statistics.get(0).getTotalLocks(), abortThreshold,
+ String.format("Expected that method with rtm lock elision was"
+ + " deoptimized after %d lock attempts",
+ abortThreshold));
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMAbortThreshold().test();
+ }
+}
+
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,210 @@
+/*
+ * 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 8031320
+ * @summary Verify that if we use RTMDeopt, then deoptimization
+ * caused by reason other then rtm_state_change will reset
+ * method's RTM state. And if we don't use RTMDeopt, then
+ * RTM state remain the same after such deoptimization.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMAfterNonRTMDeopt
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMAfterNonRTMDeopt
+ */
+
+import java.util.List;
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+import sun.misc.Unsafe;
+
+/**
+ * To verify that with +UseRTMDeopt method's RTM state will be
+ * changed to ProfileRTM on deoptimization unrelated to
+ * rtm_state_change following sequence of events is used:
+ *
+ *
+ * rtm state ^
+ * |
+ * UseRTM | ******| ******
+ * | |
+ * ProfileRTM |******| |*****|
+ * | | | |
+ * 0-------|-----|-----|---------------------> time
+ * | | \ force abort
+ * | |
+ * | \ force deoptimization
+ * |
+ * \ force xabort
+ *
+ * When xabort is forced by native method call method should
+ * change it's state to UseRTM, because we use RTMAbortRatio=100
+ * and low RTMLockingThreshold, so at this point actual abort
+ * ratio will be below 100% and there should be enough lock
+ * attempts to recompile method without RTM profiling.
+ */
+public class TestRTMAfterNonRTMDeopt extends CommandLineOptionTest {
+ private static final int ABORT_THRESHOLD = 1000;
+ private static final String RANGE_CHECK = "range_check";
+
+ private TestRTMAfterNonRTMDeopt() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ verifyRTMAfterDeopt(false, false);
+ verifyRTMAfterDeopt(true, false);
+
+ verifyRTMAfterDeopt(false, true);
+ verifyRTMAfterDeopt(true, true);
+ }
+
+ private void verifyRTMAfterDeopt(boolean useStackLock,
+ boolean useRTMDeopt) throws Throwable {
+ CompilableTest test = new Test();
+ String logFile = String.format("rtm_%s_stack_lock_%s_deopt.xml",
+ (useStackLock ? "use" : "no"), (useRTMDeopt ? "use" : "no"));
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ logFile,
+ test,
+ "-XX:CompileThreshold=1",
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
+ useStackLock),
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMDeopt",
+ useRTMDeopt),
+ "-XX:RTMAbortRatio=100",
+ CommandLineOptionTest.prepareNumericFlag("RTMAbortThreshold",
+ TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD),
+ CommandLineOptionTest.prepareNumericFlag("RTMLockingThreshold",
+ TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD / 2L),
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ Test.class.getName(),
+ Boolean.toString(!useStackLock)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ int traps = RTMTestBase.firedRTMStateChangeTraps(logFile);
+
+ if (useRTMDeopt) {
+ Asserts.assertEQ(traps, 2, "Two uncommon traps with "
+ + "reason rtm_state_change should be fired.");
+ } else {
+ Asserts.assertEQ(traps, 0, "No uncommon traps with "
+ + "reason rtm_state_change should be fired.");
+ }
+
+ int rangeCheckTraps = RTMTestBase.firedUncommonTraps(logFile,
+ TestRTMAfterNonRTMDeopt.RANGE_CHECK);
+
+ Asserts.assertEQ(rangeCheckTraps, 1,
+ "One range_check uncommon trap should be fired.");
+
+ List statistics = RTMLockingStatistics.fromString(
+ test.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ int expectedStatEntries = (useRTMDeopt ? 4 : 2);
+
+ Asserts.assertEQ(statistics.size(), expectedStatEntries,
+ String.format("VM output should contain %d RTM locking "
+ + "statistics entries.", expectedStatEntries));
+ }
+
+ public static class Test implements CompilableTest {
+ // Following field have to be static in order to avoid escape analysis.
+ @SuppressWarnings("UnsuedDeclaration")
+ private static int field = 0;
+ private static final int ITERATIONS = 10000;
+ private static final int RANGE_CHECK_AT = ITERATIONS / 2;
+ private static final Unsafe UNSAFE = Utils.getUnsafe();
+ private final Object monitor = new Object();
+
+ @Override
+ public String getMethodWithLockName() {
+ return this.getClass().getName() + "::forceAbort";
+ }
+
+ @Override
+ public String[] getMethodsToCompileNames() {
+ return new String[] {
+ getMethodWithLockName(),
+ sun.misc.Unsafe.class.getName() + "::forceAbort"
+ };
+ }
+
+ public void forceAbort(int a[], boolean abort) {
+ try {
+ synchronized(monitor) {
+ a[0]++;
+ if (abort) {
+ Test.field = Test.UNSAFE.addressSize();
+ }
+ }
+ } catch (Throwable t) {
+ // suppress any throwables
+ }
+ }
+
+ /**
+ * Usage:
+ * Test <inflate monitor>
+ */
+ public static void main(String args[]) throws Throwable {
+ Test t = new Test();
+
+ if (Boolean.valueOf(args[0])) {
+ AbortProvoker.inflateMonitor(t.monitor);
+ }
+
+ int tmp[] = new int[1];
+
+ for (int i = 0; i < Test.ITERATIONS; i++ ) {
+ if (i == Test.RANGE_CHECK_AT) {
+ t.forceAbort(new int[0], false);
+ } else {
+ boolean isThreshold
+ = (i == TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD);
+ boolean isThresholdPlusRange
+ = (i == TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD
+ + Test.RANGE_CHECK_AT);
+ t.forceAbort(tmp, isThreshold || isThresholdPlusRange);
+ }
+ }
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMAfterNonRTMDeopt().test();
+ }
+}
+
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnHighAbortRatio.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,114 @@
+/*
+ * 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 8031320
+ * @summary Verify that on high abort ratio method will be recompiled
+ * without rtm locking.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMDeoptOnHighAbortRatio
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMDeoptOnHighAbortRatio
+ */
+
+import java.util.List;
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that on high abort ratio method wil be deoptimized with
+ * rtm_state_change reason and after that RTM-based lock elision will not
+ * be used for that method.
+ * This test make asserts on total locks count done by compiled method,
+ * so in order to avoid issue with retriable locks -XX:RTMRetryCount=0 is used.
+ * For more details on that issue see {@link TestUseRTMAfterLockInflation}.
+ */
+public class TestRTMDeoptOnHighAbortRatio extends CommandLineOptionTest {
+ private static final long ABORT_THRESHOLD
+ = AbortProvoker.DEFAULT_ITERATIONS / 2L;
+
+ private TestRTMDeoptOnHighAbortRatio() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ verifyDeopt(false);
+ verifyDeopt(true);
+ }
+
+ private void verifyDeopt(boolean useStackLock) throws Throwable {
+ AbortProvoker provoker = AbortType.XABORT.provoker();
+ String logFileName = String.format("rtm_deopt_%s_stack_lock.xml",
+ (useStackLock ? "use" : "no"));
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ logFileName,
+ provoker,
+ "-XX:+UseRTMDeopt",
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
+ useStackLock),
+ "-XX:RTMRetryCount=0",
+ CommandLineOptionTest.prepareNumericFlag("RTMAbortThreshold",
+ TestRTMDeoptOnHighAbortRatio.ABORT_THRESHOLD),
+ "-XX:RTMAbortRatio=100",
+ "-XX:CompileThreshold=1",
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ AbortProvoker.class.getName(),
+ AbortType.XABORT.toString(),
+ Boolean.toString(!useStackLock)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ int firedTraps = RTMTestBase.firedRTMStateChangeTraps(logFileName);
+
+ Asserts.assertEQ(firedTraps, 1, "Expected to get only one "
+ + "deoptimization due to rtm state change");
+
+ List statistics = RTMLockingStatistics.fromString(
+ provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 1, "VM output should contain "
+ + "exactly one RTM locking statistics entry for method "
+ + provoker.getMethodWithLockName());
+
+ Asserts.assertEQ(statistics.get(0).getTotalLocks(),
+ TestRTMDeoptOnHighAbortRatio.ABORT_THRESHOLD,
+ "After AbortThreshold was reached, method should be"
+ + " recompiled without rtm lock eliding.");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMDeoptOnHighAbortRatio().test();
+ }
+}
+
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,167 @@
+/*
+ * 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 8031320
+ * @summary Verify that on low abort ratio method will be recompiled.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMDeoptOnLowAbortRatio
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMDeoptOnLowAbortRatio
+ */
+
+import java.util.List;
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+import sun.misc.Unsafe;
+
+/**
+ * Test verifies that low abort ratio method will be deoptimized with
+ * rtm_state_change reason and will continue to use RTM-based lock
+ * elision after that.
+ * This test make asserts on total locks count done by compiled method,
+ * so in order to avoid issue with retriable locks -XX:RTMRetryCount=0 is used.
+ * For more details on that issue see {@link TestUseRTMAfterLockInflation}.
+ */
+public class TestRTMDeoptOnLowAbortRatio extends CommandLineOptionTest {
+ private static final long LOCKING_THRESHOLD = 100L;
+
+ private TestRTMDeoptOnLowAbortRatio() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ verifyRTMDeopt(false);
+ verifyRTMDeopt(true);
+ }
+
+ private void verifyRTMDeopt(boolean useStackLock) throws Throwable {
+ CompilableTest test = new Test();
+ String logFileName = String.format("rtm_deopt_%s_stack_lock.xml",
+ useStackLock ? "use" : "no");
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ logFileName,
+ test,
+ "-XX:+UseRTMDeopt",
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
+ useStackLock),
+ CommandLineOptionTest.prepareNumericFlag("RTMLockingThreshold",
+ TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD),
+ "-XX:RTMAbortThreshold=1",
+ "-XX:RTMAbortRatio=100",
+ "-XX:CompileThreshold=1",
+ "-XX:RTMRetryCount=0",
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ Test.class.getName(),
+ Boolean.toString(!useStackLock)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ int firedTraps = RTMTestBase.firedRTMStateChangeTraps(logFileName);
+
+ Asserts.assertEQ(firedTraps, 1,
+ "Expected to get only one deoptimization due to rtm"
+ + " state change");
+
+ List statistics = RTMLockingStatistics.fromString(
+ test.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 2,
+ "VM output should contain two RTM locking "
+ + "statistics entries for method "
+ + test.getMethodWithLockName());
+
+ RTMLockingStatistics statisticsBeforeDeopt = null;
+
+ for (RTMLockingStatistics s : statistics) {
+ if (s.getTotalLocks()
+ == TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD + 1L) {
+ Asserts.assertNull(statisticsBeforeDeopt,
+ "Only one abort was expected during test run");
+ statisticsBeforeDeopt = s;
+ }
+ }
+
+ Asserts.assertNotNull(statisticsBeforeDeopt,
+ "After LockThreshold was reached, method should be recompiled "
+ + "with rtm lock eliding.");
+ }
+
+ public static class Test implements CompilableTest {
+ private static final Unsafe UNSAFE = Utils.getUnsafe();
+ private final Object monitor = new Object();
+
+ @Override
+ public String getMethodWithLockName() {
+ return this.getClass().getName() + "::forceAbort";
+ }
+
+ @Override
+ public String[] getMethodsToCompileNames() {
+ return new String[] {
+ getMethodWithLockName(),
+ sun.misc.Unsafe.class.getName() + "::addressSize"
+ };
+ }
+
+ public void forceAbort(boolean abort) {
+ synchronized(monitor) {
+ if (abort) {
+ Test.UNSAFE.addressSize();
+ }
+ }
+ }
+
+ /**
+ * Usage:
+ * Test <inflate monitor>
+ */
+ public static void main(String args[]) throws Throwable {
+ Asserts.assertGTE(args.length, 1, "One argument required.");
+ Test t = new Test();
+
+ if (Boolean.valueOf(args[0])) {
+ AbortProvoker.inflateMonitor(t.monitor);
+ }
+ for (int i = 0; i < AbortProvoker.DEFAULT_ITERATIONS; i++) {
+ t.forceAbort(
+ i == TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD);
+ }
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMDeoptOnLowAbortRatio().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingCalculationDelay.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,106 @@
+/*
+ * 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 8031320
+ * @summary Verify that RTMLockingCalculationDelay affect when
+ * abort ratio calculation is started.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMLockingCalculationDelay
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMLockingCalculationDelay
+ */
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that abort ratio calculation could be delayed using
+ * RTMLockingCalculationDelay option.
+ */
+public class TestRTMLockingCalculationDelay extends CommandLineOptionTest {
+ private static final boolean INFLATE_MONITOR = true;
+
+ private TestRTMLockingCalculationDelay() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ // verify that calculation will be started immediately
+ verifyLockingCalculationDelay(0, 0, true);
+
+ // verify that calculation will not be started during
+ // first 10 minutes, while test will be started immediately
+ verifyLockingCalculationDelay(600000, 0, false);
+
+ // verify that calculation will be started after a second
+ verifyLockingCalculationDelay(1000, 1000, true);
+ }
+
+ private void verifyLockingCalculationDelay(long delay, long testDelay,
+ boolean deoptExpected) throws Throwable {
+ AbortProvoker provoker = AbortType.XABORT.provoker();
+ String logFileName = String.format("rtm_delay_%d_%d.xml", delay,
+ testDelay);
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ logFileName,
+ provoker,
+ "-XX:+UseRTMDeopt",
+ CommandLineOptionTest.prepareNumericFlag(
+ "RTMLockingCalculationDelay", delay),
+ "-XX:RTMAbortRatio=0",
+ "-XX:RTMAbortThreshold=0",
+ AbortProvoker.class.getName(),
+ AbortType.XABORT.toString(),
+ Boolean.toString(
+ TestRTMLockingCalculationDelay.INFLATE_MONITOR),
+ Long.toString(AbortProvoker.DEFAULT_ITERATIONS),
+ Long.toString(testDelay)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ int deopts = RTMTestBase.firedRTMStateChangeTraps(logFileName);
+
+ if (deoptExpected) {
+ Asserts.assertGT(deopts, 0, "At least one deoptimization due to "
+ + "rtm_state_chage is expected");
+ } else {
+ Asserts.assertEQ(deopts, 0, "No deoptimizations due to "
+ + "rtm_state_chage are expected");
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMLockingCalculationDelay().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,179 @@
+/*
+ * 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 8031320
+ * @summary Verify that RTMLockingThreshold affects rtm state transition
+ * ProfileRTM => UseRTM.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMLockingThreshold
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMLockingThreshold
+ */
+
+import java.util.List;
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+import sun.misc.Unsafe;
+
+/**
+ * Test verifies that RTMLockingThreshold option actually affects how soon
+ * method will be deoptimized on low abort ratio.
+ */
+public class TestRTMLockingThreshold extends CommandLineOptionTest {
+ private TestRTMLockingThreshold() {
+ super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ }
+
+ /**
+ * We use non-zero abort threshold to avoid abort related to
+ * interrupts, VMM calls, etc. during first lock attempt.
+ *
+ */
+ private static final int ABORT_THRESHOLD = 10;
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ verifyLockingThreshold(0, false);
+ verifyLockingThreshold(100, false);
+ verifyLockingThreshold(1000, false);
+
+ verifyLockingThreshold(0, true);
+ verifyLockingThreshold(100, true);
+ verifyLockingThreshold(1000, true);
+ }
+
+ private void verifyLockingThreshold(int lockingThreshold,
+ boolean useStackLock) throws Throwable {
+ CompilableTest test = new Test();
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ test,
+ "-XX:CompileThreshold=1",
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
+ useStackLock),
+ "-XX:+UseRTMDeopt",
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:RTMRetryCount=0",
+ CommandLineOptionTest.prepareNumericFlag("RTMAbortThreshold",
+ TestRTMLockingThreshold.ABORT_THRESHOLD),
+ CommandLineOptionTest.prepareNumericFlag("RTMLockingThreshold",
+ lockingThreshold),
+ "-XX:RTMAbortRatio=100",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ Test.class.getName(),
+ Boolean.toString(!useStackLock),
+ Integer.toString(lockingThreshold)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ test.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 2, "VM output should contain two "
+ + "RTM locking statistics entries.");
+
+ /**
+ * We force abort on each odd iteration, so if RTMLockingThreshold==0,
+ * then we have to make 1 call without abort to avoid rtm state
+ * transition to NoRTM (otherwise actual abort ratio will be 100%),
+ * and after that make 1 call with abort to force deoptimization.
+ * This leads us to two locks for threshold 0.
+ * For other threshold values we have to make RTMLockingThreshold + 1
+ * locks if locking threshold is even, or + 0 if odd.
+ */
+ long expectedValue = lockingThreshold +
+ (lockingThreshold == 0L ? 2L : lockingThreshold % 2L);
+
+ RTMLockingStatistics statBeforeDeopt = null;
+ for (RTMLockingStatistics s : statistics) {
+ if (s.getTotalLocks() == expectedValue) {
+ Asserts.assertNull(statBeforeDeopt,
+ "Only one statistics entry should contain aborts");
+ statBeforeDeopt = s;
+ }
+ }
+
+ Asserts.assertNotNull(statBeforeDeopt, "There should be exactly one "
+ + "statistics entry corresponding to ProfileRTM state.");
+ }
+
+ public static class Test implements CompilableTest {
+ // Following field have to be static in order to avoid escape analysis.
+ @SuppressWarnings("UnsuedDeclaration")
+ private static int field = 0;
+ private static final int TOTAL_ITERATIONS = 10000;
+ private static final Unsafe UNSAFE = Utils.getUnsafe();
+ private final Object monitor = new Object();
+
+
+ @Override
+ public String getMethodWithLockName() {
+ return this.getClass().getName() + "::lock";
+ }
+
+ @Override
+ public String[] getMethodsToCompileNames() {
+ return new String[] {
+ getMethodWithLockName(),
+ sun.misc.Unsafe.class.getName() + "::addressSize"
+ };
+ }
+
+ public void lock(boolean abort) {
+ synchronized(monitor) {
+ if (abort) {
+ Test.field += Test.UNSAFE.addressSize();
+ }
+ }
+ }
+
+ /**
+ * Usage:
+ * Test <inflate monitor>
+ */
+ public static void main(String args[]) throws Throwable {
+ Asserts.assertGTE(args.length, 1, "One argument required.");
+ Test t = new Test();
+
+ if (Boolean.valueOf(args[0])) {
+ AbortProvoker.inflateMonitor(t.monitor);
+ }
+ for (int i = 0; i < Test.TOTAL_ITERATIONS; i++) {
+ t.lock(i % 2 == 1);
+ }
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMLockingThreshold().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMRetryCount.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,102 @@
+/*
+ * 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 8031320
+ * @summary Verify that RTMRetryCount affects actual amount of retries.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMRetryCount
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMRetryCount
+ */
+
+import java.util.List;
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that RTMRetryCount option actually affects amount of
+ * retries on lock busy.
+ */
+public class TestRTMRetryCount extends CommandLineOptionTest {
+ /**
+ * Time in ms, during which busy lock will be locked.
+ */
+ private static final int LOCKING_TIME = 5000;
+ private static final boolean INFLATE_MONITOR = true;
+
+ private TestRTMRetryCount() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ verifyRTMRetryCount(0);
+ verifyRTMRetryCount(1);
+ verifyRTMRetryCount(5);
+ verifyRTMRetryCount(10);
+ }
+
+ private void verifyRTMRetryCount(int retryCount) throws Throwable {
+ CompilableTest busyLock = new BusyLock();
+ long expectedAborts = retryCount + 1L;
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ busyLock,
+ "-XX:-UseRTMXendForLockBusy",
+ "-XX:RTMTotalCountIncrRate=1",
+ CommandLineOptionTest.prepareNumericFlag("RTMRetryCount",
+ retryCount),
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ BusyLock.class.getName(),
+ Boolean.toString(TestRTMRetryCount.INFLATE_MONITOR),
+ Integer.toString(TestRTMRetryCount.LOCKING_TIME)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ busyLock.getMethodWithLockName(), outputAnalyzer.getStdout());
+
+ Asserts.assertEQ(statistics.size(), 1, "VM output should contain "
+ + "exactly one rtm locking statistics entry for method "
+ + busyLock.getMethodWithLockName());
+
+ Asserts.assertEQ(statistics.get(0).getTotalAborts(), expectedAborts,
+ String.format("It is expected to get %d aborts",
+ expectedAborts));
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMRetryCount().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMSpinLoopCount.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,115 @@
+/*
+ * 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 8031320
+ * @summary Verify that RTMSpinLoopCount affects time spent
+ * between locking attempts.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMSpinLoopCount
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMSpinLoopCount
+ */
+
+import java.util.List;
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that RTMSpinLoopCount increase time spent between retries
+ * by comparing amount of retries done with different RTMSpinLoopCount's values.
+ */
+public class TestRTMSpinLoopCount extends CommandLineOptionTest {
+ private static final int LOCKING_TIME = 1000;
+ private static final int RTM_RETRY_COUNT = 1000;
+ private static final boolean INFLATE_MONITOR = true;
+ private static final long MAX_ABORTS = RTM_RETRY_COUNT + 1L;
+ private static final int[] SPIN_LOOP_COUNTS
+ = new int[] { 0, 100, 1_000, 1_000_000, 10_000_000 };
+
+ private TestRTMSpinLoopCount() {
+ super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ long[] aborts = new long[TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length];
+ for (int i = 0; i < TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length; i++) {
+ aborts[i] = getAbortsCountOnLockBusy(
+ TestRTMSpinLoopCount.SPIN_LOOP_COUNTS[i]);
+ }
+
+ for (int i = 1; i < aborts.length; i++) {
+ Asserts.assertLTE(aborts[i], aborts[i - 1], "Increased spin loop "
+ + "count should not increase retries count.");
+ }
+ }
+
+ private long getAbortsCountOnLockBusy(int spinLoopCount) throws Throwable {
+ CompilableTest test = new BusyLock();
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ test,
+ CommandLineOptionTest.prepareNumericFlag("RTMRetryCount",
+ TestRTMSpinLoopCount.RTM_RETRY_COUNT),
+ CommandLineOptionTest.prepareNumericFlag("RTMSpinLoopCount",
+ spinLoopCount),
+ "-XX:-UseRTMXendForLockBusy",
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ BusyLock.class.getName(),
+ Boolean.toString(TestRTMSpinLoopCount.INFLATE_MONITOR),
+ Integer.toString(TestRTMSpinLoopCount.LOCKING_TIME)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ test.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 1,
+ "VM output should contain exactly one entry for method "
+ + test.getMethodWithLockName());
+
+ RTMLockingStatistics lock = statistics.get(0);
+
+ Asserts.assertLTE(lock.getTotalAborts(),
+ TestRTMSpinLoopCount.MAX_ABORTS, String.format("Total aborts "
+ + "count (%d) should be less or equal to %d",
+ lock.getTotalAborts(),
+ TestRTMSpinLoopCount.MAX_ABORTS));
+
+ return lock.getTotalAborts();
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMSpinLoopCount().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,150 @@
+/*
+ * 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 8031320
+ * @summary Verify that RTMTotalCountIncrRate option affects
+ * RTM locking statistics.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestRTMTotalCountIncrRate
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestRTMTotalCountIncrRate
+ */
+
+import java.util.List;
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that with RTMTotalCountIncrRate=1 RTM locking statistics
+ * contains precise information abort attempted locks and that with other values
+ * statistics contains information abort non-zero locking attempts.
+ * Since assert done for RTMTotalCountIncrRate=1 is pretty strict, test uses
+ * -XX:RTMRetryCount=0 to avoid issue with retriable aborts. For more details on
+ * that issue see {@link TestUseRTMAfterLockInflation}.
+ */
+public class TestRTMTotalCountIncrRate extends CommandLineOptionTest {
+ private TestRTMTotalCountIncrRate() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ verifyLocksCount(1, false);
+ verifyLocksCount(64, false);
+ verifyLocksCount(128, false);
+ verifyLocksCount(1, true);
+ verifyLocksCount(64, true);
+ verifyLocksCount(128, true);
+ }
+
+ private void verifyLocksCount(int incrRate, boolean useStackLock)
+ throws Throwable{
+ CompilableTest test = new Test();
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ test,
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
+ useStackLock),
+ CommandLineOptionTest.prepareNumericFlag(
+ "RTMTotalCountIncrRate", incrRate),
+ "-XX:RTMRetryCount=0",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ Test.class.getName(),
+ Boolean.toString(!useStackLock)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ test.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 1, "VM output should contain "
+ + "exactly one RTM locking statistics entry for method "
+ + test.getMethodWithLockName());
+
+ RTMLockingStatistics lock = statistics.get(0);
+ if (incrRate == 1) {
+ Asserts.assertEQ(lock.getTotalLocks(), Test.TOTAL_ITERATIONS,
+ "Total locks should be exactly the same as amount of "
+ + "iterations.");
+ } else {
+ Asserts.assertGT(lock.getTotalLocks(), 0L, "RTM statistics "
+ + "should contain information for at least on lock.");
+ }
+ }
+
+ public static class Test implements CompilableTest {
+ private static final long TOTAL_ITERATIONS = 10000L;
+ private final Object monitor = new Object();
+ // Following field have to be static in order to avoid escape analysis.
+ @SuppressWarnings("UnsuedDeclaration")
+ private static int field = 0;
+
+ @Override
+ public String getMethodWithLockName() {
+ return this.getClass().getName() + "::lock";
+ }
+
+ @Override
+ public String[] getMethodsToCompileNames() {
+ return new String[] {
+ getMethodWithLockName()
+ };
+ }
+
+ public void lock() {
+ synchronized(monitor) {
+ Test.field++;
+ }
+ }
+
+ /**
+ * Usage:
+ * Test <inflate monitor>
+ */
+ public static void main(String args[]) throws Throwable {
+ Asserts.assertGTE(args.length, 1, "One argument required.");
+ Test test = new Test();
+
+ if (Boolean.valueOf(args[0])) {
+ AbortProvoker.inflateMonitor(test.monitor);
+ }
+ for (long i = 0L; i < Test.TOTAL_ITERATIONS; i++) {
+ test.lock();
+ }
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestRTMTotalCountIncrRate().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMAfterLockInflation.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,127 @@
+/*
+ * 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 8031320
+ * @summary Verify that rtm locking is used for stack locks before
+ * inflation and after it used for inflated locks.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMAfterLockInflation
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMAfterLockInflation
+ */
+
+import java.util.List;
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that RTM is used after lock inflation by executing compiled
+ * method with RTM-based lock elision using stack lock first, then that lock
+ * is inflated and the same compiled method invoked again.
+ *
+ * Compiled method invoked {@code AbortProvoker.DEFAULT_ITERATIONS} times before
+ * lock inflation and the same amount of times after inflation.
+ * As a result total locks count should be equal to
+ * {@code 2*AbortProvoker.DEFAULT_ITERATIONS}.
+ * It is a pretty strict assertion which could fail if some retriable abort
+ * happened: it could be {@code AbortType.RETRIABLE} or
+ * {@code AbortType.MEM_CONFLICT}, but unfortunately abort can has both these
+ * reasons simultaneously. In order to avoid false negative failures related
+ * to incorrect aborts counting, -XX:RTMRetryCount=0 is used.
+ */
+public class TestUseRTMAfterLockInflation extends CommandLineOptionTest {
+ private static final long EXPECTED_LOCKS
+ = 2L * AbortProvoker.DEFAULT_ITERATIONS;
+
+ private TestUseRTMAfterLockInflation() {
+ super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ AbortProvoker provoker = AbortType.XABORT.provoker();
+ long totalLocksCount = 0;
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ provoker,
+ "-XX:+UseRTMForStackLocks",
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:RTMRetryCount=0",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ Test.class.getName(),
+ AbortType.XABORT.toString());
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 2,
+ "VM output should contain two rtm locking statistics entries "
+ + "for method " + provoker.getMethodWithLockName());
+
+ for (RTMLockingStatistics s : statistics) {
+ totalLocksCount += s.getTotalLocks();
+ }
+
+ Asserts.assertEQ(totalLocksCount,
+ TestUseRTMAfterLockInflation.EXPECTED_LOCKS,
+ "Total lock count should be greater or equal to "
+ + TestUseRTMAfterLockInflation.EXPECTED_LOCKS);
+ }
+
+ public static class Test {
+
+ /**
+ * Usage:
+ * Test <provoker type>
+ */
+ public static void main(String args[]) throws Throwable {
+ Asserts.assertGT(args.length, 0,
+ "AbortType name is expected as first argument.");
+
+ AbortProvoker provoker
+ = AbortType.lookup(Integer.valueOf(args[0])).provoker();
+ for (int i = 0; i < AbortProvoker.DEFAULT_ITERATIONS; i++) {
+ provoker.forceAbort();
+ }
+ provoker.inflateMonitor();
+ for (int i = 0; i < AbortProvoker.DEFAULT_ITERATIONS; i++) {
+ provoker.forceAbort();
+ }
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMAfterLockInflation().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMDeopt.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,88 @@
+/*
+ * 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 8031320
+ * @summary Verify that UseRTMDeopt affects uncommon trap installation in
+ * copmpiled methods with synchronized block.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMDeopt
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMDeopt
+ */
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that usage of UseRTMDeopt option affects uncommon traps usage
+ * for methods that use locking.
+ */
+public class TestUseRTMDeopt extends CommandLineOptionTest {
+ private TestUseRTMDeopt() {
+ super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ verifyUseRTMDeopt(false);
+ verifyUseRTMDeopt(true);
+ }
+
+ private void verifyUseRTMDeopt(boolean useRTMDeopt) throws Throwable {
+ AbortProvoker provoker = AbortType.XABORT.provoker();
+ String logFileName = String.format("rtm_%s_deopt.xml",
+ useRTMDeopt ? "use" : "no");
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ logFileName,
+ provoker,
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMDeopt",
+ useRTMDeopt),
+ AbortProvoker.class.getName(),
+ AbortType.XABORT.toString()
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ int expectedUncommonTraps = useRTMDeopt ? 1 : 0;
+ int installedUncommonTraps
+ = RTMTestBase.installedRTMStateChangeTraps(logFileName);
+
+ Asserts.assertEQ(expectedUncommonTraps, installedUncommonTraps,
+ String.format("Expected to find %d uncommon traps "
+ + "installed with reason rtm_state_change.",
+ expectedUncommonTraps));
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMDeopt().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForInflatedLocks.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,92 @@
+/*
+ * 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 8031320
+ * @summary Verify that rtm locking is used for inflated locks.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMForInflatedLocks
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMForInflatedLocks
+ */
+
+import java.util.List;
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that RTM-based lock elision could be used for inflated locks
+ * by calling compiled method that use RTM-based lock elision and using
+ * manually inflated lock.
+ * Compiled method invoked {@code AbortProvoker.DEFAULT_ITERATIONS} times,
+ * so total locks count should be the same.
+ * This test could also be affected by retriable aborts, so -XX:RTMRetryCount=0
+ * is used. For more information abort that issue see
+ * {@link TestUseRTMAfterLockInflation}.
+ */
+public class TestUseRTMForInflatedLocks extends CommandLineOptionTest {
+ private TestUseRTMForInflatedLocks() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ AbortProvoker provoker = AbortType.XABORT.provoker();
+ RTMLockingStatistics lock;
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ provoker,
+ "-XX:-UseRTMForStackLocks",
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:RTMRetryCount=0",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ AbortProvoker.class.getName(),
+ AbortType.XABORT.toString());
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 1,
+ "VM output should contain exactly one rtm locking statistics "
+ + "entry for method " + provoker.getMethodWithLockName());
+
+ lock = statistics.get(0);
+ Asserts.assertEQ(lock.getTotalLocks(), AbortProvoker.DEFAULT_ITERATIONS,
+ "Total lock count should be greater or equal to "
+ + AbortProvoker.DEFAULT_ITERATIONS);
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMForInflatedLocks().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMForStackLocks.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,95 @@
+/*
+ * 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 8031320
+ * @summary Verify that rtm locking is used for stack locks.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMForStackLocks
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMForStackLocks
+ */
+
+import java.util.List;
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that RTM-based lock elision could be used for stack locks
+ * by calling compiled method that use RTM-based lock elision and using
+ * stack lock.
+ * Compiled method invoked {@code AbortProvoker.DEFAULT_ITERATIONS} times,
+ * so total locks count should be the same.
+ * This test could also be affected by retriable aborts, so -XX:RTMRetryCount=0
+ * is used. For more information abort that issue see
+ * {@link TestUseRTMAfterLockInflation}.
+ */
+public class TestUseRTMForStackLocks extends CommandLineOptionTest {
+ private static final boolean INFLATE_MONITOR = false;
+
+ private TestUseRTMForStackLocks() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ AbortProvoker provoker = AbortType.XABORT.provoker();
+ RTMLockingStatistics lock;
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ provoker,
+ "-XX:+UseRTMForStackLocks",
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:RTMRetryCount=0",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ AbortProvoker.class.getName(),
+ AbortType.XABORT.toString(),
+ Boolean.toString(TestUseRTMForStackLocks.INFLATE_MONITOR));
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 1,
+ "VM output should contain exactly one rtm locking statistics "
+ + "entry for method " + provoker.getMethodWithLockName());
+
+ lock = statistics.get(0);
+ Asserts.assertEQ(lock.getTotalLocks(), AbortProvoker.DEFAULT_ITERATIONS,
+ "Total locks count should be greater or equal to "
+ + AbortProvoker.DEFAULT_ITERATIONS);
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMForStackLocks().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/locking/TestUseRTMXendForLockBusy.java Tue Apr 29 14:40:07 2014 -0700
@@ -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 8031320
+ * @summary Verify that UseRTMXendForLockBusy option affects
+ * method behaviour if lock is busy.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMXendForLockBusy
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMXendForLockBusy
+ */
+
+import java.util.List;
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that with +UseRTMXendForLockBusy there will be no aborts
+ * forced by the test.
+ */
+public class TestUseRTMXendForLockBusy extends CommandLineOptionTest {
+ private final static int LOCKING_TIME = 5000;
+
+ private TestUseRTMXendForLockBusy() {
+ super(new AndPredicate(new SupportedVM(), new SupportedCPU()));
+ }
+
+ @Override
+ protected void runTestCases() throws Throwable {
+ // inflated lock, xabort on lock busy
+ verifyXendForLockBusy(true, false);
+ // inflated lock, xend on lock busy
+ verifyXendForLockBusy(true, true);
+ // stack lock, xabort on lock busy
+ verifyXendForLockBusy(false, false);
+ // stack lock, xend on lock busy
+ verifyXendForLockBusy(false, true);
+ }
+
+ private void verifyXendForLockBusy(boolean inflateMonitor,
+ boolean useXend) throws Throwable {
+ CompilableTest test = new BusyLock();
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ test,
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
+ inflateMonitor),
+ CommandLineOptionTest.prepareBooleanFlag(
+ "UseRTMXendForLockBusy",
+ useXend),
+ "-XX:RTMRetryCount=0",
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ BusyLock.class.getName(),
+ Boolean.toString(inflateMonitor),
+ Integer.toString(TestUseRTMXendForLockBusy.LOCKING_TIME)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ test.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 1, "VM output should contain "
+ + "exactly one rtm locking statistics entry for method "
+ + test.getMethodWithLockName());
+
+ long aborts = statistics.get(0).getAborts(AbortType.XABORT);
+
+ if (useXend) {
+ Asserts.assertEQ(aborts, 0L,
+ "Expected to get no aborts on busy lock");
+ } else {
+ Asserts.assertGT(aborts, 0L,
+ "Expected to get at least one abort on busy lock");
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMXendForLockBusy().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/method_options/TestNoRTMLockElidingOption.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,102 @@
+/*
+ * 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 8031320
+ * @summary Verify that NoRTMLockEliding option could be applied to
+ * specified method and that such method will not use rtm.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestNoRTMLockElidingOption
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestNoRTMLockElidingOption
+ */
+
+import java.util.List;
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that method tagged with option NoRTMLockElidingOption
+ * will not use RTM-based lock elision.
+ * Test invokes compiled method and checks that no deoptimization with
+ * rtm_state_change reason had happened and that that VM output
+ * does not contain RTM locking statistics for compiled method.
+ */
+public class TestNoRTMLockElidingOption extends CommandLineOptionTest {
+ private TestNoRTMLockElidingOption() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ public void runTestCases() throws Throwable {
+ verifyOption(false);
+ verifyOption(true);
+ }
+
+ public void verifyOption(boolean useStackLock) throws Throwable {
+ AbortProvoker provoker = AbortType.XABORT.provoker();
+ String logFileName = String.format("rtm_deopt_%s_stack_lock.xml",
+ (useStackLock ? "use" : "no"));
+ String methodOption = String.format("-XX:CompileCommand=option," +
+ "%s,NoRTMLockEliding", provoker.getMethodWithLockName());
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ logFileName,
+ provoker,
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
+ useStackLock),
+ methodOption,
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:+UseRTMDeopt",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ AbortProvoker.class.getName(),
+ AbortType.XABORT.toString(),
+ Boolean.toString(!useStackLock)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ int firedTraps = RTMTestBase.firedRTMStateChangeTraps(logFileName);
+
+ Asserts.assertEQ(firedTraps, 0,
+ "No deoptimizations with rtm_state_change reason are expected");
+
+ List statistics = RTMLockingStatistics.fromString(
+ provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 0,
+ "VM output should not contain RTM locking statistics entries "
+ + "for method " + provoker.getMethodWithLockName());
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestNoRTMLockElidingOption().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/method_options/TestUseRTMLockElidingOption.java Tue Apr 29 14:40:07 2014 -0700
@@ -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.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8031320
+ * @summary Verify that UseRTMLockEliding option could be applied to
+ * specified method and that such method will not be deoptimized
+ * on high abort ratio.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestUseRTMLockElidingOption
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestUseRTMLockElidingOption
+ */
+
+import java.util.List;
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that method tagged with option UseRTMLockElidingOption
+ * will use RTM-based lock elision, but will be never deoptimized with
+ * rtm_state_change reason.
+ * Test invokes compiled method and checks that no deoptimization with
+ * rtm_state_change reason had happened and that that VM output
+ * contains RTM locking statistics for compiled method and that total locks
+ * count equals to method's invocations.
+ * Since last assert is pretty strict, test uses -XX:RTMRetryCount=0 in order
+ * to avoid issue with retriable aborts described in
+ * {@link TestUseRTMAfterLockInflation}.
+ */
+public class TestUseRTMLockElidingOption extends CommandLineOptionTest {
+ private TestUseRTMLockElidingOption() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ public void runTestCases() throws Throwable {
+ verifyOption(false);
+ verifyOption(true);
+ }
+
+ public void verifyOption(boolean useStackLock) throws Throwable {
+ AbortProvoker provoker = AbortType.XABORT.provoker();
+ String logFileName = String.format("rtm_deopt_%s_stack_lock.xml",
+ (useStackLock ? "use" : "no"));
+ String methodOption = String.format("-XX:CompileCommand=option," +
+ "%s,UseRTMLockEliding", provoker.getMethodWithLockName());
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ logFileName,
+ provoker,
+ CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
+ useStackLock),
+ methodOption,
+ "-XX:RTMTotalCountIncrRate=1",
+ "-XX:RTMRetryCount=0",
+ "-XX:+UseRTMDeopt",
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ provoker.getClass().getName(),
+ AbortType.XABORT.toString(),
+ Boolean.toString(!useStackLock)
+ );
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ int firedTraps = RTMTestBase.firedRTMStateChangeTraps(logFileName);
+
+ Asserts.assertEQ(firedTraps, 0,
+ "Method deoptimization with rtm_state_change is unexpected");
+
+ List statistics = RTMLockingStatistics.fromString(
+ provoker.getMethodWithLockName(), outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 1,
+ "VM output should contain exactly one RTM locking "
+ + "statistics entry for method "
+ + provoker.getMethodWithLockName());
+
+ RTMLockingStatistics lock = statistics.get(0);
+
+ Asserts.assertEQ(lock.getTotalLocks(), AbortProvoker.DEFAULT_ITERATIONS,
+ "Expected to get total locks count equal to total amount of "
+ + "lock attempts.");
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestUseRTMLockElidingOption().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,142 @@
+/*
+ * 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 8031320
+ * @summary Verify that rtm locking statistics contain proper information
+ * on overall aborts and locks count and count of aborts of
+ * different types. Test also verify that VM output does not
+ * contain rtm locking statistics when it should not.
+ * @library /testlibrary /testlibrary/whitebox /compiler/testlibrary
+ * @build TestPrintPreciseRTMLockingStatistics
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
+ * -XX:+WhiteBoxAPI TestPrintPreciseRTMLockingStatistics
+ */
+
+import java.util.*;
+
+import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+import com.oracle.java.testlibrary.cli.predicate.AndPredicate;
+import rtm.*;
+import rtm.predicate.SupportedCPU;
+import rtm.predicate.SupportedVM;
+
+/**
+ * Test verifies that VM output does not contain RTM locking statistics when it
+ * should not (when PrintPreciseRTMLockingStatistics is off) and that with
+ * -XX:+PrintPreciseRTMLockingStatistics locking statistics contains sane
+ * total locks and aborts count as well as for specific abort types.
+ */
+public class TestPrintPreciseRTMLockingStatistics
+ extends CommandLineOptionTest {
+ private TestPrintPreciseRTMLockingStatistics() {
+ super(new AndPredicate(new SupportedCPU(), new SupportedVM()));
+ }
+
+ @Override
+ public void runTestCases() throws Throwable {
+ verifyNoStatistics();
+ verifyStatistics();
+ }
+
+ // verify that VM output does not contain
+ // rtm locking statistics
+ private void verifyNoStatistics() throws Throwable {
+ verifyNoStatistics(AbortType.XABORT);
+
+ verifyNoStatistics(AbortType.XABORT,
+ "-XX:-PrintPreciseRTMLockingStatistics");
+
+ verifyNoStatistics(AbortType.XABORT, "-XX:-UseRTMLocking",
+ "-XX:+PrintPreciseRTMLockingStatistics");
+ }
+
+ // verify that rtm locking statistics contain information
+ // about each type of aborts
+ private void verifyStatistics() throws Throwable {
+ verifyAbortsCount(AbortType.XABORT);
+ verifyAbortsCount(AbortType.MEM_CONFLICT);
+ verifyAbortsCount(AbortType.BUF_OVERFLOW);
+ verifyAbortsCount(AbortType.NESTED_ABORT);
+ }
+
+ private void verifyNoStatistics(AbortType abortProvokerType,
+ String... vmOpts) throws Throwable {
+ AbortProvoker provoker = abortProvokerType.provoker();
+ List finalVMOpts = new LinkedList<>();
+ Collections.addAll(finalVMOpts, vmOpts);
+ Collections.addAll(finalVMOpts, AbortProvoker.class.getName(),
+ abortProvokerType.toString());
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(provoker,
+ finalVMOpts.toArray(new String[finalVMOpts.size()]));
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ outputAnalyzer.getOutput());
+
+ Asserts.assertEQ(statistics.size(), 0, "VM output should not contain "
+ + "any RTM locking statistics");
+ }
+
+ private void verifyAbortsCount(AbortType abortType) throws Throwable {
+ AbortProvoker provoker = abortType.provoker();
+
+ OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
+ provoker,
+ "-XX:+PrintPreciseRTMLockingStatistics",
+ AbortProvoker.class.getName(),
+ abortType.toString());
+
+ outputAnalyzer.shouldHaveExitValue(0);
+
+ List statistics = RTMLockingStatistics.fromString(
+ provoker.getMethodWithLockName(),outputAnalyzer.getOutput());
+
+ Asserts.assertGT(statistics.size(), 0, "VM output should contain one "
+ + "rtm locking statistics entry for method "
+ + provoker.getMethodWithLockName());
+
+ RTMLockingStatistics lock = statistics.get(0);
+
+ Asserts.assertGT(lock.getTotalLocks(), 0L, "RTM locking statistics "
+ + "should contain non zero total locks count");
+
+ Asserts.assertGT(lock.getTotalAborts(), 0L,
+ "RTM locking statistics should contain non zero total aborts "
+ + "count");
+
+ Asserts.assertGT(lock.getAborts(abortType), 0L, String.format(
+ "RTM locking statistics should contain non zero aborts count "
+ + "for abort reason %s", abortType));
+ }
+
+ public static void main(String args[]) throws Throwable {
+ new TestPrintPreciseRTMLockingStatistics().test();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/AbortProvoker.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/AbortProvoker.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,172 @@
+/*
+ * 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 rtm;
+
+import java.util.Objects;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+import com.oracle.java.testlibrary.Asserts;
+import com.oracle.java.testlibrary.Utils;
+import sun.misc.Unsafe;
+
+/**
+ * Base class for different transactional execution abortion
+ * provokers aimed to force abort due to specified reason.
+ */
+public abstract class AbortProvoker implements CompilableTest {
+ public static final long DEFAULT_ITERATIONS = 10000L;
+ /**
+ * Inflates monitor associated with object {@code monitor}.
+ * Inflation is forced by entering the same monitor from
+ * two different threads.
+ *
+ * @param monitor monitor to be inflated.
+ * @return inflated monitor.
+ * @throws Exception if something went wrong.
+ */
+ public static Object inflateMonitor(Object monitor) throws Exception {
+ Unsafe unsafe = Utils.getUnsafe();
+ CyclicBarrier barrier = new CyclicBarrier(2);
+
+ Runnable inflatingRunnable = () -> {
+ unsafe.monitorEnter(monitor);
+ try {
+ barrier.await();
+ barrier.await();
+ } catch (InterruptedException | BrokenBarrierException e) {
+ throw new RuntimeException(
+ "Synchronization issue occurred.", e);
+ } finally {
+ unsafe.monitorExit(monitor);
+ }
+ };
+
+ Thread t = new Thread(inflatingRunnable);
+ t.start();
+ // Wait until thread t enters the monitor.
+ barrier.await();
+ // At this point monitor will be owned by thread t,
+ // so our attempt to enter the same monitor will force
+ // monitor inflation.
+ Asserts.assertFalse(unsafe.tryMonitorEnter(monitor),
+ "Not supposed to enter the monitor first");
+ barrier.await();
+ t.join();
+ return monitor;
+ }
+
+
+ /**
+ * Get instance of specified AbortProvoker, inflate associated monitor
+ * if needed and then invoke forceAbort method in a loop.
+ *
+ * Usage:
+ * AbortProvoker <AbortType name> [<inflate monitor>
+ * [<iterations> [ <delay>]]]
+ *
+ * Default parameters are:
+ *
+ * - inflate monitor = true
+ * - iterations = {@code AbortProvoker.DEFAULT_ITERATIONS}
+ * - delay = 0
+ *
+ */
+ public static void main(String args[]) throws Throwable {
+ Asserts.assertGT(args.length, 0, "At least one argument is required.");
+
+ AbortType abortType = AbortType.lookup(Integer.valueOf(args[0]));
+ boolean monitorShouldBeInflated = true;
+ long iterations = AbortProvoker.DEFAULT_ITERATIONS;
+
+ if (args.length > 1) {
+ monitorShouldBeInflated = Boolean.valueOf(args[1]);
+
+ if (args.length > 2) {
+ iterations = Long.valueOf(args[2]);
+
+ if (args.length > 3) {
+ Thread.sleep(Integer.valueOf(args[3]));
+ }
+ }
+ }
+
+ AbortProvoker provoker = abortType.provoker();
+
+ if (monitorShouldBeInflated) {
+ provoker.inflateMonitor();
+ }
+
+ for (long i = 0; i < iterations; i++) {
+ provoker.forceAbort();
+ }
+ }
+
+ protected final Object monitor;
+
+ protected AbortProvoker() {
+ this(new Object());
+ }
+
+ protected AbortProvoker(Object monitor) {
+ this.monitor = Objects.requireNonNull(monitor);
+ }
+
+ /**
+ * Inflates monitor used by this AbortProvoker instance.
+ * @throws Exception
+ */
+ public void inflateMonitor() throws Exception {
+ AbortProvoker.inflateMonitor(monitor);
+ }
+
+ /**
+ * Forces transactional execution abortion.
+ */
+ public abstract void forceAbort();
+
+ /**
+ * Returns names of all methods that have to be compiled
+ * in order to successfully force transactional execution
+ * abortion.
+ *
+ * @return array with methods' names that have to be compiled.
+ */
+ @Override
+ public String[] getMethodsToCompileNames() {
+ return new String[] { getMethodWithLockName() };
+ }
+
+ /**
+ * Returns name of the method that will contain monitor whose locking
+ * will be elided using transactional execution.
+ *
+ * @return name of the method that will contain elided lock.
+ */
+ @Override
+ public String getMethodWithLockName() {
+ return this.getClass().getName() + "::forceAbort";
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/AbortType.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/AbortType.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,103 @@
+/*
+ * 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 rtm;
+
+import com.oracle.java.testlibrary.Asserts;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Type of transactional execution abort.
+ * For more details on different abort types please see
+ * shared/vm/runtime/rtmLocking.hpp
+ */
+public enum AbortType {
+ XABORT(0),
+ RETRIABLE(1),
+ MEM_CONFLICT(2),
+ BUF_OVERFLOW(3),
+ DEBUG_BREAKPOINT(4),
+ NESTED_ABORT(5);
+
+ private final int type;
+ private static final Map LOOKUP_MAP = new HashMap<>();
+
+ static {
+ for (AbortType abortType : AbortType.values()) {
+ Asserts.assertFalse(LOOKUP_MAP.containsKey(abortType.type),
+ "Abort type values should be unique.");
+ LOOKUP_MAP.put(abortType.type, abortType);
+ }
+ }
+
+ private AbortType(int type) {
+ this.type = type;
+ }
+
+ /**
+ * Returns AbortProvoker for aborts represented by this abort type.
+ *
+ * @return an AbortProvoker instance
+ */
+ public AbortProvoker provoker() {
+ return AbortType.createNewProvoker(this);
+ }
+
+ public static AbortType lookup(int type) {
+ Asserts.assertLT(type, AbortType.values().length,
+ "Unknown abort type.");
+ return LOOKUP_MAP.get(type);
+ }
+
+ /**
+ * Returns transaction execution abort provoker for specified abortion type.
+ *
+ * @param type a type of abort which will be forced by returned
+ * AbortProvoker instance.
+ * @return AbortProvoker instance that will force abort of specified type
+ * @throws RuntimeException if there is no provoker for specified type
+ */
+ private static AbortProvoker createNewProvoker(AbortType type) {
+ switch (type) {
+ case XABORT:
+ return new XAbortProvoker();
+ case MEM_CONFLICT:
+ return new MemoryConflictProvoker();
+ case BUF_OVERFLOW:
+ return new BufferOverflowProvoker();
+ case NESTED_ABORT:
+ return new NestedAbortProvoker();
+ default:
+ throw new RuntimeException("No provoker exists for type "
+ + type.name());
+ }
+ }
+
+ @Override
+ public String toString() {
+ return Integer.toString(type);
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/BufferOverflowProvoker.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/BufferOverflowProvoker.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,48 @@
+/*
+ * 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 rtm;
+
+/**
+ * In order to provoke transactional execution abort due to
+ * internal's buffer overflow BufferOverflowProvoker modifies
+ * 1MB of BYTES during single transaction.
+ */
+class BufferOverflowProvoker extends AbortProvoker {
+ /**
+ * To force buffer overflow abort we modify memory region with
+ * size more then L1d cache size.
+ */
+ private static final int MORE_THAN_L1D_SIZE = 1024 * 1024;
+ private static final byte[] DATA = new byte[MORE_THAN_L1D_SIZE];
+
+ @Override
+ public void forceAbort() {
+ synchronized(monitor) {
+ for (int i = 0; i < BufferOverflowProvoker.DATA.length; i++) {
+ BufferOverflowProvoker.DATA[i]++;
+ }
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/BusyLock.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/BusyLock.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,136 @@
+/*
+ * 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 rtm;
+
+import com.oracle.java.testlibrary.Utils;
+import sun.misc.Unsafe;
+
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+/**
+ * Test case for busy lock scenario.
+ * One thread enters the monitor and sleep for a while.
+ * Another thread is blocked on the same monitor.
+ */
+public class BusyLock implements CompilableTest, Runnable {
+ private static final int DEFAULT_TIMEOUT = 1000;
+ private final CyclicBarrier barrier;
+
+ // Following field have to be static in order to avoid escape analysis.
+ @SuppressWarnings("UnsuedDeclaration")
+ private static int field = 0;
+ private static final Unsafe UNSAFE = Utils.getUnsafe();
+ protected final Object monitor;
+ protected final int timeout;
+
+ public BusyLock() {
+ this(BusyLock.DEFAULT_TIMEOUT);
+ }
+
+ public BusyLock(int timeout) {
+ this.timeout = timeout;
+ this.monitor = new Object();
+ this.barrier = new CyclicBarrier(2);
+ }
+
+ @Override
+ public void run() {
+ try {
+ // wait until forceAbort leave monitor
+ barrier.await();
+ if (UNSAFE.tryMonitorEnter(monitor)) {
+ try {
+ barrier.await();
+ Thread.sleep(timeout);
+ } finally {
+ UNSAFE.monitorExit(monitor);
+ }
+ } else {
+ throw new RuntimeException("Monitor should be entered by " +
+ "::run() first.");
+ }
+ } catch (InterruptedException | BrokenBarrierException e) {
+ throw new RuntimeException("Synchronization error happened.", e);
+ }
+ }
+
+ public void test() {
+ try {
+ barrier.await();
+ // wait until monitor is locked by a ::run method
+ barrier.await();
+ } catch (InterruptedException | BrokenBarrierException e) {
+ throw new RuntimeException("Synchronization error happened.", e);
+ }
+ synchronized(monitor) {
+ BusyLock.field++;
+ }
+ }
+
+ @Override
+ public String getMethodWithLockName() {
+ return this.getClass().getName() + "::test";
+ }
+
+ @Override
+ public String[] getMethodsToCompileNames() {
+ return new String[] { getMethodWithLockName() };
+ }
+
+ /**
+ * Usage:
+ * BusyLock [ <inflate monitor> [ <timeout> ] ]
+ *
+ * Default values are:
+ *
+ * - inflate monitor = {@code true}
+ * - timeout = {@code BusyLock.DEFAULT_TIMEOUT}
+ *
+ */
+ public static void main(String args[]) throws Exception {
+ int timeoutValue = BusyLock.DEFAULT_TIMEOUT;
+ boolean inflateMonitor = true;
+
+ if (args.length > 0 ) {
+ inflateMonitor = Boolean.valueOf(args[0]);
+
+ if (args.length > 1) {
+ timeoutValue = Integer.valueOf(args[1]);
+ }
+ }
+
+ BusyLock busyLock = new BusyLock(timeoutValue);
+
+ if (inflateMonitor) {
+ AbortProvoker.inflateMonitor(busyLock.monitor);
+ }
+
+ Thread t = new Thread(busyLock);
+ t.start();
+ busyLock.test();
+ t.join();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/CompilableTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/CompilableTest.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,41 @@
+/*
+ * 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 rtm;
+
+/**
+ * Interface for test scenarios that contain methods
+ * that should be compiled.
+ */
+public interface CompilableTest {
+ /**
+ * @return array with methods' names that should be compiled.
+ */
+ String[] getMethodsToCompileNames();
+
+ /**
+ * @return name of method with RTM-elided lock.
+ */
+ String getMethodWithLockName();
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/MemoryConflictProvoker.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/MemoryConflictProvoker.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,100 @@
+/*
+ * 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 rtm;
+
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+/**
+ * To force transactional execution abort due to memory conflict
+ * one thread should access memory region from transactional region
+ * while another thread should modify the same memory region.
+ * Since this scenario is based on the race condition between threads
+ * you should not expect some particular amount of aborts.
+ */
+class MemoryConflictProvoker extends AbortProvoker {
+ // Following field have to be static in order to avoid escape analysis.
+ @SuppressWarnings("UnsuedDeclaration")
+ private static int field = 0;
+ private static final int INNER_ITERATIONS = 10000;
+ private final CyclicBarrier barrier;
+ /**
+ * This thread will access and modify memory region
+ * from outside of the transaction.
+ */
+ private final Runnable conflictingThread;
+
+ public MemoryConflictProvoker() {
+ this(new Object());
+ }
+
+ public MemoryConflictProvoker(Object monitor) {
+ super(monitor);
+ barrier = new CyclicBarrier(2);
+ conflictingThread = () -> {
+ try {
+ barrier.await();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ for (int i = 0; i < MemoryConflictProvoker.INNER_ITERATIONS; i++) {
+ MemoryConflictProvoker.field++;
+ }
+ };
+ }
+
+ /**
+ * Accesses and modifies memory region from within the transaction.
+ */
+ public void transactionalRegion() {
+ try {
+ barrier.await();
+ } catch (InterruptedException | BrokenBarrierException e) {
+ throw new RuntimeException(e);
+ }
+ for (int i = 0; i < MemoryConflictProvoker.INNER_ITERATIONS; i++) {
+ synchronized(monitor) {
+ MemoryConflictProvoker.field--;
+ }
+ }
+ }
+
+ @Override
+ public void forceAbort() {
+ try {
+ Thread t = new Thread(conflictingThread);
+ t.start();
+ transactionalRegion();
+ t.join();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public String getMethodWithLockName() {
+ return this.getClass().getName() + "::transactionalRegion";
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/NestedAbortProvoker.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/NestedAbortProvoker.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,61 @@
+/*
+ * 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 rtm;
+
+import java.util.Arrays;
+
+/**
+ * In order to force nested transaction abort NestedAbortProvoker
+ * invoke BufferOverflowProvoker from transactional region.
+ */
+class NestedAbortProvoker extends AbortProvoker {
+ // Following field have to be static in order to avoid escape analysis.
+ @SuppressWarnings("UnsuedDeclaration")
+ private static int field = 0;
+ private final AbortProvoker nestedAbortProvoker;
+
+ public NestedAbortProvoker() {
+ this.nestedAbortProvoker = new XAbortProvoker(monitor);
+ }
+
+ @Override
+ public void forceAbort() {
+ synchronized(monitor) {
+ NestedAbortProvoker.field++;
+ nestedAbortProvoker.forceAbort();
+ NestedAbortProvoker.field--;
+ }
+ }
+
+ @Override
+ public String[] getMethodsToCompileNames() {
+ String nestedProvokerMethods[]
+ = nestedAbortProvoker.getMethodsToCompileNames();
+ String methods[] = Arrays.copyOf(nestedProvokerMethods,
+ nestedProvokerMethods.length + 1);
+ methods[methods.length - 1] = getMethodWithLockName();
+ return methods;
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/RTMLockingStatistics.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/RTMLockingStatistics.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,227 @@
+/*
+ * 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 rtm;
+
+import java.util.EnumMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+/**
+ * Wrapper for +UsePreciseRTMLockingStatistics output.
+ *
+ * Example of locking statistics:
+ *
+ * java/lang/ClassLoader.loadClass@7
+ * # rtm locks total (estimated): 0
+ * # rtm lock aborts : 13
+ * # rtm lock aborts 0: 12
+ * # rtm lock aborts 1: 0
+ * # rtm lock aborts 2: 0
+ * # rtm lock aborts 3: 0
+ * # rtm lock aborts 4: 0
+ * # rtm lock aborts 5: 0
+ */
+public class RTMLockingStatistics {
+ /**
+ * Pattern for aborts per abort type entries.
+ */
+ private static final Pattern ABORT_PATTERN;
+
+ /**
+ * Pattern for whole statistics.
+ */
+ private static final Pattern RTM_LOCKING_STATISTICS_PATTERN;
+
+ static {
+ String abortRe
+ = "# rtm lock aborts\\s+(?[0-9]+):\\s(?[0-9]+)";
+
+ ABORT_PATTERN = Pattern.compile(abortRe);
+ RTM_LOCKING_STATISTICS_PATTERN = Pattern.compile(
+ "(?[^.\n]+)\\." +
+ "(?[^@\n]+)@(?[0-9]+)\n" +
+ "# rtm locks total \\(estimated\\):\\s*" +
+ "(?[0-9]+)\n" +
+ "# rtm lock aborts\\s+:\\s*(?[0-9]+)\n" +
+ "(?(" + abortRe + "\n)+)");
+ }
+
+ private final long totalLocks;
+ private final long totalAborts;
+ private final String className;
+ private final String methodName;
+ private final int bci;
+ private final Map aborts = new EnumMap<>(AbortType.class);
+
+ /**
+ * Constructs RTMLockingStatistics from matcher captured statistics entry.
+ * @param matcher Matcher captured statistics entry.
+ */
+ private RTMLockingStatistics(Matcher matcher) {
+ className = matcher.group("className");
+ methodName = matcher.group("methodName");
+ bci = Integer.valueOf(matcher.group("bci"));
+ totalLocks = Long.valueOf(matcher.group("totalLocks"));
+ totalAborts = Long.valueOf(matcher.group("totalAborts"));
+
+ Matcher abortMatcher = ABORT_PATTERN.matcher(matcher.
+ group("abortStats"));
+
+ while (abortMatcher.find()) {
+ int type = Integer.valueOf(abortMatcher.group("type"));
+ long count = Long.valueOf(abortMatcher.group("count"));
+ setAborts(AbortType.lookup(type), count);
+ }
+ }
+
+
+ /**
+ * Parses string and return all founded RTM locking statistics entries.
+ *
+ * @param str the string to be parsed.
+ * @return list with all founded RTM locking statistics entries or
+ * empty list if nothing was found.
+ */
+ public static List fromString(String str) {
+ List statistics = new LinkedList<>();
+ Matcher matcher = RTM_LOCKING_STATISTICS_PATTERN.matcher(str);
+
+ while (matcher.find()) {
+ RTMLockingStatistics lock = new RTMLockingStatistics(matcher);
+ statistics.add(lock);
+ }
+
+ return statistics;
+ }
+
+ /**
+ * Parses string and return all founded RTM locking statistics entries
+ * for locks in method {@code methodName}.
+ *
+ * @param methodName a name of the method for locks from which statistics
+ * should be gathered.
+ * @param str the string to be parsed.
+ * @return list with all founded RTM locking statistics entries or
+ * empty list if nothing was found.
+ */
+ public static List fromString(String methodName,
+ String str) {
+ String formattedMethodName = formatMethodName(methodName);
+
+ List statisticsForMethod = new LinkedList<>();
+ for (RTMLockingStatistics statistics : fromString(str)) {
+ if (statistics.getLockName().startsWith(formattedMethodName)) {
+ statisticsForMethod.add(statistics);
+ }
+ }
+ return statisticsForMethod;
+ }
+
+ /**
+ * Formats method's name so it will have the same format as
+ * in rtm locking statistics.
+ *
+ *
+ * Example:
+ * com/example/Klass::method => com/example/Klass.method
+ * com/example/Klass.method => com/example/Klass.method
+ * com.example.Klass::method => com/example/Klass.method
+ * com.example.Klass.method => com/example/Klass.method
+ *
+ *
+ * @param methodName method's name that should be formatted.
+ * @return formatted method's name.
+ */
+ private static String formatMethodName(String methodName) {
+ String m[];
+ if (methodName.contains("::")) {
+ m = methodName.split("::");
+ } else {
+ int splitAt = methodName.lastIndexOf('.');
+ m = new String[2];
+ m[0] = methodName.substring(0, splitAt);
+ m[1] = methodName.substring(splitAt + 1);
+ }
+ return String.format("%s.%s", m[0].replaceAll("\\.", "/"), m[1]);
+ }
+
+ /**
+ * Returns name of lock for which this statistics was collected.
+ * Lock name has following format:
+ * <class name>.<method name>@<bci>
+ *
+ * @return name of lock.
+ */
+ public String getLockName() {
+ return String.format("%s.%s@%d", className, methodName, bci);
+ }
+
+ /**
+ * Returns aborts count for specified abort type.
+ *
+ * @param type an abort type.
+ * @return count of aborts.
+ */
+ public long getAborts(AbortType type) {
+ return aborts.getOrDefault(type, 0L);
+ }
+
+ /**
+ * Sets aborts count for specified abort type.
+ *
+ * @param type an abort type.
+ * @param count count of aborts.
+ */
+ public void setAborts(AbortType type, long count) {
+ aborts.put(type, count);
+ }
+
+ public long getTotalLocks() {
+ return totalLocks;
+ }
+
+ public long getTotalAborts() {
+ return totalAborts;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(getLockName()).append('\n');
+ builder.append(String.format("# rtm locks total (estimated): %d\n",
+ getTotalLocks()));
+ builder.append(String.format("# rtm lock aborts: %d\n",
+ getTotalLocks()));
+
+ for (AbortType type : AbortType.values()) {
+ builder.append(String.format("# rtm lock aborts %s %d\n",
+ type.toString(), getAborts(type)));
+ }
+ return builder.toString();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/RTMTestBase.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/RTMTestBase.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,279 @@
+/*
+ * 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 rtm;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+import com.oracle.java.testlibrary.Utils;
+import com.oracle.java.testlibrary.cli.CommandLineOptionTest;
+
+/**
+ * Auxiliary methods used for RTM testing.
+ */
+public class RTMTestBase {
+ private static final String RTM_STATE_CHANGE_REASON = "rtm_state_change";
+ /**
+ * We don't parse compilation log as XML-document and use regular
+ * expressions instead, because in some cases it could be
+ * malformed.
+ */
+ private static final String FIRED_UNCOMMON_TRAP_PATTERN_TEMPLATE
+ = "rtm_state_change
+ * installed during compilation.
+ *
+ * @param compilationLogFile a path to file with LogCompilation output.
+ * @return count of installed uncommon traps with reason
+ * rtm_state_change.
+ * @throws IOException
+ */
+ public static int installedRTMStateChangeTraps(String compilationLogFile)
+ throws IOException {
+ return RTMTestBase.installedUncommonTraps(compilationLogFile,
+ RTMTestBase.RTM_STATE_CHANGE_REASON);
+ }
+
+ /**
+ * Finds count of fired uncommon traps with reason {@code reason}.
+ *
+ * @param compilationLogFile a path to file with LogCompilation output.
+ * @param reason a reason of fired uncommon traps.
+ * @return count of fired uncommon traps with reason {@code reason}.
+ * @throws IOException
+ */
+ public static int firedUncommonTraps(String compilationLogFile,
+ String reason) throws IOException {
+ String pattern = String.format(
+ RTMTestBase.FIRED_UNCOMMON_TRAP_PATTERN_TEMPLATE,
+ reason);
+ return RTMTestBase.findTraps(compilationLogFile, pattern);
+ }
+
+ /**
+ * Finds count of fired uncommon traps with reason rtm_state_change.
+ *
+ * @param compilationLogFile a path to file with LogCompilation output.
+ * @return count of fired uncommon traps with reason
+ * rtm_state_change.
+ * @throws IOException
+ */
+ public static int firedRTMStateChangeTraps(String compilationLogFile)
+ throws IOException {
+ return RTMTestBase.firedUncommonTraps(compilationLogFile,
+ RTMTestBase.RTM_STATE_CHANGE_REASON);
+ }
+
+ /**
+ * Finds count of uncommon traps that matches regular
+ * expression in {@code re}.
+ *
+ * @param compilationLogFile a path to file with LogCompilation output.
+ * @param re regular expression to match uncommon traps.
+ * @throws IOException
+ */
+ private static int findTraps(String compilationLogFile, String re)
+ throws IOException {
+ String compilationLog = RTMTestBase.fileAsString(compilationLogFile);
+ Pattern pattern = Pattern.compile(re);
+ Matcher matcher = pattern.matcher(compilationLog);
+ int traps = 0;
+ while (matcher.find()) {
+ traps++;
+ }
+ return traps;
+ }
+
+ /**
+ * Returns file's content as a string.
+ *
+ * @param path a path to file to operate on.
+ * @return string with content of file.
+ * @throws IOException
+ */
+ private static String fileAsString(String path) throws IOException {
+ byte[] fileAsBytes = Files.readAllBytes(Paths.get(path));
+ return new String(fileAsBytes);
+ }
+
+ /**
+ * Prepares VM options for test execution.
+ * This method get test java options, filter out all RTM-related options,
+ * adds CompileCommand=compileonly,method_name options for each method
+ * from {@code methodToCompile} and finally appends all {@code vmOpts}.
+ *
+ * @param test test case whose methods that should be compiled.
+ * If {@code null} then no additional compileonly
+ * commands will be added to VM options.
+ * @param vmOpts additional options to pass to VM.
+ * @return Array with VM options.
+ */
+ private static String[] prepareTestOptions(CompilableTest test,
+ String... vmOpts) {
+ return RTMTestBase.prepareFilteredTestOptions(test, null, vmOpts);
+ }
+
+ /**
+ * Prepares VM options for test execution.
+ * This method get test java options, filter out all RTM-related options
+ * and all options that matches regexps in {@code additionalFilters},
+ * adds CompileCommand=compileonly,method_name options for each method
+ * from {@code methodToCompile} and finally appends all {@code vmOpts}.
+ *
+ * @param test test case whose methods that should be compiled.
+ * If {@code null} then no additional compileonly
+ * commands will be added to VM options.
+ * @param additionalFilters array with regular expression that will be
+ * used to filter out test java options.
+ * If {@code null} then no additional filters
+ * will be used.
+ * @param vmOpts additional options to pass to VM.
+ * @return array with VM options.
+ */
+ private static String[] prepareFilteredTestOptions(CompilableTest test,
+ String[] additionalFilters, String... vmOpts) {
+ List finalVMOpts = new LinkedList<>();
+ String[] filters;
+
+ if (additionalFilters != null) {
+ filters = Arrays.copyOf(additionalFilters,
+ additionalFilters.length + 1);
+ } else {
+ filters = new String[1];
+ }
+
+ filters[filters.length - 1] = "RTM";
+ String[] filteredVMOpts = Utils.getFilteredTestJavaOpts(filters);
+ Collections.addAll(finalVMOpts, filteredVMOpts);
+ Collections.addAll(finalVMOpts, "-Xcomp", "-server",
+ "-XX:-TieredCompilation", "-XX:+UseRTMLocking",
+ CommandLineOptionTest.UNLOCK_DIAGNOSTIC_VM_OPTIONS,
+ CommandLineOptionTest.UNLOCK_EXPERIMENTAL_VM_OPTIONS);
+
+ if (test != null) {
+ for (String method : test.getMethodsToCompileNames()) {
+ finalVMOpts.add("-XX:CompileCommand=compileonly," + method);
+ }
+ }
+ Collections.addAll(finalVMOpts, vmOpts);
+ return finalVMOpts.toArray(new String[finalVMOpts.size()]);
+ }
+
+ /**
+ * Adds additional options for VM required for successful execution of test.
+ *
+ * @param logFileName a name of compilation log file
+ * @param test a test case to execute
+ * @param options additional options to VM
+ * @return an array with VM options
+ */
+ private static String[] prepareTestOptions(String logFileName,
+ CompilableTest test, String... options) {
+ String[] preparedOptions = RTMTestBase.prepareFilteredTestOptions(
+ test,
+ new String[] {
+ "LogCompilation",
+ "LogFile"
+ });
+ List updatedOptions = new LinkedList<>();
+ Collections.addAll(updatedOptions, preparedOptions);
+ Collections.addAll(updatedOptions,
+ "-XX:+LogCompilation",
+ "-XX:LogFile=" + logFileName);
+ Collections.addAll(updatedOptions, options);
+
+ return updatedOptions.toArray(new String[updatedOptions.size()]);
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,62 @@
+/*
+ * 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 rtm;
+
+import com.oracle.java.testlibrary.Utils;
+import sun.misc.Unsafe;
+
+/**
+ * Current RTM locking implementation force transaction abort
+ * before native method call by explicit xabort(0) call.
+ */
+class XAbortProvoker extends AbortProvoker {
+ // Following field have to be static in order to avoid escape analysis.
+ @SuppressWarnings("UnsuedDeclaration")
+ private static int field = 0;
+ private static final Unsafe UNSAFE = Utils.getUnsafe();
+
+ public XAbortProvoker() {
+ this(new Object());
+ }
+
+ public XAbortProvoker(Object monitor) {
+ super(monitor);
+ }
+
+ @Override
+ public void forceAbort() {
+ synchronized(monitor) {
+ XAbortProvoker.field = UNSAFE.addressSize();
+ }
+ }
+
+ @Override
+ public String[] getMethodsToCompileNames() {
+ return new String[] {
+ getMethodWithLockName(),
+ Unsafe.class.getName() + "::addressSize"
+ };
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/predicate/SupportedCPU.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedCPU.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,36 @@
+/*
+ * 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 rtm.predicate;
+
+import sun.hotspot.cpuinfo.CPUInfo;
+
+import java.util.function.BooleanSupplier;
+
+public class SupportedCPU implements BooleanSupplier {
+ @Override
+ public boolean getAsBoolean() {
+ return CPUInfo.hasFeature("rtm");
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/testlibrary/rtm/predicate/SupportedVM.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/testlibrary/rtm/predicate/SupportedVM.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,36 @@
+/*
+ * 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 rtm.predicate;
+
+import com.oracle.java.testlibrary.Platform;
+
+import java.util.function.BooleanSupplier;
+
+public class SupportedVM implements BooleanSupplier {
+ @Override
+ public boolean getAsBoolean() {
+ return Platform.isServer() && !Platform.isEmbedded();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/CorrectnessTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/CorrectnessTest.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,159 @@
+/*
+ * 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 CorrectnessTest
+ * @bug 8038418
+ * @library /testlibrary /testlibrary/whitebox
+ * @compile execution/TypeConflict.java execution/TypeProfile.java
+ * execution/MethodHandleDelegate.java
+ * @build CorrectnessTest
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation
+ * -XX:CompileCommand=exclude,execution/*::methodNotToCompile
+ * -XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType
+ * CorrectnessTest RETURN
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation
+ * -XX:CompileCommand=exclude,execution/*::methodNotToCompile
+ * -XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType
+ * CorrectnessTest PARAMETERS
+ * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
+ * -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation
+ * -XX:CompileCommand=exclude,execution/*::methodNotToCompile
+ * -XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType
+ * CorrectnessTest ARGUMENTS
+ * @summary Tests correctness of type usage with type profiling and speculations
+ */
+
+import com.oracle.java.testlibrary.Asserts;
+import com.oracle.java.testlibrary.Platform;
+import execution.Execution;
+import execution.MethodHandleDelegate;
+import execution.TypeConflict;
+import execution.TypeProfile;
+import hierarchies.*;
+import scenarios.*;
+import sun.hotspot.WhiteBox;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.BiFunction;
+
+public class CorrectnessTest {
+ private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
+
+ public static void main(String[] args) {
+ if (!Platform.isServer()) {
+ System.out.println("ALL TESTS SKIPPED");
+ }
+ Asserts.assertGTE(args.length, 1);
+ ProfilingType profilingType = ProfilingType.valueOf(args[0]);
+ if (runTests(profilingType)) {
+ System.out.println("ALL TESTS PASSED");
+ } else {
+ throw new RuntimeException("SOME TESTS FAILED");
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static boolean runTests(ProfilingType profilingType) {
+ boolean result = true;
+
+ List executionList = new ArrayList<>();
+ executionList.add(new TypeConflict());
+ executionList.add(new TypeProfile());
+ for (int i = 0, n = executionList.size(); i < n; i++) {
+ executionList.add(new MethodHandleDelegate(executionList.get(i)));
+ }
+
+ List hierarchyList = new ArrayList<>();
+ hierarchyList.add(new DefaultMethodInterface.Hierarchy());
+ hierarchyList.add(new DefaultMethodInterface2.Hierarchy());
+ hierarchyList.add(new Linear.Hierarchy());
+ hierarchyList.add(new Linear2.Hierarchy());
+ hierarchyList.add(new OneRank.Hierarchy());
+ for (int i = 0, n = hierarchyList.size(); i < n; i++) {
+ hierarchyList.add(new NullableType(hierarchyList.get(i)));
+ }
+
+ List>> testCasesConstructors
+ = new ArrayList<>();
+ testCasesConstructors.add(ArrayCopy::new);
+ testCasesConstructors.add(ArrayReferenceStore::new);
+ testCasesConstructors.add(ClassIdentity::new);
+ testCasesConstructors.add(ClassInstanceOf::new);
+ testCasesConstructors.add(ClassIsInstance::new);
+ testCasesConstructors.add(ReceiverAtInvokes::new);
+ testCasesConstructors.add(CheckCast::new);
+
+ for (TypeHierarchy hierarchy : hierarchyList) {
+ for (BiFunction> constructor : testCasesConstructors) {
+ for (Execution execution : executionList) {
+ Scenario, ?> scenario = constructor.apply(profilingType, hierarchy);
+ if (scenario.isApplicable()) {
+ result &= executeTest(hierarchy, execution, scenario);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Executes test case
+ *
+ * @param hierarchy type hierarchy for the test
+ * @param execution execution scenario
+ * @param scenario test scenario executed with given Execution
+ */
+ private static boolean executeTest(TypeHierarchy hierarchy, Execution execution, Scenario, ?> scenario) {
+ boolean testCaseResult = false;
+ String testName = hierarchy.getClass().getName() + " :: " + scenario.getName() + " @ " + execution.getName();
+ clearAllMethodsState(scenario.getClass());
+ try {
+ execution.execute(scenario);
+ testCaseResult = true;
+ } catch (Exception e) {
+ System.err.println(testName + " failed with exception " + e);
+ e.printStackTrace();
+ }
+ System.out.println((testCaseResult ? "PASSED: " : "FAILED: ") + testName);
+ return testCaseResult;
+ }
+
+ private static void clearAllMethodsState(Class aClass) {
+ while (aClass != null) {
+ for (Method m : aClass.getDeclaredMethods()) {
+ WHITE_BOX.clearMethodState(m);
+ }
+ aClass = aClass.getSuperclass();
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/OffTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/OffTest.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,108 @@
+/*
+ * 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 CorrectnessTest
+ * @bug 8038418
+ * @library /testlibrary /testlibrary/whitebox
+ * @compile execution/TypeConflict.java execution/TypeProfile.java
+ * execution/MethodHandleDelegate.java
+ * @build CorrectnessTest
+ * @build OffTest
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/timeout=1200 OffTest
+ */
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.ProcessTools;
+import scenarios.ProfilingType;
+
+import java.util.Random;
+
+public class OffTest {
+ private static final String[] OPTIONS = {
+ "-Xbootclasspath/a:.",
+ "-XX:+IgnoreUnrecognizedVMOptions",
+ "-XX:+UnlockExperimentalVMOptions",
+ "-XX:+UnlockDiagnosticVMOptions",
+ "-XX:+WhiteBoxAPI",
+ "-XX:CompileCommand=exclude,execution/*::methodNotToCompile",
+ "-XX:CompileCommand=dontinline,scenarios/Scenario::collectReturnType",
+ "", // -XX:TypeProfileLevel=?
+ "", // -XX:?UseTypeSpeculation
+ CorrectnessTest.class.getName(),
+ "", // ProfilingType.name()
+ };
+
+ private static final String TYPE_PROFILE_LEVEL = "TypeProfileLevel";
+ private static final String USE_TYPE_SPECULATION = "UseTypeSpeculation";
+ private static final int TYPE_PROFILE_LEVEL_LENGTH = 3;
+ private static final int TYPE_PROFILE_LEVEL_BOUND = 3;
+ private static final int DEFAULT_COUNT = 10;
+ private static final int PROFILING_TYPE_INDEX = OPTIONS.length - 1;
+ private static final int TYPE_PROFILE_INDEX = OPTIONS.length - 4;
+ private static final int USE_TYPE_SPECULATION_INDEX = OPTIONS.length - 3;
+ private static final Random RNG;
+
+ static {
+ String str = System.getProperty("seed");
+ long seed = str != null ? Long.parseLong(str) : new Random().nextLong();
+ RNG = new Random(seed);
+ System.out.printf("-Dseed=%d%n", seed);
+ }
+
+ public static void main(String[] args) throws Exception {
+ int count = DEFAULT_COUNT;
+ if (args.length > 0) {
+ count = Integer.parseInt(args[0]) ;
+ }
+ for (int i = 0; i < count; ++i) {
+ runTest();
+ }
+ }
+
+ private static void runTest() throws Exception {
+ String useTypeSpeculation = "-XX:" + (RNG.nextBoolean() ? "+" : "-") + USE_TYPE_SPECULATION;
+ String typeProfileLevel = "-XX:" + TYPE_PROFILE_LEVEL + "=" + randomTypeProfileLevel();
+ ProfilingType type = randomProfileType();
+ OPTIONS[TYPE_PROFILE_INDEX] = typeProfileLevel;
+ OPTIONS[USE_TYPE_SPECULATION_INDEX] = useTypeSpeculation;
+ OPTIONS[PROFILING_TYPE_INDEX] = type.name();
+ ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(/* addTestVmOptions= */ true, OPTIONS);
+ OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start());
+ outputAnalyzer.shouldHaveExitValue(0);
+ }
+
+ private static ProfilingType randomProfileType() {
+ ProfilingType[] value = ProfilingType.values();
+ return value[RNG.nextInt(value.length)];
+ }
+
+ private static String randomTypeProfileLevel() {
+ StringBuilder stringBuilder = new StringBuilder();
+ for (int i = 0; i < TYPE_PROFILE_LEVEL_LENGTH; ++i) {
+ stringBuilder.append(RNG.nextInt(TYPE_PROFILE_LEVEL_BOUND));
+ }
+ return stringBuilder.toString();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/execution/Execution.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/execution/Execution.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,45 @@
+/*
+ * 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 execution;
+
+import hierarchies.TypeHierarchy;
+import scenarios.Scenario;
+
+/**
+ * Execution scenario represents test methods execution type.
+ * @param parameter type
+ * @param result Type
+ */
+public interface Execution {
+ /**
+ * Executes the test code of the given scenario
+ * See {@link scenarios.Scenario#run(T)}
+ *
+ * @param scenario test scenario
+ */
+ void execute(Scenario scenario);
+
+ default String getName() {
+ return this.getClass().getName();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/execution/MethodHandleDelegate.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/execution/MethodHandleDelegate.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,105 @@
+/*
+ * 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 execution;
+
+import hierarchies.TypeHierarchy;
+import scenarios.Scenario;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+/**
+ * Executes test scenario using {@link MethodHandle#invoke(Object...)}.
+ * Delegates execution to the given {@link Execution} by creating
+ * new test scenario, see {@link Scenario}
+ */
+public class MethodHandleDelegate implements Execution {
+ private final Execution delegate;
+
+ public MethodHandleDelegate(Execution delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void execute(Scenario scenario) {
+ delegate.execute(new MHScenario(scenario));
+ }
+
+ @Override
+ public String getName() {
+ return "MethodHandleDelegate # " + delegate.getName();
+ }
+
+ private static class MHScenario extends Scenario {
+ private final Scenario scenario;
+ private static final MethodHandle METHOD_HANDLE_RUN;
+
+ static {
+ MethodHandles.Lookup lookup = MethodHandles.lookup();
+ MethodType methodType = MethodType.methodType(Object.class, TypeHierarchy.I.class);
+
+ try {
+ METHOD_HANDLE_RUN = lookup.findVirtual(Scenario.class, "run", methodType);
+ } catch (NoSuchMethodException | IllegalAccessException e) {
+ System.err.println("Failed to get target method run() with " + e);
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Constructor
+ *
+ * @param scenario test scenario to be executed
+ */
+ private MHScenario(Scenario scenario) {
+ super("MethodHandle::" + scenario.getName(), scenario.profilingType, scenario.hierarchy);
+ this.scenario = scenario;
+ }
+
+ /**
+ * Runs {@link Scenario#run(T)} with {@link MethodHandle#invoke(Object...)}
+ *
+ * @param t subject of the test
+ * @return result of the underlying {@link Scenario#run(T)} invocation
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public R run(T t) {
+ try {
+ return (R) METHOD_HANDLE_RUN.invoke(scenario, t);
+ } catch (Throwable thr) {
+ System.err.println(scenario.getName()
+ + " failed to invoke target method run() with " + thr);
+ throw new RuntimeException("Invocation failed", thr);
+ }
+ }
+
+ @Override
+ public void check(R r, T t) {
+ scenario.check(r, t);
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/execution/TypeConflict.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/execution/TypeConflict.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,74 @@
+/*
+ * 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 execution;
+
+import hierarchies.TypeHierarchy;
+import scenarios.Scenario;
+
+/**
+ * Type profiling conflict execution scenario. The main goal is
+ * to make compiler profile and compile methods with different types.
+ * Scenario tests guards by passing conflicting types (incompatible
+ * for the profiled data).
+ */
+public class TypeConflict implements Execution {
+ /** Test methods execution number to make profile */
+ private final static int POLLUTION_THRESHOLD = 5000;
+ /** Test methods execution number to make it profiled and compiled*/
+ private final static int PROFILE_THRESHOLD = 20000;
+
+ @Override
+ public void execute(Scenario scenario) {
+ T base = scenario.getProfiled();
+ T incompatible = scenario.getConflict();
+
+ // pollute profile by passing different types
+ R baseResult = null;
+ R incResult = null;
+ for (int i = 0; i < POLLUTION_THRESHOLD; i++) {
+ baseResult = methodNotToCompile(scenario, base);
+ incResult = methodNotToCompile(scenario, incompatible);
+ }
+ scenario.check(baseResult, base);
+ scenario.check(incResult, incompatible);
+
+ // profile and compile
+ R result = null;
+ for (int i = 0; i < PROFILE_THRESHOLD; i++) {
+ result = methodNotToCompile(scenario, base);
+ }
+ scenario.check(result, base);
+
+ // pass another type to make guard work and recompile
+ for (int i = 0; i < PROFILE_THRESHOLD; i++) {
+ result = methodNotToCompile(scenario, incompatible);
+ }
+ scenario.check(result, incompatible);
+ }
+
+ private R methodNotToCompile(Scenario scenario, T t) {
+ return scenario.run(t);
+ }
+}
+
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/execution/TypeProfile.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/execution/TypeProfile.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,59 @@
+/*
+ * 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 execution;
+
+import hierarchies.TypeHierarchy;
+import scenarios.Scenario;
+
+/**
+ * Profile type execution scenario. Executes tester method
+ * in a loop without any manipulation with types or instances.
+ */
+public class TypeProfile implements Execution {
+ /** Number of test method execution to make it profiled and compiled */
+ private final static int PROFILE_THRESHOLD = 100000;
+
+ /**
+ * Makes scenario code be profiled and compiled
+ * @param scenario Test scenario
+ */
+ @Override
+ public void execute(Scenario scenario) {
+ R result = null;
+ T prof = scenario.getProfiled();
+ T confl = scenario.getConflict();
+
+ for (int i = 0; i < PROFILE_THRESHOLD; i++) {
+ result = methodNotToCompile(scenario, prof);
+ }
+ scenario.check(result, prof);
+
+ result = methodNotToCompile(scenario, confl);
+ scenario.check(result, confl);
+ }
+
+ protected R methodNotToCompile(Scenario scenario, T t) {
+ return scenario.run(t);
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/hierarchies/DefaultMethodInterface.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/hierarchies/DefaultMethodInterface.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,54 @@
+/*
+ * 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 hierarchies;
+
+public class DefaultMethodInterface {
+ private DefaultMethodInterface() {
+ }
+
+ public static class Hierarchy
+ extends TypeHierarchy {
+ public Hierarchy() {
+ super(new DefaultMethodInterface.A(), new DefaultMethodInterface.B(),
+ DefaultMethodInterface.A.class, DefaultMethodInterface.B.class);
+ }
+ }
+
+ public static interface I2 extends TypeHierarchy.I {
+ default int m() {
+ return TypeHierarchy.ANSWER;
+ }
+ }
+
+ public static class A implements I2 {
+ // use default method from I2
+ }
+
+ public static class B extends A {
+ @Override
+ public int m() {
+ return TypeHierarchy.YEAR;
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/hierarchies/DefaultMethodInterface2.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/hierarchies/DefaultMethodInterface2.java Tue Apr 29 14:40:07 2014 -0700
@@ -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.
+ */
+
+package hierarchies;
+
+public class DefaultMethodInterface2 {
+ private DefaultMethodInterface2() {
+ }
+
+ public static class Hierarchy
+ extends TypeHierarchy {
+ public Hierarchy() {
+ super(new TypeHierarchy.A(), new DefaultMethodInterface2.B(),
+ TypeHierarchy.A.class, DefaultMethodInterface2.B.class);
+ }
+ }
+
+ public static interface I2 extends TypeHierarchy.I {
+ default int m() {
+ return TypeHierarchy.ANSWER;
+ }
+ }
+
+ public static class B implements I2 {
+ // default method I2.m()
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/hierarchies/Linear.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/hierarchies/Linear.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,43 @@
+/*
+ * 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 hierarchies;
+
+public class Linear {
+ private Linear() {
+ }
+
+ public static class Hierarchy extends TypeHierarchy {
+ public Hierarchy() {
+ super(new TypeHierarchy.A(), new Linear.B(),
+ TypeHierarchy.A.class, Linear.B.class);
+ }
+ }
+
+ public static class B extends TypeHierarchy.A {
+ @Override
+ public int m() {
+ return TypeHierarchy.YEAR;
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/hierarchies/Linear2.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/hierarchies/Linear2.java Tue Apr 29 14:40:07 2014 -0700
@@ -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.
+ */
+
+package hierarchies;
+
+public class Linear2 {
+ private Linear2() {
+ }
+
+ public static class Hierarchy extends TypeHierarchy {
+ public Hierarchy() {
+ super(new A(), new Linear2.B(),
+ A.class, Linear2.B.class);
+ }
+ }
+
+ public static interface I2 {
+ int m();
+ }
+
+ public static class B extends TypeHierarchy.A implements Linear2.I2 {
+ @Override
+ public int m() {
+ return TypeHierarchy.YEAR;
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/hierarchies/NullableType.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/hierarchies/NullableType.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,33 @@
+/*
+ * 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 hierarchies;
+
+public class NullableType
+ extends TypeHierarchy {
+
+ public NullableType(TypeHierarchy delegate) {
+ super(delegate.getM(), null,
+ delegate.getClassM(), delegate.getClassN());
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/hierarchies/OneRank.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/hierarchies/OneRank.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,44 @@
+/*
+ * 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 hierarchies;
+
+public class OneRank {
+ private OneRank() {
+ }
+
+ public static class Hierarchy extends TypeHierarchy {
+ public Hierarchy() {
+ super(new TypeHierarchy.A(), new OneRank.B(),
+ TypeHierarchy.A.class, OneRank.B.class);
+ }
+ }
+
+ public static class B implements TypeHierarchy.I {
+ @Override
+ public int m() {
+ return TypeHierarchy.YEAR;
+ }
+ }
+
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/hierarchies/TypeHierarchy.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/hierarchies/TypeHierarchy.java Tue Apr 29 14:40:07 2014 -0700
@@ -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.
+ */
+
+package hierarchies;
+
+/**
+ * Type hierarchy contains classes the type profiling and speculation are tested with
+ */
+public abstract class TypeHierarchy {
+ // Magic numbers
+ public static final int ANSWER = 42;
+ public static final int TEMP = 451;
+ public static final int YEAR = 1984;
+
+ private final M m;
+ private final N n;
+ private final Class classM;
+ private final Class classN;
+
+ protected TypeHierarchy(M m, N n, Class classM, Class classN) {
+ this.m = m;
+ this.n = n;
+ this.classM = classM;
+ this.classN = classN;
+ }
+
+ public final M getM() {
+ return m;
+ }
+
+ public final N getN() {
+ return n;
+ }
+
+ public final Class getClassM() {
+ return classM;
+ }
+
+ public final Class getClassN() {
+ return classN;
+ }
+
+ public interface I {
+ int m();
+ }
+
+ public static class A implements I {
+ @Override
+ public int m() {
+ return TypeHierarchy.ANSWER;
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/scenarios/ArrayCopy.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/scenarios/ArrayCopy.java Tue Apr 29 14:40:07 2014 -0700
@@ -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.
+ *
+ * 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 scenarios;
+
+import hierarchies.TypeHierarchy;
+
+import java.util.Arrays;
+
+/**
+ * Tests System.arraycopy()
+ */
+public class ArrayCopy extends ArrayScenario {
+ public ArrayCopy(ProfilingType profilingType,
+ TypeHierarchy extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
+ super("ArrayCopy", profilingType, hierarchy);
+ }
+
+ /**
+ * @param obj is used to fill arrays
+ * @return the same obj
+ */
+ @Override
+ public TypeHierarchy.I run(TypeHierarchy.I obj) {
+ switch (profilingType) {
+ case RETURN:
+ TypeHierarchy.I t = collectReturnType(obj);
+ Arrays.fill(array, t);
+ System.arraycopy(array, 0, matrix[0], 0, array.length);
+ return array[0];
+ case ARGUMENTS:
+ field = obj;
+ Arrays.fill(array, field);
+ System.arraycopy(array, 0, matrix[0], 0, array.length);
+ return array[0];
+ case PARAMETERS:
+ Arrays.fill(array, obj);
+ System.arraycopy(array, 0, matrix[0], 0, array.length);
+ return array[0];
+ }
+ throw new RuntimeException("Should not reach here");
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/scenarios/ArrayReferenceStore.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/scenarios/ArrayReferenceStore.java Tue Apr 29 14:40:07 2014 -0700
@@ -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.
+ *
+ * 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 scenarios;
+
+import hierarchies.TypeHierarchy;
+
+import java.util.Arrays;
+
+/**
+ * Tests aastore bytecode
+ */
+public class ArrayReferenceStore extends ArrayScenario {
+ public ArrayReferenceStore(ProfilingType profilingType,
+ TypeHierarchy extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
+ super("ArrayReferenceStore", profilingType, hierarchy);
+ }
+
+ /**
+ * @param obj is used to fill arrays
+ * @return obj
+ */
+ @Override
+ public TypeHierarchy.I run(TypeHierarchy.I obj) {
+ switch (profilingType) {
+ case RETURN:
+ TypeHierarchy.I t = collectReturnType(obj);
+ Arrays.fill(array, t);
+ matrix[0] = array;
+ return matrix[0][0];
+ case ARGUMENTS:
+ field = obj;
+ Arrays.fill(array, field);
+ matrix[0] = array;
+ return matrix[0][0];
+ case PARAMETERS:
+ Arrays.fill(array, obj);
+ matrix[0] = array;
+ return matrix[0][0];
+ }
+ throw new RuntimeException("Should not reach here");
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/scenarios/ArrayScenario.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/scenarios/ArrayScenario.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,68 @@
+/*
+ * 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 scenarios;
+
+import com.oracle.java.testlibrary.Asserts;
+import hierarchies.TypeHierarchy;
+
+import java.lang.reflect.Array;
+import java.util.Arrays;
+
+/**
+ * Base class for array scenarios
+ */
+public abstract class ArrayScenario extends Scenario {
+ protected final TypeHierarchy.I[] array;
+ protected final TypeHierarchy.I[][] matrix;
+
+ protected ArrayScenario(String name, ProfilingType profilingType,
+ TypeHierarchy extends TypeHierarchy.I, ? extends TypeHierarchy.I> hierarchy) {
+ super(name, profilingType, hierarchy);
+ final int x = 20;
+ final int y = 10;
+
+ TypeHierarchy.I prof = hierarchy.getM();
+ TypeHierarchy.I confl = hierarchy.getN();
+
+ this.array = (TypeHierarchy.I[]) Array.newInstance(hierarchy.getClassM(), y);
+ Arrays.fill(array, prof);
+
+ this.matrix = (TypeHierarchy.I[][]) Array.newInstance(hierarchy.getClassM(), x, y);
+ for (int i = 0; i < x; i++) {
+ this.matrix[i] = this.array;
+ }
+
+ Asserts.assertEquals(array.length, matrix[0].length, "Invariant");
+ }
+
+ @Override
+ public boolean isApplicable() {
+ return hierarchy.getClassM().isAssignableFrom(hierarchy.getClassN());
+ }
+
+ @Override
+ public void check(TypeHierarchy.I res, TypeHierarchy.I orig) {
+ Asserts.assertEquals(res, orig, "Check failed");
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/scenarios/CheckCast.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/scenarios/CheckCast.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,77 @@
+/*
+ * 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 scenarios;
+
+import com.oracle.java.testlibrary.Asserts;
+import hierarchies.TypeHierarchy;
+
+import java.util.Objects;
+
+/**
+ * Checkcast scenario
+ * @param profiling parameter
+ */
+public class CheckCast extends Scenario {
+ public CheckCast(ProfilingType profilingType, TypeHierarchy extends T, ? extends T> hierarchy) {
+ super("CheckCast", profilingType, hierarchy);
+ }
+
+ /**
+ * Returns type profiling.
+ * @param obj is a profiled parameter for the test
+ * @return parameter casted to the type R
+ */
+ @Override
+ public Integer run(T obj) {
+ switch (profilingType) {
+ case RETURN:
+ T t = collectReturnType(obj);
+ if (t != null) {
+ return t.m();
+ }
+ return null;
+ case ARGUMENTS:
+ field = obj;
+ if (field != null) {
+ return field.m();
+ }
+ return null;
+ case PARAMETERS:
+ if (obj != null) {
+ return obj.m();
+ }
+ return null;
+ }
+ throw new RuntimeException("Should not reach here");
+ }
+
+ @Override
+ public void check(Integer result, T orig) {
+ if (result != null || orig != null) {
+ Objects.requireNonNull(result);
+ Objects.requireNonNull(orig);
+ Asserts.assertEquals(result, orig.m(), "Results mismatch");
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/scenarios/ClassIdentity.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/scenarios/ClassIdentity.java Tue Apr 29 14:40:07 2014 -0700
@@ -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.
+ */
+
+package scenarios;
+
+import com.oracle.java.testlibrary.Asserts;
+import hierarchies.TypeHierarchy;
+
+/**
+ * Tests pattern: if (a.getClass() == D.class)
+ */
+public class ClassIdentity extends Scenario {
+ public ClassIdentity(ProfilingType profilingType,
+ TypeHierarchy extends T, ? extends T> hierarchy) {
+ super("ClassIdentity", profilingType, hierarchy);
+ }
+
+ @Override
+ public boolean isApplicable() {
+ return hierarchy.getM() != null && hierarchy.getN() != null;
+ }
+
+ @Override
+ public Integer run(T obj) {
+ switch (profilingType) {
+ case RETURN:
+ T t = collectReturnType(obj);
+ if (t.getClass() == TypeHierarchy.A.class) {
+ return inlinee(t);
+ }
+ return TypeHierarchy.TEMP;
+ case ARGUMENTS:
+ field = obj;
+ if (field.getClass() == TypeHierarchy.A.class) {
+ return inlinee(field);
+ }
+ return TypeHierarchy.TEMP;
+ case PARAMETERS:
+ if (obj.getClass() == TypeHierarchy.A.class) {
+ return inlinee(obj);
+ }
+ return TypeHierarchy.TEMP;
+ }
+ throw new RuntimeException("Should not reach here");
+ }
+
+ public int inlinee(T obj) {
+ return obj.m();
+ }
+
+ @Override
+ public void check(Integer result, T orig) {
+ if (orig.getClass() == TypeHierarchy.A.class) {
+ Asserts.assertEquals(result, orig.m(),
+ "Results are not equal for TypeHierarchy.A.class");
+ } else {
+ Asserts.assertEquals(result, TypeHierarchy.TEMP, "Result differs from expected");
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/scenarios/ClassInstanceOf.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/scenarios/ClassInstanceOf.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,74 @@
+/*
+ * 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 scenarios;
+
+import com.oracle.java.testlibrary.Asserts;
+import hierarchies.TypeHierarchy;
+
+/**
+ * Tests instanceof
+ */
+public class ClassInstanceOf extends Scenario {
+ public ClassInstanceOf(ProfilingType profilingType,
+ TypeHierarchy extends T, ? extends T> hierarchy) {
+ super("ClassInstanceOf", profilingType, hierarchy);
+ }
+
+ @Override
+ public Integer run(T obj) {
+ switch (profilingType) {
+ case RETURN:
+ T t = collectReturnType(obj);
+ if (t instanceof TypeHierarchy.A) {
+ return inlinee(t);
+ }
+ return TypeHierarchy.TEMP;
+ case ARGUMENTS:
+ field = obj;
+ if (field instanceof TypeHierarchy.A) {
+ return inlinee(field);
+ }
+ return TypeHierarchy.TEMP;
+ case PARAMETERS:
+ if (obj instanceof TypeHierarchy.A) {
+ return inlinee(obj);
+ }
+ return TypeHierarchy.TEMP;
+ }
+ throw new RuntimeException("Should not reach here");
+ }
+
+ public int inlinee(T obj) {
+ return obj.m();
+ }
+
+ @Override
+ public void check(Integer result, T orig) {
+ if (orig instanceof TypeHierarchy.A) {
+ Asserts.assertEquals(result, orig.m(), "Results are not equal for TypeHierarchy.A");
+ } else {
+ Asserts.assertEquals(result, TypeHierarchy.TEMP, "Result differs from expected");
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/scenarios/ClassIsInstance.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/scenarios/ClassIsInstance.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,77 @@
+/*
+ * 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 scenarios;
+
+import com.oracle.java.testlibrary.Asserts;
+import hierarchies.TypeHierarchy;
+
+/**
+ * Tests {@link Class#isInstance(Object)}
+ */
+public class ClassIsInstance extends Scenario {
+ private final Class> baseClass;
+
+ public ClassIsInstance(ProfilingType profilingType,
+ TypeHierarchy extends T, ? extends T> hierarchy) {
+ super("ClassIsInstance", profilingType, hierarchy);
+ this.baseClass = hierarchy.getClassM();
+ }
+
+ @Override
+ public Integer run(T obj) {
+ switch (profilingType) {
+ case RETURN:
+ T t = collectReturnType(obj);
+ if (baseClass.isInstance(t)) {
+ return inlinee(t);
+ }
+ return TypeHierarchy.TEMP;
+ case ARGUMENTS:
+ field = obj;
+ if (baseClass.isInstance(field)) {
+ return inlinee(field);
+ }
+ return TypeHierarchy.TEMP;
+ case PARAMETERS:
+ if (baseClass.isInstance(obj)) {
+ return inlinee(obj);
+ }
+ return TypeHierarchy.TEMP;
+ }
+ throw new RuntimeException("Should not reach here");
+ }
+
+ public int inlinee(T obj) {
+ return obj.m();
+ }
+
+ @Override
+ public void check(Integer result, T orig) {
+ if (baseClass.isInstance(orig)) {
+ Asserts.assertEquals(result, orig.m(), "Results are not equal for base class");
+ } else {
+ Asserts.assertEquals(result, TypeHierarchy.TEMP, "Result differs from expected");
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/scenarios/ProfilingType.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/scenarios/ProfilingType.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,33 @@
+/*
+ * 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 scenarios;
+
+public enum ProfilingType {
+ /** type profiling of return values of reference types from an invoke */
+ RETURN,
+ /** type profiling for reference parameters on method entries */
+ PARAMETERS,
+ /** type profiling for reference arguments at an invoke */
+ ARGUMENTS,
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/scenarios/ReceiverAtInvokes.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/scenarios/ReceiverAtInvokes.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,74 @@
+/*
+ * 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 scenarios;
+
+import com.oracle.java.testlibrary.Asserts;
+import hierarchies.TypeHierarchy;
+
+/**
+ * Receiver at invokes profiling and speculation
+ *
+ * @param parameter to be returned
+ */
+public class ReceiverAtInvokes extends Scenario {
+ public ReceiverAtInvokes(ProfilingType profilingType,
+ TypeHierarchy extends T, ? extends T> hierarchy) {
+ super("ReceiverAtInvokes", profilingType, hierarchy);
+ }
+
+ @Override
+ public boolean isApplicable() {
+ return hierarchy.getM() != null && hierarchy.getN() != null;
+ }
+
+ /**
+ * Receiver profiling
+ *
+ * @param obj is a profiled parameter for the test
+ * @return parameter casted to the type R
+ */
+ @Override
+ public Integer run(T obj) {
+ switch (profilingType) {
+ case RETURN:
+ T t = collectReturnType(obj);
+ return inlinee(t);
+ case ARGUMENTS:
+ field = obj;
+ return inlinee(field);
+ case PARAMETERS:
+ return inlinee(obj);
+ }
+ throw new RuntimeException("Should not reach here");
+ }
+
+ private Integer inlinee(T obj) {
+ return obj.m(); // should be inlined
+ }
+
+ @Override
+ public void check(Integer result, T orig) {
+ Asserts.assertEquals(result, orig.m(), "Results mismatch");
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/types/correctness/scenarios/Scenario.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/types/correctness/scenarios/Scenario.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,108 @@
+/*
+ * 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 scenarios;
+
+import hierarchies.TypeHierarchy;
+
+/**
+ * Test scenario
+ *
+ * @param parameter type
+ * @param result type
+ */
+public abstract class Scenario {
+
+ private final String name;
+ public final ProfilingType profilingType;
+ public final TypeHierarchy extends T, ? extends T> hierarchy;
+ protected volatile T field;
+
+ /**
+ * Constructor
+ *
+ * @param name scenario name
+ * @param profilingType tested profiling type
+ * @param hierarchy type hierarchy
+ */
+ protected Scenario(String name, ProfilingType profilingType,
+ TypeHierarchy extends T, ? extends T> hierarchy) {
+ this.profilingType = profilingType;
+ this.name = name + " # " + profilingType.name();
+ this.hierarchy = hierarchy;
+ }
+
+ /**
+ * Returns the object which should be used as a parameter
+ * for the methods used for profile data
+ *
+ * @return profiled type object
+ */
+ public T getProfiled() {
+ return hierarchy.getM();
+ }
+
+ /**
+ * Returns the object which makes a conflict for a profiled data
+ * when passed instead of {@linkplain Scenario#getProfiled}
+ *
+ * @return incompatible to profiled object
+ */
+ public T getConflict() {
+ return hierarchy.getN();
+ }
+
+ /**
+ * @return scenario name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /** Is this scenario applicable for a hierarchy it was constructed with */
+ public boolean isApplicable() {
+ return true;
+ }
+
+ /**
+ * Runs test scenario
+ *
+ * @param t subject of the test
+ * @return result of the test invocation
+ */
+ public abstract R run(T t);
+
+ /** Used for a return type profiling */
+ protected final T collectReturnType(T t) {
+ return t;
+ }
+
+ /**
+ * Checks the result for R and T
+ *
+ * @param r result
+ * @param t original
+ * @throws java.lang.RuntimeException on result mismatch
+ */
+ public abstract void check(R r, T t);
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/compiler/uncommontrap/TestStackBangMonitorOwned.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/uncommontrap/TestStackBangMonitorOwned.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8032410
+ * @summary Stack overflow at deoptimization doesn't release owned monitors
+ * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestStackBangMonitorOwned::m1 -XX:CompileCommand=exclude,TestStackBangMonitorOwned::m2 -Xss256K -XX:-UseOnStackReplacement TestStackBangMonitorOwned
+ *
+ */
+public class TestStackBangMonitorOwned {
+
+ static class UnloadedClass1 {
+ volatile int field;
+ }
+
+ static Object m1(boolean deopt) {
+ long l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12,
+ l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24,
+ l25, l26, l27, l28, l29, l30, l31, l32, l33, l34, l35, l36,
+ l37, l38, l39, l40, l41, l42, l43, l44, l45, l46, l47, l48,
+ l49, l50, l51, l52, l53, l54, l55, l56, l57, l58, l59, l60,
+ l61, l62, l63, l64, l65, l66, l67, l68, l69, l70, l71, l72,
+ l73, l74, l75, l76, l77, l78, l79, l80, l81, l82, l83, l84,
+ l85, l86, l87, l88, l89, l90, l91, l92, l93, l94, l95, l96,
+ l97, l98, l99, l100, l101, l102, l103, l104, l105, l106, l107,
+ l108, l109, l110, l111, l112, l113, l114, l115, l116, l117,
+ l118, l119, l120, l121, l122, l123, l124, l125, l126, l127,
+ l128, l129, l130, l131, l132, l133, l134, l135, l136, l137,
+ l138, l139, l140, l141, l142, l143, l144, l145, l146, l147,
+ l148, l149, l150, l151, l152, l153, l154, l155, l156, l157,
+ l158, l159, l160, l161, l162, l163, l164, l165, l166, l167,
+ l168, l169, l170, l171, l172, l173, l174, l175, l176, l177,
+ l178, l179, l180, l181, l182, l183, l184, l185, l186, l187,
+ l188, l189, l190, l191, l192, l193, l194, l195, l196, l197,
+ l198, l199, l200, l201, l202, l203, l204, l205, l206, l207,
+ l208, l209, l210, l211, l212, l213, l214, l215, l216, l217,
+ l218, l219, l220, l221, l222, l223, l224, l225, l226, l227,
+ l228, l229, l230, l231, l232, l233, l234, l235, l236, l237,
+ l238, l239, l240, l241, l242, l243, l244, l245, l246, l247,
+ l248, l249, l250, l251, l252, l253, l254, l255, l256, l257,
+ l258, l259, l260, l261, l262, l263, l264, l265, l266, l267,
+ l268, l269, l270, l271, l272, l273, l274, l275, l276, l277,
+ l278, l279, l280, l281, l282, l283, l284, l285, l286, l287,
+ l288, l289, l290, l291, l292, l293, l294, l295, l296, l297,
+ l298, l299, l300, l301, l302, l303, l304, l305, l306, l307,
+ l308, l309, l310, l311, l312, l313, l314, l315, l316, l317,
+ l318, l319, l320, l321, l322, l323, l324, l325, l326, l327,
+ l328, l329, l330, l331, l332, l333, l334, l335, l336, l337,
+ l338, l339, l340, l341, l342, l343, l344, l345, l346, l347,
+ l348, l349, l350, l351, l352, l353, l354, l355, l356, l357,
+ l358, l359, l360, l361, l362, l363, l364, l365, l366, l367,
+ l368, l369, l370, l371, l372, l373, l374, l375, l376, l377,
+ l378, l379, l380, l381, l382, l383, l384, l385, l386, l387,
+ l388, l389, l390, l391, l392, l393, l394, l395, l396, l397,
+ l398, l399, l400, l401, l402, l403, l404, l405, l406, l407,
+ l408, l409, l410, l411, l412, l413, l414, l415, l416, l417,
+ l418, l419, l420, l421, l422, l423, l424, l425, l426, l427,
+ l428, l429, l430, l431, l432, l433, l434, l435, l436, l437,
+ l438, l439, l440, l441, l442, l443, l444, l445, l446, l447,
+ l448, l449, l450, l451, l452, l453, l454, l455, l456, l457,
+ l458, l459, l460, l461, l462, l463, l464, l465, l466, l467,
+ l468, l469, l470, l471, l472, l473, l474, l475, l476, l477,
+ l478, l479, l480, l481, l482, l483, l484, l485, l486, l487,
+ l488, l489, l490, l491, l492, l493, l494, l495, l496, l497,
+ l498, l499, l500, l501, l502, l503, l504, l505, l506, l507,
+ l508, l509, l510, l511;
+
+ long ll0, ll1, ll2, ll3, ll4, ll5, ll6, ll7, ll8, ll9, ll10, ll11, ll12,
+ ll13, ll14, ll15, ll16, ll17, ll18, ll19, ll20, ll21, ll22, ll23, ll24,
+ ll25, ll26, ll27, ll28, ll29, ll30, ll31, ll32, ll33, ll34, ll35, ll36,
+ ll37, ll38, ll39, ll40, ll41, ll42, ll43, ll44, ll45, ll46, ll47, ll48,
+ ll49, ll50, ll51, ll52, ll53, ll54, ll55, ll56, ll57, ll58, ll59, ll60,
+ ll61, ll62, ll63, ll64, ll65, ll66, ll67, ll68, ll69, ll70, ll71, ll72,
+ ll73, ll74, ll75, ll76, ll77, ll78, ll79, ll80, ll81, ll82, ll83, ll84,
+ ll85, ll86, ll87, ll88, ll89, ll90, ll91, ll92, ll93, ll94, ll95, ll96,
+ ll97, ll98, ll99, ll100, ll101, ll102, ll103, ll104, ll105, ll106, ll107,
+ ll108, ll109, ll110, ll111, ll112, ll113, ll114, ll115, ll116, ll117,
+ ll118, ll119, ll120, ll121, ll122, ll123, ll124, ll125, ll126, ll127,
+ ll128, ll129, ll130, ll131, ll132, ll133, ll134, ll135, ll136, ll137,
+ ll138, ll139, ll140, ll141, ll142, ll143, ll144, ll145, ll146, ll147,
+ ll148, ll149, ll150, ll151, ll152, ll153, ll154, ll155, ll156, ll157,
+ ll158, ll159, ll160, ll161, ll162, ll163, ll164, ll165, ll166, ll167,
+ ll168, ll169, ll170, ll171, ll172, ll173, ll174, ll175, ll176, ll177,
+ ll178, ll179, ll180, ll181, ll182, ll183, ll184, ll185, ll186, ll187,
+ ll188, ll189, ll190, ll191, ll192, ll193, ll194, ll195, ll196, ll197,
+ ll198, ll199, ll200, ll201, ll202, ll203, ll204, ll205, ll206, ll207,
+ ll208, ll209, ll210, ll211, ll212, ll213, ll214, ll215, ll216, ll217,
+ ll218, ll219, ll220, ll221, ll222, ll223, ll224, ll225, ll226, ll227,
+ ll228, ll229, ll230, ll231, ll232, ll233, ll234, ll235, ll236, ll237,
+ ll238, ll239, ll240, ll241, ll242, ll243, ll244, ll245, ll246, ll247,
+ ll248, ll249, ll250, ll251, ll252, ll253, ll254, ll255, ll256, ll257,
+ ll258, ll259, ll260, ll261, ll262, ll263, ll264, ll265, ll266, ll267,
+ ll268, ll269, ll270, ll271, ll272, ll273, ll274, ll275, ll276, ll277,
+ ll278, ll279, ll280, ll281, ll282, ll283, ll284, ll285, ll286, ll287,
+ ll288, ll289, ll290, ll291, ll292, ll293, ll294, ll295, ll296, ll297,
+ ll298, ll299, ll300, ll301, ll302, ll303, ll304, ll305, ll306, ll307,
+ ll308, ll309, ll310, ll311, ll312, ll313, ll314, ll315, ll316, ll317,
+ ll318, ll319, ll320, ll321, ll322, ll323, ll324, ll325, ll326, ll327,
+ ll328, ll329, ll330, ll331, ll332, ll333, ll334, ll335, ll336, ll337,
+ ll338, ll339, ll340, ll341, ll342, ll343, ll344, ll345, ll346, ll347,
+ ll348, ll349, ll350, ll351, ll352, ll353, ll354, ll355, ll356, ll357,
+ ll358, ll359, ll360, ll361, ll362, ll363, ll364, ll365, ll366, ll367,
+ ll368, ll369, ll370, ll371, ll372, ll373, ll374, ll375, ll376, ll377,
+ ll378, ll379, ll380, ll381, ll382, ll383, ll384, ll385, ll386, ll387,
+ ll388, ll389, ll390, ll391, ll392, ll393, ll394, ll395, ll396, ll397,
+ ll398, ll399, ll400, ll401, ll402, ll403, ll404, ll405, ll406, ll407,
+ ll408, ll409, ll410, ll411, ll412, ll413, ll414, ll415, ll416, ll417,
+ ll418, ll419, ll420, ll421, ll422, ll423, ll424, ll425, ll426, ll427,
+ ll428, ll429, ll430, ll431, ll432, ll433, ll434, ll435, ll436, ll437,
+ ll438, ll439, ll440, ll441, ll442, ll443, ll444, ll445, ll446, ll447,
+ ll448, ll449, ll450, ll451, ll452, ll453, ll454, ll455, ll456, ll457,
+ ll458, ll459, ll460, ll461, ll462, ll463, ll464, ll465, ll466, ll467,
+ ll468, ll469, ll470, ll471, ll472, ll473, ll474, ll475, ll476, ll477,
+ ll478, ll479, ll480, ll481, ll482, ll483, ll484, ll485, ll486, ll487,
+ ll488, ll489, ll490, ll491, ll492, ll493, ll494, ll495, ll496, ll497,
+ ll498, ll499, ll500, ll501, ll502, ll503, ll504, ll505, ll506, ll507,
+ ll508, ll509, ll510, ll511;
+
+ if (deopt) {
+ method_entered = true;
+ synchronized(monitor) {
+ do_monitor_acquire = true;
+ UnloadedClass1 res = new UnloadedClass1(); // forces deopt with c2
+ res.field = 0; //forced deopt with c1
+ return res;
+ }
+ }
+ return null;
+ }
+
+ static boolean m2(boolean deopt) {
+ long l0, l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12,
+ l13, l14, l15, l16, l17, l18, l19, l20, l21, l22, l23, l24,
+ l25, l26, l27, l28, l29, l30, l31, l32, l33, l34, l35, l36,
+ l37, l38, l39, l40, l41, l42, l43, l44, l45, l46, l47, l48,
+ l49, l50, l51, l52, l53, l54, l55, l56, l57, l58, l59, l60,
+ l61, l62, l63, l64, l65, l66, l67, l68, l69, l70, l71, l72,
+ l73, l74, l75, l76, l77, l78, l79, l80, l81, l82, l83, l84,
+ l85, l86, l87, l88, l89, l90, l91, l92, l93, l94, l95, l96,
+ l97, l98, l99, l100, l101, l102, l103, l104, l105, l106, l107,
+ l108, l109, l110, l111, l112, l113, l114, l115, l116, l117,
+ l118, l119, l120, l121, l122, l123, l124, l125, l126, l127,
+ l128, l129, l130, l131, l132, l133, l134, l135, l136, l137,
+ l138, l139, l140, l141, l142, l143, l144, l145, l146, l147,
+ l148, l149, l150, l151, l152, l153, l154, l155, l156, l157,
+ l158, l159, l160, l161, l162, l163, l164, l165, l166, l167,
+ l168, l169, l170, l171, l172, l173, l174, l175, l176, l177,
+ l178, l179, l180, l181, l182, l183, l184, l185, l186, l187,
+ l188, l189, l190, l191, l192, l193, l194, l195, l196, l197,
+ l198, l199, l200, l201, l202, l203, l204, l205, l206, l207,
+ l208, l209, l210, l211, l212, l213, l214, l215, l216, l217,
+ l218, l219, l220, l221, l222, l223, l224, l225, l226, l227,
+ l228, l229, l230, l231, l232, l233, l234, l235, l236, l237,
+ l238, l239, l240, l241, l242, l243, l244, l245, l246, l247,
+ l248, l249, l250, l251, l252, l253, l254, l255, l256, l257,
+ l258, l259, l260, l261, l262, l263, l264, l265, l266, l267,
+ l268, l269, l270, l271, l272, l273, l274, l275, l276, l277,
+ l278, l279, l280, l281, l282, l283, l284, l285, l286, l287,
+ l288, l289, l290, l291, l292, l293, l294, l295, l296, l297,
+ l298, l299, l300, l301, l302, l303, l304, l305, l306, l307,
+ l308, l309, l310, l311, l312, l313, l314, l315, l316, l317,
+ l318, l319, l320, l321, l322, l323, l324, l325, l326, l327,
+ l328, l329, l330, l331, l332, l333, l334, l335, l336, l337,
+ l338, l339, l340, l341, l342, l343, l344, l345, l346, l347,
+ l348, l349, l350, l351, l352, l353, l354, l355, l356, l357,
+ l358, l359, l360, l361, l362, l363, l364, l365, l366, l367,
+ l368, l369, l370, l371, l372, l373, l374, l375, l376, l377,
+ l378, l379, l380, l381, l382, l383, l384, l385, l386, l387,
+ l388, l389, l390, l391, l392, l393, l394, l395, l396, l397,
+ l398, l399, l400, l401, l402, l403, l404, l405, l406, l407,
+ l408, l409, l410, l411, l412, l413, l414, l415, l416, l417,
+ l418, l419, l420, l421, l422, l423, l424, l425, l426, l427,
+ l428, l429, l430, l431, l432, l433, l434, l435, l436, l437,
+ l438, l439, l440, l441, l442, l443, l444, l445, l446, l447,
+ l448, l449, l450, l451, l452, l453, l454, l455, l456, l457,
+ l458, l459, l460, l461, l462, l463, l464, l465, l466, l467,
+ l468, l469, l470, l471, l472, l473, l474, l475, l476, l477,
+ l478, l479, l480, l481, l482, l483, l484, l485, l486, l487,
+ l488, l489, l490, l491, l492, l493, l494, l495, l496, l497,
+ l498, l499, l500, l501, l502, l503, l504, l505, l506, l507,
+ l508, l509, l510, l511;
+
+ boolean do_m3 = false;
+ try {
+ do_m3 = m2(deopt);
+ } catch (StackOverflowError e) {
+ return true;
+ }
+ if (do_m3) {
+ try {
+ m1(deopt);
+ } catch (StackOverflowError e) {}
+ }
+ return false;
+ }
+
+ // Used for synchronization betwen threads
+ static volatile boolean thread_started = false;
+ static volatile boolean do_monitor_acquire = false;
+ static volatile boolean monitor_acquired = false;
+ static volatile boolean method_entered = false;
+
+ static Object monitor = new Object();
+
+ static public void main(String[] args) {
+ // get m1 compiled
+ for (int i = 0; i < 20000; i++) {
+ m1(false);
+ }
+
+ Thread thread = new Thread() {
+ public void run() {
+ thread_started = true;
+ while(!do_monitor_acquire);
+ System.out.println("Ok to try to acquire the lock");
+ synchronized(monitor) {
+ monitor_acquired = true;
+ }
+ }
+ };
+
+ thread.setDaemon(true);
+ thread.start();
+
+ while(!thread_started);
+
+ m2(true);
+
+ if (!method_entered) {
+ System.out.println("TEST PASSED");
+ return;
+ }
+
+ for (int i = 0; i < 10; i++) {
+ System.out.println("Is lock acquired?");
+ if (monitor_acquired) {
+ System.out.println("TEST PASSED");
+ return;
+ }
+ try {
+ Thread.sleep(10000);
+ } catch(InterruptedException ie) {
+ }
+ }
+ System.out.println("TEST FAILED");
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/gc/g1/TestStringDeduplicationTools.java
--- a/hotspot/test/gc/g1/TestStringDeduplicationTools.java Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/gc/g1/TestStringDeduplicationTools.java Tue Apr 29 14:40:07 2014 -0700
@@ -310,7 +310,9 @@
}
System.gc();
+
System.out.println("Heap Memory Usage: " + ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed());
+ System.out.println("Array Header Size: " + unsafe.ARRAY_CHAR_BASE_OFFSET);
System.out.println("End: MemoryUsageTest");
}
@@ -482,31 +484,40 @@
public static void testMemoryUsage() throws Exception {
// Test that memory usage is reduced after deduplication
OutputAnalyzer output;
- final String usagePattern = "Heap Memory Usage: (\\d+)";
+ final String heapMemoryUsagePattern = "Heap Memory Usage: (\\d+)";
+ final String arrayHeaderSizePattern = "Array Header Size: (\\d+)";
// Run without deduplication
output = MemoryUsageTest.run(false);
output.shouldHaveExitValue(0);
- final long memoryUsageWithoutDedup = Long.parseLong(output.firstMatch(usagePattern, 1));
+ final long heapMemoryUsageWithoutDedup = Long.parseLong(output.firstMatch(heapMemoryUsagePattern, 1));
+ final long arrayHeaderSizeWithoutDedup = Long.parseLong(output.firstMatch(arrayHeaderSizePattern, 1));
// Run with deduplication
output = MemoryUsageTest.run(true);
output.shouldHaveExitValue(0);
- final long memoryUsageWithDedup = Long.parseLong(output.firstMatch(usagePattern, 1));
+ final long heapMemoryUsageWithDedup = Long.parseLong(output.firstMatch(heapMemoryUsagePattern, 1));
+ final long arrayHeaderSizeWithDedup = Long.parseLong(output.firstMatch(arrayHeaderSizePattern, 1));
+
+ // Sanity check to make sure one instance isn't using compressed class pointers and the other not
+ if (arrayHeaderSizeWithoutDedup != arrayHeaderSizeWithDedup) {
+ throw new Exception("Unexpected difference between array header sizes");
+ }
// Calculate expected memory usage with deduplication enabled. This calculation does
// not take alignment and padding into account, so it's a conservative estimate.
- final long sizeOfChar = 2; // bytes
- final long bytesSaved = (LargeNumberOfStrings - 1) * (StringLength * sizeOfChar + unsafe.ARRAY_CHAR_BASE_OFFSET);
- final long memoryUsageWithDedupExpected = memoryUsageWithoutDedup - bytesSaved;
+ final long sizeOfChar = unsafe.ARRAY_CHAR_INDEX_SCALE;
+ final long sizeOfCharArray = StringLength * sizeOfChar + arrayHeaderSizeWithoutDedup;
+ final long bytesSaved = (LargeNumberOfStrings - 1) * sizeOfCharArray;
+ final long heapMemoryUsageWithDedupExpected = heapMemoryUsageWithoutDedup - bytesSaved;
System.out.println("Memory usage summary:");
- System.out.println(" memoryUsageWithoutDedup: " + memoryUsageWithoutDedup);
- System.out.println(" memoryUsageWithDedup: " + memoryUsageWithDedup);
- System.out.println(" memoryUsageWithDedupExpected: " + memoryUsageWithDedupExpected);
+ System.out.println(" heapMemoryUsageWithoutDedup: " + heapMemoryUsageWithoutDedup);
+ System.out.println(" heapMemoryUsageWithDedup: " + heapMemoryUsageWithDedup);
+ System.out.println(" heapMemoryUsageWithDedupExpected: " + heapMemoryUsageWithDedupExpected);
- if (memoryUsageWithDedup > memoryUsageWithDedupExpected) {
- throw new Exception("Unexpected memory usage, memoryUsageWithDedup should less or equal to memoryUsageWithDedupExpected");
+ if (heapMemoryUsageWithDedup > heapMemoryUsageWithDedupExpected) {
+ throw new Exception("Unexpected memory usage, heapMemoryUsageWithDedup should be less or equal to heapMemoryUsageWithDedupExpected");
}
}
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/runtime/6626217/Test6626217.sh
--- a/hotspot/test/runtime/6626217/Test6626217.sh Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/runtime/6626217/Test6626217.sh Tue Apr 29 14:40:07 2014 -0700
@@ -22,7 +22,6 @@
#
-# @ignore 8028733
# @test @(#)Test6626217.sh
# @bug 6626217
# @summary Loader-constraint table allows arrays instead of only the base-classes
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/runtime/6888954/vmerrors.sh
--- a/hotspot/test/runtime/6888954/vmerrors.sh Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/runtime/6888954/vmerrors.sh Tue Apr 29 14:40:07 2014 -0700
@@ -85,7 +85,7 @@
[ $i -lt 10 ] && i2=0$i
"$TESTJAVA/bin/java" $TESTVMOPTS -XX:+IgnoreUnrecognizedVMOptions \
- -XX:-TransmitErrorReport \
+ -XX:-TransmitErrorReport -XX:-CreateMinidumpOnCrash \
-XX:ErrorHandlerTest=${i} -version > ${i2}.out 2>&1
# If ErrorHandlerTest is ignored (product build), stop.
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/runtime/6929067/Test6929067.sh
--- a/hotspot/test/runtime/6929067/Test6929067.sh Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/runtime/6929067/Test6929067.sh Tue Apr 29 14:40:07 2014 -0700
@@ -18,115 +18,39 @@
## Adding common setup Variables for running shell tests.
. ${TESTSRC}/../../test_env.sh
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- Linux)
- gcc_cmd=`which gcc`
- if [ "x$gcc_cmd" == "x" ]; then
- echo "WARNING: gcc not found. Cannot execute test." 2>&1
- exit 0;
- fi
- NULL=/dev/null
- PS=":"
- FS="/"
- ;;
- * )
- echo "Test passed; only valid for Linux"
- exit 0;
- ;;
-esac
+if [ "${VM_OS}" != "linux" ]
+then
+ echo "Test only valid for Linux"
+ exit 0
+fi
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Xinternalversion > vm_version.out 2>&1
-
-# Bitness:
-# Cannot simply look at TESTVMOPTS as -d64 is not
-# passed if there is only a 64-bit JVM available.
-
-grep "64-Bit" vm_version.out > ${NULL}
-if [ "$?" = "0" ]
-then
- COMP_FLAG="-m64"
-else
- COMP_FLAG="-m32"
+gcc_cmd=`which gcc`
+if [ "x$gcc_cmd" = "x" ]; then
+ echo "WARNING: gcc not found. Cannot execute test." 2>&1
+ exit 0;
fi
+CFLAGS=-m${VM_BITS}
-# Architecture:
-# Translate uname output to JVM directory name, but permit testing
-# 32-bit x86 on an x64 platform.
-ARCH=`uname -m`
-case "$ARCH" in
- x86_64)
- if [ "$COMP_FLAG" = "-m32" ]; then
- ARCH=i386
- else
- ARCH=amd64
- fi
- ;;
- ppc64)
- if [ "$COMP_FLAG" = "-m32" ]; then
- ARCH=ppc
- else
- ARCH=ppc64
- fi
- ;;
- sparc64)
- if [ "$COMP_FLAG" = "-m32" ]; then
- ARCH=sparc
- else
- ARCH=sparc64
- fi
- ;;
- arm*)
- # 32-bit ARM machine: compiler may not recognise -m32
- COMP_FLAG=""
- ARCH=arm
- ;;
- aarch64)
- # 64-bit arm machine, could be testing 32 or 64-bit:
- if [ "$COMP_FLAG" = "-m32" ]; then
- ARCH=arm
- else
- ARCH=aarch64
- fi
- ;;
- i586)
- ARCH=i386
- ;;
- i686)
- ARCH=i386
- ;;
- # Assuming other ARCH values need no translation
-esac
-
-
-# VM type: need to know server or client
-VMTYPE=client
-grep Server vm_version.out > ${NULL}
-if [ "$?" = "0" ]
-then
- VMTYPE=server
-fi
-
-
-LD_LIBRARY_PATH=.:${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE}:/usr/lib:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${VM_CPU}/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
-cp ${TESTSRC}${FS}*.java ${THIS_DIR}
-${COMPILEJAVA}${FS}bin${FS}javac *.java
+cp ${TESTSRC}/*.java ${THIS_DIR}
+${COMPILEJAVA}/bin/javac *.java
-echo "Architecture: ${ARCH}"
-echo "Compilation flag: ${COMP_FLAG}"
-echo "VM type: ${VMTYPE}"
+echo "Architecture: ${VM_CPU}"
+echo "Compilation flag: ${CFLAGS}"
+echo "VM type: ${VM_TYPE}"
+echo "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}"
+
# Note pthread may not be found thus invoke creation will fail to be created.
# Check to ensure you have a /usr/lib/libpthread.so if you don't please look
# for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation.
-$gcc_cmd -DLINUX ${COMP_FLAG} -o invoke \
- -I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
- -L${COMPILEJAVA}/jre/lib/${ARCH}/${VMTYPE} \
- ${TESTSRC}${FS}invoke.c -ljvm -lpthread
+$gcc_cmd -DLINUX ${CFLAGS} -o invoke \
+ -I${TESTJAVA}/include -I${TESTJAVA}/include/linux \
+ -L${TESTJAVA}/jre/lib/${VM_CPU}/${VM_TYPE} \
+ ${TESTSRC}/invoke.c -ljvm -lpthread
./invoke
exit $?
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/runtime/InitialThreadOverflow/invoke.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/InitialThreadOverflow/invoke.c Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include
+#include
+
+#include
+
+JavaVM* jvm;
+
+void *
+floobydust (void *p) {
+ JNIEnv *env;
+ jclass class_id;
+ jmethodID method_id;
+
+ (*jvm)->AttachCurrentThread(jvm, (void**)&env, NULL);
+
+ class_id = (*env)->FindClass (env, "DoOverflow");
+ assert (class_id);
+
+ method_id = (*env)->GetStaticMethodID(env, class_id, "printIt", "()V");
+ assert (method_id);
+
+ (*env)->CallStaticVoidMethod(env, class_id, method_id, NULL);
+
+ (*jvm)->DetachCurrentThread(jvm);
+}
+
+int
+main (int argc, const char** argv) {
+ JavaVMOption options[1];
+ options[0].optionString = (char*) "-Xss320k";
+
+ JavaVMInitArgs vm_args;
+ vm_args.version = JNI_VERSION_1_2;
+ vm_args.ignoreUnrecognized = JNI_TRUE;
+ vm_args.options = options;
+ vm_args.nOptions = 1;
+
+ JNIEnv* env;
+ jint result = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
+ assert(result >= 0);
+
+ pthread_t thr;
+ pthread_create(&thr, NULL, floobydust, NULL);
+ pthread_join(thr, NULL);
+
+ floobydust(NULL);
+
+ return 0;
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/runtime/InitialThreadOverflow/invoke.cxx
--- a/hotspot/test/runtime/InitialThreadOverflow/invoke.cxx Tue Apr 29 15:44:14 2014 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-
-#include
-
-JavaVM* jvm;
-
-void *
-floobydust (void *p) {
- JNIEnv *env;
-
- jvm->AttachCurrentThread((void**)&env, NULL);
-
- jclass class_id = env->FindClass ("DoOverflow");
- assert (class_id);
-
- jmethodID method_id = env->GetStaticMethodID(class_id, "printIt", "()V");
- assert (method_id);
-
- env->CallStaticVoidMethod(class_id, method_id, NULL);
-
- jvm->DetachCurrentThread();
-}
-
-int
-main (int argc, const char** argv) {
- JavaVMOption options[1];
- options[0].optionString = (char*) "-Xss320k";
-
- JavaVMInitArgs vm_args;
- vm_args.version = JNI_VERSION_1_2;
- vm_args.ignoreUnrecognized = JNI_TRUE;
- vm_args.options = options;
- vm_args.nOptions = 1;
-
- JNIEnv* env;
- jint result = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
- assert(result >= 0);
-
- pthread_t thr;
- pthread_create(&thr, NULL, floobydust, NULL);
- pthread_join(thr, NULL);
-
- floobydust(NULL);
-
- return 0;
-}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/runtime/InitialThreadOverflow/testme.sh
--- a/hotspot/test/runtime/InitialThreadOverflow/testme.sh Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/runtime/InitialThreadOverflow/testme.sh Tue Apr 29 14:40:07 2014 -0700
@@ -21,7 +21,6 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
-# @ignore 8029139
# @test testme.sh
# @bug 8009062
# @summary Poor performance of JNI AttachCurrentThread after fix for 7017193
@@ -44,31 +43,35 @@
exit 0
fi
-gcc_cmd=`which g++`
+gcc_cmd=`which gcc`
if [ "x$gcc_cmd" = "x" ]; then
- echo "WARNING: g++ not found. Cannot execute test." 2>&1
+ echo "WARNING: gcc not found. Cannot execute test." 2>&1
exit 0;
fi
CFLAGS="-m${VM_BITS}"
-LD_LIBRARY_PATH=.:${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
+LD_LIBRARY_PATH=.:${TESTJAVA}/jre/lib/${VM_CPU}/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
-cp ${TESTSRC}${FS}invoke.cxx .
+cp ${TESTSRC}/invoke.c .
# Copy the result of our @compile action:
-cp ${TESTCLASSES}${FS}DoOverflow.class .
+cp ${TESTCLASSES}/DoOverflow.class .
-echo "Compilation flag: ${COMP_FLAG}"
+echo "Architecture: ${VM_CPU}"
+echo "Compilation flag: ${CFLAGS}"
+echo "VM type: ${VM_TYPE}"
+echo "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}"
+
# Note pthread may not be found thus invoke creation will fail to be created.
# Check to ensure you have a /usr/lib/libpthread.so if you don't please look
# for /usr/lib/`uname -m`-linux-gnu version ensure to add that path to below compilation.
$gcc_cmd -DLINUX ${CFLAGS} -o invoke \
- -I${COMPILEJAVA}/include -I${COMPILEJAVA}/include/linux \
- -L${COMPILEJAVA}/jre/lib/${VM_CPU}/${VM_TYPE} \
- -ljvm -lpthread invoke.cxx
+ -I${TESTJAVA}/include -I${TESTJAVA}/include/linux \
+ -L${TESTJAVA}/jre/lib/${VM_CPU}/${VM_TYPE} \
+ -ljvm -lpthread invoke.c
./invoke
exit $?
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/runtime/Thread/CancellableThreadTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/Thread/CancellableThreadTest.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,167 @@
+/*
+ * 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.
+ */
+
+/**
+ * This test is useful for finding out whether a Thread can have a
+ * private variable indicate whether or not it is finished, and to illustrate
+ * the ease with which Threads terminate each other.
+ *
+ * @test
+ */
+
+public class CancellableThreadTest {
+ public static final int THREADPAIRS = Integer.parseInt(System.getProperty("test.threadpairs", "128"));
+
+ public static void main(String args[]) {
+ Thread[] threads = new Thread[THREADPAIRS];
+ Canceller[] cancellers = new Canceller[THREADPAIRS];
+
+ System.out.println("Running with " + THREADPAIRS + " thread pairs");
+
+ for (int i = 0; i < THREADPAIRS; i++) {
+ cancellers[i] = new Canceller(i);
+ threads[i] = new Thread(cancellers[i]);
+ threads[i].start();
+ }
+
+ for (int i = 0; i < THREADPAIRS; i++) {
+ try {
+ threads[i].join();
+ } catch (InterruptedException e) {
+ }
+
+ if (cancellers[i].failed) {
+ throw new RuntimeException(" Test failed in " + i + " th pair. See error messages above.");
+ }
+ }
+ }
+}
+
+class Canceller implements Runnable {
+
+ private final CancellableTimer timer;
+
+ public final String name;
+ public volatile boolean failed = false;
+ private volatile boolean hasBeenNotified = false;
+
+ public Canceller(int index) {
+ this.name = "Canceller #" + index;
+ timer = new CancellableTimer(index, this);
+ }
+
+ public void setHasBeenNotified() {
+ hasBeenNotified = true;
+ }
+
+ /**
+ * This method contains the "action" of this Canceller Thread.
+ * It starts a CancellableTimer, waits, and then interrupts the
+ * CancellableTimer after the CancellableTimer notifies it. It then
+ * tries to join the CancellableTimer to itself and reports on whether
+ * it was successful in doing so.
+ */
+ public void run() {
+ Thread timerThread = new Thread(timer);
+
+ try {
+ synchronized(this) {
+ timerThread.start();
+ wait();
+ }
+ } catch (InterruptedException e) {
+ System.err.println(name + " was interrupted during wait()");
+ failed = true;
+ }
+
+ if (!hasBeenNotified) {
+ System.err.println(name + ".hasBeenNotified is not true as expected");
+ failed = true;
+ }
+
+ synchronized (timer) {
+ timerThread.interrupt();
+ }
+
+ try {
+ timerThread.join();
+ } catch (InterruptedException ie) {
+ System.err.println(name + " was interrupted while joining " +
+ timer.name);
+ failed = true;
+ }
+
+ if (timerThread.isAlive()) {
+ System.err.println(timer.name + " is still alive after " + name +
+ " attempted to join it.");
+ failed = true;
+ }
+ }
+}
+
+/**
+ * This non-public class is the Thread which the Canceller Thread deliberately
+ * interrupts and then joins to itself after this Thread has slept for a few milliseconds.
+ */
+
+class CancellableTimer implements Runnable {
+
+ public final String name;
+ private final Canceller myCanceller;
+
+ public CancellableTimer(int index, Canceller aCanceller) {
+ this.name = "CancellableTimer #" + index;
+ this.myCanceller = aCanceller;
+ }
+
+ /**
+ * This is where this CancellableTimer does its work. It notifies its
+ * Canceller, waits for the Canceller to interrupt it, then catches the
+ * InterruptedException, and sleeps for a few milliseconds before exiting.
+ */
+ public void run() {
+ try {
+ synchronized (this) {
+ synchronized (myCanceller) {
+ myCanceller.setHasBeenNotified();
+ myCanceller.notify();
+ }
+ wait();
+ }
+ } catch (InterruptedException first) {
+ // isInterrupted should've been cleared here and we should not register a
+ // second interrupt
+ if (Thread.currentThread().isInterrupted()) {
+ System.err.println(name + " should not register an interrupt here");
+ myCanceller.failed = true;
+ }
+
+ try {
+ Thread.sleep(1);
+ } catch (InterruptedException e) {
+ System.err.println(name + " was interrupted when sleeping");
+ myCanceller.failed = true;
+ }
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/runtime/verifier/TestMultiANewArray.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/verifier/TestMultiANewArray.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,82 @@
+/*
+ * 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.File;
+import java.io.FileOutputStream;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+import static jdk.internal.org.objectweb.asm.Opcodes.*;
+import com.oracle.java.testlibrary.*;
+
+/*
+ * @test TestMultiANewArray
+ * @bug 8038076
+ * @library /testlibrary
+ * @compile -XDignore.symbol.file TestMultiANewArray.java
+ * @run main/othervm TestMultiANewArray 49
+ * @run main/othervm TestMultiANewArray 50
+ * @run main/othervm TestMultiANewArray 51
+ * @run main/othervm TestMultiANewArray 52
+ */
+
+public class TestMultiANewArray {
+ public static void main(String... args) throws Exception {
+ int cfv = Integer.parseInt(args[0]);
+ writeClassFile(cfv);
+ System.err.println("Running with cfv: " + cfv);
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".", "ClassFile");
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldContain("VerifyError");
+ output.shouldHaveExitValue(1);
+ }
+
+ public static void writeClassFile(int cfv) throws Exception {
+ ClassWriter cw = new ClassWriter(0);
+ MethodVisitor mv;
+
+ cw.visit(cfv, ACC_PUBLIC + ACC_SUPER, "ClassFile", null, "java/lang/Object", null);
+ mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null);
+ mv.visitCode();
+ mv.visitVarInsn(ALOAD, 0);
+ mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", false);
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(1, 1);
+ mv.visitEnd();
+
+ mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
+ mv.visitCode();
+ mv.visitInsn(ICONST_1);
+ mv.visitInsn(ICONST_2);
+ mv.visitMultiANewArrayInsn("[I", 2);
+ mv.visitVarInsn(ASTORE, 1);
+ mv.visitInsn(RETURN);
+ mv.visitMaxs(2, 2);
+ mv.visitEnd();
+
+ cw.visitEnd();
+
+ try (FileOutputStream fos = new FileOutputStream(new File("ClassFile.class"))) {
+ fos.write(cw.toByteArray());
+ }
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/testlibrary/com/oracle/java/testlibrary/Platform.java
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/Platform.java Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/Platform.java Tue Apr 29 14:40:07 2014 -0700
@@ -30,13 +30,25 @@
private static final String osArch = System.getProperty("os.arch");
private static final String vmName = System.getProperty("java.vm.name");
- public static boolean isClient() {
- return vmName.endsWith(" Client VM");
- }
+ public static boolean isClient() {
+ return vmName.endsWith(" Client VM");
+ }
+
+ public static boolean isServer() {
+ return vmName.endsWith(" Server VM");
+ }
- public static boolean isServer() {
- return vmName.endsWith(" Server VM");
- }
+ public static boolean isGraal() {
+ return vmName.endsWith(" Graal VM");
+ }
+
+ public static boolean isMinimal() {
+ return vmName.endsWith(" Minimal VM");
+ }
+
+ public static boolean isEmbedded() {
+ return vmName.contains("Embedded");
+ }
public static boolean is32bit() {
return dataModel.equals("32");
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java Tue Apr 29 14:40:07 2014 -0700
@@ -145,18 +145,15 @@
return createJavaProcessBuilder(false, command);
}
- public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmOptions, String... command) throws Exception {
+ public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
String javapath = JDKToolFinder.getJDKTool("java");
ArrayList args = new ArrayList<>();
args.add(javapath);
Collections.addAll(args, getPlatformSpecificVMArgs());
- if (addTestVmOptions) {
- String vmopts = System.getProperty("test.vm.opts");
- if (vmopts != null && vmopts.length() > 0) {
- Collections.addAll(args, vmopts.split("\\s"));
- }
+ if (addTestVmAndJavaOptions) {
+ Collections.addAll(args, Utils.getTestJavaOpts());
}
Collections.addAll(args, command);
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/testlibrary/com/oracle/java/testlibrary/Utils.java
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/Utils.java Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/Utils.java Tue Apr 29 14:40:07 2014 -0700
@@ -38,6 +38,8 @@
import java.util.Collections;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
+import java.lang.reflect.Field;
+import sun.misc.Unsafe;
/**
* Common library for various test helper functions.
@@ -59,6 +61,8 @@
*/
public static final String JAVA_OPTIONS = System.getProperty("test.java.opts", "").trim();
+ private static Unsafe unsafe = null;
+
/**
* Returns the value of 'test.timeout.factor' system property
* converted to {@code double}.
@@ -109,10 +113,10 @@
/**
* Returns the default JTReg arguments for a jvm running a test without
- * options that matches regular expresions in {@code filters}.
+ * options that matches regular expressions in {@code filters}.
* This is the combination of JTReg arguments test.vm.opts and test.java.opts.
* @param filters Regular expressions used to filter out options.
- * @return An array of options, or an empty array if no opptions.
+ * @return An array of options, or an empty array if no options.
*/
public static String[] getFilteredTestJavaOpts(String... filters) {
String options[] = getTestJavaOpts();
@@ -294,4 +298,38 @@
return output;
}
+ /**
+ * @return Unsafe instance.
+ */
+ public static synchronized Unsafe getUnsafe() {
+ if (unsafe == null) {
+ try {
+ Field f = Unsafe.class.getDeclaredField("theUnsafe");
+ f.setAccessible(true);
+ unsafe = (Unsafe) f.get(null);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ throw new RuntimeException("Unable to get Unsafe instance.", e);
+ }
+ }
+ return unsafe;
+ }
+ private static final char[] hexArray = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+
+ /**
+ * Returns hex view of byte array
+ *
+ * @param bytes byte array to process
+ * @return Space separated hexadecimal string representation of bytes
+ */
+
+ public static String toHexString(byte[] bytes) {
+ char[] hexView = new char[bytes.length * 3];
+ int i = 0;
+ for (byte b : bytes) {
+ hexView[i++] = hexArray[(b >> 4) & 0x0F];
+ hexView[i++] = hexArray[b & 0x0F];
+ hexView[i++] = ' ';
+ }
+ return new String(hexView);
+ }
}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CPUSpecificCommandLineOptionTest.java
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CPUSpecificCommandLineOptionTest.java Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CPUSpecificCommandLineOptionTest.java Tue Apr 29 14:40:07 2014 -0700
@@ -23,22 +23,16 @@
package com.oracle.java.testlibrary.cli;
-import sun.hotspot.cpuinfo.CPUInfo;
-import com.oracle.java.testlibrary.*;
+import com.oracle.java.testlibrary.cli.predicate.CPUSpecificPredicate;
/**
* Base class for command line options tests that
* requires specific CPU arch or specific CPU features.
*/
public abstract class CPUSpecificCommandLineOptionTest
- extends CommandLineOptionTest {
-
- private String cpuArchPattern;
- private String supportedCPUFeatures[];
- private String unsupportedCPUFeatures[];
-
+ extends CommandLineOptionTest {
/**
- * Create new CPU specific test instance that does not
+ * Creates new CPU specific test instance that does not
* require any CPU features.
*
* @param cpuArchPattern Regular expression that should
@@ -49,62 +43,23 @@
}
/**
- * Create new CPU specific test instance that does not
+ * Creates new CPU specific test instance that does not
* require from CPU support of {@code supportedCPUFeatures} features
* and no support of {@code unsupportedCPUFeatures}.
*
* @param cpuArchPattern Regular expression that should
* match os.arch.
* @param supportedCPUFeatures Array with names of features that
- * should be supported by CPU. If null,
+ * should be supported by CPU. If {@code null},
* then no features have to be supported.
* @param unsupportedCPUFeatures Array with names of features that
* should not be supported by CPU.
- * If null, then CPU may support any
+ * If {@code null}, then CPU may support any
* features.
*/
public CPUSpecificCommandLineOptionTest(String cpuArchPattern,
- String supportedCPUFeatures[],
- String unsupportedCPUFeatures[]) {
- this.cpuArchPattern = cpuArchPattern;
- this.supportedCPUFeatures = supportedCPUFeatures;
- this.unsupportedCPUFeatures = unsupportedCPUFeatures;
- }
-
- /**
- * Check that CPU on test box has appropriate architecture, support all
- * required features and does not support all features that should not be
- * supported.
- *
- * @return true if CPU on test box fulfill all requirements.
- */
- @Override
- public boolean checkPreconditions() {
- if (!Platform.getOsArch().matches(cpuArchPattern)) {
- System.out.println("CPU arch does not match " + cpuArchPattern);
- return false;
- }
-
- if (supportedCPUFeatures != null) {
- for (String feature : supportedCPUFeatures) {
- if (!CPUInfo.hasFeature(feature)) {
- System.out.println("CPU does not support " + feature +
- " feature");
- return false;
- }
- }
- }
-
- if (unsupportedCPUFeatures != null) {
- for (String feature : unsupportedCPUFeatures) {
- if (CPUInfo.hasFeature(feature)) {
- System.out.println("CPU support " + feature + " feature");
- return false;
- }
- }
- }
-
- return true;
+ String supportedCPUFeatures[], String unsupportedCPUFeatures[]) {
+ super(new CPUSpecificPredicate(cpuArchPattern, supportedCPUFeatures,
+ unsupportedCPUFeatures));
}
}
-
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java Tue Apr 29 15:44:14 2014 -0400
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/CommandLineOptionTest.java Tue Apr 29 14:40:07 2014 -0700
@@ -26,6 +26,7 @@
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.function.BooleanSupplier;
import com.oracle.java.testlibrary.*;
@@ -33,34 +34,71 @@
* Base class for command line option tests.
*/
public abstract class CommandLineOptionTest {
-
- public static final String UNRECOGNIZED_OPTION_ERROR_FORMAT =
- "Unrecognized VM option '[+-]?%s'";
-
- public static final String printFlagsFinalFormat = "%s\\s*:?=\\s*%s";
+ public static final String UNLOCK_DIAGNOSTIC_VM_OPTIONS
+ = "-XX:+UnlockDiagnosticVMOptions";
+ public static final String UNLOCK_EXPERIMENTAL_VM_OPTIONS
+ = "-XX:+UnlockExperimentalVMOptions";
+ protected static final String UNRECOGNIZED_OPTION_ERROR_FORMAT
+ = "Unrecognized VM option '[+-]?%s(=.*)?'";
+ protected static final String EXPERIMENTAL_OPTION_ERROR_FORMAT
+ = "VM option '%s' is experimental and must be enabled via "
+ + "-XX:\\+UnlockExperimentalVMOptions.";
+ protected static final String DIAGNOSTIC_OPTION_ERROR_FORMAT
+ = " VM option '%s' is diagnostic and must be enabled via "
+ + "-XX:\\+UnlockDiagnosticVMOptions.";
+ private static final String PRINT_FLAGS_FINAL_FORMAT = "%s\\s*:?=\\s*%s";
/**
- * Verify that JVM startup behaviour matches our expectations.
+ * Verifies that JVM startup behaviour matches our expectations.
*
- * @param option The option that should be passed to JVM
- * @param excpectedMessages Array of patterns that should occur
- * in JVM output. If null then
+ * @param option an option that should be passed to JVM
+ * @param expectedMessages an array of patterns that should occur
+ * in JVM output. If {@code null} then
* JVM output could be empty.
- * @param unexpectedMessages Array of patterns that should not
- * occur in JVM output. If null then
- * JVM output could be empty.
+ * @param unexpectedMessages an array of patterns that should not
+ * occur in JVM output. If {@code null} then
+ * JVM output could be empty.
* @param exitCode expected exit code.
* @throws Throwable if verification fails or some other issues occur.
*/
public static void verifyJVMStartup(String option,
- String expectedMessages[],
- String unexpectedMessages[],
- ExitCode exitCode)
- throws Throwable {
+ String expectedMessages[], String unexpectedMessages[],
+ ExitCode exitCode) throws Throwable {
+ CommandLineOptionTest.verifyJVMStartup(expectedMessages,
+ unexpectedMessages, exitCode, false, option);
+ }
- OutputAnalyzer outputAnalyzer =
- ProcessTools.executeTestJvm(option, "-version");
+ /**
+ * Verifies that JVM startup behaviour matches our expectations.
+ *
+ * @param expectedMessages an array of patterns that should occur
+ * in JVM output. If {@code null} then
+ * JVM output could be empty.
+ * @param unexpectedMessages an array of patterns that should not
+ * occur in JVM output. If {@code null} then
+ * JVM output could be empty.
+ * @param exitCode expected exit code.
+ * @param addTestVMOptions if {@code true} then test VM options will be
+ * passed to VM.
+ * @param options options that should be passed to VM in addition to mode
+ * flag.
+ * @throws Throwable if verification fails or some other issues occur.
+ */
+ public static void verifyJVMStartup(String expectedMessages[],
+ String unexpectedMessages[], ExitCode exitCode,
+ boolean addTestVMOptions, String... options) throws Throwable {
+ List finalOptions = new ArrayList<>();
+ if (addTestVMOptions) {
+ Collections.addAll(finalOptions, Utils.getTestJavaOpts());
+ }
+ Collections.addAll(finalOptions, options);
+ finalOptions.add("-version");
+ ProcessBuilder processBuilder
+ = ProcessTools.createJavaProcessBuilder(finalOptions.toArray(
+ new String[finalOptions.size()]));
+ OutputAnalyzer outputAnalyzer
+ = new OutputAnalyzer(processBuilder.start());
outputAnalyzer.shouldHaveExitValue(exitCode.value);
if (expectedMessages != null) {
@@ -77,97 +115,216 @@
}
/**
- * Verify that value of specified JVM option is the same as
+ * Verifies that JVM startup behaviour matches our expectations when type
+ * of newly started VM is the same as the type of current.
+ *
+ * @param expectedMessages an array of patterns that should occur
+ * in JVM output. If {@code null} then
+ * JVM output could be empty.
+ * @param unexpectedMessages an array of patterns that should not
+ * occur in JVM output. If {@code null} then
+ * JVM output could be empty.
+ * @param exitCode expected exit code.
+ * @param options options that should be passed to VM in addition to mode
+ * flag.
+ * @throws Throwable if verification fails or some other issues occur.
+ */
+ public static void verifySameJVMStartup(String expectedMessages[],
+ String unexpectedMessages[], ExitCode exitCode, String... options)
+ throws Throwable {
+ List finalOptions = new ArrayList<>();
+ finalOptions.add(CommandLineOptionTest.getVMTypeOption());
+ Collections.addAll(finalOptions, options);
+
+ CommandLineOptionTest.verifyJVMStartup(expectedMessages,
+ unexpectedMessages, exitCode, false,
+ finalOptions.toArray(new String[finalOptions.size()]));
+ }
+
+ /**
+ * Verifies that value of specified JVM option is the same as
* expected value.
* This method filter out option with {@code optionName}
* name from test java options.
*
- * @param optionName Name of tested option.
- * @param expectedValue Expected value of tested option.
- * @param additionalVMOpts Additonal options that should be
+ * @param optionName a name of tested option.
+ * @param expectedValue expected value of tested option.
+ * @param additionalVMOpts additional options that should be
* passed to JVM.
* @throws Throwable if verification fails or some other issues occur.
*/
public static void verifyOptionValue(String optionName,
- String expectedValue,
- String... additionalVMOpts)
- throws Throwable {
+ String expectedValue, String... additionalVMOpts) throws Throwable {
verifyOptionValue(optionName, expectedValue, true, additionalVMOpts);
}
/**
- * Verify that value of specified JVM option is the same as
+ * Verifies that value of specified JVM option is the same as
* expected value.
* This method filter out option with {@code optionName}
* name from test java options.
*
- * @param optionName Name of tested option.
- * @param expectedValue Expected value of tested option.
- * @param addTestVmOptions If true, then test VM options
+ * @param optionName a name of tested option.
+ * @param expectedValue expected value of tested option.
+ * @param addTestVmOptions if {@code true}, then test VM options
* will be used.
- * @param additionalVMOpts Additonal options that should be
+ * @param additionalVMOpts additional options that should be
* passed to JVM.
- * @throws Throwable if verification fails or some other issues occur.
+ * @throws Throwable if verification fails or some other issues
+ * occur.
*/
public static void verifyOptionValue(String optionName,
- String expectedValue,
- boolean addTestVmOptions,
- String... additionalVMOpts)
- throws Throwable {
-
- List vmOpts = new ArrayList();
+ String expectedValue, boolean addTestVmOptions,
+ String... additionalVMOpts) throws Throwable {
+ List vmOpts = new ArrayList<>();
if (addTestVmOptions) {
Collections.addAll(vmOpts,
Utils.getFilteredTestJavaOpts(optionName));
}
Collections.addAll(vmOpts, additionalVMOpts);
- Collections.addAll(vmOpts, new String[] {
- "-XX:+PrintFlagsFinal",
- "-version"
- });
+ Collections.addAll(vmOpts, "-XX:+PrintFlagsFinal", "-version");
- ProcessBuilder processBuilder =
- ProcessTools.
- createJavaProcessBuilder(vmOpts.
- toArray(new String[vmOpts.size()]));
+ ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
+ vmOpts.toArray(new String[vmOpts.size()]));
- OutputAnalyzer outputAnalyzer =
- new OutputAnalyzer(processBuilder.start());
+ OutputAnalyzer outputAnalyzer
+ = new OutputAnalyzer(processBuilder.start());
outputAnalyzer.shouldHaveExitValue(0);
- outputAnalyzer.shouldMatch(String.
- format(printFlagsFinalFormat,
- optionName,
- expectedValue));
+ outputAnalyzer.shouldMatch(String.format(
+ CommandLineOptionTest.PRINT_FLAGS_FINAL_FORMAT,
+ optionName, expectedValue));
+ }
+
+ /**
+ * Verifies that value of specified JVM when type of newly started VM
+ * is the same as the type of current.
+ * This method filter out option with {@code optionName}
+ * name from test java options.
+ * Only mode flag will be passed to VM in addition to
+ * {@code additionalVMOpts}
+ *
+ * @param optionName name of tested option.
+ * @param expectedValue expected value of tested option.
+ * @param additionalVMOpts additional options that should be
+ * passed to JVM.
+ * @throws Throwable if verification fails or some other issues occur.
+ */
+ public static void verifyOptionValueForSameVM(String optionName,
+ String expectedValue, String... additionalVMOpts) throws Throwable {
+ List finalOptions = new ArrayList<>();
+ finalOptions.add(CommandLineOptionTest.getVMTypeOption());
+ Collections.addAll(finalOptions, additionalVMOpts);
+
+ CommandLineOptionTest.verifyOptionValue(optionName, expectedValue,
+ false, finalOptions.toArray(new String[finalOptions.size()]));
+ }
+
+ /**
+ * Prepares boolean command line flag with name {@code name} according
+ * to it's {@code value}.
+ *
+ * @param name the name of option to be prepared
+ * @param value the value of option
+ * @return prepared command line flag
+ */
+ public static String prepareBooleanFlag(String name, boolean value) {
+ return String.format("-XX:%c%s", (value ? '+' : '-'), name);
+ }
+
+ /**
+ * Prepares numeric command line flag with name {@code name} by setting
+ * it's value to {@code value}.
+ *
+ * @param name the name of option to be prepared
+ * @param value the value of option
+ * @return prepared command line flag
+ */
+ public static String prepareNumericFlag(String name, Number value) {
+ return String.format("-XX:%s=%s", name, value.toString());
}
+ /**
+ * Returns message that should occur in VM output if option
+ * {@code optionName} if unrecognized.
+ *
+ * @param optionName the name of option for which message should be returned
+ * @return message saying that option {@code optionName} is unrecognized
+ */
+ public static String getUnrecognizedOptionErrorMessage(String optionName) {
+ return String.format(
+ CommandLineOptionTest.UNRECOGNIZED_OPTION_ERROR_FORMAT,
+ optionName);
+ }
+
+ /**
+ * Returns message that should occur in VM output if option
+ * {@code optionName} is experimental and
+ * -XX:+UnlockExperimentalVMOptions was not passed to VM.
+ *
+ * @param optionName the name of option for which message should be returned
+ * @return message saying that option {@code optionName} is experimental
+ */
+ public static String getExperimentalOptionErrorMessage(String optionName) {
+ return String.format(
+ CommandLineOptionTest.EXPERIMENTAL_OPTION_ERROR_FORMAT,
+ optionName);
+ }
/**
- * Run command line option test.
+ * Returns message that should occur in VM output if option
+ * {@code optionName} is diagnostic and -XX:+UnlockDiagnosticVMOptions
+ * was not passed to VM.
*
- * @throws Throwable if test failed.
+ * @param optionName the name of option for which message should be returned
+ * @return message saying that option {@code optionName} is diganostic
+ */
+ public static String getDiagnosticOptionErrorMessage(String optionName) {
+ return String.format(
+ CommandLineOptionTest.DIAGNOSTIC_OPTION_ERROR_FORMAT,
+ optionName);
+ }
+
+ /**
+ * @return option required to start a new VM with the same type as current.
+ * @throws RuntimeException when VM type is unknown.
+ */
+ private static String getVMTypeOption() {
+ if (Platform.isServer()) {
+ return "-server";
+ } else if (Platform.isClient()) {
+ return "-client";
+ } else if (Platform.isMinimal()) {
+ return "-minimal";
+ } else if (Platform.isGraal()) {
+ return "-graal";
+ }
+ throw new RuntimeException("Unknown VM mode.");
+ }
+
+ private final BooleanSupplier predicate;
+
+ /**
+ * Constructs new CommandLineOptionTest that will be executed only if
+ * predicate {@code predicate} return {@code true}.
+ * @param predicate a predicate responsible for test's preconditions check.
+ */
+ public CommandLineOptionTest(BooleanSupplier predicate) {
+ this.predicate = predicate;
+ }
+
+ /**
+ * Runs command line option test.
*/
public final void test() throws Throwable {
- if (checkPreconditions()) {
+ if (predicate.getAsBoolean()) {
runTestCases();
}
}
/**
- * Check that all preconditions for test execution are met.
- *
- * @return true if test could be executed.
+ * @throws Throwable if some issue happened during test cases execution.
*/
- public boolean checkPreconditions() {
- return true;
- }
-
- /**
- * Run test cases.
- *
- * @throws Throwable if test failed.
- */
- public abstract void runTestCases() throws Throwable;
+ protected abstract void runTestCases() throws Throwable;
}
-
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/predicate/AndPredicate.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/predicate/AndPredicate.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,41 @@
+/*
+ * 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 com.oracle.java.testlibrary.cli.predicate;
+
+import java.util.function.BooleanSupplier;
+
+public class AndPredicate implements BooleanSupplier {
+ private final BooleanSupplier a;
+ private final BooleanSupplier b;
+
+ public AndPredicate(BooleanSupplier a, BooleanSupplier b) {
+ this.a = a;
+ this.b = b;
+ }
+
+ @Override
+ public boolean getAsBoolean() {
+ return a.getAsBoolean() && b.getAsBoolean();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/predicate/CPUSpecificPredicate.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/predicate/CPUSpecificPredicate.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,71 @@
+/*
+ * 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 com.oracle.java.testlibrary.cli.predicate;
+
+import com.oracle.java.testlibrary.Platform;
+import sun.hotspot.cpuinfo.CPUInfo;
+
+import java.util.function.BooleanSupplier;
+
+public class CPUSpecificPredicate implements BooleanSupplier {
+ private final String cpuArchPattern;
+ private final String supportedCPUFeatures[];
+ private final String unsupportedCPUFeatures[];
+
+ public CPUSpecificPredicate(String cpuArchPattern,
+ String supportedCPUFeatures[],
+ String unsupportedCPUFeatures[]) {
+ this.cpuArchPattern = cpuArchPattern;
+ this.supportedCPUFeatures = supportedCPUFeatures;
+ this.unsupportedCPUFeatures = unsupportedCPUFeatures;
+ }
+
+ @Override
+ public boolean getAsBoolean() {
+ if (!Platform.getOsArch().matches(cpuArchPattern)) {
+ System.out.println("CPU arch does not match " + cpuArchPattern);
+ return false;
+ }
+
+ if (supportedCPUFeatures != null) {
+ for (String feature : supportedCPUFeatures) {
+ if (!CPUInfo.hasFeature(feature)) {
+ System.out.println("CPU does not support " + feature
+ + " feature");
+ return false;
+ }
+ }
+ }
+
+ if (unsupportedCPUFeatures != null) {
+ for (String feature : unsupportedCPUFeatures) {
+ if (CPUInfo.hasFeature(feature)) {
+ System.out.println("CPU support " + feature + " feature");
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/predicate/NotPredicate.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/predicate/NotPredicate.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,40 @@
+/*
+ * 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 com.oracle.java.testlibrary.cli.predicate;
+
+import java.util.function.BooleanSupplier;
+
+public class NotPredicate implements BooleanSupplier {
+ private final BooleanSupplier s;
+
+ public NotPredicate(BooleanSupplier s) {
+ this.s = s;
+ }
+
+ @Override
+ public boolean getAsBoolean() {
+ return !s.getAsBoolean();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/predicate/OrPredicate.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/cli/predicate/OrPredicate.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,42 @@
+/*
+ * 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 com.oracle.java.testlibrary.cli.predicate;
+
+import java.util.function.BooleanSupplier;
+
+public class OrPredicate implements BooleanSupplier {
+ private final BooleanSupplier a;
+ private final BooleanSupplier b;
+
+ public OrPredicate(BooleanSupplier a, BooleanSupplier b) {
+ this.a = a;
+ this.b = b;
+ }
+
+ @Override
+ public boolean getAsBoolean() {
+ return a.getAsBoolean() || b.getAsBoolean();
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/.hgtags
--- a/jaxp/.hgtags Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/.hgtags Tue Apr 29 14:40:07 2014 -0700
@@ -250,3 +250,6 @@
b92a20e303d24c74078888cd7084b14d7626d48f jdk9-b05
46e4951b2a267e98341613a3b796f2c7554eb831 jdk9-b06
389f4094fd603c17e215997b0b40171179629007 jdk9-b07
+3b360a77658e6b3ac150dd7cdbff1a7abe855afc jdk9-b08
+f93a792fe37279d4d37aea86a99f3abbdc6fe79b jdk9-b09
+4ce98701efe3b28f6ce3ab23385445731e968af7 jdk9-b10
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/make/BuildJaxp.gmk
--- a/jaxp/make/BuildJaxp.gmk Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/make/BuildJaxp.gmk Tue Apr 29 14:40:07 2014 -0700
@@ -35,15 +35,15 @@
# The generate new bytecode uses the new compiler for to generate bytecode
# for the new jdk that is being built. The code compiled by this setup
# cannot necessarily be run with the boot jdk.
-$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG, \
+$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \
JVM := $(JAVA), \
JAVAC := $(NEW_JAVAC), \
- FLAGS := -XDignore.symbol.file=true $(DISABLE_JAXP_WARNINGS) -g, \
+ FLAGS := -XDignore.symbol.file=true $(DISABLE_JAXP_WARNINGS), \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
$(eval $(call SetupJavaCompilation,BUILD_JAXP, \
- SETUP := GENERATE_NEWBYTECODE_DEBUG, \
+ SETUP := GENERATE_NEWBYTECODE, \
SRC := $(JAXP_TOPDIR)/src, \
CLEAN := .properties, \
BIN := $(JAXP_OUTPUTDIR)/classes, \
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java
--- a/jaxp/src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java Tue Apr 29 14:40:07 2014 -0700
@@ -57,7 +57,7 @@
return securitySupport;
}
- static ClassLoader getContextClassLoader() {
+ public static ClassLoader getContextClassLoader() {
return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
ClassLoader cl = null;
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ElementSchemePointer.java Tue Apr 29 14:40:07 2014 -0700
@@ -3,11 +3,12 @@
* DO NOT REMOVE OR ALTER!
*/
/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -19,7 +20,7 @@
*/
package com.sun.org.apache.xerces.internal.xpointer;
-import java.util.Hashtable;
+import java.util.HashMap;
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
import com.sun.org.apache.xerces.internal.util.SymbolTable;
@@ -38,9 +39,8 @@
* @xerces.internal
*
* @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $
- *
*/
-class ElementSchemePointer implements XPointerPart {
+final class ElementSchemePointer implements XPointerPart {
// Fields
@@ -346,15 +346,17 @@
// Donot check for empty elements if the empty element is
// a child of a found parent element
- //if (!fIsElementFound) {
- if (checkMatch()) {
- fIsElementFound = true;
+ if (checkMatch()) {
+ if (!fIsElementFound) {
fWasOnlyEmptyElementFound = true;
} else {
- fIsElementFound = false;
+ fWasOnlyEmptyElementFound = false;
}
- //}
-
+ fIsElementFound = true;
+ } else {
+ fIsElementFound = false;
+ fWasOnlyEmptyElementFound = false;
+ }
}
}
@@ -526,7 +528,7 @@
private SymbolTable fSymbolTable;
- private Hashtable fTokenNames = new Hashtable();
+ private HashMap fTokenNames = new HashMap<>();
/**
* Constructor
@@ -548,16 +550,7 @@
* @return String The token string
*/
private String getTokenString(int token) {
- return (String) fTokenNames.get(new Integer(token));
- }
-
- /**
- * Returns the token String
- * @param token The index of the token
- * @return String The token string
- */
- private Integer getToken(int token) {
- return (Integer) fTokenNames.get(new Integer(token));
+ return fTokenNames.get(new Integer(token));
}
/**
@@ -566,12 +559,11 @@
* @param token The token string
*/
private void addToken(String tokenStr) {
- Integer tokenInt = (Integer) fTokenNames.get(tokenStr);
- if (tokenInt == null) {
- tokenInt = new Integer(fTokenNames.size());
+ if (!fTokenNames.containsValue(tokenStr)) {
+ Integer tokenInt = new Integer(fTokenNames.size());
fTokenNames.put(tokenInt, tokenStr);
+ addToken(tokenInt.intValue());
}
- addToken(tokenInt.intValue());
}
/**
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ShortHandPointer.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ShortHandPointer.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/ShortHandPointer.java Tue Apr 29 14:40:07 2014 -0700
@@ -3,11 +3,12 @@
* DO NOT REMOVE OR ALTER!
*/
/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -17,6 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.sun.org.apache.xerces.internal.xpointer;
import com.sun.org.apache.xerces.internal.impl.Constants;
@@ -37,9 +39,8 @@
* in document order that has a matching NCName as an identifier.
*
*
- *
*/
-class ShortHandPointer implements XPointerPart {
+final class ShortHandPointer implements XPointerPart {
// The name of the ShortHand pointer
private String fShortHandPointer;
@@ -261,7 +262,7 @@
* @see com.sun.org.apache.xerces.internal.xpointer.XPointerPart#isChildFragmentResolved()
*/
public boolean isChildFragmentResolved() {
- return fIsFragmentResolved & ( fMatchingChildCount > 0);
+ return fIsFragmentResolved && ( fMatchingChildCount > 0);
}
/**
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerErrorHandler.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerErrorHandler.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerErrorHandler.java Tue Apr 29 14:40:07 2014 -0700
@@ -3,11 +3,12 @@
* DO NOT REMOVE OR ALTER!
*/
/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -17,6 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.sun.org.apache.xerces.internal.xpointer;
import java.io.PrintWriter;
@@ -31,7 +33,7 @@
* implementation and reported as resource errors.
*
*/
-class XPointerErrorHandler implements XMLErrorHandler {
+final class XPointerErrorHandler implements XMLErrorHandler {
//
// Data
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerHandler.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerHandler.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerHandler.java Tue Apr 29 14:40:07 2014 -0700
@@ -3,11 +3,12 @@
* DO NOT REMOVE OR ALTER!
*/
/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -17,10 +18,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.sun.org.apache.xerces.internal.xpointer;
-import java.util.Hashtable;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.HashMap;
import com.sun.org.apache.xerces.internal.impl.Constants;
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
@@ -32,6 +34,7 @@
import com.sun.org.apache.xerces.internal.xni.Augmentations;
import com.sun.org.apache.xerces.internal.xni.QName;
import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
+import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
import com.sun.org.apache.xerces.internal.xni.XMLString;
import com.sun.org.apache.xerces.internal.xni.XNIException;
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
@@ -64,8 +67,8 @@
XPointerProcessor {
// Fields
- // A Vector of XPointerParts
- protected Vector fXPointerParts = null;
+ // An ArrayList of XPointerParts
+ protected ArrayList fXPointerParts = null;
// The current XPointerPart
protected XPointerPart fXPointerPart = null;
@@ -102,7 +105,7 @@
public XPointerHandler() {
super();
- fXPointerParts = new Vector();
+ fXPointerParts = new ArrayList<>();
fSymbolTable = new SymbolTable();
}
@@ -110,13 +113,17 @@
XMLErrorHandler errorHandler, XMLErrorReporter errorReporter) {
super();
- fXPointerParts = new Vector();
+ fXPointerParts = new ArrayList<>();
fSymbolTable = symbolTable;
fErrorHandler = errorHandler;
fXPointerErrorReporter = errorReporter;
//fErrorReporter = errorReporter; // The XInclude ErrorReporter
}
+ public void setDocumentHandler(XMLDocumentHandler handler) {
+ fDocumentHandler = handler;
+ }
+
// ************************************************************************
// Implementation of the XPointerProcessor interface.
// ************************************************************************
@@ -300,7 +307,7 @@
// in the XPointer expression until a matching element is found.
for (int i = 0; i < fXPointerParts.size(); i++) {
- fXPointerPart = (XPointerPart) fXPointerParts.get(i);
+ fXPointerPart = fXPointerParts.get(i);
if (fXPointerPart.resolveXPointer(element, attributes, augs,
event)) {
@@ -430,11 +437,11 @@
}
/**
- * Returns a Vector of XPointerPart objects
+ * Returns an ArrayList of XPointerPart objects
*
- * @return A Vector of XPointerPart objects.
+ * @return An ArrayList of XPointerPart objects.
*/
- public Vector getPointerParts() {
+ public ArrayList getPointerParts() {
return fXPointerParts;
}
@@ -480,7 +487,7 @@
private SymbolTable fSymbolTable;
- private Hashtable fTokenNames = new Hashtable();
+ private HashMap fTokenNames = new HashMap<>();
/**
* Constructor
@@ -508,7 +515,7 @@
* @return String The token string
*/
private String getTokenString(int token) {
- return (String) fTokenNames.get(new Integer(token));
+ return fTokenNames.get(new Integer(token));
}
/**
@@ -517,12 +524,11 @@
* @param token The token string
*/
private void addToken(String tokenStr) {
- Integer tokenInt = (Integer) fTokenNames.get(tokenStr);
- if (tokenInt == null) {
- tokenInt = new Integer(fTokenNames.size());
+ if (!fTokenNames.containsValue(tokenStr)) {
+ Integer tokenInt = new Integer(fTokenNames.size());
fTokenNames.put(tokenInt, tokenStr);
+ addToken(tokenInt.intValue());
}
- addToken(tokenInt.intValue());
}
/**
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerMessageFormatter.java Tue Apr 29 14:40:07 2014 -0700
@@ -3,11 +3,12 @@
* DO NOT REMOVE OR ALTER!
*/
/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -17,6 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.sun.org.apache.xerces.internal.xpointer;
import java.util.Locale;
@@ -34,7 +36,7 @@
*
* @version $Id: XPointerMessageFormatter.java,v 1.5 2010-11-01 04:40:26 joehw Exp $
*/
-class XPointerMessageFormatter implements MessageFormatter {
+final class XPointerMessageFormatter implements MessageFormatter {
public static final String XPOINTER_DOMAIN = "http://www.w3.org/TR/XPTR";
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerPart.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerPart.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerPart.java Tue Apr 29 14:40:07 2014 -0700
@@ -3,11 +3,12 @@
* DO NOT REMOVE OR ALTER!
*/
/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -17,6 +18,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package com.sun.org.apache.xerces.internal.xpointer;
import com.sun.org.apache.xerces.internal.xni.Augmentations;
@@ -49,7 +51,7 @@
* Provides scheme specific parsing of a XPointer expression i.e.
* the PointerPart or ShortHandPointer.
*
- * @param xpointer A String representing the PointerPart or ShortHandPointer.
+ * @param part A String representing the PointerPart or ShortHandPointer.
* @throws XNIException Thrown if the PointerPart string does not conform to
* the syntax defined by its scheme.
*
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerProcessor.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerProcessor.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/xpointer/XPointerProcessor.java Tue Apr 29 14:40:07 2014 -0700
@@ -3,11 +3,12 @@
* DO NOT REMOVE OR ALTER!
*/
/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -34,7 +35,6 @@
*
* @xerces.internal
*
- *
*/
public interface XPointerProcessor {
@@ -56,7 +56,6 @@
* @throws XNIException Thrown if the xpointer string does not conform to
* the XPointer Framework syntax or the syntax of the pointer part does
* not conform to its definition for its scheme.
- *
*/
public void parseXPointer(String xpointer) throws XNIException;
@@ -74,7 +73,6 @@
* 2 - An empty element call
* @return true if the element was resolved by the xpointer
* @throws XNIException Thrown to signal an error
- *
*/
public boolean resolveXPointer(QName element, XMLAttributes attributes,
Augmentations augs, int event) throws XNIException;
@@ -86,7 +84,6 @@
* @return True if the xpointer expression matches a node/fragment in the resource
* else returns false.
* @throws XNIException Thrown to signal an error
- *
*/
public boolean isFragmentResolved() throws XNIException;
@@ -97,7 +94,6 @@
* @return True if the xpointer expression matches a fragment in the resource
* else returns false.
* @throws XNIException Thrown to signal an error
- *
*/
public boolean isXPointerResolved() throws XNIException;
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xml/internal/serializer/CharInfo.java
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/CharInfo.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/CharInfo.java Tue Apr 29 14:40:07 2014 -0700
@@ -22,6 +22,11 @@
*/
package com.sun.org.apache.xml.internal.serializer;
+import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
+import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
+import com.sun.org.apache.xml.internal.serializer.utils.SystemIDResolver;
+import com.sun.org.apache.xml.internal.serializer.utils.Utils;
+import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -29,19 +34,11 @@
import java.net.URL;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Locale;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
import javax.xml.transform.TransformerException;
-import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
-import com.sun.org.apache.xml.internal.serializer.utils.SystemIDResolver;
-import com.sun.org.apache.xml.internal.serializer.utils.Utils;
-import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
-import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
-
/**
* This class provides services that tell if a character should have
* special treatement, such as entity reference substitution or normalization
@@ -176,13 +173,19 @@
// file
// 3) try treating the resource a URI
- if (internal) {
- try {
+ try {
+ if (internal) {
// Load entity property files by using PropertyResourceBundle,
// cause of security issure for applets
entities = PropertyResourceBundle.getBundle(entitiesResource);
- } catch (Exception e) {}
- }
+ } else {
+ ClassLoader cl = SecuritySupport.getContextClassLoader();
+ if (cl != null) {
+ entities = PropertyResourceBundle.getBundle(entitiesResource,
+ Locale.getDefault(), cl);
+ }
+ }
+ } catch (Exception e) {}
if (entities != null) {
Enumeration keys = entities.getKeys();
@@ -198,6 +201,7 @@
set(S_CARRIAGERETURN);
} else {
InputStream is = null;
+ String err = null;
// Load user specified resource file by using URL loading, it
// requires a valid URI as parameter
@@ -205,18 +209,22 @@
if (internal) {
is = CharInfo.class.getResourceAsStream(entitiesResource);
} else {
- ClassLoader cl = ObjectFactory.findClassLoader();
- if (cl == null) {
- is = ClassLoader.getSystemResourceAsStream(entitiesResource);
- } else {
- is = cl.getResourceAsStream(entitiesResource);
+ ClassLoader cl = SecuritySupport.getContextClassLoader();
+ if (cl != null) {
+ try {
+ is = cl.getResourceAsStream(entitiesResource);
+ } catch (Exception e) {
+ err = e.getMessage();
+ }
}
if (is == null) {
try {
URL url = new URL(entitiesResource);
is = url.openStream();
- } catch (Exception e) {}
+ } catch (Exception e) {
+ err = e.getMessage();
+ }
}
}
@@ -224,7 +232,7 @@
throw new RuntimeException(
Utils.messages.createMessage(
MsgKey.ER_RESOURCE_COULD_NOT_FIND,
- new Object[] {entitiesResource, entitiesResource}));
+ new Object[] {entitiesResource, err}));
}
// Fix Bugzilla#4000: force reading in UTF-8
@@ -456,64 +464,56 @@
return isCleanTextASCII[value];
}
-// In the future one might want to use the array directly and avoid
-// the method call, but I think the JIT alreay inlines this well enough
-// so don't do it (for now) - bjm
-// public final boolean[] getASCIIClean()
-// {
-// return isCleanTextASCII;
-// }
-
- private static CharInfo getCharInfoBasedOnPrivilege(
- final String entitiesFileName, final String method,
- final boolean internal){
- return (CharInfo) AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return new CharInfo(entitiesFileName,
- method, internal);}
- });
+ /**
+ * Read an internal resource file that describes the mapping of
+ * characters to entity references; Construct a CharInfo object.
+ *
+ * @param entitiesFileName Name of entities resource file that should
+ * be loaded, which describes the mapping of characters to entity references.
+ * @param method the output method type, which should be one of "xml", "html", and "text".
+ * @return an instance of CharInfo
+ *
+ * @xsl.usage internal
+ */
+ static CharInfo getCharInfoInternal(String entitiesFileName, String method)
+ {
+ CharInfo charInfo = (CharInfo) m_getCharInfoCache.get(entitiesFileName);
+ if (charInfo != null) {
+ return charInfo;
+ }
+
+ charInfo = new CharInfo(entitiesFileName, method, true);
+ m_getCharInfoCache.put(entitiesFileName, charInfo);
+ return charInfo;
}
/**
- * Factory that reads in a resource file that describes the mapping of
- * characters to entity references.
+ * Constructs a CharInfo object using the following process to try reading
+ * the entitiesFileName parameter:
*
- * Resource files must be encoded in UTF-8 and have a format like:
+ * 1) attempt to load it as a ResourceBundle
+ * 2) try using the class loader to find the specified file
+ * 3) try opening it as an URI
+ *
+ * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
+ * following format:
*
* # First char # is a comment
* Entity numericValue
* quot 34
* amp 38
*
- * (Note: Why don't we just switch to .properties files? Oct-01 -sc)
*
- * @param entitiesResource Name of entities resource file that should
- * be loaded, which describes that mapping of characters to entity references.
- * @param method the output method type, which should be one of "xml", "html", "text"...
- *
- * @xsl.usage internal
+ * @param entitiesFileName Name of entities resource file that should
+ * be loaded, which describes the mapping of characters to entity references.
+ * @param method the output method type, which should be one of "xml", "html", and "text".
+ * @return an instance of CharInfo
*/
static CharInfo getCharInfo(String entitiesFileName, String method)
{
- CharInfo charInfo = (CharInfo) m_getCharInfoCache.get(entitiesFileName);
- if (charInfo != null) {
- return charInfo;
- }
-
- // try to load it internally - cache
try {
- charInfo = getCharInfoBasedOnPrivilege(entitiesFileName,
- method, true);
- m_getCharInfoCache.put(entitiesFileName, charInfo);
- return charInfo;
- } catch (Exception e) {}
-
- // try to load it externally - do not cache
- try {
- return getCharInfoBasedOnPrivilege(entitiesFileName,
- method, false);
+ return new CharInfo(entitiesFileName, method, false);
} catch (Exception e) {}
String absoluteEntitiesFileName;
@@ -530,8 +530,7 @@
}
}
- return getCharInfoBasedOnPrivilege(entitiesFileName,
- method, false);
+ return new CharInfo(absoluteEntitiesFileName, method, false);
}
/** Table of user-specified char infos. */
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToHTMLStream.java Tue Apr 29 14:40:07 2014 -0700
@@ -60,7 +60,7 @@
*/
private static final CharInfo m_htmlcharInfo =
// new CharInfo(CharInfo.HTML_ENTITIES_RESOURCE);
- CharInfo.getCharInfo(CharInfo.HTML_ENTITIES_RESOURCE, Method.HTML);
+ CharInfo.getCharInfoInternal(CharInfo.HTML_ENTITIES_RESOURCE, Method.HTML);
/** A digital search trie for fast, case insensitive lookup of ElemDesc objects. */
static final Trie m_elementFlags = new Trie();
diff -r 1d117d2dfe92 -r 2061862eb57c jaxp/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/ToXMLStream.java Tue Apr 29 14:40:07 2014 -0700
@@ -58,7 +58,7 @@
*/
private static CharInfo m_xmlcharInfo =
// new CharInfo(CharInfo.XML_ENTITIES_RESOURCE);
- CharInfo.getCharInfo(CharInfo.XML_ENTITIES_RESOURCE, Method.XML);
+ CharInfo.getCharInfoInternal(CharInfo.XML_ENTITIES_RESOURCE, Method.XML);
/**
* Default constructor.
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/.hgtags
--- a/jaxws/.hgtags Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/.hgtags Tue Apr 29 14:40:07 2014 -0700
@@ -253,3 +253,6 @@
eae966c8133fec0a8bf9e16d1274a4ede3c0fb52 jdk9-b05
cf0a6e41670f990414cd337000ad5f3bd1908073 jdk9-b06
856a9132f506cafe2f251c1a16a0b14e4d16048d jdk9-b07
+2d9f4166e0be68aa43c5f4fd0f8d34768e11f652 jdk9-b08
+c9e8bb8c1144a966ca7b481142c6b5e55d14a29c jdk9-b09
+9af43f4d215f6f19b1767f6ac66da931b8ee9535 jdk9-b10
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/make/BuildJaxws.gmk
--- a/jaxws/make/BuildJaxws.gmk Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/make/BuildJaxws.gmk Tue Apr 29 14:40:07 2014 -0700
@@ -35,21 +35,21 @@
# The generate new bytecode uses the new compiler for to generate bytecode
# for the new jdk that is being built. The code compiled by this setup
# cannot necessarily be run with the boot jdk.
-$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG, \
+$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \
JVM := $(JAVA), \
JAVAC := $(NEW_JAVAC), \
- FLAGS := -XDignore.symbol.file=true $(DISABLE_JAXWS_WARNINGS) -g, \
+ FLAGS := -XDignore.symbol.file=true $(DISABLE_JAXWS_WARNINGS), \
SERVER_DIR := $(SJAVAC_SERVER_DIR), \
SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
$(eval $(call SetupJavaCompilation,BUILD_JAF, \
- SETUP := GENERATE_NEWBYTECODE_DEBUG, \
+ SETUP := GENERATE_NEWBYTECODE, \
SRC := $(JAXWS_TOPDIR)/src/share/jaf_classes, \
CLEAN := .properties, \
BIN := $(JAXWS_OUTPUTDIR)/jaf_classes))
$(eval $(call SetupJavaCompilation,BUILD_JAXWS, \
- SETUP := GENERATE_NEWBYTECODE_DEBUG, \
+ SETUP := GENERATE_NEWBYTECODE, \
SRC := $(JAXWS_TOPDIR)/src/share/jaxws_classes, \
BIN := $(JAXWS_OUTPUTDIR)/jaxws_classes, \
COPY := .xsd, \
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaf_classes/javax/activation/CommandMap.java
--- a/jaxws/src/share/jaf_classes/javax/activation/CommandMap.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaf_classes/javax/activation/CommandMap.java Tue Apr 29 14:40:07 2014 -0700
@@ -25,6 +25,9 @@
package javax.activation;
+import java.util.Map;
+import java.util.WeakHashMap;
+
/**
* The CommandMap class provides an interface to a registry of
@@ -38,6 +41,8 @@
*/
public abstract class CommandMap {
private static CommandMap defaultCommandMap = null;
+ private static Map map =
+ new WeakHashMap();
/**
* Get the default CommandMap.
@@ -56,11 +61,18 @@
*
* @return the CommandMap
*/
- public static CommandMap getDefaultCommandMap() {
- if (defaultCommandMap == null)
- defaultCommandMap = new MailcapCommandMap();
+ public static synchronized CommandMap getDefaultCommandMap() {
+ if (defaultCommandMap != null)
+ return defaultCommandMap;
- return defaultCommandMap;
+ // fetch per-thread-context-class-loader default
+ ClassLoader tccl = SecuritySupport.getContextClassLoader();
+ CommandMap def = map.get(tccl);
+ if (def == null) {
+ def = new MailcapCommandMap();
+ map.put(tccl, def);
+ }
+ return def;
}
/**
@@ -71,7 +83,7 @@
* @exception SecurityException if the caller doesn't have permission
* to change the default
*/
- public static void setDefaultCommandMap(CommandMap commandMap) {
+ public static synchronized void setDefaultCommandMap(CommandMap commandMap) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
@@ -79,13 +91,16 @@
security.checkSetFactory();
} catch (SecurityException ex) {
// otherwise, we also allow it if this code and the
- // factory come from the same class loader (e.g.,
+ // factory come from the same (non-system) class loader (e.g.,
// the JAF classes were loaded with the applet classes).
- if (CommandMap.class.getClassLoader() !=
+ if (CommandMap.class.getClassLoader() == null ||
+ CommandMap.class.getClassLoader() !=
commandMap.getClass().getClassLoader())
throw ex;
}
}
+ // remove any per-thread-context-class-loader CommandMap
+ map.remove(SecuritySupport.getContextClassLoader());
defaultCommandMap = commandMap;
}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaf_classes/javax/activation/DataHandler.java
--- a/jaxws/src/share/jaf_classes/javax/activation/DataHandler.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaf_classes/javax/activation/DataHandler.java Tue Apr 29 14:40:07 2014 -0700
@@ -368,7 +368,12 @@
// if it's not set, set it...
if (transferFlavors == emptyFlavors)
transferFlavors = getDataContentHandler().getTransferDataFlavors();
- return transferFlavors;
+
+ if (transferFlavors == emptyFlavors)
+ return transferFlavors;
+ else
+ return transferFlavors.clone();
+
}
/**
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java
--- a/jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java Tue Apr 29 14:40:07 2014 -0700
@@ -26,6 +26,8 @@
package javax.activation;
import java.io.File;
+import java.util.Map;
+import java.util.WeakHashMap;
/**
* The FileTypeMap is an abstract class that provides a data typing
@@ -48,6 +50,8 @@
public abstract class FileTypeMap {
private static FileTypeMap defaultMap = null;
+ private static Map map =
+ new WeakHashMap();
/**
* The default constructor.
@@ -78,11 +82,11 @@
* Sets the default FileTypeMap for the system. This instance
* will be returned to callers of getDefaultFileTypeMap.
*
- * @param map The FileTypeMap.
+ * @param fileTypeMap The FileTypeMap.
* @exception SecurityException if the caller doesn't have permission
* to change the default
*/
- public static void setDefaultFileTypeMap(FileTypeMap map) {
+ public static synchronized void setDefaultFileTypeMap(FileTypeMap fileTypeMap) {
SecurityManager security = System.getSecurityManager();
if (security != null) {
try {
@@ -90,14 +94,17 @@
security.checkSetFactory();
} catch (SecurityException ex) {
// otherwise, we also allow it if this code and the
- // factory come from the same class loader (e.g.,
+ // factory come from the same (non-system) class loader (e.g.,
// the JAF classes were loaded with the applet classes).
- if (FileTypeMap.class.getClassLoader() !=
- map.getClass().getClassLoader())
+ if (FileTypeMap.class.getClassLoader() == null ||
+ FileTypeMap.class.getClassLoader() !=
+ fileTypeMap.getClass().getClassLoader())
throw ex;
}
}
- defaultMap = map;
+ // remove any per-thread-context-class-loader FileTypeMap
+ map.remove(SecuritySupport.getContextClassLoader());
+ defaultMap = fileTypeMap;
}
/**
@@ -109,10 +116,17 @@
* @return The default FileTypeMap
* @see javax.activation.FileTypeMap#setDefaultFileTypeMap
*/
- public static FileTypeMap getDefaultFileTypeMap() {
- // XXX - probably should be synchronized
- if (defaultMap == null)
- defaultMap = new MimetypesFileTypeMap();
- return defaultMap;
+ public static synchronized FileTypeMap getDefaultFileTypeMap() {
+ if (defaultMap != null)
+ return defaultMap;
+
+ // fetch per-thread-context-class-loader default
+ ClassLoader tccl = SecuritySupport.getContextClassLoader();
+ FileTypeMap def = map.get(tccl);
+ if (def == null) {
+ def = new MimetypesFileTypeMap();
+ map.put(tccl, def);
+ }
+ return def;
}
}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaf_classes/javax/activation/MailcapCommandMap.java
--- a/jaxws/src/share/jaf_classes/javax/activation/MailcapCommandMap.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaf_classes/javax/activation/MailcapCommandMap.java Tue Apr 29 14:40:07 2014 -0700
@@ -120,11 +120,7 @@
public class MailcapCommandMap extends CommandMap {
/*
* We manage a collection of databases, searched in order.
- * The default database is shared between all instances
- * of this class.
- * XXX - Can we safely share more databases between instances?
*/
- private static MailcapFile defDB = null;
private MailcapFile[] DB;
private static final int PROG = 0; // programmatically added entries
@@ -164,14 +160,10 @@
loadAllResources(dbv, "META-INF/mailcap");
LogSupport.log("MailcapCommandMap: load DEF");
- synchronized (MailcapCommandMap.class) {
- // see if another instance has created this yet.
- if (defDB == null)
- defDB = loadResource("/META-INF/mailcap.default");
- }
+ mf = loadResource("/META-INF/mailcap.default");
- if (defDB != null)
- dbv.add(defDB);
+ if (mf != null)
+ dbv.add(mf);
DB = new MailcapFile[dbv.size()];
DB = (MailcapFile[])dbv.toArray(DB);
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java
--- a/jaxws/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaf_classes/javax/activation/MimetypesFileTypeMap.java Tue Apr 29 14:40:07 2014 -0700
@@ -69,11 +69,7 @@
public class MimetypesFileTypeMap extends FileTypeMap {
/*
* We manage a collection of databases, searched in order.
- * The default database is shared between all instances
- * of this class.
- * XXX - Can we safely share more databases between instances?
*/
- private static MimeTypeFile defDB = null;
private MimeTypeFile[] DB;
private static final int PROG = 0; // programmatically added entries
@@ -114,14 +110,10 @@
loadAllResources(dbv, "META-INF/mime.types");
LogSupport.log("MimetypesFileTypeMap: load DEF");
- synchronized (MimetypesFileTypeMap.class) {
- // see if another instance has created this yet.
- if (defDB == null)
- defDB = loadResource("/META-INF/mimetypes.default");
- }
+ mf = loadResource("/META-INF/mimetypes.default");
- if (defDB != null)
- dbv.addElement(defDB);
+ if (mf != null)
+ dbv.addElement(mf);
DB = new MimeTypeFile[dbv.size()];
dbv.copyInto(DB);
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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.internal.ws.wsdl.parser;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap CACHE = new WeakHashMap();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/ContextClassloaderLocal.properties Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java
--- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/Internalizer.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -60,12 +60,10 @@
*/
public class Internalizer {
- private static final XPathFactory xpf = XmlUtil.newXPathFactory(true);
- private final XPath xpath = xpf.newXPath();
+ private final XPath xpath = xpf.get().newXPath();
private final DOMForest forest;
private final ErrorReceiver errorReceiver;
-
public Internalizer(DOMForest forest, WsimportOptions options, ErrorReceiver errorReceiver) {
this.forest = forest;
this.errorReceiver = errorReceiver;
@@ -77,6 +75,12 @@
}
}
+ private static final ContextClassloaderLocal xpf = new ContextClassloaderLocal() {
+ @Override
+ protected XPathFactory initialValue() throws Exception {
+ return XPathFactory.newInstance();
+ }
+ };
/**
* Validates attributes of a <JAXWS:bindings> element.
*/
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java
--- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/JAXWSBindingExtensionHandler.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -54,8 +54,14 @@
public class JAXWSBindingExtensionHandler extends AbstractExtensionHandler {
// xml security enabled always, xpath used for parsing "part" attribute
- private static final XPathFactory xpf = XmlUtil.newXPathFactory(true);
- private final XPath xpath = xpf.newXPath();
+ private static final ContextClassloaderLocal xpf = new ContextClassloaderLocal() {
+ @Override
+ protected XPathFactory initialValue() throws Exception {
+ return XPathFactory.newInstance();
+ }
+ };
+
+ private final XPath xpath = xpf.get().newXPath();
public JAXWSBindingExtensionHandler(Map extensionHandlerMap) {
super(extensionHandlerMap);
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java
--- a/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/internalizer/Internalizer.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -76,8 +76,6 @@
private static final String WSDL_NS = "http://schemas.xmlsoap.org/wsdl/";
- private static XPathFactory xpf = null;
-
private final XPath xpath;
/**
@@ -99,12 +97,7 @@
this.errorHandler = forest.getErrorHandler();
this.forest = forest;
this.enableSCD = enableSCD;
- synchronized (this) {
- if (xpf == null) {
- xpf = XmlFactory.createXPathFactory(disableSecureProcessing);
- }
- }
- xpath = xpf.newXPath();
+ xpath = XmlFactory.createXPathFactory(disableSecureProcessing).newXPath();
}
/**
@@ -170,7 +163,6 @@
if( a.getLocalName().equals("multiple") ) //
continue;
-
// TODO: flag error for this undefined attribute
}
}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/DatatypeConverterImpl.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -27,9 +27,14 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Calendar;
+import java.util.Collections;
import java.util.GregorianCalendar;
+import java.util.Map;
import java.util.TimeZone;
+import java.util.WeakHashMap;
import javax.xml.bind.DatatypeConverter;
import javax.xml.bind.DatatypeConverterInterface;
@@ -356,7 +361,7 @@
public static GregorianCalendar _parseDateTime(CharSequence s) {
String val = WhiteSpaceProcessor.trim(s).toString();
- return datatypeFactory.newXMLGregorianCalendar(val).toGregorianCalendar();
+ return getDatatypeFactory().newXMLGregorianCalendar(val).toGregorianCalendar();
}
public static String _printDateTime(Calendar val) {
@@ -722,14 +727,30 @@
}
return false;
}
- private static final DatatypeFactory datatypeFactory;
+
+ private static final Map DF_CACHE = Collections.synchronizedMap(new WeakHashMap());
- static {
- try {
- datatypeFactory = DatatypeFactory.newInstance();
- } catch (DatatypeConfigurationException e) {
- throw new Error(e);
+ public static DatatypeFactory getDatatypeFactory() {
+ ClassLoader tccl = AccessController.doPrivileged(new PrivilegedAction() {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ DatatypeFactory df = DF_CACHE.get(tccl);
+ if (df == null) {
+ synchronized (DatatypeConverterImpl.class) {
+ df = DF_CACHE.get(tccl);
+ if (df == null) { // to prevent multiple initialization
+ try {
+ df = DatatypeFactory.newInstance();
+ } catch (DatatypeConfigurationException e) {
+ throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e);
+ }
+ DF_CACHE.put(tccl, df);
+ }
+ }
}
+ return df;
}
private static final class CalendarFormatter {
@@ -1045,7 +1066,7 @@
@Deprecated
public Calendar parseTime(String lexicalXSDTime) {
- return datatypeFactory.newXMLGregorianCalendar(lexicalXSDTime).toGregorianCalendar();
+ return getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDTime).toGregorianCalendar();
}
@Deprecated
@@ -1055,7 +1076,7 @@
@Deprecated
public Calendar parseDate(String lexicalXSDDate) {
- return datatypeFactory.newXMLGregorianCalendar(lexicalXSDDate).toGregorianCalendar();
+ return getDatatypeFactory().newXMLGregorianCalendar(lexicalXSDDate).toGregorianCalendar();
}
@Deprecated
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,48 @@
+/*
+ * 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.xml.internal.bind;
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+/**
+ * Message resources
+ */
+enum Messages {
+ FAILED_TO_INITIALE_DATATYPE_FACTORY, // 0 args
+ ;
+
+ private static final ResourceBundle rb = ResourceBundle.getBundle(Messages.class.getName());
+
+ @Override
+ public String toString() {
+ return format();
+ }
+
+ public String format( Object... args ) {
+ return MessageFormat.format( rb.getString(name()), args );
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/Messages.properties Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+
+FAILED_TO_INITIALE_DATATYPE_FACTORY = \
+ Failed to initialize JAXP 1.3 DatatypeFactory class.
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/Messages.java Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, 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
@@ -60,7 +60,6 @@
PROPERTY_ORDER_CONTAINS_UNUSED_ENTRY, // 2 args
INVALID_XML_ENUM_VALUE, // 2 arg
- FAILED_TO_INITIALE_DATATYPE_FACTORY, // 0 args
NO_IMAGE_WRITER, // 1 arg
ILLEGAL_MIME_TYPE, // 2 args
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/model/impl/RuntimeBuiltinLeafInfoImpl.java Tue Apr 29 14:40:07 2014 -0700
@@ -63,9 +63,7 @@
import javax.imageio.stream.ImageOutputStream;
import javax.xml.bind.ValidationEvent;
import javax.xml.bind.helpers.ValidationEventImpl;
-import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeConstants;
-import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
@@ -574,7 +572,8 @@
public XMLGregorianCalendar parse(CharSequence lexical) throws SAXException {
try {
- return datatypeFactory.newXMLGregorianCalendar(lexical.toString().trim()); // (.trim() - issue 396)
+ return DatatypeConverterImpl.getDatatypeFactory()
+ .newXMLGregorianCalendar(lexical.toString().trim()); // (.trim() - issue 396)
} catch (Exception e) {
UnmarshallingContext.getInstance().handleError(e);
return null;
@@ -844,7 +843,7 @@
public Duration parse(CharSequence lexical) {
TODO.checkSpec("JSR222 Issue #42");
- return datatypeFactory.newDuration(lexical.toString());
+ return DatatypeConverterImpl.getDatatypeFactory().newDuration(lexical.toString());
}
});
primaryList.add(
@@ -885,21 +884,6 @@
}
}
-
- /**
- * Cached instance of {@link DatatypeFactory} to create
- * {@link XMLGregorianCalendar} and {@link Duration}.
- */
- private static final DatatypeFactory datatypeFactory = init();
-
- private static DatatypeFactory init() {
- try {
- return DatatypeFactory.newInstance();
- } catch (DatatypeConfigurationException e) {
- throw new Error(Messages.FAILED_TO_INITIALE_DATATYPE_FACTORY.format(),e);
- }
- }
-
private static void checkXmlGregorianCalendarFieldRef(QName type,
XMLGregorianCalendar cal)throws javax.xml.bind.MarshalException{
StringBuilder buf = new StringBuilder();
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/JAXBContextImpl.java Tue Apr 29 14:40:07 2014 -0700
@@ -129,14 +129,6 @@
private final Map bridges = new LinkedHashMap();
/**
- * Shared instance of {@link TransformerFactory}.
- * Lock before use, because a {@link TransformerFactory} is not thread-safe
- * whereas {@link JAXBContextImpl} is.
- * Lazily created.
- */
- private volatile static SAXTransformerFactory tf;
-
- /**
* Shared instance of {@link DocumentBuilder}.
* Lock before use. Lazily created.
*/
@@ -705,13 +697,7 @@
*/
static Transformer createTransformer(boolean disableSecureProcessing) {
try {
- if (tf==null) {
- synchronized(JAXBContextImpl.class) {
- if (tf==null) {
- tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing);
- }
- }
- }
+ SAXTransformerFactory tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing);
return tf.newTransformer();
} catch (TransformerConfigurationException e) {
throw new Error(e); // impossible
@@ -723,13 +709,7 @@
*/
public static TransformerHandler createTransformerHandler(boolean disableSecureProcessing) {
try {
- if (tf==null) {
- synchronized(JAXBContextImpl.class) {
- if (tf==null) {
- tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing);
- }
- }
- }
+ SAXTransformerFactory tf = (SAXTransformerFactory)XmlFactory.createTransformerFactory(disableSecureProcessing);
return tf.newTransformerHandler();
} catch (TransformerConfigurationException e) {
throw new Error(e); // impossible
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Messages.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Messages.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/Messages.java Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, 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
@@ -58,6 +58,7 @@
FAILED_TO_GENERATE_SCHEMA, // 0 args
ERROR_PROCESSING_SCHEMA, // 0 args
ILLEGAL_CONTENT, // 2 args
+ FAILED_TO_INITIALE_DATATYPE_FACTORY, // 2 args
;
private static final ResourceBundle rb = ResourceBundle.getBundle(Messages.class.getName());
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/output/XMLStreamWriterOutput.java Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, 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
@@ -153,7 +153,6 @@
}
}
-
/**
* Reference to FI's XMLStreamWriter class, if FI can be loaded.
*/
@@ -162,9 +161,8 @@
private static Class initFIStAXWriterClass() {
try {
- ClassLoader loader = getClassLoader();
- Class llfisw = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.stax.LowLevelFastInfosetStreamWriter", true, loader);
- Class sds = loader.loadClass("com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer");
+ Class> llfisw = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.stax.LowLevelFastInfosetStreamWriter");
+ Class> sds = Class.forName("com.sun.xml.internal.fastinfoset.stax.StAXDocumentSerializer");
// Check if StAXDocumentSerializer implements LowLevelFastInfosetStreamWriter
if (llfisw.isAssignableFrom(sds))
return sds;
@@ -179,8 +177,7 @@
try {
if (FI_STAX_WRITER_CLASS == null)
return null;
- ClassLoader loader = getClassLoader();
- Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.FastInfosetStreamWriterOutput", true, loader);
+ Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.FastInfosetStreamWriterOutput");
return c.getConstructor(FI_STAX_WRITER_CLASS, JAXBContextImpl.class);
} catch (Throwable e) {
return null;
@@ -195,8 +192,7 @@
private static Class initStAXExWriterClass() {
try {
- ClassLoader loader = getClassLoader();
- return Class.forName("com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx",true,loader);
+ return Class.forName("com.sun.xml.internal.org.jvnet.staxex.XMLStreamWriterEx");
} catch (Throwable e) {
return null;
}
@@ -204,20 +200,11 @@
private static Constructor extends XmlOutput> initStAXExOutputClass() {
try {
- ClassLoader loader = getClassLoader();
- Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.StAXExStreamWriterOutput",true, loader);
+ Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.output.StAXExStreamWriterOutput");
return c.getConstructor(STAXEX_WRITER_CLASS);
} catch (Throwable e) {
return null;
}
}
- private static ClassLoader getClassLoader() {
- ClassLoader cl = SecureLoader.getClassClassLoader(UnmarshallerImpl.class);
- if (cl == null) {
- cl = SecureLoader.getContextClassLoader();
- }
- return cl;
- }
-
}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Messages.properties
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Messages.properties Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/reflect/Messages.properties Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 1997, 2012, 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
@@ -38,3 +38,6 @@
NO_GETTER = \
The property has a setter "{0}" but no getter. \
For marshaller, please define getters.
+
+INVALID_XML_ENUM_VALUE = \
+ "{0}" is not a valid value for {1}.
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXStreamConnector.java Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, 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
@@ -336,9 +336,8 @@
private static Class initFIStAXReaderClass() {
try {
- ClassLoader cl = getClassLoader();
- Class fisr = cl.loadClass("com.sun.xml.internal.org.jvnet.fastinfoset.stax.FastInfosetStreamReader");
- Class sdp = cl.loadClass("com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser");
+ Class> fisr = Class.forName("com.sun.xml.internal.org.jvnet.fastinfoset.stax.FastInfosetStreamReader");
+ Class> sdp = Class.forName("com.sun.xml.internal.fastinfoset.stax.StAXDocumentParser");
// Check if StAXDocumentParser implements FastInfosetStreamReader
if (fisr.isAssignableFrom(sdp))
return sdp;
@@ -354,7 +353,7 @@
if (FI_STAX_READER_CLASS == null)
return null;
- Class c = getClassLoader().loadClass(
+ Class c = Class.forName(
"com.sun.xml.internal.bind.v2.runtime.unmarshaller.FastInfosetConnector");
return c.getConstructor(FI_STAX_READER_CLASS,XmlVisitor.class);
} catch (Throwable e) {
@@ -370,7 +369,7 @@
private static Class initStAXExReader() {
try {
- return getClassLoader().loadClass("com.sun.xml.internal.org.jvnet.staxex.XMLStreamReaderEx");
+ return Class.forName("com.sun.xml.internal.org.jvnet.staxex.XMLStreamReaderEx");
} catch (Throwable e) {
return null;
}
@@ -378,19 +377,11 @@
private static Constructor extends StAXConnector> initStAXExConnector() {
try {
- Class c = getClassLoader().loadClass("com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXExConnector");
+ Class c = Class.forName("com.sun.xml.internal.bind.v2.runtime.unmarshaller.StAXExConnector");
return c.getConstructor(STAX_EX_READER_CLASS,XmlVisitor.class);
} catch (Throwable e) {
return null;
}
}
- private static ClassLoader getClassLoader() {
- ClassLoader cl = SecureLoader.getClassClassLoader(UnmarshallerImpl.class);
- if (cl == null) {
- cl = SecureLoader.getContextClassLoader();
- }
- return cl;
- }
-
}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/AttachmentPartImpl.java Tue Apr 29 14:40:07 2014 -0700
@@ -62,61 +62,6 @@
Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
"com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
- static {
- try {
- CommandMap map = CommandMap.getDefaultCommandMap();
- if (map instanceof MailcapCommandMap) {
- MailcapCommandMap mailMap = (MailcapCommandMap) map;
- String hndlrStr = ";;x-java-content-handler=";
- mailMap.addMailcap(
- "text/xml"
- + hndlrStr
- + "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler");
- mailMap.addMailcap(
- "application/xml"
- + hndlrStr
- + "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler");
- mailMap.addMailcap(
- "application/fastinfoset"
- + hndlrStr
- + "com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler");
- /* Image DataContentHandler handles all image types
- mailMap.addMailcap(
- "image/jpeg"
- + hndlrStr
- + "com.sun.xml.internal.messaging.saaj.soap.JpegDataContentHandler");
- mailMap.addMailcap(
- "image/gif"
- + hndlrStr
- + "com.sun.xml.internal.messaging.saaj.soap.GifDataContentHandler"); */
- /*mailMap.addMailcap(
- "multipart/*"
- + hndlrStr
- + "com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler");*/
- mailMap.addMailcap(
- "image/*"
- + hndlrStr
- + "com.sun.xml.internal.messaging.saaj.soap.ImageDataContentHandler");
- mailMap.addMailcap(
- "text/plain"
- + hndlrStr
- + "com.sun.xml.internal.messaging.saaj.soap.StringDataContentHandler");
- } else {
- throw new SOAPExceptionImpl("Default CommandMap is not a MailcapCommandMap");
- }
- } catch (Throwable t) {
- log.log(
- Level.SEVERE,
- "SAAJ0508.soap.cannot.register.handlers",
- t);
- if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- } else {
- throw new RuntimeException(t.getLocalizedMessage());
- }
- }
- };
-
private final MimeHeaders headers;
private MimeBodyPart rawContent = null;
private DataHandler dataHandler = null;
@@ -126,6 +71,12 @@
public AttachmentPartImpl() {
headers = new MimeHeaders();
+
+ // initialization from here should cover most of cases;
+ // if not, it would be necessary to call
+ // AttachmentPartImpl.initializeJavaActivationHandlers()
+ // explicitly by programmer
+ initializeJavaActivationHandlers();
}
public AttachmentPartImpl(MIMEPart part) {
@@ -619,4 +570,43 @@
return headers;
}
+ public static void initializeJavaActivationHandlers() {
+ // DataHandler.writeTo() may search for DCH. So adding some default ones.
+ try {
+ CommandMap map = CommandMap.getDefaultCommandMap();
+ if (map instanceof MailcapCommandMap) {
+ MailcapCommandMap mailMap = (MailcapCommandMap) map;
+
+ // registering our DCH since javamail's DCH doesn't handle
+ if (!cmdMapInitialized(mailMap)) {
+ mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler");
+ mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler");
+ mailMap.addMailcap("application/fastinfoset;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler");
+ mailMap.addMailcap("multipart/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.MultipartDataContentHandler");
+ mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.ImageDataContentHandler");
+ mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.messaging.saaj.soap.StringDataContentHandler");
+ }
+ }
+ } catch (Throwable t) {
+ // ignore the exception.
+ }
+ }
+
+ private static boolean cmdMapInitialized(MailcapCommandMap mailMap) {
+
+ // checking fastinfoset handler, since this one is specific to SAAJ
+ CommandInfo[] commands = mailMap.getAllCommands("application/fastinfoset");
+ if (commands == null || commands.length == 0) {
+ return false;
+ }
+
+ String saajClassName = "com.sun.xml.internal.ws.binding.FastInfosetDataContentHandler";
+ for (CommandInfo command : commands) {
+ String commandClass = command.getCommandClass();
+ if (saajClassName.equals(commandClass)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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.xml.internal.messaging.saaj.soap;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap CACHE = new WeakHashMap();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.properties Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java Tue Apr 29 14:40:07 2014 -0700
@@ -25,7 +25,14 @@
package com.sun.xml.internal.messaging.saaj.soap;
-import java.util.logging.Logger;
+import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
+import com.sun.xml.internal.messaging.saaj.util.JAXMStreamSource;
+import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
+import com.sun.xml.internal.messaging.saaj.util.ParserPool;
+import com.sun.xml.internal.messaging.saaj.util.RejectDoctypeSaxFilter;
+import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
import javax.xml.parsers.SAXParser;
import javax.xml.soap.SOAPException;
@@ -39,13 +46,10 @@
import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamSource;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
+import com.sun.xml.internal.messaging.saaj.LazyEnvelopeSource;
+import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer;
-import com.sun.xml.internal.messaging.saaj.LazyEnvelopeSource;
-import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
-import com.sun.xml.internal.messaging.saaj.util.*;
-import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer;
+import java.util.logging.Logger;
/**
* EnvelopeFactory creates SOAP Envelope objects using different
@@ -54,10 +58,16 @@
public class EnvelopeFactory {
protected static final Logger
- log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
- "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
+ log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
+ "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
- private static ParserPool parserPool = new ParserPool(5);
+ private static ContextClassloaderLocal parserPool =
+ new ContextClassloaderLocal() {
+ @Override
+ protected ParserPool initialValue() throws Exception {
+ return new ParserPool(5);
+ }
+ };
public static Envelope createEnvelope(Source src, SOAPPartImpl soapPart)
throws SOAPException
@@ -130,15 +140,15 @@
SAXParser saxParser = null;
if (src instanceof StreamSource) {
try {
- saxParser = parserPool.get();
+ saxParser = parserPool.get().get();
} catch (Exception e) {
log.severe("SAAJ0601.util.newSAXParser.exception");
throw new SOAPExceptionImpl(
- "Couldn't get a SAX parser while constructing a envelope",
- e);
+ "Couldn't get a SAX parser while constructing a envelope",
+ e);
}
InputSource is = SAXSource.sourceToInputSource(src);
- if (is.getEncoding()== null && soapPart.getSourceCharsetEncoding() != null) {
+ if (is.getEncoding() == null && soapPart.getSourceCharsetEncoding() != null) {
is.setEncoding(soapPart.getSourceCharsetEncoding());
}
XMLReader rejectFilter;
@@ -147,15 +157,15 @@
} catch (Exception ex) {
log.severe("SAAJ0510.soap.cannot.create.envelope");
throw new SOAPExceptionImpl(
- "Unable to create envelope from given source: ",
- ex);
+ "Unable to create envelope from given source: ",
+ ex);
}
src = new SAXSource(rejectFilter, is);
}
try {
Transformer transformer =
- EfficientStreamingTransformer.newTransformer();
+ EfficientStreamingTransformer.newTransformer();
DOMResult result = new DOMResult(soapPart);
transformer.transform(src, result);
@@ -167,11 +177,11 @@
}
log.severe("SAAJ0511.soap.cannot.create.envelope");
throw new SOAPExceptionImpl(
- "Unable to create envelope from given source: ",
- ex);
+ "Unable to create envelope from given source: ",
+ ex);
} finally {
if (saxParser != null) {
- parserPool.returnParser(saxParser);
+ parserPool.get().returnParser(saxParser);
}
}
}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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.xml.internal.stream.buffer;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap CACHE = new WeakHashMap();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/ContextClassloaderLocal.properties Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/stream/buffer/XMLStreamBuffer.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -370,7 +370,12 @@
writeTo(handler, errorHandler, isFragment());
}
- private static final TransformerFactory trnsformerFactory = TransformerFactory.newInstance();
+ private static final ContextClassloaderLocal trnsformerFactory = new ContextClassloaderLocal() {
+ @Override
+ protected TransformerFactory initialValue() throws Exception {
+ return TransformerFactory.newInstance();
+ }
+ };
/**
* Writes out the contents of this buffer as DOM node and append that to the given node.
@@ -382,7 +387,7 @@
*/
public final Node writeTo(Node n) throws XMLStreamBufferException {
try {
- Transformer t = trnsformerFactory.newTransformer();
+ Transformer t = trnsformerFactory.get().newTransformer();
t.transform(new XMLStreamBufferSource(this), new DOMResult(n));
return n.getLastChild();
} catch (TransformerException e) {
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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.xml.internal.ws.api.streaming;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap CACHE = new WeakHashMap();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/ContextClassloaderLocal.properties Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamReaderFactory.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -63,39 +63,43 @@
private static final Logger LOGGER = Logger.getLogger(XMLStreamReaderFactory.class.getName());
+ private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory";
+
/**
* Singleton instance.
*/
- private static volatile @NotNull XMLStreamReaderFactory theInstance;
+ private static volatile ContextClassloaderLocal streamReader =
+ new ContextClassloaderLocal() {
- private static final String CLASS_NAME_OF_WSTXINPUTFACTORY = "com.ctc.wstx.stax.WstxInputFactory";
+ @Override
+ protected XMLStreamReaderFactory initialValue() {
- static {
- XMLInputFactory xif = getXMLInputFactory();
- XMLStreamReaderFactory f=null;
+ XMLInputFactory xif = getXMLInputFactory();
+ XMLStreamReaderFactory f=null;
- // this system property can be used to disable the pooling altogether,
- // in case someone hits an issue with pooling in the production system.
- if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) {
- f = Zephyr.newInstance(xif);
- }
+ // this system property can be used to disable the pooling altogether,
+ // in case someone hits an issue with pooling in the production system.
+ if(!getProperty(XMLStreamReaderFactory.class.getName()+".noPool")) {
+ f = Zephyr.newInstance(xif);
+ }
- if(f==null) {
- // is this Woodstox?
- if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) {
- f = new Woodstox(xif);
- }
- }
+ if(f==null) {
+ // is this Woodstox?
+ if (xif.getClass().getName().equals(CLASS_NAME_OF_WSTXINPUTFACTORY)) {
+ f = new Woodstox(xif);
+ }
+ }
- if (f==null) {
- f = new Default();
- }
+ if (f==null) {
+ f = new Default();
+ }
- theInstance = f;
- if (LOGGER.isLoggable(Level.FINE)) {
- LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", theInstance);
- }
- }
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "XMLStreamReaderFactory instance is = {0}", f);
+ }
+ return f;
+ }
+ };
private static XMLInputFactory getXMLInputFactory() {
XMLInputFactory xif = null;
@@ -126,11 +130,11 @@
if(f==null) {
throw new IllegalArgumentException();
}
- theInstance = f;
+ streamReader.set(f);
}
public static XMLStreamReaderFactory get() {
- return theInstance;
+ return streamReader.get();
}
public static XMLStreamReader create(InputSource source, boolean rejectDTDs) {
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/api/streaming/XMLStreamWriterFactory.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -62,52 +62,54 @@
/**
* Singleton instance.
*/
- private static volatile @NotNull XMLStreamWriterFactory theInstance;
-
+ private static volatile ContextClassloaderLocal writerFactory =
+ new ContextClassloaderLocal() {
- static {
- XMLOutputFactory xof = null;
- if (Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".woodstox")) {
- try {
- xof = (XMLOutputFactory)Class.forName("com.ctc.wstx.stax.WstxOutputFactory").newInstance();
- } catch (Exception e) {
- // Ignore and fallback to default XMLOutputFactory
+ @Override
+ protected XMLStreamWriterFactory initialValue() {
+ XMLOutputFactory xof = null;
+ if (Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".woodstox")) {
+ try {
+ xof = (XMLOutputFactory)Class.forName("com.ctc.wstx.stax.WstxOutputFactory").newInstance();
+ } catch (Exception e) {
+ // Ignore and fallback to default XMLOutputFactory
+ }
}
- }
- if (xof == null) {
- xof = XMLOutputFactory.newInstance();
- }
+ if (xof == null) {
+ xof = XMLOutputFactory.newInstance();
+ }
- XMLStreamWriterFactory f=null;
+ XMLStreamWriterFactory f=null;
- // this system property can be used to disable the pooling altogether,
- // in case someone hits an issue with pooling in the production system.
- if (!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) {
- try {
- Class> clazz = xof.createXMLStreamWriter(new StringWriter()).getClass();
- if (clazz.getName().startsWith("com.sun.xml.internal.stream.")) {
- f = new Zephyr(xof,clazz);
+ // this system property can be used to disable the pooling altogether,
+ // in case someone hits an issue with pooling in the production system.
+ if (!Boolean.getBoolean(XMLStreamWriterFactory.class.getName()+".noPool")) {
+ try {
+ Class> clazz = xof.createXMLStreamWriter(new StringWriter()).getClass();
+ if (clazz.getName().startsWith("com.sun.xml.internal.stream.")) {
+ f = new Zephyr(xof,clazz);
+ }
+ } catch (XMLStreamException ex) {
+ Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
+ } catch (NoSuchMethodException ex) {
+ Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
}
- } catch (XMLStreamException ex) {
- Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
- } catch (NoSuchMethodException ex) {
- Logger.getLogger(XMLStreamWriterFactory.class.getName()).log(Level.INFO, null, ex);
+ }
+
+ if(f==null) {
+ // is this Woodstox?
+ if(xof.getClass().getName().equals("com.ctc.wstx.stax.WstxOutputFactory"))
+ f = new NoLock(xof);
}
+ if (f == null)
+ f = new Default(xof);
+
+ if (LOGGER.isLoggable(Level.FINE)) {
+ LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f);
+ }
+ return f;
}
-
- if(f==null) {
- // is this Woodstox?
- if(xof.getClass().getName().equals("com.ctc.wstx.stax.WstxOutputFactory"))
- f = new NoLock(xof);
- }
- if (f == null)
- f = new Default(xof);
-
- theInstance = f;
- if (LOGGER.isLoggable(Level.FINE)) {
- LOGGER.log(Level.FINE, "XMLStreamWriterFactory instance is = {0}", f);
- }
- }
+ };
/**
* See {@link #create(OutputStream)} for the contract.
@@ -170,7 +172,7 @@
* Gets the singleton instance.
*/
public static @NotNull XMLStreamWriterFactory get() {
- return theInstance;
+ return writerFactory.get();
}
/**
@@ -183,7 +185,7 @@
@SuppressWarnings({"null", "ConstantConditions"})
public static void set(@NotNull XMLStreamWriterFactory f) {
if(f==null) throw new IllegalArgumentException();
- theInstance = f;
+ writerFactory.set(f);
}
/**
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/binding/BindingImpl.java Tue Apr 29 14:40:07 2014 -0700
@@ -37,6 +37,9 @@
import com.sun.xml.internal.ws.developer.MemberSubmissionAddressingFeature;
import com.sun.xml.internal.ws.developer.BindingTypeFeature;
+import javax.activation.CommandInfo;
+import javax.activation.CommandMap;
+import javax.activation.MailcapCommandMap;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceFeature;
@@ -151,12 +154,61 @@
return addressingVersion;
}
- public final
@NotNull
- Codec createCodec() {
+ public final Codec createCodec() {
+
+ // initialization from here should cover most of cases;
+ // if not, it would be necessary to call
+ // BindingImpl.initializeJavaActivationHandlers()
+ // explicitly by programmer
+ initializeJavaActivationHandlers();
+
return bindingId.createEncoder(this);
}
+ public static void initializeJavaActivationHandlers() {
+ // DataHandler.writeTo() may search for DCH. So adding some default ones.
+ try {
+ CommandMap map = CommandMap.getDefaultCommandMap();
+ if (map instanceof MailcapCommandMap) {
+ MailcapCommandMap mailMap = (MailcapCommandMap) map;
+
+ // registering our DCH since javamail's DCH doesn't handle
+ if (!cmdMapInitialized(mailMap)) {
+ mailMap.addMailcap("text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler");
+ mailMap.addMailcap("application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler");
+ mailMap.addMailcap("image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler");
+ mailMap.addMailcap("text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler");
+ }
+ }
+ } catch (Throwable t) {
+ // ignore the exception.
+ }
+ }
+
+ private static boolean cmdMapInitialized(MailcapCommandMap mailMap) {
+ CommandInfo[] commands = mailMap.getAllCommands("text/xml");
+ if (commands == null || commands.length == 0) {
+ return false;
+ }
+
+ // SAAJ RI implements it's own DataHandlers which can be used for JAX-WS too;
+ // see com.sun.xml.internal.messaging.saaj.soap.AttachmentPartImpl#initializeJavaActivationHandlers
+ // so if found any of SAAJ or our own handler registered, we are ok; anyway using SAAJ directly here
+ // is not good idea since we don't want standalone JAX-WS to depend on specific SAAJ impl.
+ // This is also reason for duplication of Handler's code by JAX-WS
+ String saajClassName = "com.sun.xml.internal.messaging.saaj.soap.XmlDataContentHandler";
+ String jaxwsClassName = "com.sun.xml.internal.ws.encoding.XmlDataContentHandler";
+ for (CommandInfo command : commands) {
+ String commandClass = command.getCommandClass();
+ if (saajClassName.equals(commandClass) ||
+ jaxwsClassName.equals(commandClass)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public static BindingImpl create(@NotNull BindingID bindingId) {
if (bindingId.equals(BindingID.XML_HTTP))
return new HTTPBindingImpl();
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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.xml.internal.ws.commons.xmlutil;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap CACHE = new WeakHashMap();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/ContextClassloaderLocal.properties Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/commons/xmlutil/Converter.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -53,7 +53,12 @@
// prevents instantiation
}
private static final Logger LOGGER = Logger.getLogger(Converter.class);
- private static final XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance();
+ private static final ContextClassloaderLocal xmlOutputFactory = new ContextClassloaderLocal() {
+ @Override
+ protected XMLOutputFactory initialValue() throws Exception {
+ return XMLOutputFactory.newInstance();
+ }
+ };
private static final AtomicBoolean logMissingStaxUtilsWarning = new AtomicBoolean(false);
/**
@@ -110,7 +115,7 @@
stringOut = new StringWriter();
XMLStreamWriter writer = null;
try {
- writer = xmlOutputFactory.createXMLStreamWriter(stringOut);
+ writer = xmlOutputFactory.get().createXMLStreamWriter(stringOut);
if (createIndenter) {
writer = createIndenter(writer);
}
@@ -143,7 +148,7 @@
try {
if (message != null) {
- XMLStreamWriter xsw = xmlOutputFactory.createXMLStreamWriter(baos, encoding);
+ XMLStreamWriter xsw = xmlOutputFactory.get().createXMLStreamWriter(baos, encoding);
try {
message.writeTo(xsw);
} finally {
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/ContextClassloaderLocal.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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.xml.internal.ws.developer;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap CACHE = new WeakHashMap();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/developer/MemberSubmissionEndpointReference.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -64,7 +64,12 @@
@XmlType(name = "EndpointReferenceType", namespace = MemberSubmissionEndpointReference.MSNS)
public final class MemberSubmissionEndpointReference extends EndpointReference implements MemberSubmissionAddressingConstants {
- private final static JAXBContext msjc = MemberSubmissionEndpointReference.getMSJaxbContext();
+ private final static ContextClassloaderLocal msjc = new ContextClassloaderLocal() {
+ @Override
+ protected JAXBContext initialValue() throws Exception {
+ return MemberSubmissionEndpointReference.getMSJaxbContext();
+ }
+ };
public MemberSubmissionEndpointReference() {
}
@@ -86,7 +91,7 @@
}
try {
- Unmarshaller unmarshaller = MemberSubmissionEndpointReference.msjc.createUnmarshaller();
+ Unmarshaller unmarshaller = MemberSubmissionEndpointReference.msjc.get().createUnmarshaller();
MemberSubmissionEndpointReference epr = unmarshaller.unmarshal(source,MemberSubmissionEndpointReference.class).getValue();
this.addr = epr.addr;
@@ -106,7 +111,7 @@
@Override
public void writeTo(Result result) {
try {
- Marshaller marshaller = MemberSubmissionEndpointReference.msjc.createMarshaller();
+ Marshaller marshaller = MemberSubmissionEndpointReference.msjc.get().createMarshaller();
//marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
marshaller.marshal(this, result);
} catch (JAXBException e) {
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/encoding/MimeCodec.java Tue Apr 29 14:40:07 2014 -0700
@@ -34,8 +34,6 @@
import com.sun.xml.internal.ws.api.pipe.Codec;
import com.sun.xml.internal.ws.api.pipe.ContentType;
import com.sun.xml.internal.ws.developer.StreamingAttachmentFeature;
-import javax.activation.CommandMap;
-import javax.activation.MailcapCommandMap;
import java.io.IOException;
import java.io.InputStream;
@@ -63,33 +61,6 @@
*/
abstract class MimeCodec implements Codec {
- static {
- // DataHandler.writeTo() may search for DCH. So adding some default ones.
- try {
- CommandMap map = CommandMap.getDefaultCommandMap();
- if (map instanceof MailcapCommandMap) {
- MailcapCommandMap mailMap = (MailcapCommandMap) map;
- String hndlrStr = ";;x-java-content-handler=";
- // registering our DCH since javamail's DCH doesn't handle
- // Source
- mailMap.addMailcap(
- "text/xml" + hndlrStr + XmlDataContentHandler.class.getName());
- mailMap.addMailcap(
- "application/xml" + hndlrStr + XmlDataContentHandler.class.getName());
- if (map.createDataContentHandler("image/*") == null) {
- mailMap.addMailcap(
- "image/*" + hndlrStr + ImageDataContentHandler.class.getName());
- }
- if (map.createDataContentHandler("text/plain") == null) {
- mailMap.addMailcap(
- "text/plain" + hndlrStr + StringDataContentHandler.class.getName());
- }
- }
- } catch (Throwable t) {
- // ignore the exception.
- }
- }
-
public static final String MULTIPART_RELATED_MIME_TYPE = "multipart/related";
protected Codec mimeRootCodec;
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,84 @@
+/*
+ * 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.xml.internal.ws.policy.sourcemodel.attach;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap CACHE = new WeakHashMap();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return AccessController.doPrivileged(new PrivilegedAction() {
+ public ClassLoader run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ContextClassloaderLocal.properties Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+
+# Error messages for ContextClassloaderLocal utility class
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/sourcemodel/attach/ExternalAttachmentsUnmarshaller.java Tue Apr 29 14:40:07 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2012, 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
@@ -83,7 +83,13 @@
private static final QName POLICY = new QName("http://www.w3.org/ns/ws-policy", "Policy");
private static final QName URI = new QName("http://www.w3.org/ns/ws-policy", "URI");
private static final QName POLICIES = new QName(PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "Policies");
- private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance();
+ private static final ContextClassloaderLocal XML_INPUT_FACTORY = new ContextClassloaderLocal() {
+ @Override
+ protected XMLInputFactory initialValue() throws Exception {
+ return XMLInputFactory.newInstance();
+ }
+ };
+
private static final PolicyModelUnmarshaller POLICY_UNMARSHALLER = PolicyModelUnmarshaller.getXmlUnmarshaller();
private final Map map = new HashMap();
@@ -93,7 +99,7 @@
public static Map unmarshal(final Reader source) throws PolicyException {
LOGGER.entering(source);
try {
- XMLEventReader reader = XML_INPUT_FACTORY.createXMLEventReader(source);
+ XMLEventReader reader = XML_INPUT_FACTORY.get().createXMLEventReader(source);
ExternalAttachmentsUnmarshaller instance = new ExternalAttachmentsUnmarshaller();
final Map map = instance.unmarshal(reader, null);
LOGGER.exiting(map);
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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.xml.internal.ws.spi;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap CACHE = new WeakHashMap();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ContextClassloaderLocal.properties Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/spi/ProviderImpl.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -80,7 +80,12 @@
*/
public class ProviderImpl extends Provider {
- private final static JAXBContext eprjc = getEPRJaxbContext();
+ private final static ContextClassloaderLocal eprjc = new ContextClassloaderLocal() {
+ @Override
+ protected JAXBContext initialValue() throws Exception {
+ return getEPRJaxbContext();
+ }
+ };
/**
* Convenient singleton instance.
@@ -148,7 +153,7 @@
return AccessController.doPrivileged(new PrivilegedAction() {
public EndpointReference run() {
try {
- Unmarshaller unmarshaller = eprjc.createUnmarshaller();
+ Unmarshaller unmarshaller = eprjc.get().createUnmarshaller();
return (EndpointReference) unmarshaller.unmarshal(eprInfoset);
} catch (JAXBException e) {
throw new WebServiceException("Error creating Marshaller or marshalling.", e);
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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.xml.internal.ws.util.xml;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap CACHE = new WeakHashMap();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/ContextClassloaderLocal.properties Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -215,20 +215,28 @@
}
}
- static final TransformerFactory transformerFactory = newTransformerFactory();
-
- static final SAXParserFactory saxParserFactory = newSAXParserFactory(true);
+ static final ContextClassloaderLocal transformerFactory = new ContextClassloaderLocal() {
+ @Override
+ protected TransformerFactory initialValue() throws Exception {
+ return TransformerFactory.newInstance();
+ }
+ };
- static {
- saxParserFactory.setNamespaceAware(true);
- }
+ static final ContextClassloaderLocal saxParserFactory = new ContextClassloaderLocal() {
+ @Override
+ protected SAXParserFactory initialValue() throws Exception {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ factory.setNamespaceAware(true);
+ return factory;
+ }
+ };
/**
* Creates a new identity transformer.
*/
public static Transformer newTransformer() {
try {
- return transformerFactory.newTransformer();
+ return transformerFactory.get().newTransformer();
} catch (TransformerConfigurationException tex) {
throw new IllegalStateException("Unable to create a JAXP transformer");
}
@@ -243,9 +251,9 @@
// work around a bug in JAXP in JDK6u4 and earlier where the namespace processing
// is not turned on by default
StreamSource ssrc = (StreamSource) src;
- TransformerHandler th = ((SAXTransformerFactory) transformerFactory).newTransformerHandler();
+ TransformerHandler th = ((SAXTransformerFactory) transformerFactory.get()).newTransformerHandler();
th.setResult(result);
- XMLReader reader = saxParserFactory.newSAXParser().getXMLReader();
+ XMLReader reader = saxParserFactory.get().newSAXParser().getXMLReader();
reader.setContentHandler(th);
reader.setProperty(LEXICAL_HANDLER_PROPERTY, th);
reader.parse(toInputSource(ssrc));
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * 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.xml.internal.xsom.util;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
+/**
+ * Simple utility ensuring that the value is cached only in case it is non-internal implementation
+ */
+abstract class ContextClassloaderLocal {
+
+ private static final String FAILED_TO_CREATE_NEW_INSTANCE = "FAILED_TO_CREATE_NEW_INSTANCE";
+
+ private WeakHashMap CACHE = new WeakHashMap();
+
+ public V get() throws Error {
+ ClassLoader tccl = getContextClassLoader();
+ V instance = CACHE.get(tccl);
+ if (instance == null) {
+ instance = createNewInstance();
+ CACHE.put(tccl, instance);
+ }
+ return instance;
+ }
+
+ public void set(V instance) {
+ CACHE.put(getContextClassLoader(), instance);
+ }
+
+ protected abstract V initialValue() throws Exception;
+
+ private V createNewInstance() {
+ try {
+ return initialValue();
+ } catch (Exception e) {
+ throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
+ }
+ }
+
+ private static String format(String property, Object... args) {
+ String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
+ return MessageFormat.format(text, args);
+ }
+
+ private static ClassLoader getContextClassLoader() {
+ return (ClassLoader)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ ClassLoader cl = null;
+ try {
+ cl = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException ex) {
+ }
+ return cl;
+ }
+ });
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/ContextClassloaderLocal.properties Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,26 @@
+#
+# 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.
+#
+
+FAILED_TO_CREATE_NEW_INSTANCE=Failed to create new instance of {0}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java
--- a/jaxws/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/com/sun/xml/internal/xsom/util/DomAnnotationParserFactory.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -63,10 +63,15 @@
}
public AnnotationParser create(boolean disableSecureProcessing) {
- return new AnnotationParserImpl();
+ return new AnnotationParserImpl(disableSecureProcessing);
}
- private static final SAXTransformerFactory stf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+ private static final ContextClassloaderLocal stf = new ContextClassloaderLocal() {
+ @Override
+ protected SAXTransformerFactory initialValue() throws Exception {
+ return (SAXTransformerFactory) SAXTransformerFactory.newInstance();
+ }
+ };
private static class AnnotationParserImpl extends AnnotationParser {
@@ -82,8 +87,9 @@
AnnotationParserImpl(boolean disableSecureProcessing) {
try {
- transformer = stf.newTransformerHandler();
- stf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, disableSecureProcessing);
+ SAXTransformerFactory factory = stf.get();
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, disableSecureProcessing);
+ transformer = factory.newTransformerHandler();
} catch (TransformerConfigurationException e) {
throw new Error(e); // impossible
}
diff -r 1d117d2dfe92 -r 2061862eb57c jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java
--- a/jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jaxws/src/share/jaxws_classes/javax/xml/ws/wsaddressing/W3CEndpointReference.java Tue Apr 29 14:40:07 2014 -0700
@@ -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
@@ -69,7 +69,7 @@
@XmlType(name="EndpointReferenceType",namespace=W3CEndpointReference.NS)
public final class W3CEndpointReference extends EndpointReference {
- private final static JAXBContext w3cjc = getW3CJaxbContext();
+ private final JAXBContext w3cjc = getW3CJaxbContext();
// should be changed to package private, keeping original modifier to keep backwards compatibility
protected static final String NS = "http://www.w3.org/2005/08/addressing";
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/.hgtags
--- a/jdk/.hgtags Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/.hgtags Tue Apr 29 14:40:07 2014 -0700
@@ -250,3 +250,6 @@
263198a1d8f1f4cb97d35f40c61704b08ebd3686 jdk9-b05
cac7b28b8b1e0e11d7a8e1ac1fe75a03b3749eab jdk9-b06
f4e624447514f12dd7c51f1e5b0cb97efcd15be2 jdk9-b07
+9e7bd44ea85c72318130379c34b98716b9c7c248 jdk9-b08
+2cef452ba711b17950da275fd15931925799f07c jdk9-b09
+ab06ba2894313a47e4969ca37792ff119c49e711 jdk9-b10
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/make/CompileDemos.gmk
--- a/jdk/make/CompileDemos.gmk Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/make/CompileDemos.gmk Tue Apr 29 14:40:07 2014 -0700
@@ -176,7 +176,6 @@
$(eval $(call SetupDemo,JTop,management,,JTop,,,README*))
$(eval $(call SetupDemo,MemoryMonitor,management,,MemoryMonitor,,,README*))
$(eval $(call SetupDemo,VerboseGC,management,,VerboseGC,,,README*))
-$(eval $(call SetupDemo,zipfs,nio,,,,,README* *.java,,,,Main-Class: \n))
ifndef OPENJDK
$(eval $(call SetupDemo,Laffy,jfc,,,,closed/,*))
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/make/CompileJavaClasses.gmk
--- a/jdk/make/CompileJavaClasses.gmk Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/make/CompileJavaClasses.gmk Tue Apr 29 14:40:07 2014 -0700
@@ -326,7 +326,7 @@
ifeq ($(ENABLE_SJAVAC),yes)
# With sjavac enabled, excluded sources are not even considered for linking.
# Explicitly add the security sources to sourcepath for linking.
- BUILD_JDK_SOURCEPATH:=$(patsubst %,-i$(SPACE)%.*,$(subst /,.,$(SECURITY_PKGS))) \
+ BUILD_JDK_SOURCEPATH:=$(patsubst %,-i$(SPACE)%/*,$(SECURITY_PKGS)) \
-sourcepath $(JDK_TOPDIR)/src/share/classes
endif
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/make/CopyFiles.gmk
--- a/jdk/make/CopyFiles.gmk Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/make/CopyFiles.gmk Tue Apr 29 14:40:07 2014 -0700
@@ -158,15 +158,6 @@
##########################################################################################
-CONTENT_TYPES_SRC = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib
-
-$(LIBDIR)/content-types.properties: $(CONTENT_TYPES_SRC)/content-types.properties
- $(call install-file)
-
-COPY_FILES += $(LIBDIR)/content-types.properties
-
-##########################################################################################
-
CALENDARS_SRC := $(JDK_TOPDIR)/src/share/lib
$(LIBDIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties
@@ -183,9 +174,9 @@
##########################################################################################
-ifeq ($(OPENJDK_TARGET_OS), windows)
+ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),)
- TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib
+ TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS)/lib
$(LIBDIR)/tzmappings: $(TZMAPPINGS_SRC)/tzmappings
$(call install-file)
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/make/CopyIntoClasses.gmk
--- a/jdk/make/CopyIntoClasses.gmk Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/make/CopyIntoClasses.gmk Tue Apr 29 14:40:07 2014 -0700
@@ -26,7 +26,7 @@
# Copy icu and _dict files used by the text break iterator
COPY_PATTERNS := .icu _dict .dat _options .js aliasmap .spp .wav .css \
- .png .gif .xml .dtd .txt oqlhelp.html
+ .png .gif .xml .dtd .txt oqlhelp.html content-types.properties
# These directories should not be copied at all
EXCLUDES += \
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/make/CreateJars.gmk
--- a/jdk/make/CreateJars.gmk Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/make/CreateJars.gmk Tue Apr 29 14:40:07 2014 -0700
@@ -160,11 +160,13 @@
javax/swing/JWindowBeanInfo.class \
javax/swing/SwingBeanInfoBase.class \
javax/swing/text/JTextComponentBeanInfo.class \
+ jdk/nio/zipfs \
META-INF/services/com.sun.jdi.connect.Connector \
META-INF/services/com.sun.jdi.connect.spi.TransportService \
META-INF/services/com.sun.tools.attach.spi.AttachProvider \
META-INF/services/com.sun.tools.xjc.Plugin \
META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor \
+ META-INF/services/java.nio.file.spi.FileSystemProvider \
org/relaxng/datatype \
sun/awt/HKSCS.class \
sun/awt/motif/X11GB2312.class \
@@ -356,6 +358,16 @@
##########################################################################################
+$(eval $(call SetupArchive,BUILD_ZIPFS_JAR, , \
+ SRCS := $(JDK_OUTPUTDIR)/classes, \
+ INCLUDES := jdk/nio/zipfs, \
+ EXTRA_FILES := META-INF/services/java.nio.file.spi.FileSystemProvider, \
+ JAR := $(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar, \
+ SKIP_METAINF := true, \
+ CHECK_COMPRESS_JAR := true))
+
+##########################################################################################
+
ifndef OPENJDK
ifeq ($(ENABLE_JFR), true)
$(eval $(call SetupArchive,BUILD_JFR_JAR, , \
@@ -660,11 +672,6 @@
##########################################################################################
-$(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar: $(JDK_OUTPUTDIR)/demo/nio/zipfs/zipfs.jar
- $(install-file)
-
-##########################################################################################
-
# This file is imported from hotspot in Import.gmk. Copying it into images/lib so that
# all jars can be found in one place when creating images in Images.gmk. It needs to be
# done here so that clean targets can be simple and accurate.
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/make/data/jdwp/jdwp.spec
--- a/jdk/make/data/jdwp/jdwp.spec Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/make/data/jdwp/jdwp.spec Tue Apr 29 14:40:07 2014 -0700
@@ -1079,7 +1079,7 @@
(Command InvokeMethod=3
"Invokes a static method. "
"The method must be member of the class type "
- "or one of its superclasses, superinterfaces, or implemented interfaces. "
+ "or one of its superclasses. "
"Access control is not enforced; for example, private "
"methods can be invoked."
""
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/make/mapfiles/libnet/mapfile-vers
--- a/jdk/make/mapfiles/libnet/mapfile-vers Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/make/mapfiles/libnet/mapfile-vers Tue Apr 29 14:40:07 2014 -0700
@@ -94,6 +94,10 @@
Java_sun_net_sdp_SdpSupport_create0;
Java_sun_net_spi_DefaultProxySelector_init;
Java_sun_net_spi_DefaultProxySelector_getSystemProxy;
+ Java_sun_net_ExtendedOptionsImpl_init;
+ Java_sun_net_ExtendedOptionsImpl_setFlowOption;
+ Java_sun_net_ExtendedOptionsImpl_getFlowOption;
+ Java_sun_net_ExtendedOptionsImpl_flowSupported;
NET_AllocSockaddr;
NET_SockaddrToInetAddress;
NET_SockaddrEqualsInetAddress;
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/make/profile-includes.txt
--- a/jdk/make/profile-includes.txt Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/make/profile-includes.txt Tue Apr 29 14:40:07 2014 -0700
@@ -56,7 +56,6 @@
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \
calendars.properties \
classlist \
- content-types.properties \
currency.data \
ext/localedata.jar \
ext/meta-index \
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/src/aix/lib/tzmappings
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/aix/lib/tzmappings Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,586 @@
+#
+#
+# Copyright (c) 1994, 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.
+#
+
+#
+# Portions Copyright (c) 2014 IBM Corporation
+#
+
+# This table describes mappings between AIX time zone IDs and Java time zone
+# IDs. Fields are separated by a single TAB ('\t'). Lines must be in the ascending
+# order in ASCII. (non-ASCII characters can't be used.)
+# NOTE
+# This table format is not a public interface of any Java
+# platforms. No applications should depend on this file in any form.
+# This file has been generated using programs. Do not edit this file manually.
+#
+# Solaris Java
+
+ACST-9:30ACDT Australia/Adelaide
+AST4 America/Curacao
+AST4ADT America/Halifax
+AST9 Pacific/Gambier
+AST9ADT America/Anchorage
+AZOREST1 Atlantic/Cape_Verde
+AZOREST1AZOREDT Atlantic/Azores
+Africa/Abidjan Africa/Abidjan
+Africa/Accra Africa/Accra
+Africa/Addis_Ababa Africa/Addis_Ababa
+Africa/Algiers Africa/Algiers
+Africa/Asmera Africa/Asmera
+Africa/Bamako GMT
+Africa/Bangui Africa/Bangui
+Africa/Banjul Africa/Banjul
+Africa/Bissau Africa/Bissau
+Africa/Blantyre Africa/Blantyre
+Africa/Brazzaville Africa/Luanda
+Africa/Bujumbura Africa/Bujumbura
+Africa/Cairo Africa/Cairo
+Africa/Casablanca Africa/Casablanca
+Africa/Ceuta Europe/Paris
+Africa/Conakry Africa/Conakry
+Africa/Dakar Africa/Dakar
+Africa/Dar_es_Salaam Africa/Dar_es_Salaam
+Africa/Djibouti Africa/Djibouti
+Africa/Douala Africa/Douala
+Africa/El_Aaiun Africa/Casablanca
+Africa/Freetown Africa/Freetown
+Africa/Gaborone Africa/Gaborone
+Africa/Harare Africa/Harare
+Africa/Johannesburg Africa/Johannesburg
+Africa/Kampala Africa/Kampala
+Africa/Khartoum Africa/Khartoum
+Africa/Kigali Africa/Kigali
+Africa/Kinshasa Africa/Kinshasa
+Africa/Lagos Africa/Lagos
+Africa/Libreville Africa/Libreville
+Africa/Lome Africa/Lome
+Africa/Luanda Africa/Luanda
+Africa/Lubumbashi Africa/Lubumbashi
+Africa/Lusaka Africa/Lusaka
+Africa/Malabo Africa/Malabo
+Africa/Maputo Africa/Maputo
+Africa/Maseru Africa/Maseru
+Africa/Mbabane Africa/Mbabane
+Africa/Mogadishu Africa/Mogadishu
+Africa/Monrovia Africa/Monrovia
+Africa/Nairobi Africa/Nairobi
+Africa/Ndjamena Africa/Ndjamena
+Africa/Niamey Africa/Niamey
+Africa/Nouakchott Africa/Nouakchott
+Africa/Ouagadougou Africa/Ouagadougou
+Africa/Porto-Novo Africa/Porto-Novo
+Africa/Sao_Tome Africa/Sao_Tome
+Africa/Timbuktu Africa/Timbuktu
+Africa/Tripoli Africa/Tripoli
+Africa/Tunis Africa/Tunis
+Africa/Windhoek Africa/Windhoek
+America/Adak America/Adak
+America/Anchorage America/Anchorage
+America/Anguilla America/Anguilla
+America/Antigua America/Antigua
+America/Araguaina America/Sao_Paulo
+America/Argentina/Buenos_Aires America/Argentina/Buenos_Aires
+America/Argentina/Catamarca America/Argentina/Catamarca
+America/Argentina/ComodRivadavia America/Argentina/Catamarca
+America/Argentina/Cordoba America/Argentina/Cordoba
+America/Argentina/Jujuy America/Argentina/Jujuy
+America/Argentina/La_Rioja America/Argentina/La_Rioja
+America/Argentina/Mendoza America/Argentina/Mendoza
+America/Argentina/Rio_Gallegos America/Argentina/Rio_Gallegos
+America/Argentina/Salta America/Argentina/Salta
+America/Argentina/San_Juan America/Argentina/San_Juan
+America/Argentina/San_Luis America/Argentina/San_Luis
+America/Argentina/Tucuman America/Argentina/Tucuman
+America/Argentina/Ushuaia America/Argentina/Ushuaia
+America/Aruba America/Aruba
+America/Asuncion America/Asuncion
+America/Atka America/Adak
+America/Barbados America/Barbados
+America/Belize America/Belize
+America/Bogota America/Bogota
+America/Boise America/Denver
+America/Buenos_Aires America/Argentina/Buenos_Aires
+America/Cancun America/Chicago
+America/Caracas America/Caracas
+America/Catamarca America/Argentina/Catamarca
+America/Cayenne America/Cayenne
+America/Cayman America/Cayman
+America/Chicago America/Chicago
+America/Chihuahua America/Denver
+America/Coral_Harbour America/Atikokan
+America/Cordoba America/Argentina/Cordoba
+America/Costa_Rica America/Costa_Rica
+America/Cuiaba America/Cuiaba
+America/Curacao America/Curacao
+America/Dawson America/Los_Angeles
+America/Dawson_Creek America/Dawson_Creek
+America/Denver America/Denver
+America/Detroit America/New_York
+America/Dominica America/Dominica
+America/Edmonton America/Edmonton
+America/El_Salvador America/El_Salvador
+America/Ensenada America/Los_Angeles
+America/Fort_Wayne America/Indiana/Indianapolis
+America/Fortaleza America/Fortaleza
+America/Glace_Bay America/Halifax
+America/Godthab America/Godthab
+America/Goose_Bay America/Thule
+America/Grand_Turk America/Grand_Turk
+America/Grenada America/Grenada
+America/Guadeloupe America/Guadeloupe
+America/Guatemala America/Guatemala
+America/Guayaquil America/Guayaquil
+America/Guyana America/Guyana
+America/Halifax America/Halifax
+America/Havana America/Havana
+America/Indiana/Indianapolis America/Indianapolis
+America/Indianapolis America/Indiana/Indianapolis
+America/Inuvik America/Denver
+America/Iqaluit America/New_York
+America/Jamaica America/Jamaica
+America/Jujuy America/Argentina/Jujuy
+America/Juneau America/Anchorage
+America/Knox_IN America/Indiana/Knox
+America/La_Paz America/La_Paz
+America/Lima America/Lima
+America/Los_Angeles America/Los_Angeles
+America/Louisville America/Kentucky/Louisville
+America/Managua America/Managua
+America/Manaus America/Manaus
+America/Marigot America/Guadeloupe
+America/Martinique America/Martinique
+America/Mazatlan America/Mazatlan
+America/Mendoza America/Argentina/Mendoza
+America/Menominee America/Winnipeg
+America/Mexico_City America/Mexico_City
+America/Miquelon America/Miquelon
+America/Moncton America/Moncton
+America/Montevideo America/Montevideo
+America/Montreal America/Montreal
+America/Montserrat America/Montserrat
+America/Nassau America/Nassau
+America/New_York America/New_York
+America/Nipigon America/New_York
+America/Nome America/Anchorage
+America/Noronha America/Noronha
+America/Panama America/Panama
+America/Pangnirtung America/Thule
+America/Paramaribo America/Paramaribo
+America/Phoenix America/Phoenix
+America/Port-au-Prince America/Port-au-Prince
+America/Port_of_Spain America/Port_of_Spain
+America/Porto_Acre America/Rio_Branco
+America/Puerto_Rico America/Puerto_Rico
+America/Rainy_River America/Chicago
+America/Rankin_Inlet America/Chicago
+America/Regina America/Regina
+America/Rio_Branco America/Rio_Branco
+America/Rosario America/Argentina/Cordoba
+America/Santiago America/Santiago
+America/Santo_Domingo America/Santo_Domingo
+America/Sao_Paulo America/Sao_Paulo
+America/Scoresbysund America/Scoresbysund
+America/Shiprock America/Denver
+America/St_Barthelemy America/Guadeloupe
+America/St_Johns America/St_Johns
+America/St_Kitts America/St_Kitts
+America/St_Lucia America/St_Lucia
+America/St_Thomas America/St_Thomas
+America/St_Vincent America/St_Vincent
+America/Tegucigalpa America/Tegucigalpa
+America/Thule America/Thule
+America/Thunder_Bay America/New_York
+America/Tijuana America/Tijuana
+America/Toronto America/Toronto
+America/Tortola America/Tortola
+America/Vancouver America/Vancouver
+America/Virgin America/St_Thomas
+America/Whitehorse America/Los_Angeles
+America/Winnipeg America/Winnipeg
+America/Yakutat America/Anchorage
+America/Yellowknife America/Denver
+Antarctica/Casey Antarctica/Casey
+Antarctica/DumontDUrville Antarctica/DumontDUrville
+Antarctica/Mawson Antarctica/Mawson
+Antarctica/McMurdo Antarctica/McMurdo
+Antarctica/Palmer Antarctica/Palmer
+Antarctica/South_Pole Antarctica/McMurdo
+Arctic/Longyearbyen Europe/Oslo
+Asia/Aden Asia/Aden
+Asia/Almaty Asia/Almaty
+Asia/Amman Asia/Amman
+Asia/Anadyr Asia/Anadyr
+Asia/Aqtau Asia/Aqtau
+Asia/Aqtobe Asia/Aqtobe
+Asia/Ashkhabad Asia/Ashkhabad
+Asia/Baghdad Asia/Baghdad
+Asia/Bahrain Asia/Bahrain
+Asia/Baku Asia/Baku
+Asia/Bangkok Asia/Bangkok
+Asia/Beirut Asia/Beirut
+Asia/Bishkek Asia/Bishkek
+Asia/Brunei Asia/Brunei
+Asia/Calcutta Asia/Calcutta
+Asia/Chungking Asia/Shanghai
+Asia/Colombo Asia/Colombo
+Asia/Dacca Asia/Dacca
+Asia/Damascus Asia/Damascus
+Asia/Dhaka Asia/Dhaka
+Asia/Dubai Asia/Dubai
+Asia/Dushanbe Asia/Dushanbe
+Asia/Gaza Asia/Amman
+Asia/Harbin Asia/Shanghai
+Asia/Hong_Kong Asia/Hong_Kong
+Asia/Irkutsk Asia/Irkutsk
+Asia/Istanbul Europe/Istanbul
+Asia/Jakarta Asia/Jakarta
+Asia/Jayapura Asia/Jayapura
+Asia/Jerusalem Asia/Jerusalem
+Asia/Kabul Asia/Kabul
+Asia/Kamchatka Asia/Kamchatka
+Asia/Karachi Asia/Karachi
+Asia/Kashgar Asia/Shanghai
+Asia/Katmandu Asia/Katmandu
+Asia/Kolkata Asia/Kolkata
+Asia/Krasnoyarsk Asia/Krasnoyarsk
+Asia/Kuala_Lumpur Asia/Kuala_Lumpur
+Asia/Kuwait Asia/Kuwait
+Asia/Macao Asia/Macao
+Asia/Magadan Asia/Magadan
+Asia/Manila Asia/Manila
+Asia/Muscat Asia/Muscat
+Asia/Nicosia Asia/Nicosia
+Asia/Novosibirsk Asia/Novosibirsk
+Asia/Omsk Asia/Novosibirsk
+Asia/Phnom_Penh Asia/Phnom_Penh
+Asia/Pyongyang Asia/Pyongyang
+Asia/Qatar Asia/Qatar
+Asia/Rangoon Asia/Rangoon
+Asia/Riyadh Asia/Riyadh
+Asia/Saigon Asia/Ho_Chi_Minh
+Asia/Seoul Asia/Seoul
+Asia/Shanghai Asia/Shanghai
+Asia/Singapore Asia/Singapore
+Asia/Taipei Asia/Taipei
+Asia/Tashkent Asia/Tashkent
+Asia/Tbilisi Asia/Tbilisi
+Asia/Tehran Asia/Tehran
+Asia/Tel_Aviv Asia/Jerusalem
+Asia/Thimbu Asia/Thimbu
+Asia/Tokyo Asia/Tokyo
+Asia/Ujung_Pandang Asia/Ujung_Pandang
+Asia/Ulan_Bator Asia/Ulaanbaatar
+Asia/Urumqi Asia/Shanghai
+Asia/Vientiane Asia/Vientiane
+Asia/Vladivostok Asia/Vladivostok
+Asia/Yakutsk Asia/Yakutsk
+Asia/Yekaterinburg Asia/Yekaterinburg
+Asia/Yerevan Asia/Yerevan
+Atlantic/Azores Atlantic/Azores
+Atlantic/Bermuda Atlantic/Bermuda
+Atlantic/Canary Atlantic/Canary
+Atlantic/Cape_Verde Atlantic/Cape_Verde
+Atlantic/Faeroe Atlantic/Faeroe
+Atlantic/Jan_Mayen Atlantic/Jan_Mayen
+Atlantic/Madeira Europe/London
+Atlantic/Reykjavik Atlantic/Reykjavik
+Atlantic/South_Georgia Atlantic/South_Georgia
+Atlantic/St_Helena Atlantic/St_Helena
+Atlantic/Stanley Atlantic/Stanley
+Australia/ACT Australia/Sydney
+Australia/Adelaide Australia/Adelaide
+Australia/Brisbane Australia/Brisbane
+Australia/Broken_Hill Australia/Broken_Hill
+Australia/Canberra Australia/Sydney
+Australia/Darwin Australia/Darwin
+Australia/Hobart Australia/Hobart
+Australia/LHI Australia/Lord_Howe
+Australia/Lord_Howe Australia/Lord_Howe
+Australia/Melbourne Australia/Sydney
+Australia/NSW Australia/Sydney
+Australia/North Australia/Darwin
+Australia/Perth Australia/Perth
+Australia/Queensland Australia/Brisbane
+Australia/South Australia/Adelaide
+Australia/Sydney Australia/Sydney
+Australia/Tasmania Australia/Hobart
+Australia/Victoria Australia/Melbourne
+Australia/West Australia/Perth
+Australia/Yancowinna Australia/Broken_Hill
+BRT3BRST America/Sao_Paulo
+BST11 Pacific/Apia
+BST11BDT Pacific/Apia
+Brazil/Acre America/Rio_Branco
+Brazil/DeNoronha America/Noronha
+Brazil/East America/Sao_Paulo
+Brazil/West America/Manaus
+CET Europe/Paris
+CET-1CEST Europe/Paris
+CET-1CEST-2 Europe/Berlin
+CET-1CET-2 Europe/Paris
+CST6 America/Costa_Rica
+CST6CDT America/Chicago
+CUT0 UTC
+CUT0GDT Europe/London
+Canada/Atlantic America/Halifax
+Canada/Central America/Winnipeg
+Canada/East-Saskatchewan America/Regina
+Canada/Eastern America/Montreal
+Canada/Mountain America/Edmonton
+Canada/Newfoundland America/St_Johns
+Canada/Pacific America/Vancouver
+Canada/Saskatchewan America/Regina
+Canada/Yukon America/Whitehorse
+Chile/Continental America/Santiago
+Chile/EasterIsland Pacific/Easter
+Cuba America/Havana
+EET Europe/Istanbul
+EET-10 Australia/Brisbane
+EET-10EETDT Australia/Sydney
+EST America/Indianapolis
+EST5 America/Indianapolis
+EST5EDT America/New_York
+Egypt Africa/Cairo
+Eire Europe/Dublin
+Etc/GMT GMT
+Etc/GMT0 GMT
+Etc/Greenwich GMT
+Etc/UCT UTC
+Etc/UTC UTC
+Etc/Universal UTC
+Etc/Zulu UTC
+Europe/Amsterdam Europe/Amsterdam
+Europe/Andorra Europe/Andorra
+Europe/Athens Europe/Athens
+Europe/Belfast Europe/London
+Europe/Belgrade Europe/Belgrade
+Europe/Berlin Europe/Berlin
+Europe/Bratislava Europe/Prague
+Europe/Brussels Europe/Brussels
+Europe/Bucharest Europe/Bucharest
+Europe/Budapest Europe/Budapest
+Europe/Chisinau Europe/Chisinau
+Europe/Copenhagen Europe/Copenhagen
+Europe/Dublin Europe/Dublin
+Europe/Gibraltar Europe/Gibraltar
+Europe/Guernsey Europe/London
+Europe/Helsinki Europe/Helsinki
+Europe/Isle_of_Man Europe/London
+Europe/Istanbul Europe/Istanbul
+Europe/Jersey Europe/London
+Europe/Kaliningrad Europe/Kaliningrad
+Europe/Kiev Europe/Kiev
+Europe/Lisbon Europe/Lisbon
+Europe/Ljubljana Europe/Belgrade
+Europe/London Europe/London
+Europe/Luxembourg Europe/Luxembourg
+Europe/Madrid Europe/Madrid
+Europe/Malta Europe/Malta
+Europe/Mariehamn Europe/Helsinki
+Europe/Minsk Europe/Minsk
+Europe/Monaco Europe/Monaco
+Europe/Moscow Europe/Moscow
+Europe/Nicosia Asia/Nicosia
+Europe/Oslo Europe/Oslo
+Europe/Paris Europe/Paris
+Europe/Podgorica Europe/Belgrade
+Europe/Prague Europe/Prague
+Europe/Riga Europe/Riga
+Europe/Rome Europe/Rome
+Europe/Samara Europe/Samara
+Europe/San_Marino Europe/Rome
+Europe/Sarajevo Europe/Belgrade
+Europe/Simferopol Europe/Simferopol
+Europe/Skopje Europe/Belgrade
+Europe/Sofia Europe/Sofia
+Europe/Stockholm Europe/Stockholm
+Europe/Tallinn Europe/Tallinn
+Europe/Tirane Europe/Tirane
+Europe/Vaduz Europe/Vaduz
+Europe/Vatican Europe/Rome
+Europe/Vienna Europe/Vienna
+Europe/Vilnius Europe/Vilnius
+Europe/Warsaw Europe/Warsaw
+Europe/Zagreb Europe/Belgrade
+Europe/Zurich Europe/Zurich
+FALKST2 Atlantic/South_Georgia
+FALKST2FALKDT Atlantic/South_Georgia
+Factory GMT
+GB Europe/London
+GB-Eire Europe/London
+GMT GMT
+GMT0 GMT
+GMT0BST Europe/London
+GMT0BST-1 Europe/London
+GMT0WET Europe/Lisbon
+GRNLNDST3 America/Buenos_Aires
+GRNLNDST3GRNLNDDT America/Godthab
+Greenwich GMT
+HST Pacific/Honolulu
+HST10 Pacific/Honolulu
+HST10HDT America/Adak
+Hongkong Asia/Hong_Kong
+Iceland Atlantic/Reykjavik
+Indian/Antananarivo Indian/Antananarivo
+Indian/Chagos Indian/Chagos
+Indian/Christmas Indian/Christmas
+Indian/Cocos Indian/Cocos
+Indian/Comoro Indian/Comoro
+Indian/Kerguelen Indian/Kerguelen
+Indian/Mahe Indian/Mahe
+Indian/Maldives Indian/Maldives
+Indian/Mauritius Indian/Mauritius
+Indian/Mayotte Indian/Mayotte
+Indian/Reunion Indian/Reunion
+Iran Asia/Tehran
+Israel Asia/Jerusalem
+JST-9 Asia/Tokyo
+JST-9JSTDT Asia/Tokyo
+Jamaica America/Jamaica
+Japan Asia/Tokyo
+KORST-9 Asia/Seoul
+KORST-9KORDT Asia/Seoul
+Kwajalein Pacific/Kwajalein
+Libya Africa/Tripoli
+MEST-2 Europe/Istanbul
+MEST-2MEDT Europe/Istanbul
+MEST-3 Asia/Riyadh
+MEST-3MEDT Europe/Moscow
+MET Europe/Paris
+MET-11 Pacific/Guadalcanal
+MET-11METDT Asia/Magadan
+MET-1MEST Europe/Paris
+MET-1MST-2 Europe/Berlin
+MEZ-1MESZ Europe/Berlin
+MEZ-1MESZ-2 Europe/Berlin
+MSK-3MSD Europe/Moscow
+MST America/Phoenix
+MST7 America/Phoenix
+MST7MDT America/Denver
+Mexico/BajaNorte America/Tijuana
+Mexico/BajaSur America/Mazatlan
+Mexico/General America/Mexico_City
+Mideast/Riyadh87 Asia/Riyadh87
+Mideast/Riyadh88 Asia/Riyadh88
+Mideast/Riyadh89 Asia/Riyadh89
+NFT-1 Africa/Algiers
+NFT-1DFT Europe/Paris
+NFT-1DST Europe/Paris
+NZ Pacific/Auckland
+NZ-CHAT Pacific/Chatham
+NZST-12 Pacific/Fiji
+NZST-12NZDT Pacific/Auckland
+Navajo America/Denver
+PAKST-5 Asia/Karachi
+PAKST-5PAKDT Asia/Yekaterinburg
+PRC Asia/Shanghai
+PST8 Pacific/Pitcairn
+PST8PDT America/Los_Angeles
+PST8PDT7 America/Tijuana
+Pacific/Apia Pacific/Apia
+Pacific/Auckland Pacific/Auckland
+Pacific/Chatham Pacific/Chatham
+Pacific/Easter Pacific/Easter
+Pacific/Efate Pacific/Efate
+Pacific/Enderbury Pacific/Enderbury
+Pacific/Fakaofo Pacific/Fakaofo
+Pacific/Fiji Pacific/Fiji
+Pacific/Funafuti Pacific/Funafuti
+Pacific/Galapagos Pacific/Galapagos
+Pacific/Gambier Pacific/Gambier
+Pacific/Guadalcanal Pacific/Guadalcanal
+Pacific/Guam Pacific/Guam
+Pacific/Honolulu Pacific/Honolulu
+Pacific/Kiritimati Pacific/Kiritimati
+Pacific/Kosrae Pacific/Kosrae
+Pacific/Majuro Pacific/Majuro
+Pacific/Marquesas Pacific/Marquesas
+Pacific/Nauru Pacific/Nauru
+Pacific/Niue Pacific/Niue
+Pacific/Norfolk Pacific/Norfolk
+Pacific/Noumea Pacific/Noumea
+Pacific/Pago_Pago Pacific/Pago_Pago
+Pacific/Palau Pacific/Palau
+Pacific/Pitcairn Pacific/Pitcairn
+Pacific/Ponape Pacific/Ponape
+Pacific/Port_Moresby Pacific/Port_Moresby
+Pacific/Rarotonga Pacific/Rarotonga
+Pacific/Saipan Pacific/Saipan
+Pacific/Samoa Pacific/Pago_Pago
+Pacific/Tahiti Pacific/Tahiti
+Pacific/Tarawa Pacific/Tarawa
+Pacific/Tongatapu Pacific/Tongatapu
+Pacific/Truk Pacific/Truk
+Pacific/Wake Pacific/Wake
+Pacific/Wallis Pacific/Wallis
+Poland Europe/Warsaw
+Portugal Europe/Lisbon
+ROC Asia/Taipei
+ROK Asia/Seoul
+SAUST-3 Asia/Riyadh
+SAUST-3SAUDT Europe/Moscow
+Singapore Asia/Singapore
+SystemV/AST4ADT America/Thule
+SystemV/CST6CDT America/Chicago
+SystemV/EST5EDT America/New_York
+SystemV/MST7MDT America/Denver
+SystemV/PST8PDT America/Los_Angeles
+SystemV/YST9YDT America/Anchorage
+TAIST-8 Asia/Taipei
+TAIST-8TAIDT Asia/Irkutsk
+TASHST-6 Asia/Dacca
+TASHST-6TASHDT Asia/Novosibirsk
+THAIST-7 Asia/Bangkok
+THAIST-7THAIDT Asia/Krasnoyarsk
+Turkey Europe/Istanbul
+UCT UTC
+US/Alaska America/Anchorage
+US/Aleutian America/Adak
+US/Arizona America/Phoenix
+US/Central America/Chicago
+US/East-Indiana America/Indiana/Indianapolis
+US/Eastern America/New_York
+US/Hawaii Pacific/Honolulu
+US/Indiana-Starke America/Indiana/Knox
+US/Michigan America/New_York
+US/Mountain America/Denver
+US/Pacific America/Los_Angeles
+US/Pacific-New America/Los_Angeles
+US/Samoa Pacific/Pago_Pago
+USAST-2 Africa/Johannesburg
+USAST-2USADT Europe/Istanbul
+UTC UTC
+UYT3UYST America/Montevideo
+Universal UTC
+W-SU Europe/Moscow
+WAUST-8 Australia/Perth
+WAUST-8WAUDT Australia/Perth
+WET WET
+WET-2 Africa/Johannesburg
+WET-2WET Europe/Helsinki
+WST-4 Asia/Dubai
+WST-4WDT Europe/Samara
+Zulu UTC
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/src/macosx/classes/sun/font/CFontManager.java
--- a/jdk/src/macosx/classes/sun/font/CFontManager.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/src/macosx/classes/sun/font/CFontManager.java Tue Apr 29 14:40:07 2014 -0700
@@ -27,6 +27,8 @@
import java.awt.*;
import java.io.File;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
@@ -38,6 +40,7 @@
import sun.awt.FontConfiguration;
import sun.awt.HeadlessToolkit;
+import sun.misc.ThreadGroupUtils;
import sun.lwawt.macosx.*;
public class CFontManager extends SunFontManager {
@@ -215,24 +218,19 @@
});
}
};
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction
@@ -2448,7 +2447,7 @@
}
/**
- * Used by isReadbale, isWritable, isExecutable to test access to a file.
+ * Used by isReadable, isWritable, isExecutable to test access to a file.
*/
private static boolean isAccessible(Path path, AccessMode... modes) {
try {
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/src/share/classes/java/nio/file/spi/FileSystemProvider.java
--- a/jdk/src/share/classes/java/nio/file/spi/FileSystemProvider.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/src/share/classes/java/nio/file/spi/FileSystemProvider.java Tue Apr 29 14:40:07 2014 -0700
@@ -81,7 +81,7 @@
// installed providers
private static volatile ListA pseudorandom {@code double} value is generated as if it's the result - * of calling the method {@link #nextDouble()}}. + * of calling the method {@link #nextDouble()}. * * @param streamSize the number of values to generate * @return a stream of {@code double} values @@ -897,7 +897,7 @@ * (exclusive). * *
A pseudorandom {@code double} value is generated as if it's the result
- * of calling the method {@link #nextDouble()}}.
+ * of calling the method {@link #nextDouble()}.
*
* @implNote This method is implemented to be equivalent to {@code
* doubles(Long.MAX_VALUE)}.
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/src/share/classes/java/util/ServiceLoader.java
--- a/jdk/src/share/classes/java/util/ServiceLoader.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/src/share/classes/java/util/ServiceLoader.java Tue Apr 29 14:40:07 2014 -0700
@@ -382,7 +382,7 @@
return p;
} catch (Throwable x) {
fail(service,
- "Provider " + cn + " could not be instantiated: " + x,
+ "Provider " + cn + " could not be instantiated",
x);
}
throw new Error(); // This cannot happen
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/src/share/classes/java/util/jar/JarVerifier.java
--- a/jdk/src/share/classes/java/util/jar/JarVerifier.java Tue Apr 29 15:44:14 2014 -0400
+++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java Tue Apr 29 14:40:07 2014 -0700
@@ -676,6 +676,8 @@
} else {
matchUnsigned = true;
}
+ } else {
+ matchUnsigned = true;
}
}
@@ -778,23 +780,7 @@
// true if file is part of the signature mechanism itself
static boolean isSigningRelated(String name) {
- name = name.toUpperCase(Locale.ENGLISH);
- if (!name.startsWith("META-INF/")) {
- return false;
- }
- name = name.substring(9);
- if (name.indexOf('/') != -1) {
- return false;
- }
- if (name.endsWith(".DSA")
- || name.endsWith(".RSA")
- || name.endsWith(".SF")
- || name.endsWith(".EC")
- || name.startsWith("SIG-")
- || name.equals("MANIFEST.MF")) {
- return true;
- }
- return false;
+ return SignatureFileVerifier.isSigningRelated(name);
}
private Enumeration
+ * The following targets are defined:
+ *
+ *
+ * The priority and bandwidth parameters must be set before
+ * setting the socket option.
+ *
+ * When the {@code SO_FLOW_SLA} option is set then it may not take effect
+ * immediately. If the value of the socket option is obtained with
+ * {@code getOption()} then the status may be returned as {@code INPROGRESS}
+ * until it takes effect. The priority and bandwidth values are only valid when
+ * the status is returned as OK.
+ *
+ * When a security manager is installed, a {@link NetworkPermission}
+ * is required to set or get this option.
+ *
+ * @since 1.9
+ */
+@jdk.Exported
+public class SocketFlow {
+
+ private static final int UNSET = -1;
+ @Native public static final int NORMAL_PRIORITY = 1;
+ @Native public static final int HIGH_PRIORITY = 2;
+
+ private int priority = NORMAL_PRIORITY;
+
+ private long bandwidth = UNSET;
+
+ private Status status = Status.NO_STATUS;
+
+ private SocketFlow() {}
+
+ /**
+ * Enumeration of the return values from the SO_FLOW_SLA
+ * socket option. Both setting and getting the option return
+ * one of these statuses, which reflect the state of socket's
+ * flow.
+ *
+ * @since 1.9
+ */
+ @jdk.Exported
+ public enum Status {
+ /**
+ * Set or get socket option has not been called yet. Status
+ * values can only be retrieved after calling set or get.
+ */
+ NO_STATUS,
+ /**
+ * Flow successfully created.
+ */
+ OK,
+ /**
+ * Caller has no permission to create flow.
+ */
+ NO_PERMISSION,
+ /**
+ * Flow can not be created because socket is not connected.
+ */
+ NOT_CONNECTED,
+ /**
+ * Flow creation not supported for this socket.
+ */
+ NOT_SUPPORTED,
+ /**
+ * A flow already exists with identical attributes.
+ */
+ ALREADY_CREATED,
+ /**
+ * A flow is being created.
+ */
+ IN_PROGRESS,
+ /**
+ * Some other unspecified error.
+ */
+ OTHER
+ }
+
+ /**
+ * Creates a new SocketFlow that can be used to set the SO_FLOW_SLA
+ * socket option and create a socket flow.
+ */
+ public static SocketFlow create() {
+ return new SocketFlow();
+ }
+
+ /**
+ * Sets this SocketFlow's priority. Must be either NORMAL_PRIORITY
+ * HIGH_PRIORITY. If not set, a flow's priority is normal.
+ *
+ * @throws IllegalArgumentException if priority is not NORMAL_PRIORITY or
+ * HIGH_PRIORITY.
+ */
+ public SocketFlow priority(int priority) {
+ if (priority != NORMAL_PRIORITY && priority != HIGH_PRIORITY) {
+ throw new IllegalArgumentException("invalid priority");
+ }
+ this.priority = priority;
+ return this;
+ }
+
+ /**
+ * Sets this SocketFlow's bandwidth. Must be greater than or equal to zero.
+ * A value of zero drops all packets for the socket.
+ *
+ * @throws IllegalArgumentException if bandwidth is less than zero.
+ */
+ public SocketFlow bandwidth(long bandwidth) {
+ if (bandwidth < 0) {
+ throw new IllegalArgumentException("invalid bandwidth");
+ } else {
+ this.bandwidth = bandwidth;
+ }
+ return this;
+ }
+
+ /**
+ * Returns this SocketFlow's priority.
+ */
+ public int priority() {
+ return priority;
+ }
+
+ /**
+ * Returns this SocketFlow's bandwidth.
+ *
+ * @return this SocketFlow's bandwidth, or {@code -1} if status is not OK.
+ */
+ public long bandwidth() {
+ return bandwidth;
+ }
+
+ /**
+ * Returns the Status value of this SocketFlow. NO_STATUS is returned
+ * if the object was not used in a call to set or get the option.
+ */
+ public Status status() {
+ return status;
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/src/share/classes/jdk/net/Sockets.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/jdk/net/Sockets.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,311 @@
+/*
+ * 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 jdk.net;
+
+import java.net.*;
+import java.io.IOException;
+import java.io.FileDescriptor;
+import java.security.PrivilegedAction;
+import java.security.AccessController;
+import java.lang.reflect.Field;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Collections;
+import sun.net.ExtendedOptionsImpl;
+
+/**
+ * Defines static methods to set and get socket options defined by the
+ * {@link java.net.SocketOption} interface. All of the standard options defined
+ * by {@link java.net.Socket}, {@link java.net.ServerSocket}, and
+ * {@link java.net.DatagramSocket} can be set this way, as well as additional
+ * or platform specific options supported by each socket type.
+ *
+ * The {@link #supportedOptions(Class)} method can be called to determine
+ * the complete set of options available (per socket type) on the
+ * current system.
+ *
+ * When a security manager is installed, some non-standard socket options
+ * may require a security permission before being set or get.
+ * The details are specified in {@link ExtendedSocketOptions}. No permission
+ * is required for {@link java.net.StandardSocketOption}s.
+ *
+ * @see java.nio.channels.NetworkChannel
+ */
+@jdk.Exported
+public class Sockets {
+
+ private final static HashMapSyncProvider
@@ -329,7 +332,7 @@
// Local implementation class names and keys from Properties
// file, translate names into Class objects using Class.forName
// and store mappings
- Properties properties = new Properties();
+ final Properties properties = new Properties();
if (implementations == null) {
implementations = new Hashtable<>();
@@ -356,10 +359,11 @@
public String run() {
return System.getProperty("rowset.properties");
}
- }, null, new PropertyPermission("rowset.properties","read"));
+ }, null, new PropertyPermission("rowset.properties", "read"));
} catch (Exception ex) {
+ System.out.println("errorget rowset.properties: " + ex);
strRowsetProperties = null;
- }
+ };
if (strRowsetProperties != null) {
// Load user's implementation of SyncProvider
@@ -380,14 +384,27 @@
ClassLoader cl = Thread.currentThread().getContextClassLoader();
- try (InputStream stream =
- (cl == null) ? ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES)
- : cl.getResourceAsStream(ROWSET_PROPERTIES)) {
- if (stream == null) {
- throw new SyncFactoryException(
- "Resource " + ROWSET_PROPERTIES + " not found");
+ try {
+ AccessController.doPrivileged((PrivilegedExceptionAction
+ *
+ *
+ * @see jdk.net.ExtendedSocketOptions
+ *
+ * @since 1.9
+ */
+
+@jdk.Exported
+public final class NetworkPermission extends BasicPermission {
+
+ private static final long serialVersionUID = -2012939586906722291L;
+
+ /**
+ * Creates a NetworkPermission with the given target name.
+ *
+ * @param name the permission target name
+ * @throws NullPointerException if {@code name} is {@code null}.
+ * @throws IllegalArgumentException if {@code name} is empty.
+ */
+ public NetworkPermission(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Creates a NetworkPermission with the given target name.
+ *
+ * @param name the permission target name
+ * @param actions should be {@code null}. Is ignored if not.
+ * @throws NullPointerException if {@code name} is {@code null}.
+ * @throws IllegalArgumentException if {@code name} is empty.
+ */
+ public NetworkPermission(String name, String actions)
+ {
+ super(name, actions);
+ }
+}
diff -r 1d117d2dfe92 -r 2061862eb57c jdk/src/share/classes/jdk/net/SocketFlow.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/jdk/net/SocketFlow.java Tue Apr 29 14:40:07 2014 -0700
@@ -0,0 +1,169 @@
+/*
+ * 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 jdk.net;
+
+import java.lang.annotation.Native;
+
+/**
+ * Represents the service level properties for the platform specific socket
+ * option {@link ExtendedSocketOptions#SO_FLOW_SLA}.
+ *
+ *
+ * Permission Target Name
+ * What the Permission Allows
+ * Risks of Allowing this Permission
+ *
+ *
+ * setOption.SO_FLOW_SLA
+ * set the {@link ExtendedSocketOptions#SO_FLOW_SLA SO_FLOW_SLA} option
+ * on any socket that supports it
+ * allows caller to set a higher priority or bandwidth allocation
+ * to sockets it creates, than they might otherwise be allowed.
+ *
+ * getOption.SO_FLOW_SLA
+ * retrieve the {@link ExtendedSocketOptions#SO_FLOW_SLA SO_FLOW_SLA}
+ * setting from any socket that supports the option
+ * allows caller access to SLA information that it might not
+ * otherwise have
+ *