< prev index next >

hotspot/src/share/vm/opto/stringopts.cpp

Print this page
rev 7079 : 8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat
Reviewed-by: kvn

@@ -1505,14 +1505,16 @@
         assert(kit.gvn().type(arg)->higher_equal(TypeInstPtr::NOTNULL), "sanity");
         // Fallthrough to add string length.
       }
       case StringConcat::StringMode: {
         const Type* type = kit.gvn().type(arg);
+        Node* count = NULL;
         if (type == TypePtr::NULL_PTR) {
           // replace the argument with the null checked version
           arg = null_string;
           sc->set_argument(argi, arg);
+          count = kit.load_String_length(kit.control(), arg);
         } else if (!type->higher_equal(TypeInstPtr::NOTNULL)) {
           // s = s != null ? s : "null";
           // length = length + (s.count - s.offset);
           RegionNode *r = new (C) RegionNode(3);
           kit.gvn().set_type(r, Type::CONTROL);

@@ -1531,14 +1533,17 @@
           C->record_for_igvn(r);
           C->record_for_igvn(phi);
           // replace the argument with the null checked version
           arg = phi;
           sc->set_argument(argi, arg);
+          count = kit.load_String_length(kit.control(), arg);
+        } else {
+          // A corresponding nullcheck will be connected during IGVN MemNode::Ideal_common_DU_postCCP
+          // kit.control might be a different test, that can be hoisted above the actual nullcheck
+          // in case, that the control input is not null, Ideal_common_DU_postCCP will not look for a nullcheck.
+          count = kit.load_String_length(NULL, arg);
         }
-
-        Node* count = kit.load_String_length(kit.control(), arg);
-
         length = __ AddI(length, count);
         string_sizes->init_req(argi, NULL);
         break;
       }
       case StringConcat::CharMode: {
< prev index next >