Merge
authormockner
Tue, 29 Mar 2016 21:44:06 +0200
changeset 37205 dd547442bfea
parent 37202 4100f25e4b09 (current diff)
parent 37204 c57d749ef4fb (diff)
child 37206 639ad21e6fad
Merge
hotspot/src/share/vm/logging/logTag.hpp
hotspot/src/share/vm/runtime/arguments.cpp
hotspot/src/share/vm/runtime/globals.hpp
--- a/hotspot/src/share/vm/logging/logTag.hpp	Tue Mar 29 13:02:16 2016 -0400
+++ b/hotspot/src/share/vm/logging/logTag.hpp	Tue Mar 29 21:44:06 2016 +0200
@@ -66,6 +66,7 @@
   LOG_TAG(metaspace) \
   LOG_TAG(modules) \
   LOG_TAG(monitorinflation) \
+  LOG_TAG(monitormismatch) \
   LOG_TAG(os) \
   LOG_TAG(phases) \
   LOG_TAG(plab) \
--- a/hotspot/src/share/vm/oops/generateOopMap.cpp	Tue Mar 29 13:02:16 2016 -0400
+++ b/hotspot/src/share/vm/oops/generateOopMap.cpp	Tue Mar 29 21:44:06 2016 +0200
@@ -24,6 +24,7 @@
 
 #include "precompiled.hpp"
 #include "interpreter/bytecodeStream.hpp"
+#include "logging/log.hpp"
 #include "oops/generateOopMap.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/symbol.hpp"
@@ -32,6 +33,7 @@
 #include "runtime/relocator.hpp"
 #include "runtime/timerTrace.hpp"
 #include "utilities/bitMap.inline.hpp"
+#include "utilities/ostream.hpp"
 #include "prims/methodHandles.hpp"
 
 //
@@ -787,7 +789,7 @@
         bb->set_changed(true);
       }
     } else {
-      if (TraceMonitorMismatch) {
+      if (log_is_enabled(Info, monitormismatch)) {
         report_monitor_mismatch("monitor stack height merge conflict");
       }
       // When the monitor stacks are not matched, we set _monitor_top to
@@ -856,7 +858,7 @@
     _monitor_safe = false;
      _monitor_top = bad_monitors;
 
-    if (TraceMonitorMismatch) {
+    if (log_is_enabled(Info, monitormismatch)) {
       report_monitor_mismatch("monitor stack underflow");
     }
     return CellTypeState::ref; // just to keep the analysis going.
@@ -872,7 +874,7 @@
     _monitor_safe = false;
     _monitor_top = bad_monitors;
 
-    if (TraceMonitorMismatch) {
+    if (log_is_enabled(Info, monitormismatch)) {
       report_monitor_mismatch("monitor stack overflow");
     }
     return;
@@ -1245,7 +1247,7 @@
   // We don't set _monitor_top to bad_monitors because there are no successors
   // to this exceptional exit.
 
-  if (TraceMonitorMismatch && _monitor_safe) {
+  if (log_is_enabled(Info, monitormismatch) && _monitor_safe) {
     // We check _monitor_safe so that we only report the first mismatched
     // exceptional exit.
     report_monitor_mismatch("non-empty monitor stack at exceptional exit");
@@ -1255,11 +1257,11 @@
 }
 
 void GenerateOopMap::report_monitor_mismatch(const char *msg) {
-#ifndef PRODUCT
-  tty->print("    Monitor mismatch in method ");
-  method()->print_short_name(tty);
-  tty->print_cr(": %s", msg);
-#endif
+  ResourceMark rm;
+  outputStream* out = LogHandle(monitormismatch)::info_stream();
+  out->print("Monitor mismatch in method ");
+  method()->print_short_name(out);
+  out->print_cr(": %s", msg);
 }
 
 void GenerateOopMap::print_states(outputStream *os,
@@ -1782,7 +1784,7 @@
     _monitor_top = bad_monitors;
     _monitor_safe = false;
 
-    if (TraceMonitorMismatch) {
+    if (log_is_enabled(Info, monitormismatch)) {
       report_monitor_mismatch("nested redundant lock -- bailout...");
     }
     return;
@@ -1820,7 +1822,7 @@
     bb->set_changed(true);
     bb->_monitor_top = bad_monitors;
 
-    if (TraceMonitorMismatch) {
+    if (log_is_enabled(Info, monitormismatch)) {
       report_monitor_mismatch("improper monitor pair");
     }
   } else {
@@ -1846,7 +1848,7 @@
     // Since there are no successors to the *return bytecode, it
     // isn't necessary to set _monitor_top to bad_monitors.
 
-    if (TraceMonitorMismatch) {
+    if (log_is_enabled(Info, monitormismatch)) {
       report_monitor_mismatch("non-empty monitor stack at return");
     }
   }
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Tue Mar 29 13:02:16 2016 -0400
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Tue Mar 29 21:44:06 2016 +0200
@@ -438,6 +438,7 @@
   { "TraceClassLoaderData",       "-Xlog:classloaderdata" },
   { "TraceDefaultMethods",        "-Xlog:defaultmethods=debug" },
   { "TraceItables",               "-Xlog:itables=debug" },
+  { "TraceMonitorMismatch",       "-Xlog:monitormismatch=info" },
   { "TraceSafepoint",             "-Xlog:safepoint=debug" },
   { "TraceStartupTime",           "-Xlog:startuptime" },
   { "TraceVMOperation",           "-Xlog:vmoperation=debug" },
--- a/hotspot/src/share/vm/runtime/globals.hpp	Tue Mar 29 13:02:16 2016 -0400
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Tue Mar 29 21:44:06 2016 +0200
@@ -1451,9 +1451,6 @@
   develop(bool, TimeOopMap2, false,                                         \
           "Time calls to GenerateOopMap::compute_map() individually")       \
                                                                             \
-  develop(bool, TraceMonitorMismatch, false,                                \
-          "Trace monitor matching failures during OopMapGeneration")        \
-                                                                            \
   develop(bool, TraceOopMapRewrites, false,                                 \
           "Trace rewriting of method oops during oop map generation")       \
                                                                             \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/logging/MonitorMismatchHelper.jasm	Tue Mar 29 21:44:06 2016 +0200
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+super public class MonitorMismatchHelper
+	version 52:0
+{
+
+private Field c:I;
+
+public Method "<init>":"()V"
+	stack 2 locals 1
+{
+		aload_0;
+		invokespecial	Method java/lang/Object."<init>":"()V";
+		aload_0;
+		iconst_0;
+		putfield	Field c:"I";
+		return;
+}
+
+public synchronized Method increment:"()V"
+	stack 3 locals 1
+{
+		aload_0;
+		dup;
+		getfield	Field c:"I";
+		iconst_1;
+		iadd;
+		putfield	Field c:"I";
+		return;
+}
+
+public synchronized Method decrement:"()V"
+	stack 3 locals 1
+{
+		aload_0;
+		dup;
+		getfield	Field c:"I";
+		iconst_1;
+		isub;
+		putfield	Field c:"I";
+		return;
+}
+
+public synchronized Method value:"()I"
+	stack 1 locals 1
+{
+		aload_0;
+		getfield	Field c:"I";
+		ireturn;
+}
+
+public static varargs Method main:"([Ljava/lang/String;)V"
+	stack 2 locals 4
+{
+		new	class MonitorMismatchHelper;
+		dup;
+		invokespecial	Method "<init>":"()V";
+		astore_1;
+		aload_1;
+		dup;
+		astore_2;
+		monitorenter;
+		try t0;
+		aload_1;
+		invokevirtual	Method increment:"()V";
+		aload_1;
+		invokevirtual	Method increment:"()V";
+		aload_1;
+		invokevirtual	Method decrement:"()V";
+		getstatic	Field java/lang/System.out:"Ljava/io/PrintStream;";
+		aload_1;
+		invokevirtual	Method value:"()I";
+		invokevirtual	Method java/io/PrintStream.print:"(I)V";
+		aload_2;
+		monitorexit;
+		endtry t0;
+		goto	L44;
+		catch t0 #0;
+		catch t1 #0;
+		try t1;
+		stack_frame_type full;
+		locals_map class "[Ljava/lang/String;", class MonitorMismatchHelper, class java/lang/Object;
+		stack_map class java/lang/Throwable;
+		astore_3;
+		aload_2;
+		endtry t1;
+		aload_3;
+		athrow;
+	L44:	stack_frame_type chop1;
+		return;
+}
+
+} // end Class MonitorMismatchHelper
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/logging/MonitorMismatchTest.java	Tue Mar 29 21:44:06 2016 +0200
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test MonitorMismatchTest
+ * @bug 8150084
+ * @library /testlibrary
+ * @compile MonitorMismatchHelper.jasm
+ * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools jdk.test.lib.Platform
+ * @run driver MonitorMismatchTest
+ */
+
+import jdk.test.lib.OutputAnalyzer;
+import jdk.test.lib.ProcessTools;
+import jdk.test.lib.Platform;
+
+public class MonitorMismatchTest {
+
+    public static void main(String... args) throws Exception {
+        if (!Platform.isEmbedded()){
+            // monitormismatch should turn on.
+            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xcomp",
+                                                                      "-XX:+TieredCompilation",
+                                                                      "-Xlog:monitormismatch=info",
+                                                                      "MonitorMismatchHelper");
+            OutputAnalyzer o = new OutputAnalyzer(pb.start());
+            o.shouldContain("[monitormismatch] Monitor mismatch in method");
+
+            // monitormismatch should turn off.
+            pb = ProcessTools.createJavaProcessBuilder("-Xcomp",
+                                                       "-XX:+TieredCompilation",
+                                                       "-Xlog:monitormismatch=off",
+                                                       "MonitorMismatchHelper");
+            o = new OutputAnalyzer(pb.start());
+            o.shouldNotContain("[monitormismatch]");
+        }
+    };
+
+}