8227117: normal interpreter table is not restored after single stepping with TLH
authordcubed
Mon, 08 Jul 2019 11:38:49 -0400
changeset 55608 47af68c44e02
parent 55604 a30c86af2eb7
child 55609 377e49b3014c
child 55620 eb1fbe4d61b2
8227117: normal interpreter table is not restored after single stepping with TLH Reviewed-by: sspitsyn, eosterlund, dholmes, coleenp
src/hotspot/share/interpreter/templateInterpreter.cpp
src/hotspot/share/prims/jvmtiEventController.cpp
--- a/src/hotspot/share/interpreter/templateInterpreter.cpp	Fri Jul 05 00:24:54 2019 -0700
+++ b/src/hotspot/share/interpreter/templateInterpreter.cpp	Mon Jul 08 11:38:49 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 #include "interpreter/templateInterpreter.hpp"
 #include "interpreter/templateInterpreterGenerator.hpp"
 #include "interpreter/templateTable.hpp"
+#include "logging/log.hpp"
 #include "memory/resourceArea.hpp"
 #include "runtime/timerTrace.hpp"
 
@@ -283,9 +284,13 @@
 
 void TemplateInterpreter::notice_safepoints() {
   if (!_notice_safepoints) {
+    log_debug(interpreter, safepoint)("switching active_table to safept_table.");
     // switch to safepoint dispatch table
     _notice_safepoints = true;
     copy_table((address*)&_safept_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address));
+  } else {
+    log_debug(interpreter, safepoint)("active_table is already safept_table; "
+                                      "notice_safepoints() call is no-op.");
   }
 }
 
@@ -297,10 +302,17 @@
 void TemplateInterpreter::ignore_safepoints() {
   if (_notice_safepoints) {
     if (!JvmtiExport::should_post_single_step()) {
+      log_debug(interpreter, safepoint)("switching active_table to normal_table.");
       // switch to normal dispatch table
       _notice_safepoints = false;
       copy_table((address*)&_normal_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address));
+    } else {
+      log_debug(interpreter, safepoint)("single stepping is still active; "
+                                        "ignoring ignore_safepoints() call.");
     }
+  } else {
+    log_debug(interpreter, safepoint)("active_table is already normal_table; "
+                                      "ignore_safepoints() call is no-op.");
   }
 }
 
--- a/src/hotspot/share/prims/jvmtiEventController.cpp	Fri Jul 05 00:24:54 2019 -0700
+++ b/src/hotspot/share/prims/jvmtiEventController.cpp	Mon Jul 08 11:38:49 2019 -0400
@@ -264,7 +264,7 @@
 
 
 VM_ChangeSingleStep::VM_ChangeSingleStep(bool on)
-  : _on(on != 0)
+  : _on(on)
 {
 }
 
@@ -331,18 +331,20 @@
 }
 
 
-// This change must always be occur when at a safepoint.
-// Being at a safepoint causes the interpreter to use the
-// safepoint dispatch table which we overload to find single
-// step points.  Just to be sure that it has been set, we
-// call notice_safepoints when turning on single stepping.
-// When we leave our current safepoint, should_post_single_step
-// will be checked by the interpreter, and the table kept
-// or changed accordingly.
+// When _on == true, we use the safepoint interpreter dispatch table
+// to allow us to find the single step points. Otherwise, we switch
+// back to the regular interpreter dispatch table.
+// Note: We call Interpreter::notice_safepoints() and ignore_safepoints()
+// in a VM_Operation to safely make the dispatch table switch. We
+// no longer rely on the safepoint mechanism to do any of this work
+// for us.
 void VM_ChangeSingleStep::doit() {
+  log_debug(interpreter, safepoint)("changing single step to '%s'", _on ? "on" : "off");
   JvmtiEventControllerPrivate::set_should_post_single_step(_on);
   if (_on) {
     Interpreter::notice_safepoints();
+  } else {
+    Interpreter::ignore_safepoints();
   }
 }