618 assert(comp_mirror.not_null(), "must have a mirror"); |
618 assert(comp_mirror.not_null(), "must have a mirror"); |
619 |
619 |
620 // Two-way link between the array klass and its component mirror: |
620 // Two-way link between the array klass and its component mirror: |
621 // (array_klass) k -> mirror -> component_mirror -> array_klass -> k |
621 // (array_klass) k -> mirror -> component_mirror -> array_klass -> k |
622 set_component_mirror(mirror(), comp_mirror()); |
622 set_component_mirror(mirror(), comp_mirror()); |
623 ArrayKlass::cast(k())->set_component_mirror(comp_mirror()); |
|
624 set_array_klass(comp_mirror(), k()); |
623 set_array_klass(comp_mirror(), k()); |
625 } else { |
624 } else { |
626 assert(k->oop_is_instance(), "Must be"); |
625 assert(k->oop_is_instance(), "Must be"); |
627 |
626 |
628 initialize_mirror_fields(k, mirror, protection_domain, THREAD); |
627 initialize_mirror_fields(k, mirror, protection_domain, THREAD); |
680 assert(_protection_domain_offset != 0, "must be set"); |
679 assert(_protection_domain_offset != 0, "must be set"); |
681 java_class->obj_field_put(_protection_domain_offset, pd); |
680 java_class->obj_field_put(_protection_domain_offset, pd); |
682 } |
681 } |
683 |
682 |
684 void java_lang_Class::set_component_mirror(oop java_class, oop comp_mirror) { |
683 void java_lang_Class::set_component_mirror(oop java_class, oop comp_mirror) { |
685 if (_component_mirror_offset != 0) { |
684 assert(_component_mirror_offset != 0, "must be set"); |
686 java_class->obj_field_put(_component_mirror_offset, comp_mirror); |
685 java_class->obj_field_put(_component_mirror_offset, comp_mirror); |
687 } |
686 } |
688 } |
|
689 oop java_lang_Class::component_mirror(oop java_class) { |
687 oop java_lang_Class::component_mirror(oop java_class) { |
690 assert(_component_mirror_offset != 0, "must be set"); |
688 assert(_component_mirror_offset != 0, "must be set"); |
691 return java_class->obj_field(_component_mirror_offset); |
689 return java_class->obj_field(_component_mirror_offset); |
692 } |
690 } |
693 |
691 |
873 |
871 |
874 void java_lang_Class::compute_offsets() { |
872 void java_lang_Class::compute_offsets() { |
875 assert(!offsets_computed, "offsets should be initialized only once"); |
873 assert(!offsets_computed, "offsets should be initialized only once"); |
876 offsets_computed = true; |
874 offsets_computed = true; |
877 |
875 |
878 Klass* klass_oop = SystemDictionary::Class_klass(); |
876 Klass* k = SystemDictionary::Class_klass(); |
879 // The classRedefinedCount field is only present starting in 1.5, |
877 // The classRedefinedCount field is only present starting in 1.5, |
880 // so don't go fatal. |
878 // so don't go fatal. |
881 compute_optional_offset(classRedefinedCount_offset, |
879 compute_optional_offset(classRedefinedCount_offset, |
882 klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature()); |
880 k, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature()); |
883 |
881 |
884 // Needs to be optional because the old build runs Queens during bootstrapping |
882 // Needs to be optional because the old build runs Queens during bootstrapping |
885 // and jdk8-9 doesn't have coordinated pushes yet. |
883 // and jdk8-9 doesn't have coordinated pushes yet. |
886 compute_optional_offset(_class_loader_offset, |
884 compute_optional_offset(_class_loader_offset, |
887 klass_oop, vmSymbols::classLoader_name(), |
885 k, vmSymbols::classLoader_name(), |
888 vmSymbols::classloader_signature()); |
886 vmSymbols::classloader_signature()); |
889 |
887 |
890 compute_optional_offset(_component_mirror_offset, |
888 compute_offset(_component_mirror_offset, |
891 klass_oop, vmSymbols::componentType_name(), |
889 k, vmSymbols::componentType_name(), |
892 vmSymbols::class_signature()); |
890 vmSymbols::class_signature()); |
|
891 |
|
892 // Init lock is a C union with component_mirror. Only instanceKlass mirrors have |
|
893 // init_lock and only ArrayKlass mirrors have component_mirror. Since both are oops |
|
894 // GC treats them the same. |
|
895 _init_lock_offset = _component_mirror_offset; |
893 |
896 |
894 CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); |
897 CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET); |
895 } |
898 } |
896 |
899 |
897 int java_lang_Class::classRedefinedCount(oop the_class_mirror) { |
900 int java_lang_Class::classRedefinedCount(oop the_class_mirror) { |