Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/javaClasses.cpp @ 24162:0137da2b56d9
Update JDK-8182397 to final version
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 03 Aug 2017 11:53:11 -0700 |
parents | f4e6ddeb5b6f |
children | f32391b837d5 |
comparison
equal
deleted
inserted
replaced
24161:cc8d6f9d5db3 | 24162:0137da2b56d9 |
---|---|
575 InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK); | 575 InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK); |
576 } | 576 } |
577 | 577 |
578 void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader, | 578 void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader, |
579 Handle protection_domain, TRAPS) { | 579 Handle protection_domain, TRAPS) { |
580 assert(k() != NULL, "Use create_basic_type_mirror for primitive types"); | |
580 assert(k->java_mirror() == NULL, "should only assign mirror once"); | 581 assert(k->java_mirror() == NULL, "should only assign mirror once"); |
581 // Use this moment of initialization to cache modifier_flags also, | 582 // Use this moment of initialization to cache modifier_flags also, |
582 // to support Class.getModifiers(). Instance classes recalculate | 583 // to support Class.getModifiers(). Instance classes recalculate |
583 // the cached flags after the class file is parsed, but before the | 584 // the cached flags after the class file is parsed, but before the |
584 // class is put into the system dictionary. | 585 // class is put into the system dictionary. |
590 // Allocate mirror (java.lang.Class instance) | 591 // Allocate mirror (java.lang.Class instance) |
591 Handle mirror = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK); | 592 Handle mirror = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK); |
592 Handle comp_mirror; | 593 Handle comp_mirror; |
593 | 594 |
594 // Setup indirection from mirror->klass | 595 // Setup indirection from mirror->klass |
595 if (!k.is_null()) { | 596 java_lang_Class::set_klass(mirror(), k()); |
596 java_lang_Class::set_klass(mirror(), k()); | |
597 } | |
598 | 597 |
599 InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(mirror->klass()); | 598 InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(mirror->klass()); |
600 assert(oop_size(mirror()) == mk->instance_size(k), "should have been set"); | 599 assert(oop_size(mirror()) == mk->instance_size(k), "should have been set"); |
601 | 600 |
602 java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror())); | 601 java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror())); |
603 | 602 |
604 // It might also have a component mirror. This mirror must already exist. | 603 // It might also have a component mirror. This mirror must already exist. |
605 if (k->oop_is_array()) { | 604 if (k->oop_is_array()) { |
605 Handle comp_mirror; | |
606 if (k->oop_is_typeArray()) { | 606 if (k->oop_is_typeArray()) { |
607 BasicType type = TypeArrayKlass::cast(k())->element_type(); | 607 BasicType type = TypeArrayKlass::cast(k())->element_type(); |
608 comp_mirror = Handle(THREAD, Universe::java_mirror(type)); | 608 comp_mirror = Handle(THREAD, Universe::java_mirror(type)); |
609 } else { | 609 } else { |
610 assert(k->oop_is_objArray(), "Must be"); | 610 assert(k->oop_is_objArray(), "Must be"); |
611 Klass* element_klass = ObjArrayKlass::cast(k())->element_klass(); | 611 Klass* element_klass = ObjArrayKlass::cast(k())->element_klass(); |
612 assert(element_klass != NULL, "Must have an element klass"); | 612 assert(element_klass != NULL, "Must have an element klass"); |
613 comp_mirror = Handle(THREAD, element_klass->java_mirror()); | 613 comp_mirror = Handle(THREAD, element_klass->java_mirror()); |
614 } | 614 } |
615 assert(comp_mirror.not_null(), "must have a mirror"); | 615 assert(comp_mirror() != NULL, "must have a mirror"); |
616 | 616 |
617 // Two-way link between the array klass and its component mirror: | 617 // Two-way link between the array klass and its component mirror: |
618 ArrayKlass::cast(k())->set_component_mirror(comp_mirror()); | 618 ArrayKlass::cast(k())->set_component_mirror(comp_mirror()); |
619 // Set after k->java_mirror() is published. | 619 // See below for ordering dependencies between field array_klass in component mirror |
620 // set_array_klass(comp_mirror(), k()); | 620 // and java_mirror in this klass. |
621 } else { | 621 } else { |
622 assert(k->oop_is_instance(), "Must be"); | 622 assert(k->oop_is_instance(), "Must be"); |
623 | 623 |
624 initialize_mirror_fields(k, mirror, protection_domain, THREAD); | 624 initialize_mirror_fields(k, mirror, protection_domain, THREAD); |
625 if (HAS_PENDING_EXCEPTION) { | 625 if (HAS_PENDING_EXCEPTION) { |
638 | 638 |
639 // Setup indirection from klass->mirror | 639 // Setup indirection from klass->mirror |
640 // after any exceptions can happen during allocations. | 640 // after any exceptions can happen during allocations. |
641 k->set_java_mirror(mirror()); | 641 k->set_java_mirror(mirror()); |
642 if (comp_mirror() != NULL) { | 642 if (comp_mirror() != NULL) { |
643 set_array_klass(comp_mirror(), k()); | 643 // Set after k->java_mirror() is published, because compiled code running |
644 // concurrently doesn't expect a k to have a null java_mirror. | |
645 release_set_array_klass(comp_mirror(), k()); | |
644 } | 646 } |
645 } else { | 647 } else { |
646 if (fixup_mirror_list() == NULL) { | 648 if (fixup_mirror_list() == NULL) { |
647 GrowableArray<Klass*>* list = | 649 GrowableArray<Klass*>* list = |
648 new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true); | 650 new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true); |
715 // introducing a new VM klass (see comment in ClassFileParser) | 717 // introducing a new VM klass (see comment in ClassFileParser) |
716 oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0); | 718 oop java_class = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(NULL, CHECK_0); |
717 if (type != T_VOID) { | 719 if (type != T_VOID) { |
718 Klass* aklass = Universe::typeArrayKlassObj(type); | 720 Klass* aklass = Universe::typeArrayKlassObj(type); |
719 assert(aklass != NULL, "correct bootstrap"); | 721 assert(aklass != NULL, "correct bootstrap"); |
720 set_array_klass(java_class, aklass); | 722 release_set_array_klass(java_class, aklass); |
721 } | 723 } |
722 #ifdef ASSERT | 724 #ifdef ASSERT |
723 InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(SystemDictionary::Class_klass()); | 725 InstanceMirrorKlass* mk = InstanceMirrorKlass::cast(SystemDictionary::Class_klass()); |
724 assert(java_lang_Class::static_oop_field_count(java_class) == 0, "should have been zeroed by allocation"); | 726 assert(java_lang_Class::static_oop_field_count(java_class) == 0, "should have been zeroed by allocation"); |
725 #endif | 727 #endif |
811 Klass* k = ((Klass*)java_class->metadata_field(_array_klass_offset)); | 813 Klass* k = ((Klass*)java_class->metadata_field(_array_klass_offset)); |
812 assert(k == NULL || k->is_klass() && k->oop_is_array(), "should be array klass"); | 814 assert(k == NULL || k->is_klass() && k->oop_is_array(), "should be array klass"); |
813 return k; | 815 return k; |
814 } | 816 } |
815 | 817 |
816 void java_lang_Class::set_array_klass(oop java_class, Klass* klass) { | 818 |
819 void java_lang_Class::release_set_array_klass(oop java_class, Klass* klass) { | |
817 assert(klass->is_klass() && klass->oop_is_array(), "should be array klass"); | 820 assert(klass->is_klass() && klass->oop_is_array(), "should be array klass"); |
818 java_class->metadata_field_put_volatile(_array_klass_offset, klass); | 821 java_class->release_metadata_field_put(_array_klass_offset, klass); |
819 } | 822 } |
820 | 823 |
821 | 824 |
822 bool java_lang_Class::is_primitive(oop java_class) { | 825 bool java_lang_Class::is_primitive(oop java_class) { |
823 // should assert: | 826 // should assert: |