changeset 248:18aab3cdd513

6726504: handle do_ifxxx calls in parser more uniformly Summary: make do_ifnull() handling similar to do_if() Reviewed-by: jrose, kvn
author rasbold
date Mon, 21 Jul 2008 13:37:05 -0700
parents 02a35ad4adf8
children 910a4cb98e9e
files src/share/vm/opto/parse.hpp src/share/vm/opto/parse2.cpp
diffstat 2 files changed, 15 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/opto/parse.hpp	Wed Jul 16 16:04:39 2008 -0700
+++ b/src/share/vm/opto/parse.hpp	Mon Jul 21 13:37:05 2008 -0700
@@ -479,7 +479,7 @@
   float   branch_prediction(float &cnt, BoolTest::mask btest, int target_bci);
   bool    seems_never_taken(float prob);
 
-  void    do_ifnull(BoolTest::mask btest);
+  void    do_ifnull(BoolTest::mask btest, Node* c);
   void    do_if(BoolTest::mask btest, Node* c);
   void    repush_if_args();
   void    adjust_map_after_if(BoolTest::mask btest, Node* c, float prob,
--- a/src/share/vm/opto/parse2.cpp	Wed Jul 16 16:04:39 2008 -0700
+++ b/src/share/vm/opto/parse2.cpp	Mon Jul 21 13:37:05 2008 -0700
@@ -894,7 +894,7 @@
 }
 
 //----------------------------------do_ifnull----------------------------------
-void Parse::do_ifnull(BoolTest::mask btest) {
+void Parse::do_ifnull(BoolTest::mask btest, Node *c) {
   int target_bci = iter().get_dest();
 
   Block* branch_block = successor_for_bci(target_bci);
@@ -906,8 +906,9 @@
     // (An earlier version of do_ifnull omitted this trap for OSR methods.)
 #ifndef PRODUCT
     if (PrintOpto && Verbose)
-      tty->print_cr("Never-taken backedge stops compilation at bci %d",bci());
+      tty->print_cr("Never-taken edge stops compilation at bci %d",bci());
 #endif
+    repush_if_args(); // to gather stats on loop
     // We need to mark this branch as taken so that if we recompile we will
     // see that it is possible. In the tiered system the interpreter doesn't
     // do profiling and by the time we get to the lower tier from the interpreter
@@ -928,14 +929,6 @@
   maybe_add_safepoint(target_bci);
 
   explicit_null_checks_inserted++;
-  Node* a = null();
-  Node* b = pop();
-  Node* c = _gvn.transform( new (C, 3) CmpPNode(b, a) );
-
-  // Make a cast-away-nullness that is control dependent on the test
-  const Type *t = _gvn.type(b);
-  const Type *t_not_null = t->join(TypePtr::NOTNULL);
-  Node *cast = new (C, 2) CastPPNode(b,t_not_null);
 
   // Generate real control flow
   Node   *tst = _gvn.transform( new (C, 2) BoolNode( c, btest ) );
@@ -997,7 +990,7 @@
   if (prob == PROB_UNKNOWN) {
 #ifndef PRODUCT
     if (PrintOpto && Verbose)
-      tty->print_cr("Never-taken backedge stops compilation at bci %d",bci());
+      tty->print_cr("Never-taken edge stops compilation at bci %d",bci());
 #endif
     repush_if_args(); // to gather stats on loop
     // We need to mark this branch as taken so that if we recompile we will
@@ -1016,6 +1009,9 @@
     return;
   }
 
+  // If this is a backwards branch in the bytecodes, add Safepoint
+  maybe_add_safepoint(target_bci);
+
   // Sanity check the probability value
   assert(0.0f < prob && prob < 1.0f,"Bad probability in Parser");
 
@@ -2101,18 +2097,18 @@
     break;
   }
 
-  case Bytecodes::_ifnull:
-    do_ifnull(BoolTest::eq);
-    break;
-  case Bytecodes::_ifnonnull:
-    do_ifnull(BoolTest::ne);
+  case Bytecodes::_ifnull:    btest = BoolTest::eq; goto handle_if_null;
+  case Bytecodes::_ifnonnull: btest = BoolTest::ne; goto handle_if_null;
+  handle_if_null:
+    a = null();
+    b = pop();
+    c = _gvn.transform( new (C, 3) CmpPNode(b, a) );
+    do_ifnull(btest, c);
     break;
 
   case Bytecodes::_if_acmpeq: btest = BoolTest::eq; goto handle_if_acmp;
   case Bytecodes::_if_acmpne: btest = BoolTest::ne; goto handle_if_acmp;
   handle_if_acmp:
-    // If this is a backwards branch in the bytecodes, add Safepoint
-    maybe_add_safepoint(iter().get_dest());
     a = pop();
     b = pop();
     c = _gvn.transform( new (C, 3) CmpPNode(b, a) );
@@ -2126,8 +2122,6 @@
   case Bytecodes::_ifgt: btest = BoolTest::gt; goto handle_ifxx;
   case Bytecodes::_ifge: btest = BoolTest::ge; goto handle_ifxx;
   handle_ifxx:
-    // If this is a backwards branch in the bytecodes, add Safepoint
-    maybe_add_safepoint(iter().get_dest());
     a = _gvn.intcon(0);
     b = pop();
     c = _gvn.transform( new (C, 3) CmpINode(b, a) );
@@ -2141,8 +2135,6 @@
   case Bytecodes::_if_icmpgt: btest = BoolTest::gt; goto handle_if_icmp;
   case Bytecodes::_if_icmpge: btest = BoolTest::ge; goto handle_if_icmp;
   handle_if_icmp:
-    // If this is a backwards branch in the bytecodes, add Safepoint
-    maybe_add_safepoint(iter().get_dest());
     a = pop();
     b = pop();
     c = _gvn.transform( new (C, 3) CmpINode( b, a ) );