changeset 10239:417cf2936379

8149969: [JVMCI] PrintNMethods is ignored for CompilerToVM.installCode when not called from the broker Reviewed-by: kvn
author never
date Tue, 16 Feb 2016 09:49:58 -0800
parents 9cf33e51c2d4
children ccc25f034f38
files src/share/vm/code/nmethod.cpp src/share/vm/code/nmethod.hpp src/share/vm/compiler/compileBroker.cpp src/share/vm/jvmci/jvmciEnv.cpp
diffstat 4 files changed, 21 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/code/nmethod.cpp	Mon Feb 15 23:45:15 2016 +0300
+++ b/src/share/vm/code/nmethod.cpp	Tue Feb 16 09:49:58 2016 -0800
@@ -33,6 +33,7 @@
 #include "compiler/compileBroker.hpp"
 #include "compiler/compileLog.hpp"
 #include "compiler/compilerDirectives.hpp"
+#include "compiler/directivesParser.hpp"
 #include "compiler/disassembler.hpp"
 #include "interpreter/bytecode.hpp"
 #include "oops/methodData.hpp"
@@ -965,6 +966,12 @@
   }
 }
 
+void nmethod::maybe_print_nmethod(DirectiveSet* directive) {
+  bool printnmethods = directive->PrintAssemblyOption || directive->PrintNMethodsOption;
+  if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
+    print_nmethod(printnmethods);
+  }
+}
 
 void nmethod::print_nmethod(bool printmethod) {
   ttyLocker ttyl;  // keep the following output all in one block
--- a/src/share/vm/code/nmethod.hpp	Mon Feb 15 23:45:15 2016 +0300
+++ b/src/share/vm/code/nmethod.hpp	Tue Feb 16 09:49:58 2016 -0800
@@ -29,6 +29,8 @@
 #include "code/pcDesc.hpp"
 #include "oops/metadata.hpp"
 
+class DirectiveSet;
+
 // This class is used internally by nmethods, to cache
 // exception/pc/handler information.
 
@@ -714,6 +716,8 @@
   void print_nul_chk_table()                      PRODUCT_RETURN;
   void print_recorded_oops()                      PRODUCT_RETURN;
   void print_recorded_metadata()                  PRODUCT_RETURN;
+
+  void maybe_print_nmethod(DirectiveSet* directive);
   void print_nmethod(bool print_code);
 
   // need to re-define this from CodeBlob else the overload hides it
--- a/src/share/vm/compiler/compileBroker.cpp	Mon Feb 15 23:45:15 2016 +0300
+++ b/src/share/vm/compiler/compileBroker.cpp	Tue Feb 16 09:49:58 2016 -0800
@@ -1919,12 +1919,9 @@
 
   collect_statistics(thread, time, task);
 
-  bool printnmethods = directive->PrintAssemblyOption || directive->PrintNMethodsOption;
-  if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
-    nmethod* nm = task->code();
-    if (nm != NULL) {
-      nm->print_nmethod(printnmethods);
-    }
+  nmethod* nm = task->code();
+  if (nm != NULL) {
+    nm->maybe_print_nmethod(directive);
   }
   DirectivesStack::release(directive);
 
--- a/src/share/vm/jvmci/jvmciEnv.cpp	Mon Feb 15 23:45:15 2016 +0300
+++ b/src/share/vm/jvmci/jvmciEnv.cpp	Tue Feb 16 09:49:58 2016 -0800
@@ -591,6 +591,13 @@
   // JVMTI -- compiled method notification (must be done outside lock)
   if (nm != NULL) {
     nm->post_compiled_method_load_event();
+
+    if (env == NULL) {
+      // This compile didn't come through the CompileBroker so perform the printing here
+      DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, compiler);
+      nm->maybe_print_nmethod(directive);
+      DirectivesStack::release(directive);
+    }
   }
 
   return result;