1663 1664 1665 //--------------------------------find_alias_type------------------------------ 1666 Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create, ciField* original_field) { 1667 if (_AliasLevel == 0) 1668 return alias_type(AliasIdxBot); 1669 1670 AliasCacheEntry* ace = probe_alias_cache(adr_type); 1671 if (ace->_adr_type == adr_type) { 1672 return alias_type(ace->_index); 1673 } 1674 1675 // Handle special cases. 1676 if (adr_type == NULL) return alias_type(AliasIdxTop); 1677 if (adr_type == TypePtr::BOTTOM) return alias_type(AliasIdxBot); 1678 1679 // Do it the slow way. 1680 const TypePtr* flat = flatten_alias_type(adr_type); 1681 1682 #ifdef ASSERT 1683 assert(flat == flatten_alias_type(flat), "idempotent"); 1684 assert(flat != TypePtr::BOTTOM, "cannot alias-analyze an untyped ptr"); 1685 if (flat->isa_oopptr() && !flat->isa_klassptr()) { 1686 const TypeOopPtr* foop = flat->is_oopptr(); 1687 // Scalarizable allocations have exact klass always. 1688 bool exact = !foop->klass_is_exact() || foop->is_known_instance(); 1689 const TypePtr* xoop = foop->cast_to_exactness(exact)->is_ptr(); 1690 assert(foop == flatten_alias_type(xoop), "exactness must not affect alias type"); 1691 } 1692 assert(flat == flatten_alias_type(flat), "exact bit doesn't matter"); 1693 #endif 1694 1695 int idx = AliasIdxTop; 1696 for (int i = 0; i < num_alias_types(); i++) { 1697 if (alias_type(i)->adr_type() == flat) { 1698 idx = i; 1699 break; 1700 } 1701 } 1702 1703 if (idx == AliasIdxTop) { 1704 if (no_create) return NULL; 1705 // Grow the array if necessary. 1706 if (_num_alias_types == _max_alias_types) grow_alias_types(); 1707 // Add a new alias type. 1708 idx = _num_alias_types++; 1709 _alias_types[idx]->Init(idx, flat); 1710 if (flat == TypeInstPtr::KLASS) alias_type(idx)->set_rewritable(false); 1711 if (flat == TypeAryPtr::RANGE) alias_type(idx)->set_rewritable(false); 1712 if (flat->isa_instptr()) { | 1663 1664 1665 //--------------------------------find_alias_type------------------------------ 1666 Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create, ciField* original_field) { 1667 if (_AliasLevel == 0) 1668 return alias_type(AliasIdxBot); 1669 1670 AliasCacheEntry* ace = probe_alias_cache(adr_type); 1671 if (ace->_adr_type == adr_type) { 1672 return alias_type(ace->_index); 1673 } 1674 1675 // Handle special cases. 1676 if (adr_type == NULL) return alias_type(AliasIdxTop); 1677 if (adr_type == TypePtr::BOTTOM) return alias_type(AliasIdxBot); 1678 1679 // Do it the slow way. 1680 const TypePtr* flat = flatten_alias_type(adr_type); 1681 1682 #ifdef ASSERT 1683 { 1684 ResourceMark rm; 1685 assert(flat == flatten_alias_type(flat), 1686 err_msg("not idempotent: adr_type = %s; flat = %s => %s", Type::str(adr_type), 1687 Type::str(flat), Type::str(flatten_alias_type(flat)))); 1688 assert(flat != TypePtr::BOTTOM, 1689 err_msg("cannot alias-analyze an untyped ptr: adr_type = %s", Type::str(adr_type))); 1690 if (flat->isa_oopptr() && !flat->isa_klassptr()) { 1691 const TypeOopPtr* foop = flat->is_oopptr(); 1692 // Scalarizable allocations have exact klass always. 1693 bool exact = !foop->klass_is_exact() || foop->is_known_instance(); 1694 const TypePtr* xoop = foop->cast_to_exactness(exact)->is_ptr(); 1695 assert(foop == flatten_alias_type(xoop), 1696 err_msg("exactness must not affect alias type: foop = %s; xoop = %s", 1697 Type::str(foop), Type::str(xoop))); 1698 } 1699 } 1700 #endif 1701 1702 int idx = AliasIdxTop; 1703 for (int i = 0; i < num_alias_types(); i++) { 1704 if (alias_type(i)->adr_type() == flat) { 1705 idx = i; 1706 break; 1707 } 1708 } 1709 1710 if (idx == AliasIdxTop) { 1711 if (no_create) return NULL; 1712 // Grow the array if necessary. 1713 if (_num_alias_types == _max_alias_types) grow_alias_types(); 1714 // Add a new alias type. 1715 idx = _num_alias_types++; 1716 _alias_types[idx]->Init(idx, flat); 1717 if (flat == TypeInstPtr::KLASS) alias_type(idx)->set_rewritable(false); 1718 if (flat == TypeAryPtr::RANGE) alias_type(idx)->set_rewritable(false); 1719 if (flat->isa_instptr()) { |