1715
1716
1717 static Node* extract_obj_from_klass_load(PhaseGVN* gvn, Node* n) {
1718 Node* ldk;
1719 if (n->is_DecodeNKlass()) {
1720 if (n->in(1)->Opcode() != Op_LoadNKlass) {
1721 return nullptr;
1722 } else {
1723 ldk = n->in(1);
1724 }
1725 } else if (n->Opcode() != Op_LoadKlass) {
1726 return nullptr;
1727 } else {
1728 ldk = n;
1729 }
1730 assert(ldk != nullptr && ldk->is_Load(), "should have found a LoadKlass or LoadNKlass node");
1731
1732 Node* adr = ldk->in(MemNode::Address);
1733 intptr_t off = 0;
1734 Node* obj = AddPNode::Ideal_base_and_offset(adr, gvn, off);
1735 if (obj == nullptr || off != oopDesc::klass_offset_in_bytes()) // loading oopDesc::_klass?
1736 return nullptr;
1737 const TypePtr* tp = gvn->type(obj)->is_ptr();
1738 if (tp == nullptr || !(tp->isa_instptr() || tp->isa_aryptr())) // is obj a Java object ptr?
1739 return nullptr;
1740
1741 return obj;
1742 }
1743
1744 // Matches exact and inexact type check IR shapes during parsing.
1745 // On successful match, returns type checked object node and its type after successful check
1746 // as out parameters.
1747 static bool match_type_check(PhaseGVN& gvn,
1748 BoolTest::mask btest,
1749 Node* con, const Type* tcon,
1750 Node* val, const Type* tval,
1751 Node** obj, const TypeOopPtr** cast_type) { // out-parameters
1752 // Look for opportunities to sharpen the type of a node whose klass is compared with a constant klass.
1753 // The constant klass being tested against can come from many bytecode instructions (implicitly or explicitly),
1754 // and also from profile data used by speculative casts.
1755 if (btest == BoolTest::eq && tcon->isa_klassptr()) {
|
1715
1716
1717 static Node* extract_obj_from_klass_load(PhaseGVN* gvn, Node* n) {
1718 Node* ldk;
1719 if (n->is_DecodeNKlass()) {
1720 if (n->in(1)->Opcode() != Op_LoadNKlass) {
1721 return nullptr;
1722 } else {
1723 ldk = n->in(1);
1724 }
1725 } else if (n->Opcode() != Op_LoadKlass) {
1726 return nullptr;
1727 } else {
1728 ldk = n;
1729 }
1730 assert(ldk != nullptr && ldk->is_Load(), "should have found a LoadKlass or LoadNKlass node");
1731
1732 Node* adr = ldk->in(MemNode::Address);
1733 intptr_t off = 0;
1734 Node* obj = AddPNode::Ideal_base_and_offset(adr, gvn, off);
1735 if (obj == nullptr || off != Type::klass_offset()) // loading oopDesc::_klass?
1736 return nullptr;
1737 const TypePtr* tp = gvn->type(obj)->is_ptr();
1738 if (tp == nullptr || !(tp->isa_instptr() || tp->isa_aryptr())) // is obj a Java object ptr?
1739 return nullptr;
1740
1741 return obj;
1742 }
1743
1744 // Matches exact and inexact type check IR shapes during parsing.
1745 // On successful match, returns type checked object node and its type after successful check
1746 // as out parameters.
1747 static bool match_type_check(PhaseGVN& gvn,
1748 BoolTest::mask btest,
1749 Node* con, const Type* tcon,
1750 Node* val, const Type* tval,
1751 Node** obj, const TypeOopPtr** cast_type) { // out-parameters
1752 // Look for opportunities to sharpen the type of a node whose klass is compared with a constant klass.
1753 // The constant klass being tested against can come from many bytecode instructions (implicitly or explicitly),
1754 // and also from profile data used by speculative casts.
1755 if (btest == BoolTest::eq && tcon->isa_klassptr()) {
|