< prev index next >

src/share/vm/opto/stringopts.cpp

Print this page




 805               ctrl = copy->is_copy();
 806             } else { // a cast
 807               assert(ctrl->req() == 3 &&
 808                      ctrl->in(1) != NULL && ctrl->in(1)->is_Proj() &&
 809                      ctrl->in(2) != NULL && ctrl->in(2)->is_Proj() &&
 810                      ctrl->in(1)->in(0) == ctrl->in(2)->in(0) &&
 811                      ctrl->in(1)->in(0) != NULL && ctrl->in(1)->in(0)->is_If(),
 812                      "must be a simple diamond");
 813               Node* true_proj = ctrl->in(1)->is_IfTrue() ? ctrl->in(1) : ctrl->in(2);
 814               for (SimpleDUIterator i(true_proj); i.has_next(); i.next()) {
 815                 Node* use = i.get();
 816                 assert(use == ctrl || use->is_ConstraintCast(),
 817                        err_msg_res("unexpected user: %s", use->Name()));
 818               }
 819 
 820               iff = ctrl->in(1)->in(0)->as_If();
 821               ctrl = iff->in(0);
 822             }
 823           } else if (ctrl->is_IfTrue()) { // null checks, class checks
 824             iff = ctrl->in(0)->as_If();
 825             assert(iff->is_If(), "must be if");
 826             // Verify that the other arm is an uncommon trap
 827             Node* otherproj = iff->proj_out(1 - ctrl->as_Proj()->_con);
 828             CallStaticJavaNode* call = otherproj->unique_out()->isa_CallStaticJava();
 829             assert(strcmp(call->_name, "uncommon_trap") == 0, "must be uncommond trap");
 830             ctrl = iff->in(0);
 831           } else {
 832             break;
 833           }
 834         }
 835 
 836         assert(ctrl->is_Proj(), "must be a projection");
 837         assert(ctrl->in(0)->is_Initialize(), "should be initialize");
 838         for (SimpleDUIterator i(ctrl); i.has_next(); i.next()) {
 839           Node* use = i.get();
 840           assert(use == copy || use == iff || use == curr || use->is_CheckCastPP() || use->is_Load(),
 841                  err_msg_res("unexpected user: %s", use->Name()));
 842         }
 843 #endif // ASSERT
 844       }
 845     }
 846   }
 847 
 848 #ifndef PRODUCT
 849   if (PrintOptimizeStringConcat) {


 897       }
 898     } else {
 899       ShouldNotReachHere();
 900     }
 901   }
 902 
 903   // Skip backwards through the control checking for unexpected control flow
 904   Node* ptr = _end;
 905   bool fail = false;
 906   while (ptr != _begin) {
 907     if (ptr->is_Call() && ctrl_path.member(ptr)) {
 908       ptr = ptr->in(0);
 909     } else if (ptr->is_CatchProj() && ctrl_path.member(ptr)) {
 910       ptr = ptr->in(0)->in(0)->in(0);
 911       assert(ctrl_path.member(ptr), "should be a known piece of control");
 912     } else if (ptr->is_IfTrue()) {
 913       IfNode* iff = ptr->in(0)->as_If();
 914       BoolNode* b = iff->in(1)->isa_Bool();
 915 
 916       if (b == NULL) {







 917         fail = true;
 918         break;
 919       }
 920 
 921       Node* cmp = b->in(1);
 922       Node* v1 = cmp->in(1);
 923       Node* v2 = cmp->in(2);
 924       Node* otherproj = iff->proj_out(1 - ptr->as_Proj()->_con);
 925 
 926       // Null check of the return of append which can simply be eliminated
 927       if (b->_test._test == BoolTest::ne &&
 928           v2->bottom_type() == TypePtr::NULL_PTR &&
 929           v1->is_Proj() && ctrl_path.member(v1->in(0))) {
 930         // NULL check of the return value of the append
 931         null_check_count++;
 932         if (otherproj->outcnt() == 1) {
 933           CallStaticJavaNode* call = otherproj->unique_out()->isa_CallStaticJava();
 934           if (call != NULL && call->_name != NULL && strcmp(call->_name, "uncommon_trap") == 0) {
 935             ctrl_path.push(call);
 936           }




 805               ctrl = copy->is_copy();
 806             } else { // a cast
 807               assert(ctrl->req() == 3 &&
 808                      ctrl->in(1) != NULL && ctrl->in(1)->is_Proj() &&
 809                      ctrl->in(2) != NULL && ctrl->in(2)->is_Proj() &&
 810                      ctrl->in(1)->in(0) == ctrl->in(2)->in(0) &&
 811                      ctrl->in(1)->in(0) != NULL && ctrl->in(1)->in(0)->is_If(),
 812                      "must be a simple diamond");
 813               Node* true_proj = ctrl->in(1)->is_IfTrue() ? ctrl->in(1) : ctrl->in(2);
 814               for (SimpleDUIterator i(true_proj); i.has_next(); i.next()) {
 815                 Node* use = i.get();
 816                 assert(use == ctrl || use->is_ConstraintCast(),
 817                        err_msg_res("unexpected user: %s", use->Name()));
 818               }
 819 
 820               iff = ctrl->in(1)->in(0)->as_If();
 821               ctrl = iff->in(0);
 822             }
 823           } else if (ctrl->is_IfTrue()) { // null checks, class checks
 824             iff = ctrl->in(0)->as_If();

 825             // Verify that the other arm is an uncommon trap
 826             Node* otherproj = iff->proj_out(1 - ctrl->as_Proj()->_con);
 827             CallStaticJavaNode* call = otherproj->unique_out()->isa_CallStaticJava();
 828             assert(strcmp(call->_name, "uncommon_trap") == 0, "must be uncommon trap");
 829             ctrl = iff->in(0);
 830           } else {
 831             break;
 832           }
 833         }
 834 
 835         assert(ctrl->is_Proj(), "must be a projection");
 836         assert(ctrl->in(0)->is_Initialize(), "should be initialize");
 837         for (SimpleDUIterator i(ctrl); i.has_next(); i.next()) {
 838           Node* use = i.get();
 839           assert(use == copy || use == iff || use == curr || use->is_CheckCastPP() || use->is_Load(),
 840                  err_msg_res("unexpected user: %s", use->Name()));
 841         }
 842 #endif // ASSERT
 843       }
 844     }
 845   }
 846 
 847 #ifndef PRODUCT
 848   if (PrintOptimizeStringConcat) {


 896       }
 897     } else {
 898       ShouldNotReachHere();
 899     }
 900   }
 901 
 902   // Skip backwards through the control checking for unexpected control flow
 903   Node* ptr = _end;
 904   bool fail = false;
 905   while (ptr != _begin) {
 906     if (ptr->is_Call() && ctrl_path.member(ptr)) {
 907       ptr = ptr->in(0);
 908     } else if (ptr->is_CatchProj() && ctrl_path.member(ptr)) {
 909       ptr = ptr->in(0)->in(0)->in(0);
 910       assert(ctrl_path.member(ptr), "should be a known piece of control");
 911     } else if (ptr->is_IfTrue()) {
 912       IfNode* iff = ptr->in(0)->as_If();
 913       BoolNode* b = iff->in(1)->isa_Bool();
 914 
 915       if (b == NULL) {
 916 #ifndef PRODUCT
 917         if (PrintOptimizeStringConcat) {
 918           tty->print_cr("unexpected input to IfNode");
 919           iff->in(1)->dump();
 920           tty->cr();
 921         }
 922 #endif
 923         fail = true;
 924         break;
 925       }
 926 
 927       Node* cmp = b->in(1);
 928       Node* v1 = cmp->in(1);
 929       Node* v2 = cmp->in(2);
 930       Node* otherproj = iff->proj_out(1 - ptr->as_Proj()->_con);
 931 
 932       // Null check of the return of append which can simply be eliminated
 933       if (b->_test._test == BoolTest::ne &&
 934           v2->bottom_type() == TypePtr::NULL_PTR &&
 935           v1->is_Proj() && ctrl_path.member(v1->in(0))) {
 936         // NULL check of the return value of the append
 937         null_check_count++;
 938         if (otherproj->outcnt() == 1) {
 939           CallStaticJavaNode* call = otherproj->unique_out()->isa_CallStaticJava();
 940           if (call != NULL && call->_name != NULL && strcmp(call->_name, "uncommon_trap") == 0) {
 941             ctrl_path.push(call);
 942           }


< prev index next >