comparison src/share/vm/opto/memnode.cpp @ 1080:7c57aead6d3e

6892658: C2 should optimize some stringbuilder patterns Reviewed-by: kvn, twisti
author never
date Thu, 12 Nov 2009 09:24:21 -0800
parents dcdcc8c16e20
children f96a1a986f7b
comparison
equal deleted inserted replaced
1078:8e7adf982378 1080:7c57aead6d3e
1501 } 1501 }
1502 return jt; 1502 return jt;
1503 } 1503 }
1504 } 1504 }
1505 } else if (tp->base() == Type::InstPtr) { 1505 } else if (tp->base() == Type::InstPtr) {
1506 const TypeInstPtr* tinst = tp->is_instptr();
1507 ciKlass* klass = tinst->klass();
1506 assert( off != Type::OffsetBot || 1508 assert( off != Type::OffsetBot ||
1507 // arrays can be cast to Objects 1509 // arrays can be cast to Objects
1508 tp->is_oopptr()->klass()->is_java_lang_Object() || 1510 tp->is_oopptr()->klass()->is_java_lang_Object() ||
1509 // unsafe field access may not have a constant offset 1511 // unsafe field access may not have a constant offset
1510 phase->C->has_unsafe_access(), 1512 phase->C->has_unsafe_access(),
1511 "Field accesses must be precise" ); 1513 "Field accesses must be precise" );
1512 // For oop loads, we expect the _type to be precise 1514 // For oop loads, we expect the _type to be precise
1515 if (OptimizeStringConcat && klass == phase->C->env()->String_klass() &&
1516 adr->is_AddP() && off != Type::OffsetBot) {
1517 // For constant Strings treat the fields as compile time constants.
1518 Node* base = adr->in(AddPNode::Base);
1519 if (base->Opcode() == Op_ConP) {
1520 const TypeOopPtr* t = phase->type(base)->isa_oopptr();
1521 ciObject* string = t->const_oop();
1522 ciConstant constant = string->as_instance()->field_value_by_offset(off);
1523 if (constant.basic_type() == T_INT) {
1524 return TypeInt::make(constant.as_int());
1525 } else if (constant.basic_type() == T_ARRAY) {
1526 if (adr->bottom_type()->is_ptr_to_narrowoop()) {
1527 return TypeNarrowOop::make_from_constant(constant.as_object());
1528 } else {
1529 return TypeOopPtr::make_from_constant(constant.as_object());
1530 }
1531 }
1532 }
1533 }
1513 } else if (tp->base() == Type::KlassPtr) { 1534 } else if (tp->base() == Type::KlassPtr) {
1514 assert( off != Type::OffsetBot || 1535 assert( off != Type::OffsetBot ||
1515 // arrays can be cast to Objects 1536 // arrays can be cast to Objects
1516 tp->is_klassptr()->klass()->is_java_lang_Object() || 1537 tp->is_klassptr()->klass()->is_java_lang_Object() ||
1517 // also allow array-loading from the primary supertype 1538 // also allow array-loading from the primary supertype