1012 } else {
1013 return parser->lookup_interface_for_current_class(class_name);
1014 }
1015 } else {
1016 // The VM is not trying to resolve a super type of parser->current_class_name().
1017 // Instead, it's resolving an error class (because parser->current_class_name() has
1018 // failed parsing or verification). Don't do anything here.
1019 return NULL;
1020 }
1021 }
1022
1023 DumpTimeSharedClassInfo* SystemDictionaryShared::find_or_allocate_info_for(InstanceKlass* k) {
1024 MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
1025 if (_dumptime_table == NULL) {
1026 _dumptime_table = new (ResourceObj::C_HEAP, mtClass)DumpTimeSharedClassTable();
1027 }
1028 return _dumptime_table->find_or_allocate_info_for(k);
1029 }
1030
1031 void SystemDictionaryShared::set_shared_class_misc_info(InstanceKlass* k, ClassFileStream* cfs) {
1032 assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "only when dumping");
1033 assert(!is_builtin(k), "must be unregistered class");
1034 DumpTimeSharedClassInfo* info = find_or_allocate_info_for(k);
1035 info->_clsfile_size = cfs->length();
1036 info->_clsfile_crc32 = ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length());
1037 }
1038
1039 void SystemDictionaryShared::init_dumptime_info(InstanceKlass* k) {
1040 (void)find_or_allocate_info_for(k);
1041 }
1042
1043 void SystemDictionaryShared::remove_dumptime_info(InstanceKlass* k) {
1044 MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
1045 DumpTimeSharedClassInfo* p = _dumptime_table->get(k);
1046 if (p == NULL) {
1047 return;
1048 }
1049 if (p->_verifier_constraints != NULL) {
1050 for (int i = 0; i < p->_verifier_constraints->length(); i++) {
1051 DumpTimeSharedClassInfo::DTConstraint constraint = p->_verifier_constraints->at(i);
1052 if (constraint._name != NULL ) {
1168 }
1169
1170 class ExcludeDumpTimeSharedClasses : StackObj {
1171 public:
1172 bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1173 if (SystemDictionaryShared::should_be_excluded(k)) {
1174 info.set_excluded();
1175 }
1176 return true; // keep on iterating
1177 }
1178 };
1179
1180 void SystemDictionaryShared::check_excluded_classes() {
1181 ExcludeDumpTimeSharedClasses excl;
1182 _dumptime_table->iterate(&excl);
1183 _dumptime_table->update_counts();
1184 }
1185
1186 bool SystemDictionaryShared::is_excluded_class(InstanceKlass* k) {
1187 assert(_no_class_loading_should_happen, "sanity");
1188 assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "only when dumping");
1189 return find_or_allocate_info_for(k)->is_excluded();
1190 }
1191
1192 class IterateDumpTimeSharedClassTable : StackObj {
1193 MetaspaceClosure *_it;
1194 public:
1195 IterateDumpTimeSharedClassTable(MetaspaceClosure* it) : _it(it) {}
1196
1197 bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1198 if (!info.is_excluded()) {
1199 info.metaspace_pointers_do(_it);
1200 }
1201 return true; // keep on iterating
1202 }
1203 };
1204
1205 void SystemDictionaryShared::dumptime_classes_do(class MetaspaceClosure* it) {
1206 IterateDumpTimeSharedClassTable iter(it);
1207 _dumptime_table->iterate(&iter);
1208 }
1209
1210 bool SystemDictionaryShared::add_verification_constraint(InstanceKlass* k, Symbol* name,
1211 Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {
1212 assert(DumpSharedSpaces || DynamicDumpSharedSpaces, "called at dump time only");
1213 DumpTimeSharedClassInfo* info = find_or_allocate_info_for(k);
1214 info->add_verification_constraint(k, name, from_name, from_field_is_protected,
1215 from_is_array, from_is_object);
1216
1217 if (DynamicDumpSharedSpaces) {
1218 // For dynamic dumping, we can resolve all the constraint classes for all class loaders during
1219 // the initial run prior to creating the archive before vm exit. We will also perform verification
1220 // check when running with the archive.
1221 return false;
1222 } else {
1223 if (is_builtin(k)) {
1224 // For builtin class loaders, we can try to complete the verification check at dump time,
1225 // because we can resolve all the constraint classes. We will also perform verification check
1226 // when running with the archive.
1227 return false;
1228 } else {
1229 // For non-builtin class loaders, we cannot complete the verification check at dump time,
1230 // because at dump time we don't know how to resolve classes for such loaders.
1231 return true;
1232 }
|
1012 } else {
1013 return parser->lookup_interface_for_current_class(class_name);
1014 }
1015 } else {
1016 // The VM is not trying to resolve a super type of parser->current_class_name().
1017 // Instead, it's resolving an error class (because parser->current_class_name() has
1018 // failed parsing or verification). Don't do anything here.
1019 return NULL;
1020 }
1021 }
1022
1023 DumpTimeSharedClassInfo* SystemDictionaryShared::find_or_allocate_info_for(InstanceKlass* k) {
1024 MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
1025 if (_dumptime_table == NULL) {
1026 _dumptime_table = new (ResourceObj::C_HEAP, mtClass)DumpTimeSharedClassTable();
1027 }
1028 return _dumptime_table->find_or_allocate_info_for(k);
1029 }
1030
1031 void SystemDictionaryShared::set_shared_class_misc_info(InstanceKlass* k, ClassFileStream* cfs) {
1032 assert(Arguments::is_dumping_archive(), "only when dumping");
1033 assert(!is_builtin(k), "must be unregistered class");
1034 DumpTimeSharedClassInfo* info = find_or_allocate_info_for(k);
1035 info->_clsfile_size = cfs->length();
1036 info->_clsfile_crc32 = ClassLoader::crc32(0, (const char*)cfs->buffer(), cfs->length());
1037 }
1038
1039 void SystemDictionaryShared::init_dumptime_info(InstanceKlass* k) {
1040 (void)find_or_allocate_info_for(k);
1041 }
1042
1043 void SystemDictionaryShared::remove_dumptime_info(InstanceKlass* k) {
1044 MutexLocker ml(DumpTimeTable_lock, Mutex::_no_safepoint_check_flag);
1045 DumpTimeSharedClassInfo* p = _dumptime_table->get(k);
1046 if (p == NULL) {
1047 return;
1048 }
1049 if (p->_verifier_constraints != NULL) {
1050 for (int i = 0; i < p->_verifier_constraints->length(); i++) {
1051 DumpTimeSharedClassInfo::DTConstraint constraint = p->_verifier_constraints->at(i);
1052 if (constraint._name != NULL ) {
1168 }
1169
1170 class ExcludeDumpTimeSharedClasses : StackObj {
1171 public:
1172 bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1173 if (SystemDictionaryShared::should_be_excluded(k)) {
1174 info.set_excluded();
1175 }
1176 return true; // keep on iterating
1177 }
1178 };
1179
1180 void SystemDictionaryShared::check_excluded_classes() {
1181 ExcludeDumpTimeSharedClasses excl;
1182 _dumptime_table->iterate(&excl);
1183 _dumptime_table->update_counts();
1184 }
1185
1186 bool SystemDictionaryShared::is_excluded_class(InstanceKlass* k) {
1187 assert(_no_class_loading_should_happen, "sanity");
1188 assert(Arguments::is_dumping_archive(), "only when dumping");
1189 return find_or_allocate_info_for(k)->is_excluded();
1190 }
1191
1192 class IterateDumpTimeSharedClassTable : StackObj {
1193 MetaspaceClosure *_it;
1194 public:
1195 IterateDumpTimeSharedClassTable(MetaspaceClosure* it) : _it(it) {}
1196
1197 bool do_entry(InstanceKlass* k, DumpTimeSharedClassInfo& info) {
1198 if (!info.is_excluded()) {
1199 info.metaspace_pointers_do(_it);
1200 }
1201 return true; // keep on iterating
1202 }
1203 };
1204
1205 void SystemDictionaryShared::dumptime_classes_do(class MetaspaceClosure* it) {
1206 IterateDumpTimeSharedClassTable iter(it);
1207 _dumptime_table->iterate(&iter);
1208 }
1209
1210 bool SystemDictionaryShared::add_verification_constraint(InstanceKlass* k, Symbol* name,
1211 Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {
1212 assert(Arguments::is_dumping_archive(), "called at dump time only");
1213 DumpTimeSharedClassInfo* info = find_or_allocate_info_for(k);
1214 info->add_verification_constraint(k, name, from_name, from_field_is_protected,
1215 from_is_array, from_is_object);
1216
1217 if (DynamicDumpSharedSpaces) {
1218 // For dynamic dumping, we can resolve all the constraint classes for all class loaders during
1219 // the initial run prior to creating the archive before vm exit. We will also perform verification
1220 // check when running with the archive.
1221 return false;
1222 } else {
1223 if (is_builtin(k)) {
1224 // For builtin class loaders, we can try to complete the verification check at dump time,
1225 // because we can resolve all the constraint classes. We will also perform verification check
1226 // when running with the archive.
1227 return false;
1228 } else {
1229 // For non-builtin class loaders, we cannot complete the verification check at dump time,
1230 // because at dump time we don't know how to resolve classes for such loaders.
1231 return true;
1232 }
|