src/share/vm/opto/memnode.cpp

changeset 3391
069ab3f976d3
parent 3320
f745b2be3737
child 3392
1dc233a8c7fe
equal deleted inserted replaced
3390:65149e74c706 3391:069ab3f976d3
1471 // Helper to recognize certain Klass fields which are invariant across 1471 // Helper to recognize certain Klass fields which are invariant across
1472 // some group of array types (e.g., int[] or all T[] where T < Object). 1472 // some group of array types (e.g., int[] or all T[] where T < Object).
1473 const Type* 1473 const Type*
1474 LoadNode::load_array_final_field(const TypeKlassPtr *tkls, 1474 LoadNode::load_array_final_field(const TypeKlassPtr *tkls,
1475 ciKlass* klass) const { 1475 ciKlass* klass) const {
1476 if (tkls->offset() == Klass::modifier_flags_offset_in_bytes() + (int)sizeof(oopDesc)) { 1476 if (tkls->offset() == in_bytes(Klass::modifier_flags_offset())) {
1477 // The field is Klass::_modifier_flags. Return its (constant) value. 1477 // The field is Klass::_modifier_flags. Return its (constant) value.
1478 // (Folds up the 2nd indirection in aClassConstant.getModifiers().) 1478 // (Folds up the 2nd indirection in aClassConstant.getModifiers().)
1479 assert(this->Opcode() == Op_LoadI, "must load an int from _modifier_flags"); 1479 assert(this->Opcode() == Op_LoadI, "must load an int from _modifier_flags");
1480 return TypeInt::make(klass->modifier_flags()); 1480 return TypeInt::make(klass->modifier_flags());
1481 } 1481 }
1482 if (tkls->offset() == Klass::access_flags_offset_in_bytes() + (int)sizeof(oopDesc)) { 1482 if (tkls->offset() == in_bytes(Klass::access_flags_offset())) {
1483 // The field is Klass::_access_flags. Return its (constant) value. 1483 // The field is Klass::_access_flags. Return its (constant) value.
1484 // (Folds up the 2nd indirection in Reflection.getClassAccessFlags(aClassConstant).) 1484 // (Folds up the 2nd indirection in Reflection.getClassAccessFlags(aClassConstant).)
1485 assert(this->Opcode() == Op_LoadI, "must load an int from _access_flags"); 1485 assert(this->Opcode() == Op_LoadI, "must load an int from _access_flags");
1486 return TypeInt::make(klass->access_flags()); 1486 return TypeInt::make(klass->access_flags());
1487 } 1487 }
1488 if (tkls->offset() == Klass::layout_helper_offset_in_bytes() + (int)sizeof(oopDesc)) { 1488 if (tkls->offset() == in_bytes(Klass::layout_helper_offset())) {
1489 // The field is Klass::_layout_helper. Return its constant value if known. 1489 // The field is Klass::_layout_helper. Return its constant value if known.
1490 assert(this->Opcode() == Op_LoadI, "must load an int from _layout_helper"); 1490 assert(this->Opcode() == Op_LoadI, "must load an int from _layout_helper");
1491 return TypeInt::make(klass->layout_helper()); 1491 return TypeInt::make(klass->layout_helper());
1492 } 1492 }
1493 1493
1634 ciKlass* klass = tkls->klass(); 1634 ciKlass* klass = tkls->klass();
1635 if (klass->is_loaded() && tkls->klass_is_exact()) { 1635 if (klass->is_loaded() && tkls->klass_is_exact()) {
1636 // We are loading a field from a Klass metaobject whose identity 1636 // We are loading a field from a Klass metaobject whose identity
1637 // is known at compile time (the type is "exact" or "precise"). 1637 // is known at compile time (the type is "exact" or "precise").
1638 // Check for fields we know are maintained as constants by the VM. 1638 // Check for fields we know are maintained as constants by the VM.
1639 if (tkls->offset() == Klass::super_check_offset_offset_in_bytes() + (int)sizeof(oopDesc)) { 1639 if (tkls->offset() == in_bytes(Klass::super_check_offset_offset())) {
1640 // The field is Klass::_super_check_offset. Return its (constant) value. 1640 // The field is Klass::_super_check_offset. Return its (constant) value.
1641 // (Folds up type checking code.) 1641 // (Folds up type checking code.)
1642 assert(Opcode() == Op_LoadI, "must load an int from _super_check_offset"); 1642 assert(Opcode() == Op_LoadI, "must load an int from _super_check_offset");
1643 return TypeInt::make(klass->super_check_offset()); 1643 return TypeInt::make(klass->super_check_offset());
1644 } 1644 }
1645 // Compute index into primary_supers array 1645 // Compute index into primary_supers array
1646 juint depth = (tkls->offset() - (Klass::primary_supers_offset_in_bytes() + (int)sizeof(oopDesc))) / sizeof(klassOop); 1646 juint depth = (tkls->offset() - in_bytes(Klass::primary_supers_offset())) / sizeof(klassOop);
1647 // Check for overflowing; use unsigned compare to handle the negative case. 1647 // Check for overflowing; use unsigned compare to handle the negative case.
1648 if( depth < ciKlass::primary_super_limit() ) { 1648 if( depth < ciKlass::primary_super_limit() ) {
1649 // The field is an element of Klass::_primary_supers. Return its (constant) value. 1649 // The field is an element of Klass::_primary_supers. Return its (constant) value.
1650 // (Folds up type checking code.) 1650 // (Folds up type checking code.)
1651 assert(Opcode() == Op_LoadKlass, "must load a klass from _primary_supers"); 1651 assert(Opcode() == Op_LoadKlass, "must load a klass from _primary_supers");
1652 ciKlass *ss = klass->super_of_depth(depth); 1652 ciKlass *ss = klass->super_of_depth(depth);
1653 return ss ? TypeKlassPtr::make(ss) : TypePtr::NULL_PTR; 1653 return ss ? TypeKlassPtr::make(ss) : TypePtr::NULL_PTR;
1654 } 1654 }
1655 const Type* aift = load_array_final_field(tkls, klass); 1655 const Type* aift = load_array_final_field(tkls, klass);
1656 if (aift != NULL) return aift; 1656 if (aift != NULL) return aift;
1657 if (tkls->offset() == in_bytes(arrayKlass::component_mirror_offset()) + (int)sizeof(oopDesc) 1657 if (tkls->offset() == in_bytes(arrayKlass::component_mirror_offset())
1658 && klass->is_array_klass()) { 1658 && klass->is_array_klass()) {
1659 // The field is arrayKlass::_component_mirror. Return its (constant) value. 1659 // The field is arrayKlass::_component_mirror. Return its (constant) value.
1660 // (Folds up aClassConstant.getComponentType, common in Arrays.copyOf.) 1660 // (Folds up aClassConstant.getComponentType, common in Arrays.copyOf.)
1661 assert(Opcode() == Op_LoadP, "must load an oop from _component_mirror"); 1661 assert(Opcode() == Op_LoadP, "must load an oop from _component_mirror");
1662 return TypeInstPtr::make(klass->as_array_klass()->component_mirror()); 1662 return TypeInstPtr::make(klass->as_array_klass()->component_mirror());
1663 } 1663 }
1664 if (tkls->offset() == Klass::java_mirror_offset_in_bytes() + (int)sizeof(oopDesc)) { 1664 if (tkls->offset() == in_bytes(Klass::java_mirror_offset())) {
1665 // The field is Klass::_java_mirror. Return its (constant) value. 1665 // The field is Klass::_java_mirror. Return its (constant) value.
1666 // (Folds up the 2nd indirection in anObjConstant.getClass().) 1666 // (Folds up the 2nd indirection in anObjConstant.getClass().)
1667 assert(Opcode() == Op_LoadP, "must load an oop from _java_mirror"); 1667 assert(Opcode() == Op_LoadP, "must load an oop from _java_mirror");
1668 return TypeInstPtr::make(klass->java_mirror()); 1668 return TypeInstPtr::make(klass->java_mirror());
1669 } 1669 }
1677 while( inner->is_obj_array_klass() ) 1677 while( inner->is_obj_array_klass() )
1678 inner = inner->as_obj_array_klass()->base_element_type(); 1678 inner = inner->as_obj_array_klass()->base_element_type();
1679 if( inner->is_instance_klass() && 1679 if( inner->is_instance_klass() &&
1680 !inner->as_instance_klass()->flags().is_interface() ) { 1680 !inner->as_instance_klass()->flags().is_interface() ) {
1681 // Compute index into primary_supers array 1681 // Compute index into primary_supers array
1682 juint depth = (tkls->offset() - (Klass::primary_supers_offset_in_bytes() + (int)sizeof(oopDesc))) / sizeof(klassOop); 1682 juint depth = (tkls->offset() - in_bytes(Klass::primary_supers_offset())) / sizeof(klassOop);
1683 // Check for overflowing; use unsigned compare to handle the negative case. 1683 // Check for overflowing; use unsigned compare to handle the negative case.
1684 if( depth < ciKlass::primary_super_limit() && 1684 if( depth < ciKlass::primary_super_limit() &&
1685 depth <= klass->super_depth() ) { // allow self-depth checks to handle self-check case 1685 depth <= klass->super_depth() ) { // allow self-depth checks to handle self-check case
1686 // The field is an element of Klass::_primary_supers. Return its (constant) value. 1686 // The field is an element of Klass::_primary_supers. Return its (constant) value.
1687 // (Folds up type checking code.) 1687 // (Folds up type checking code.)
1693 } 1693 }
1694 1694
1695 // If the type is enough to determine that the thing is not an array, 1695 // If the type is enough to determine that the thing is not an array,
1696 // we can give the layout_helper a positive interval type. 1696 // we can give the layout_helper a positive interval type.
1697 // This will help short-circuit some reflective code. 1697 // This will help short-circuit some reflective code.
1698 if (tkls->offset() == Klass::layout_helper_offset_in_bytes() + (int)sizeof(oopDesc) 1698 if (tkls->offset() == in_bytes(Klass::layout_helper_offset())
1699 && !klass->is_array_klass() // not directly typed as an array 1699 && !klass->is_array_klass() // not directly typed as an array
1700 && !klass->is_interface() // specifically not Serializable & Cloneable 1700 && !klass->is_interface() // specifically not Serializable & Cloneable
1701 && !klass->is_java_lang_Object() // not the supertype of all T[] 1701 && !klass->is_java_lang_Object() // not the supertype of all T[]
1702 ) { 1702 ) {
1703 // Note: When interfaces are reliable, we can narrow the interface 1703 // Note: When interfaces are reliable, we can narrow the interface
1936 if (tkls != NULL && !StressReflectiveCode) { 1936 if (tkls != NULL && !StressReflectiveCode) {
1937 ciKlass* klass = tkls->klass(); 1937 ciKlass* klass = tkls->klass();
1938 if( !klass->is_loaded() ) 1938 if( !klass->is_loaded() )
1939 return _type; // Bail out if not loaded 1939 return _type; // Bail out if not loaded
1940 if( klass->is_obj_array_klass() && 1940 if( klass->is_obj_array_klass() &&
1941 (uint)tkls->offset() == objArrayKlass::element_klass_offset_in_bytes() + sizeof(oopDesc)) { 1941 tkls->offset() == in_bytes(objArrayKlass::element_klass_offset())) {
1942 ciKlass* elem = klass->as_obj_array_klass()->element_klass(); 1942 ciKlass* elem = klass->as_obj_array_klass()->element_klass();
1943 // // Always returning precise element type is incorrect, 1943 // // Always returning precise element type is incorrect,
1944 // // e.g., element type could be object and array may contain strings 1944 // // e.g., element type could be object and array may contain strings
1945 // return TypeKlassPtr::make(TypePtr::Constant, elem, 0); 1945 // return TypeKlassPtr::make(TypePtr::Constant, elem, 0);
1946 1946
1947 // The array's TypeKlassPtr was declared 'precise' or 'not precise' 1947 // The array's TypeKlassPtr was declared 'precise' or 'not precise'
1948 // according to the element type's subclassing. 1948 // according to the element type's subclassing.
1949 return TypeKlassPtr::make(tkls->ptr(), elem, 0/*offset*/); 1949 return TypeKlassPtr::make(tkls->ptr(), elem, 0/*offset*/);
1950 } 1950 }
1951 if( klass->is_instance_klass() && tkls->klass_is_exact() && 1951 if( klass->is_instance_klass() && tkls->klass_is_exact() &&
1952 (uint)tkls->offset() == Klass::super_offset_in_bytes() + sizeof(oopDesc)) { 1952 tkls->offset() == in_bytes(Klass::super_offset())) {
1953 ciKlass* sup = klass->as_instance_klass()->super(); 1953 ciKlass* sup = klass->as_instance_klass()->super();
1954 // The field is Klass::_super. Return its (constant) value. 1954 // The field is Klass::_super. Return its (constant) value.
1955 // (Folds up the 2nd indirection in aClassConstant.getSuperClass().) 1955 // (Folds up the 2nd indirection in aClassConstant.getSuperClass().)
1956 return sup ? TypeKlassPtr::make(sup) : TypePtr::NULL_PTR; 1956 return sup ? TypeKlassPtr::make(sup) : TypePtr::NULL_PTR;
1957 } 1957 }
2011 if (tkls != NULL && !tkls->empty() 2011 if (tkls != NULL && !tkls->empty()
2012 && (tkls->klass()->is_instance_klass() || 2012 && (tkls->klass()->is_instance_klass() ||
2013 tkls->klass()->is_array_klass()) 2013 tkls->klass()->is_array_klass())
2014 && adr2->is_AddP() 2014 && adr2->is_AddP()
2015 ) { 2015 ) {
2016 int mirror_field = Klass::java_mirror_offset_in_bytes(); 2016 int mirror_field = in_bytes(Klass::java_mirror_offset());
2017 if (offset == java_lang_Class::array_klass_offset_in_bytes()) { 2017 if (offset == java_lang_Class::array_klass_offset_in_bytes()) {
2018 mirror_field = in_bytes(arrayKlass::component_mirror_offset()); 2018 mirror_field = in_bytes(arrayKlass::component_mirror_offset());
2019 } 2019 }
2020 if (tkls->offset() == mirror_field + (int)sizeof(oopDesc)) { 2020 if (tkls->offset() == mirror_field) {
2021 return adr2->in(AddPNode::Base); 2021 return adr2->in(AddPNode::Base);
2022 } 2022 }
2023 } 2023 }
2024 } 2024 }
2025 } 2025 }

mercurial