hotspot/src/share/vm/opto/stringopts.cpp
changeset 28642 a42fefc69922
parent 25930 eae8b7490d2c
child 29081 c61eb4914428
equal deleted inserted replaced
28641:6b05689b7445 28642:a42fefc69922
  1505         assert(kit.gvn().type(arg)->higher_equal(TypeInstPtr::NOTNULL), "sanity");
  1505         assert(kit.gvn().type(arg)->higher_equal(TypeInstPtr::NOTNULL), "sanity");
  1506         // Fallthrough to add string length.
  1506         // Fallthrough to add string length.
  1507       }
  1507       }
  1508       case StringConcat::StringMode: {
  1508       case StringConcat::StringMode: {
  1509         const Type* type = kit.gvn().type(arg);
  1509         const Type* type = kit.gvn().type(arg);
       
  1510         Node* count = NULL;
  1510         if (type == TypePtr::NULL_PTR) {
  1511         if (type == TypePtr::NULL_PTR) {
  1511           // replace the argument with the null checked version
  1512           // replace the argument with the null checked version
  1512           arg = null_string;
  1513           arg = null_string;
  1513           sc->set_argument(argi, arg);
  1514           sc->set_argument(argi, arg);
       
  1515           count = kit.load_String_length(kit.control(), arg);
  1514         } else if (!type->higher_equal(TypeInstPtr::NOTNULL)) {
  1516         } else if (!type->higher_equal(TypeInstPtr::NOTNULL)) {
  1515           // s = s != null ? s : "null";
  1517           // s = s != null ? s : "null";
  1516           // length = length + (s.count - s.offset);
  1518           // length = length + (s.count - s.offset);
  1517           RegionNode *r = new RegionNode(3);
  1519           RegionNode *r = new RegionNode(3);
  1518           kit.gvn().set_type(r, Type::CONTROL);
  1520           kit.gvn().set_type(r, Type::CONTROL);
  1531           C->record_for_igvn(r);
  1533           C->record_for_igvn(r);
  1532           C->record_for_igvn(phi);
  1534           C->record_for_igvn(phi);
  1533           // replace the argument with the null checked version
  1535           // replace the argument with the null checked version
  1534           arg = phi;
  1536           arg = phi;
  1535           sc->set_argument(argi, arg);
  1537           sc->set_argument(argi, arg);
  1536         }
  1538           count = kit.load_String_length(kit.control(), arg);
  1537 
  1539         } else {
  1538         Node* count = kit.load_String_length(kit.control(), arg);
  1540           // A corresponding nullcheck will be connected during IGVN MemNode::Ideal_common_DU_postCCP
  1539 
  1541           // kit.control might be a different test, that can be hoisted above the actual nullcheck
       
  1542           // in case, that the control input is not null, Ideal_common_DU_postCCP will not look for a nullcheck.
       
  1543           count = kit.load_String_length(NULL, arg);
       
  1544         }
  1540         length = __ AddI(length, count);
  1545         length = __ AddI(length, count);
  1541         string_sizes->init_req(argi, NULL);
  1546         string_sizes->init_req(argi, NULL);
  1542         break;
  1547         break;
  1543       }
  1548       }
  1544       case StringConcat::CharMode: {
  1549       case StringConcat::CharMode: {