comparison src/share/vm/opto/memnode.cpp @ 3902:11a4af030e4b

7071709: JSR 292: switchpoint invalidation should be pushed not pulled Reviewed-by: never
author twisti
date Fri, 02 Sep 2011 04:28:59 -0700
parents f1c12354c3f7
children a92cdbac8b9e
comparison
equal deleted inserted replaced
3901:aa67216400d3 3902:11a4af030e4b
1491 Node* adr = in(MemNode::Address); 1491 Node* adr = in(MemNode::Address);
1492 const TypePtr* tp = phase->type(adr)->isa_ptr(); 1492 const TypePtr* tp = phase->type(adr)->isa_ptr();
1493 if (tp == NULL || tp->empty()) return Type::TOP; 1493 if (tp == NULL || tp->empty()) return Type::TOP;
1494 int off = tp->offset(); 1494 int off = tp->offset();
1495 assert(off != Type::OffsetTop, "case covered by TypePtr::empty"); 1495 assert(off != Type::OffsetTop, "case covered by TypePtr::empty");
1496 Compile* C = phase->C;
1496 1497
1497 // Try to guess loaded type from pointer type 1498 // Try to guess loaded type from pointer type
1498 if (tp->base() == Type::AryPtr) { 1499 if (tp->base() == Type::AryPtr) {
1499 const Type *t = tp->is_aryptr()->elem(); 1500 const Type *t = tp->is_aryptr()->elem();
1500 // Don't do this for integer types. There is only potential profit if 1501 // Don't do this for integer types. There is only potential profit if
1534 if (EliminateAutoBox && adr->is_AddP()) { 1535 if (EliminateAutoBox && adr->is_AddP()) {
1535 // The pointers in the autobox arrays are always non-null 1536 // The pointers in the autobox arrays are always non-null
1536 Node* base = adr->in(AddPNode::Base); 1537 Node* base = adr->in(AddPNode::Base);
1537 if (base != NULL && 1538 if (base != NULL &&
1538 !phase->type(base)->higher_equal(TypePtr::NULL_PTR)) { 1539 !phase->type(base)->higher_equal(TypePtr::NULL_PTR)) {
1539 Compile::AliasType* atp = phase->C->alias_type(base->adr_type()); 1540 Compile::AliasType* atp = C->alias_type(base->adr_type());
1540 if (is_autobox_cache(atp)) { 1541 if (is_autobox_cache(atp)) {
1541 return jt->join(TypePtr::NOTNULL)->is_ptr(); 1542 return jt->join(TypePtr::NOTNULL)->is_ptr();
1542 } 1543 }
1543 } 1544 }
1544 } 1545 }
1545 return jt; 1546 return jt;
1546 } 1547 }
1547 } 1548 }
1548 } else if (tp->base() == Type::InstPtr) { 1549 } else if (tp->base() == Type::InstPtr) {
1550 ciEnv* env = C->env();
1549 const TypeInstPtr* tinst = tp->is_instptr(); 1551 const TypeInstPtr* tinst = tp->is_instptr();
1550 ciKlass* klass = tinst->klass(); 1552 ciKlass* klass = tinst->klass();
1551 assert( off != Type::OffsetBot || 1553 assert( off != Type::OffsetBot ||
1552 // arrays can be cast to Objects 1554 // arrays can be cast to Objects
1553 tp->is_oopptr()->klass()->is_java_lang_Object() || 1555 tp->is_oopptr()->klass()->is_java_lang_Object() ||
1554 // unsafe field access may not have a constant offset 1556 // unsafe field access may not have a constant offset
1555 phase->C->has_unsafe_access(), 1557 C->has_unsafe_access(),
1556 "Field accesses must be precise" ); 1558 "Field accesses must be precise" );
1557 // For oop loads, we expect the _type to be precise 1559 // For oop loads, we expect the _type to be precise
1558 if (klass == phase->C->env()->String_klass() && 1560 if (klass == env->String_klass() &&
1559 adr->is_AddP() && off != Type::OffsetBot) { 1561 adr->is_AddP() && off != Type::OffsetBot) {
1560 // For constant Strings treat the final fields as compile time constants. 1562 // For constant Strings treat the final fields as compile time constants.
1561 Node* base = adr->in(AddPNode::Base); 1563 Node* base = adr->in(AddPNode::Base);
1562 const TypeOopPtr* t = phase->type(base)->isa_oopptr(); 1564 const TypeOopPtr* t = phase->type(base)->isa_oopptr();
1563 if (t != NULL && t->singleton()) { 1565 if (t != NULL && t->singleton()) {
1564 ciField* field = phase->C->env()->String_klass()->get_field_by_offset(off, false); 1566 ciField* field = env->String_klass()->get_field_by_offset(off, false);
1565 if (field != NULL && field->is_final()) { 1567 if (field != NULL && field->is_final()) {
1566 ciObject* string = t->const_oop(); 1568 ciObject* string = t->const_oop();
1567 ciConstant constant = string->as_instance()->field_value(field); 1569 ciConstant constant = string->as_instance()->field_value(field);
1568 if (constant.basic_type() == T_INT) { 1570 if (constant.basic_type() == T_INT) {
1569 return TypeInt::make(constant.as_int()); 1571 return TypeInt::make(constant.as_int());
1571 if (adr->bottom_type()->is_ptr_to_narrowoop()) { 1573 if (adr->bottom_type()->is_ptr_to_narrowoop()) {
1572 return TypeNarrowOop::make_from_constant(constant.as_object(), true); 1574 return TypeNarrowOop::make_from_constant(constant.as_object(), true);
1573 } else { 1575 } else {
1574 return TypeOopPtr::make_from_constant(constant.as_object(), true); 1576 return TypeOopPtr::make_from_constant(constant.as_object(), true);
1575 } 1577 }
1578 }
1579 }
1580 }
1581 }
1582 // Optimizations for constant objects
1583 ciObject* const_oop = tinst->const_oop();
1584 if (const_oop != NULL) {
1585 // For constant CallSites treat the target field as a compile time constant.
1586 if (const_oop->is_call_site()) {
1587 ciCallSite* call_site = const_oop->as_call_site();
1588 ciField* field = call_site->klass()->as_instance_klass()->get_field_by_offset(off, /*is_static=*/ false);
1589 if (field != NULL && field->is_call_site_target()) {
1590 ciMethodHandle* target = call_site->get_target();
1591 if (target != NULL) { // just in case
1592 ciConstant constant(T_OBJECT, target);
1593 const Type* t;
1594 if (adr->bottom_type()->is_ptr_to_narrowoop()) {
1595 t = TypeNarrowOop::make_from_constant(constant.as_object(), true);
1596 } else {
1597 t = TypeOopPtr::make_from_constant(constant.as_object(), true);
1598 }
1599 // Add a dependence for invalidation of the optimization.
1600 if (!call_site->is_constant_call_site()) {
1601 C->dependencies()->assert_call_site_target_value(call_site, target);
1602 }
1603 return t;
1576 } 1604 }
1577 } 1605 }
1578 } 1606 }
1579 } 1607 }
1580 } else if (tp->base() == Type::KlassPtr) { 1608 } else if (tp->base() == Type::KlassPtr) {