< prev index next >

src/hotspot/share/opto/ifnode.cpp

Print this page
rev 48500 : 8194988: 8 Null pointer dereference defect groups related to MultiNode::proj_out()
   1 /*
   2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 488   if (cmp == NULL)  return NULL;
 489   if (cmp->Opcode() != Op_CmpU)  return NULL;
 490 
 491   l = cmp->in(1);
 492   r = cmp->in(2);
 493   flip_test = 1;
 494   if (bn->_test._test == BoolTest::le) {
 495     l = cmp->in(2);
 496     r = cmp->in(1);
 497     flip_test = 2;
 498   } else if (bn->_test._test != BoolTest::lt) {
 499     return NULL;
 500   }
 501   if (l->is_top())  return NULL;   // Top input means dead test
 502   if (r->Opcode() != Op_LoadRange && !is_RangeCheck())  return NULL;
 503 
 504   // We have recognized one of these forms:
 505   //  Flip 1:  If (Bool[<] CmpU(l, LoadRange)) ...
 506   //  Flip 2:  If (Bool[<=] CmpU(LoadRange, l)) ...
 507 
 508   ProjNode* iftrap = proj_out(flip_test == 2 ? true : false);
 509   return iftrap;
 510 }
 511 
 512 
 513 //------------------------------is_range_check---------------------------------
 514 // Return 0 if not a range check.  Return 1 if a range check and set index and
 515 // offset.  Return 2 if we had to negate the test.  Index is NULL if the check
 516 // is versus a constant.
 517 int RangeCheckNode::is_range_check(Node* &range, Node* &index, jint &offset) {
 518   int flip_test = 0;
 519   Node* l = NULL;
 520   Node* r = NULL;
 521   ProjNode* iftrap = range_check_trap_proj(flip_test, l, r);
 522 
 523   if (iftrap == NULL) {
 524     return 0;
 525   }
 526 
 527   // Make sure it's a real range check by requiring an uncommon trap
 528   // along the OOB path.  Otherwise, it's possible that the user wrote


1454     tty->print("   Removing IfNode: "); this->dump();
1455   }
1456   if (VerifyOpto && !igvn->allow_progress()) {
1457     // Found an equivalent dominating test,
1458     // we can not guarantee reaching a fix-point for these during iterativeGVN
1459     // since intervening nodes may not change.
1460     return NULL;
1461   }
1462 #endif
1463 
1464   igvn->hash_delete(this);      // Remove self to prevent spurious V-N
1465   Node *idom = in(0);
1466   // Need opcode to decide which way 'this' test goes
1467   int prev_op = prev_dom->Opcode();
1468   Node *top = igvn->C->top(); // Shortcut to top
1469 
1470   // Loop predicates may have depending checks which should not
1471   // be skipped. For example, range check predicate has two checks
1472   // for lower and upper bounds.
1473   ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj();
1474   if ((unc_proj != NULL) && (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL)) {
1475     prev_dom = idom;
1476   }
1477 
1478   // Now walk the current IfNode's projections.
1479   // Loop ends when 'this' has no more uses.
1480   for (DUIterator_Last imin, i = last_outs(imin); i >= imin; --i) {
1481     Node *ifp = last_out(i);     // Get IfTrue/IfFalse
1482     igvn->add_users_to_worklist(ifp);
1483     // Check which projection it is and set target.
1484     // Data-target is either the dominating projection of the same type
1485     // or TOP if the dominating projection is of opposite type.
1486     // Data-target will be used as the new control edge for the non-CFG
1487     // nodes like Casts and Loads.
1488     Node *data_target = (ifp->Opcode() == prev_op) ? prev_dom : top;
1489     // Control-target is just the If's immediate dominator or TOP.
1490     Node *ctrl_target = (ifp->Opcode() == prev_op) ?     idom : top;
1491 
1492     // For each child of an IfTrue/IfFalse projection, reroute.
1493     // Loop ends when projection has no more uses.
1494     for (DUIterator_Last jmin, j = ifp->last_outs(jmin); j >= jmin; --j) {


   1 /*
   2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 488   if (cmp == NULL)  return NULL;
 489   if (cmp->Opcode() != Op_CmpU)  return NULL;
 490 
 491   l = cmp->in(1);
 492   r = cmp->in(2);
 493   flip_test = 1;
 494   if (bn->_test._test == BoolTest::le) {
 495     l = cmp->in(2);
 496     r = cmp->in(1);
 497     flip_test = 2;
 498   } else if (bn->_test._test != BoolTest::lt) {
 499     return NULL;
 500   }
 501   if (l->is_top())  return NULL;   // Top input means dead test
 502   if (r->Opcode() != Op_LoadRange && !is_RangeCheck())  return NULL;
 503 
 504   // We have recognized one of these forms:
 505   //  Flip 1:  If (Bool[<] CmpU(l, LoadRange)) ...
 506   //  Flip 2:  If (Bool[<=] CmpU(LoadRange, l)) ...
 507 
 508   ProjNode* iftrap = proj_out_or_null(flip_test == 2 ? true : false);
 509   return iftrap;
 510 }
 511 
 512 
 513 //------------------------------is_range_check---------------------------------
 514 // Return 0 if not a range check.  Return 1 if a range check and set index and
 515 // offset.  Return 2 if we had to negate the test.  Index is NULL if the check
 516 // is versus a constant.
 517 int RangeCheckNode::is_range_check(Node* &range, Node* &index, jint &offset) {
 518   int flip_test = 0;
 519   Node* l = NULL;
 520   Node* r = NULL;
 521   ProjNode* iftrap = range_check_trap_proj(flip_test, l, r);
 522 
 523   if (iftrap == NULL) {
 524     return 0;
 525   }
 526 
 527   // Make sure it's a real range check by requiring an uncommon trap
 528   // along the OOB path.  Otherwise, it's possible that the user wrote


1454     tty->print("   Removing IfNode: "); this->dump();
1455   }
1456   if (VerifyOpto && !igvn->allow_progress()) {
1457     // Found an equivalent dominating test,
1458     // we can not guarantee reaching a fix-point for these during iterativeGVN
1459     // since intervening nodes may not change.
1460     return NULL;
1461   }
1462 #endif
1463 
1464   igvn->hash_delete(this);      // Remove self to prevent spurious V-N
1465   Node *idom = in(0);
1466   // Need opcode to decide which way 'this' test goes
1467   int prev_op = prev_dom->Opcode();
1468   Node *top = igvn->C->top(); // Shortcut to top
1469 
1470   // Loop predicates may have depending checks which should not
1471   // be skipped. For example, range check predicate has two checks
1472   // for lower and upper bounds.
1473   ProjNode* unc_proj = proj_out(1 - prev_dom->as_Proj()->_con)->as_Proj();
1474   if (unc_proj->is_uncommon_trap_proj(Deoptimization::Reason_predicate) != NULL) {
1475     prev_dom = idom;
1476   }
1477 
1478   // Now walk the current IfNode's projections.
1479   // Loop ends when 'this' has no more uses.
1480   for (DUIterator_Last imin, i = last_outs(imin); i >= imin; --i) {
1481     Node *ifp = last_out(i);     // Get IfTrue/IfFalse
1482     igvn->add_users_to_worklist(ifp);
1483     // Check which projection it is and set target.
1484     // Data-target is either the dominating projection of the same type
1485     // or TOP if the dominating projection is of opposite type.
1486     // Data-target will be used as the new control edge for the non-CFG
1487     // nodes like Casts and Loads.
1488     Node *data_target = (ifp->Opcode() == prev_op) ? prev_dom : top;
1489     // Control-target is just the If's immediate dominator or TOP.
1490     Node *ctrl_target = (ifp->Opcode() == prev_op) ?     idom : top;
1491 
1492     // For each child of an IfTrue/IfFalse projection, reroute.
1493     // Loop ends when projection has no more uses.
1494     for (DUIterator_Last jmin, j = ifp->last_outs(jmin); j >= jmin; --j) {


< prev index next >