8068909: SIGSEGV in c2 compiled code with OptimizeStringConcat

Reviewed-by: kvn
This commit is contained in:
Axel Siebenborn 2015-01-16 13:58:22 +01:00
parent 2bd7efd60e
commit 0520df8a92
2 changed files with 97 additions and 3 deletions

View file

@ -1507,10 +1507,12 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) {
}
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);
@ -1533,10 +1535,13 @@ void PhaseStringOpts::replace_string_concat(StringConcat* sc) {
// 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;