8150720: Cleanup code around PrintOptoStatistics
authorredestad
Mon, 29 Feb 2016 15:05:45 +0100
changeset 36336 7006dd73b206
parent 36335 fb37a966adf0
child 36337 d4b2f60ff5a9
8150720: Cleanup code around PrintOptoStatistics Reviewed-by: kvn, shade, vlivanov
hotspot/src/share/vm/opto/graphKit.cpp
hotspot/src/share/vm/opto/ifnode.cpp
hotspot/src/share/vm/opto/lcm.cpp
hotspot/src/share/vm/opto/matcher.cpp
hotspot/src/share/vm/opto/node.cpp
hotspot/src/share/vm/opto/parse.hpp
hotspot/src/share/vm/opto/parse1.cpp
hotspot/src/share/vm/opto/parse2.cpp
--- a/hotspot/src/share/vm/opto/graphKit.cpp	Mon Feb 29 13:02:10 2016 +0100
+++ b/hotspot/src/share/vm/opto/graphKit.cpp	Mon Feb 29 15:05:45 2016 +0100
@@ -1179,8 +1179,10 @@
 // Helper function to do a NULL pointer check.  Returned value is
 // the incoming address with NULL casted away.  You are allowed to use the
 // not-null value only if you are control dependent on the test.
+#ifndef PRODUCT
 extern int explicit_null_checks_inserted,
            explicit_null_checks_elided;
+#endif
 Node* GraphKit::null_check_common(Node* value, BasicType type,
                                   // optional arguments for variations:
                                   bool assert_null,
@@ -1193,7 +1195,7 @@
     value = cast_not_null(value);   // Make it appear to be non-null (4962416).
     return value;
   }
-  explicit_null_checks_inserted++;
+  NOT_PRODUCT(explicit_null_checks_inserted++);
 
   // Construct NULL check
   Node *chk = NULL;
@@ -1233,7 +1235,7 @@
         // See if the type is contained in NULL_PTR.
         // If so, then the value is already null.
         if (t->higher_equal(TypePtr::NULL_PTR)) {
-          explicit_null_checks_elided++;
+          NOT_PRODUCT(explicit_null_checks_elided++);
           return value;           // Elided null assert quickly!
         }
       } else {
@@ -1242,7 +1244,7 @@
         // type.  In other words, "value" was not-null.
         if (t->meet(TypePtr::NULL_PTR) != t->remove_speculative()) {
           // same as: if (!TypePtr::NULL_PTR->higher_equal(t)) ...
-          explicit_null_checks_elided++;
+          NOT_PRODUCT(explicit_null_checks_elided++);
           return value;           // Elided null check quickly!
         }
       }
@@ -1282,7 +1284,7 @@
         set_control(cfg);
         Node *res = cast_not_null(value);
         set_control(oldcontrol);
-        explicit_null_checks_elided++;
+        NOT_PRODUCT(explicit_null_checks_elided++);
         return res;
       }
       cfg = IfNode::up_one_dom(cfg, /*linear_only=*/ true);
@@ -1326,15 +1328,18 @@
     IfNode* iff = create_and_map_if(control(), tst, ok_prob, COUNT_UNKNOWN);
     Node* null_true = _gvn.transform( new IfFalseNode(iff));
     set_control(      _gvn.transform( new IfTrueNode(iff)));
-    if (null_true == top())
+#ifndef PRODUCT
+    if (null_true == top()) {
       explicit_null_checks_elided++;
+    }
+#endif
     (*null_control) = null_true;
   } else {
     BuildCutout unless(this, tst, ok_prob);
     // Check for optimizer eliding test at parse time
     if (stopped()) {
       // Failure not possible; do not bother making uncommon trap.
-      explicit_null_checks_elided++;
+      NOT_PRODUCT(explicit_null_checks_elided++);
     } else if (assert_null) {
       uncommon_trap(reason,
                     Deoptimization::Action_make_not_entrant,
--- a/hotspot/src/share/vm/opto/ifnode.cpp	Mon Feb 29 13:02:10 2016 +0100
+++ b/hotspot/src/share/vm/opto/ifnode.cpp	Mon Feb 29 15:05:45 2016 +0100
@@ -40,7 +40,9 @@
 // Optimization - Graph Style
 
 
+#ifndef PRODUCT
 extern int explicit_null_checks_elided;
+#endif
 
 //=============================================================================
 //------------------------------Value------------------------------------------
@@ -1504,24 +1506,28 @@
   Node* prev_dom = this;
   int op = Opcode();
   // Search up the dominator tree for an If with an identical test
-  while( dom->Opcode() != op    ||  // Not same opcode?
+  while (dom->Opcode() != op    ||  // Not same opcode?
          dom->in(1)    != in(1) ||  // Not same input 1?
          (req() == 3 && dom->in(2) != in(2)) || // Not same input 2?
-         prev_dom->in(0) != dom ) { // One path of test does not dominate?
-    if( dist < 0 ) return NULL;
+         prev_dom->in(0) != dom) {  // One path of test does not dominate?
+    if (dist < 0) return NULL;
 
     dist--;
     prev_dom = dom;
-    dom = up_one_dom( dom );
-    if( !dom ) return NULL;
+    dom = up_one_dom(dom);
+    if (!dom) return NULL;
   }
 
   // Check that we did not follow a loop back to ourselves
-  if( this == dom )
+  if (this == dom) {
     return NULL;
+  }
 
-  if( dist > 2 )              // Add to count of NULL checks elided
+#ifndef PRODUCT
+  if (dist > 2) { // Add to count of NULL checks elided
     explicit_null_checks_elided++;
+  }
+#endif
 
   return prev_dom;
 }
--- a/hotspot/src/share/vm/opto/lcm.cpp	Mon Feb 29 13:02:10 2016 +0100
+++ b/hotspot/src/share/vm/opto/lcm.cpp	Mon Feb 29 15:05:45 2016 +0100
@@ -348,8 +348,10 @@
   }
 
   // ---- Found an implicit null check
+#ifndef PRODUCT
   extern int implicit_null_checks;
   implicit_null_checks++;
+#endif
 
   if( is_decoden ) {
     // Check if we need to hoist decodeHeapOop_not_null first.
--- a/hotspot/src/share/vm/opto/matcher.cpp	Mon Feb 29 13:02:10 2016 +0100
+++ b/hotspot/src/share/vm/opto/matcher.cpp	Mon Feb 29 15:05:45 2016 +0100
@@ -2415,8 +2415,10 @@
 
       bool push_it = false;
       if( proj->Opcode() == Op_IfTrue ) {
+#ifndef PRODUCT
         extern int all_null_checks_found;
         all_null_checks_found++;
+#endif
         if( b->_test._test == BoolTest::ne ) {
           push_it = true;
         }
--- a/hotspot/src/share/vm/opto/node.cpp	Mon Feb 29 13:02:10 2016 +0100
+++ b/hotspot/src/share/vm/opto/node.cpp	Mon Feb 29 15:05:45 2016 +0100
@@ -576,17 +576,11 @@
 
 //------------------------------~Node------------------------------------------
 // Fancy destructor; eagerly attempt to reclaim Node numberings and storage
-extern int reclaim_idx ;
-extern int reclaim_in  ;
-extern int reclaim_node;
 void Node::destruct() {
   // Eagerly reclaim unique Node numberings
   Compile* compile = Compile::current();
   if ((uint)_idx+1 == compile->unique()) {
     compile->set_unique(compile->unique()-1);
-#ifdef ASSERT
-    reclaim_idx++;
-#endif
   }
   // Clear debug info:
   Node_Notes* nn = compile->node_notes_at(_idx);
@@ -604,43 +598,25 @@
   int out_edge_size = _outmax*sizeof(void*);
   char *edge_end = ((char*)_in) + edge_size;
   char *out_array = (char*)(_out == NO_OUT_ARRAY? NULL: _out);
-  char *out_edge_end = out_array + out_edge_size;
   int node_size = size_of();
 
   // Free the output edge array
   if (out_edge_size > 0) {
-#ifdef ASSERT
-    if( out_edge_end == compile->node_arena()->hwm() )
-      reclaim_in  += out_edge_size;  // count reclaimed out edges with in edges
-#endif
     compile->node_arena()->Afree(out_array, out_edge_size);
   }
 
   // Free the input edge array and the node itself
   if( edge_end == (char*)this ) {
-#ifdef ASSERT
-    if( edge_end+node_size == compile->node_arena()->hwm() ) {
-      reclaim_in  += edge_size;
-      reclaim_node+= node_size;
-    }
-#else
     // It was; free the input array and object all in one hit
+#ifndef ASSERT
     compile->node_arena()->Afree(_in,edge_size+node_size);
 #endif
   } else {
-
     // Free just the input array
-#ifdef ASSERT
-    if( edge_end == compile->node_arena()->hwm() )
-      reclaim_in  += edge_size;
-#endif
     compile->node_arena()->Afree(_in,edge_size);
 
     // Free just the object
-#ifdef ASSERT
-    if( ((char*)this) + node_size == compile->node_arena()->hwm() )
-      reclaim_node+= node_size;
-#else
+#ifndef ASSERT
     compile->node_arena()->Afree(this,node_size);
 #endif
   }
--- a/hotspot/src/share/vm/opto/parse.hpp	Mon Feb 29 13:02:10 2016 +0100
+++ b/hotspot/src/share/vm/opto/parse.hpp	Mon Feb 29 15:05:45 2016 +0100
@@ -104,13 +104,6 @@
   // For temporary (stack-allocated, stateless) ilts:
   InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvms, float site_invoke_ratio, int max_inline_level);
 
-  // InlineTree enum
-  enum InlineStyle {
-    Inline_do_not_inline             =   0, //
-    Inline_cha_is_monomorphic        =   1, //
-    Inline_type_profile_monomorphic  =   2  //
-  };
-
   // See if it is OK to inline.
   // The receiver is the inline tree for the caller.
   //
@@ -349,9 +342,6 @@
   Block*            _block;     // block currently getting parsed
   ciBytecodeStream  _iter;      // stream of this method's bytecodes
 
-  int           _blocks_merged; // Progress meter: state merges from BB preds
-  int           _blocks_parsed; // Progress meter: BBs actually parsed
-
   const FastLockNode* _synch_lock; // FastLockNode for synchronized method
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/opto/parse1.cpp	Mon Feb 29 13:02:10 2016 +0100
+++ b/hotspot/src/share/vm/opto/parse1.cpp	Mon Feb 29 15:05:45 2016 +0100
@@ -45,6 +45,7 @@
 // the most. Some of the non-static variables are needed in bytecodeInfo.cpp
 // and eventually should be encapsulated in a proper class (gri 8/18/98).
 
+#ifndef PRODUCT
 int nodes_created              = 0;
 int methods_parsed             = 0;
 int methods_seen               = 0;
@@ -53,42 +54,42 @@
 
 int explicit_null_checks_inserted = 0;
 int explicit_null_checks_elided   = 0;
-int all_null_checks_found         = 0, implicit_null_checks              = 0;
-int implicit_null_throws          = 0;
+int all_null_checks_found         = 0;
+int implicit_null_checks          = 0;
 
-int reclaim_idx  = 0;
-int reclaim_in   = 0;
-int reclaim_node = 0;
-
-#ifndef PRODUCT
 bool Parse::BytecodeParseHistogram::_initialized = false;
 uint Parse::BytecodeParseHistogram::_bytecodes_parsed [Bytecodes::number_of_codes];
 uint Parse::BytecodeParseHistogram::_nodes_constructed[Bytecodes::number_of_codes];
 uint Parse::BytecodeParseHistogram::_nodes_transformed[Bytecodes::number_of_codes];
 uint Parse::BytecodeParseHistogram::_new_values       [Bytecodes::number_of_codes];
-#endif
 
 //------------------------------print_statistics-------------------------------
-#ifndef PRODUCT
 void Parse::print_statistics() {
   tty->print_cr("--- Compiler Statistics ---");
   tty->print("Methods seen: %d  Methods parsed: %d", methods_seen, methods_parsed);
   tty->print("  Nodes created: %d", nodes_created);
   tty->cr();
-  if (methods_seen != methods_parsed)
+  if (methods_seen != methods_parsed) {
     tty->print_cr("Reasons for parse failures (NOT cumulative):");
+  }
   tty->print_cr("Blocks parsed: %d  Blocks seen: %d", blocks_parsed, blocks_seen);
 
-  if( explicit_null_checks_inserted )
-    tty->print_cr("%d original NULL checks - %d elided (%2d%%); optimizer leaves %d,", explicit_null_checks_inserted, explicit_null_checks_elided, (100*explicit_null_checks_elided)/explicit_null_checks_inserted, all_null_checks_found);
-  if( all_null_checks_found )
+  if (explicit_null_checks_inserted) {
+    tty->print_cr("%d original NULL checks - %d elided (%2d%%); optimizer leaves %d,",
+                  explicit_null_checks_inserted, explicit_null_checks_elided,
+                  (100*explicit_null_checks_elided)/explicit_null_checks_inserted,
+                  all_null_checks_found);
+  }
+  if (all_null_checks_found) {
     tty->print_cr("%d made implicit (%2d%%)", implicit_null_checks,
                   (100*implicit_null_checks)/all_null_checks_found);
-  if( implicit_null_throws )
+  }
+  if (SharedRuntime::_implicit_null_throws) {
     tty->print_cr("%d implicit null exceptions at runtime",
-                  implicit_null_throws);
+                  SharedRuntime::_implicit_null_throws);
+  }
 
-  if( PrintParseStatistics && BytecodeParseHistogram::initialized() ) {
+  if (PrintParseStatistics && BytecodeParseHistogram::initialized()) {
     BytecodeParseHistogram::print();
   }
 }
@@ -495,7 +496,7 @@
     C->dependencies()->assert_evol_method(method());
   }
 
-  methods_seen++;
+  NOT_PRODUCT(methods_seen++);
 
   // Do some special top-level things.
   if (depth() == 1 && C->is_osr_compilation()) {
@@ -530,8 +531,8 @@
   }
 #endif
 
+#ifndef PRODUCT
   methods_parsed++;
-#ifndef PRODUCT
   // add method size here to guarantee that inlined methods are added too
   if (CITime)
     _total_bytes_compiled += method()->code_size();
@@ -652,7 +653,7 @@
         continue;
       }
 
-      blocks_parsed++;
+      NOT_PRODUCT(blocks_parsed++);
 
       progress = true;
       if (block->is_loop_head() || block->is_handler() || has_irreducible && !block->is_ready()) {
@@ -712,9 +713,9 @@
     }
   }
 
+#ifndef PRODUCT
   blocks_seen += block_count();
 
-#ifndef PRODUCT
   // Make sure there are no half-processed blocks remaining.
   // Every remaining unprocessed block is dead and may be ignored now.
   for (int rpo = 0; rpo < block_count(); rpo++) {
@@ -1446,7 +1447,6 @@
 
   assert(block()->is_merged(), "must be merged before being parsed");
   block()->mark_parsed();
-  ++_blocks_parsed;
 
   // Set iterator to start of block.
   iter().reset_to_bci(block()->start());
@@ -1596,9 +1596,6 @@
       return;
     }
 
-    // Record that a new block has been merged.
-    ++_blocks_merged;
-
     // Make a region if we know there are multiple or unpredictable inputs.
     // (Also, if this is a plain fall-through, we might see another region,
     // which must not be allowed into this block's map.)
--- a/hotspot/src/share/vm/opto/parse2.cpp	Mon Feb 29 13:02:10 2016 +0100
+++ b/hotspot/src/share/vm/opto/parse2.cpp	Mon Feb 29 15:05:45 2016 +0100
@@ -44,8 +44,10 @@
 #include "runtime/deoptimization.hpp"
 #include "runtime/sharedRuntime.hpp"
 
+#ifndef PRODUCT
 extern int explicit_null_checks_inserted,
            explicit_null_checks_elided;
+#endif
 
 //---------------------------------array_load----------------------------------
 void Parse::array_load(BasicType elem_type) {
@@ -997,7 +999,7 @@
     return;
   }
 
-  explicit_null_checks_inserted++;
+  NOT_PRODUCT(explicit_null_checks_inserted++);
 
   // Generate real control flow
   Node   *tst = _gvn.transform( new BoolNode( c, btest ) );
@@ -1013,7 +1015,7 @@
     set_control(iftrue);
 
     if (stopped()) {            // Path is dead?
-      explicit_null_checks_elided++;
+      NOT_PRODUCT(explicit_null_checks_elided++);
       if (C->eliminate_boxing()) {
         // Mark the successor block as parsed
         branch_block->next_path_num();
@@ -1033,7 +1035,7 @@
   set_control(iffalse);
 
   if (stopped()) {              // Path is dead?
-    explicit_null_checks_elided++;
+    NOT_PRODUCT(explicit_null_checks_elided++);
     if (C->eliminate_boxing()) {
       // Mark the successor block as parsed
       next_block->next_path_num();