1693
1694
1695 static Node* extract_obj_from_klass_load(PhaseGVN* gvn, Node* n) {
1696 Node* ldk;
1697 if (n->is_DecodeNKlass()) {
1698 if (n->in(1)->Opcode() != Op_LoadNKlass) {
1699 return nullptr;
1700 } else {
1701 ldk = n->in(1);
1702 }
1703 } else if (n->Opcode() != Op_LoadKlass) {
1704 return nullptr;
1705 } else {
1706 ldk = n;
1707 }
1708 assert(ldk != nullptr && ldk->is_Load(), "should have found a LoadKlass or LoadNKlass node");
1709
1710 Node* adr = ldk->in(MemNode::Address);
1711 intptr_t off = 0;
1712 Node* obj = AddPNode::Ideal_base_and_offset(adr, gvn, off);
1713 if (obj == nullptr || off != oopDesc::klass_offset_in_bytes()) // loading oopDesc::_klass?
1714 return nullptr;
1715 const TypePtr* tp = gvn->type(obj)->is_ptr();
1716 if (tp == nullptr || !(tp->isa_instptr() || tp->isa_aryptr())) // is obj a Java object ptr?
1717 return nullptr;
1718
1719 return obj;
1720 }
1721
1722 void Parse::sharpen_type_after_if(BoolTest::mask btest,
1723 Node* con, const Type* tcon,
1724 Node* val, const Type* tval) {
1725 // Look for opportunities to sharpen the type of a node
1726 // whose klass is compared with a constant klass.
1727 if (btest == BoolTest::eq && tcon->isa_klassptr()) {
1728 Node* obj = extract_obj_from_klass_load(&_gvn, val);
1729 const TypeOopPtr* con_type = tcon->isa_klassptr()->as_instance_type();
1730 if (obj != nullptr && (con_type->isa_instptr() || con_type->isa_aryptr())) {
1731 // Found:
1732 // Bool(CmpP(LoadKlass(obj._klass), ConP(Foo.klass)), [eq])
1733 // or the narrowOop equivalent.
|
1693
1694
1695 static Node* extract_obj_from_klass_load(PhaseGVN* gvn, Node* n) {
1696 Node* ldk;
1697 if (n->is_DecodeNKlass()) {
1698 if (n->in(1)->Opcode() != Op_LoadNKlass) {
1699 return nullptr;
1700 } else {
1701 ldk = n->in(1);
1702 }
1703 } else if (n->Opcode() != Op_LoadKlass) {
1704 return nullptr;
1705 } else {
1706 ldk = n;
1707 }
1708 assert(ldk != nullptr && ldk->is_Load(), "should have found a LoadKlass or LoadNKlass node");
1709
1710 Node* adr = ldk->in(MemNode::Address);
1711 intptr_t off = 0;
1712 Node* obj = AddPNode::Ideal_base_and_offset(adr, gvn, off);
1713 if (obj == nullptr || off != Type::klass_offset()) // loading oopDesc::_klass?
1714 return nullptr;
1715 const TypePtr* tp = gvn->type(obj)->is_ptr();
1716 if (tp == nullptr || !(tp->isa_instptr() || tp->isa_aryptr())) // is obj a Java object ptr?
1717 return nullptr;
1718
1719 return obj;
1720 }
1721
1722 void Parse::sharpen_type_after_if(BoolTest::mask btest,
1723 Node* con, const Type* tcon,
1724 Node* val, const Type* tval) {
1725 // Look for opportunities to sharpen the type of a node
1726 // whose klass is compared with a constant klass.
1727 if (btest == BoolTest::eq && tcon->isa_klassptr()) {
1728 Node* obj = extract_obj_from_klass_load(&_gvn, val);
1729 const TypeOopPtr* con_type = tcon->isa_klassptr()->as_instance_type();
1730 if (obj != nullptr && (con_type->isa_instptr() || con_type->isa_aryptr())) {
1731 // Found:
1732 // Bool(CmpP(LoadKlass(obj._klass), ConP(Foo.klass)), [eq])
1733 // or the narrowOop equivalent.
|