1.1 --- a/src/share/vm/opto/type.cpp Fri Mar 18 15:52:42 2011 -0700 1.2 +++ b/src/share/vm/opto/type.cpp Fri Mar 18 16:00:34 2011 -0700 1.3 @@ -32,6 +32,7 @@ 1.4 #include "memory/oopFactory.hpp" 1.5 #include "memory/resourceArea.hpp" 1.6 #include "oops/instanceKlass.hpp" 1.7 +#include "oops/instanceMirrorKlass.hpp" 1.8 #include "oops/klassKlass.hpp" 1.9 #include "oops/objArrayKlass.hpp" 1.10 #include "oops/typeArrayKlass.hpp" 1.11 @@ -2241,43 +2242,49 @@ 1.12 } else if (this->isa_aryptr()) { 1.13 _is_ptr_to_narrowoop = (klass()->is_obj_array_klass() && 1.14 _offset != arrayOopDesc::length_offset_in_bytes()); 1.15 - } else if (klass() == ciEnv::current()->Class_klass() && 1.16 - (_offset == java_lang_Class::klass_offset_in_bytes() || 1.17 - _offset == java_lang_Class::array_klass_offset_in_bytes())) { 1.18 - // Special hidden fields from the Class. 1.19 - assert(this->isa_instptr(), "must be an instance ptr."); 1.20 - _is_ptr_to_narrowoop = true; 1.21 } else if (klass()->is_instance_klass()) { 1.22 ciInstanceKlass* ik = klass()->as_instance_klass(); 1.23 ciField* field = NULL; 1.24 if (this->isa_klassptr()) { 1.25 - // Perm objects don't use compressed references, except for 1.26 - // static fields which are currently compressed. 1.27 - field = ik->get_field_by_offset(_offset, true); 1.28 - if (field != NULL) { 1.29 - BasicType basic_elem_type = field->layout_type(); 1.30 - _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT || 1.31 - basic_elem_type == T_ARRAY); 1.32 - } 1.33 + // Perm objects don't use compressed references 1.34 } else if (_offset == OffsetBot || _offset == OffsetTop) { 1.35 // unsafe access 1.36 _is_ptr_to_narrowoop = true; 1.37 } else { // exclude unsafe ops 1.38 assert(this->isa_instptr(), "must be an instance ptr."); 1.39 - // Field which contains a compressed oop references. 1.40 - field = ik->get_field_by_offset(_offset, false); 1.41 - if (field != NULL) { 1.42 + 1.43 + if (klass() == ciEnv::current()->Class_klass() && 1.44 + (_offset == java_lang_Class::klass_offset_in_bytes() || 1.45 + _offset == java_lang_Class::array_klass_offset_in_bytes())) { 1.46 + // Special hidden fields from the Class. 1.47 + assert(this->isa_instptr(), "must be an instance ptr."); 1.48 + _is_ptr_to_narrowoop = true; 1.49 + } else if (klass() == ciEnv::current()->Class_klass() && 1.50 + _offset >= instanceMirrorKlass::offset_of_static_fields()) { 1.51 + // Static fields 1.52 + assert(o != NULL, "must be constant"); 1.53 + ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass(); 1.54 + ciField* field = k->get_field_by_offset(_offset, true); 1.55 + assert(field != NULL, "missing field"); 1.56 BasicType basic_elem_type = field->layout_type(); 1.57 _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT || 1.58 basic_elem_type == T_ARRAY); 1.59 - } else if (klass()->equals(ciEnv::current()->Object_klass())) { 1.60 - // Compile::find_alias_type() cast exactness on all types to verify 1.61 - // that it does not affect alias type. 1.62 - _is_ptr_to_narrowoop = true; 1.63 } else { 1.64 - // Type for the copy start in LibraryCallKit::inline_native_clone(). 1.65 - assert(!klass_is_exact(), "only non-exact klass"); 1.66 - _is_ptr_to_narrowoop = true; 1.67 + // Instance fields which contains a compressed oop references. 1.68 + field = ik->get_field_by_offset(_offset, false); 1.69 + if (field != NULL) { 1.70 + BasicType basic_elem_type = field->layout_type(); 1.71 + _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT || 1.72 + basic_elem_type == T_ARRAY); 1.73 + } else if (klass()->equals(ciEnv::current()->Object_klass())) { 1.74 + // Compile::find_alias_type() cast exactness on all types to verify 1.75 + // that it does not affect alias type. 1.76 + _is_ptr_to_narrowoop = true; 1.77 + } else { 1.78 + // Type for the copy start in LibraryCallKit::inline_native_clone(). 1.79 + assert(!klass_is_exact(), "only non-exact klass"); 1.80 + _is_ptr_to_narrowoop = true; 1.81 + } 1.82 } 1.83 } 1.84 }