comparison src/share/vm/memory/metaspaceShared.cpp @ 10487:c558850fac57

8142968: Module System implementation Summary: Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Reviewed-by: acorn, ccheung, coleenp, ctornqvi, dholmes, dsimms, gtriantafill, iklam, jiangli, mgronlun, mseledtsov, cjplummer, sspitsyn, stefank, twisti, hseigel, lfoltan, alanb, mchung, dfazunen Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, harold.seigel@oracle.com, lois.foltan@oracle.com, calvin.cheung@oracle.com, christian.tornqvist@oracle.com, erik.joelsson@oracle.com, george.triantafillou@oracle.com, igor.ignatyev@oracle.com, ioi.lam@oracle.com, james.laskey@oracle.com, jean-francois.denise@oracle.com, jiangli.zhou@oracle.com, markus.gronlund@oracle.com, serguei.spitsyn@oracle.com, staffan.larsen@oracle.com, sundararajan.athijegannathan@oracle.com
author alanb
date Thu, 17 Mar 2016 19:04:01 +0000
parents eda0d9992163
children 906fa01e86a0
comparison
equal deleted inserted replaced
40:d70904c3c6c3 41:b06ec7a7992c
601 ss_low = _string_regions->is_empty() ? NULL : (char*)_string_regions->first().start(); 601 ss_low = _string_regions->is_empty() ? NULL : (char*)_string_regions->first().start();
602 602
603 SystemDictionary::reverse(); 603 SystemDictionary::reverse();
604 SystemDictionary::copy_buckets(&md_top, md_end); 604 SystemDictionary::copy_buckets(&md_top, md_end);
605 605
606 ClassLoader::verify();
607 ClassLoader::copy_package_info_buckets(&md_top, md_end);
608 ClassLoader::verify();
609
610 SystemDictionary::copy_table(&md_top, md_end); 606 SystemDictionary::copy_table(&md_top, md_end);
611 ClassLoader::verify();
612 ClassLoader::copy_package_info_table(&md_top, md_end);
613 ClassLoader::verify();
614 607
615 // Write the other data to the output array. 608 // Write the other data to the output array.
616 WriteClosure wc(md_top, md_end); 609 WriteClosure wc(md_top, md_end);
617 MetaspaceShared::serialize(&wc); 610 MetaspaceShared::serialize(&wc);
618 md_top = wc.get_top(); 611 md_top = wc.get_top();
714 } 707 }
715 #undef fmt_space 708 #undef fmt_space
716 } 709 }
717 710
718 711
719 void MetaspaceShared::link_one_shared_class(Klass* obj, TRAPS) { 712 void MetaspaceShared::link_one_shared_class(Klass* k, TRAPS) {
720 Klass* k = obj;
721 if (k->is_instance_klass()) { 713 if (k->is_instance_klass()) {
722 InstanceKlass* ik = InstanceKlass::cast(k); 714 InstanceKlass* ik = InstanceKlass::cast(k);
723 // Link the class to cause the bytecodes to be rewritten and the 715 // Link the class to cause the bytecodes to be rewritten and the
724 // cpcache to be created. Class verification is done according 716 // cpcache to be created. Class verification is done according
725 // to -Xverify setting. 717 // to -Xverify setting.
729 } 721 }
730 722
731 void MetaspaceShared::check_one_shared_class(Klass* k) { 723 void MetaspaceShared::check_one_shared_class(Klass* k) {
732 if (k->is_instance_klass() && InstanceKlass::cast(k)->check_sharing_error_state()) { 724 if (k->is_instance_klass() && InstanceKlass::cast(k)->check_sharing_error_state()) {
733 _check_classes_made_progress = true; 725 _check_classes_made_progress = true;
726 }
727 }
728
729 void MetaspaceShared::check_shared_class_loader_type(Klass* k) {
730 if (k->is_instance_klass()) {
731 InstanceKlass* ik = InstanceKlass::cast(k);
732 u2 loader_type = ik->loader_type();
733 ResourceMark rm;
734 guarantee(loader_type != 0,
735 "Class loader type is not set for this class %s", ik->name()->as_C_string());
734 } 736 }
735 } 737 }
736 738
737 void MetaspaceShared::link_and_cleanup_shared_classes(TRAPS) { 739 void MetaspaceShared::link_and_cleanup_shared_classes(TRAPS) {
738 // We need to iterate because verification may cause additional classes 740 // We need to iterate because verification may cause additional classes
763 } 765 }
764 } 766 }
765 } 767 }
766 768
767 void MetaspaceShared::prepare_for_dumping() { 769 void MetaspaceShared::prepare_for_dumping() {
770 Arguments::check_unsupported_dumping_properties();
768 ClassLoader::initialize_shared_path(); 771 ClassLoader::initialize_shared_path();
769 FileMapInfo::allocate_classpath_entry_table(); 772 FileMapInfo::allocate_classpath_entry_table();
770 } 773 }
771 774
772 // Preload classes from a list, populate the shared spaces and dump to a 775 // Preload classes from a list, populate the shared spaces and dump to a
899 // Returns true if the class's status has changed 902 // Returns true if the class's status has changed
900 bool MetaspaceShared::try_link_class(InstanceKlass* ik, TRAPS) { 903 bool MetaspaceShared::try_link_class(InstanceKlass* ik, TRAPS) {
901 assert(DumpSharedSpaces, "should only be called during dumping"); 904 assert(DumpSharedSpaces, "should only be called during dumping");
902 if (ik->init_state() < InstanceKlass::linked) { 905 if (ik->init_state() < InstanceKlass::linked) {
903 bool saved = BytecodeVerificationLocal; 906 bool saved = BytecodeVerificationLocal;
904 if (!SharedClassUtil::is_shared_boot_class(ik)) { 907 if (!(ik->is_shared_boot_class())) {
905 // The verification decision is based on BytecodeVerificationRemote 908 // The verification decision is based on BytecodeVerificationRemote
906 // for non-system classes. Since we are using the NULL classloader 909 // for non-system classes. Since we are using the NULL classloader
907 // to load non-system classes during dumping, we need to temporarily 910 // to load non-system classes during dumping, we need to temporarily
908 // change BytecodeVerificationLocal to be the same as 911 // change BytecodeVerificationLocal to be the same as
909 // BytecodeVerificationRemote. Note this can cause the parent system 912 // BytecodeVerificationRemote. Note this can cause the parent system
1087 SystemDictionary::set_shared_dictionary((HashtableBucket<mtClass>*)buffer, 1090 SystemDictionary::set_shared_dictionary((HashtableBucket<mtClass>*)buffer,
1088 sharedDictionaryLen, 1091 sharedDictionaryLen,
1089 number_of_entries); 1092 number_of_entries);
1090 buffer += sharedDictionaryLen; 1093 buffer += sharedDictionaryLen;
1091 1094
1092 // Create the package info table using the bucket array at this spot in
1093 // the misc data space. Since the package info table is never
1094 // modified, this region (of mapped pages) will be (effectively, if
1095 // not explicitly) read-only.
1096
1097 int pkgInfoLen = *(intptr_t*)buffer;
1098 buffer += sizeof(intptr_t);
1099 number_of_entries = *(intptr_t*)buffer;
1100 buffer += sizeof(intptr_t);
1101 ClassLoader::create_package_info_table((HashtableBucket<mtClass>*)buffer, pkgInfoLen,
1102 number_of_entries);
1103 buffer += pkgInfoLen;
1104 ClassLoader::verify();
1105
1106 // The following data in the shared misc data region are the linked 1095 // The following data in the shared misc data region are the linked
1107 // list elements (HashtableEntry objects) for the shared dictionary 1096 // list elements (HashtableEntry objects) for the shared dictionary
1108 // and package info table. 1097 // table.
1109 1098
1110 int len = *(intptr_t*)buffer; // skip over shared dictionary entries 1099 int len = *(intptr_t*)buffer; // skip over shared dictionary entries
1111 buffer += sizeof(intptr_t);
1112 buffer += len;
1113
1114 len = *(intptr_t*)buffer; // skip over package info table entries
1115 buffer += sizeof(intptr_t);
1116 buffer += len;
1117
1118 len = *(intptr_t*)buffer; // skip over package info table char[] arrays.
1119 buffer += sizeof(intptr_t); 1100 buffer += sizeof(intptr_t);
1120 buffer += len; 1101 buffer += len;
1121 1102
1122 intptr_t* array = (intptr_t*)buffer; 1103 intptr_t* array = (intptr_t*)buffer;
1123 ReadClosure rc(&array); 1104 ReadClosure rc(&array);