src/hotspot/share/classfile/systemDictionaryShared.cpp
changeset 52468 e0fd97beab7e
parent 51823 2a51125b2794
child 52514 f4e3900c8d08
equal deleted inserted replaced
52467:1256c8d923e8 52468:e0fd97beab7e
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "classfile/classFileStream.hpp"
    26 #include "classfile/classFileStream.hpp"
    27 #include "classfile/classListParser.hpp"
    27 #include "classfile/classListParser.hpp"
    28 #include "classfile/classLoader.hpp"
    28 #include "classfile/classLoader.hpp"
    29 #include "classfile/classLoaderData.inline.hpp"
    29 #include "classfile/classLoaderData.inline.hpp"
       
    30 #include "classfile/classLoaderDataGraph.hpp"
    30 #include "classfile/classLoaderExt.hpp"
    31 #include "classfile/classLoaderExt.hpp"
    31 #include "classfile/dictionary.hpp"
    32 #include "classfile/dictionary.hpp"
    32 #include "classfile/javaClasses.hpp"
    33 #include "classfile/javaClasses.hpp"
    33 #include "classfile/symbolTable.hpp"
    34 #include "classfile/symbolTable.hpp"
    34 #include "classfile/systemDictionary.hpp"
    35 #include "classfile/systemDictionary.hpp"
   780     // because at dump time we don't know how to resolve classes for such loaders.
   781     // because at dump time we don't know how to resolve classes for such loaders.
   781     return true;
   782     return true;
   782   }
   783   }
   783 }
   784 }
   784 
   785 
       
   786 void SystemDictionaryShared::finalize_verification_constraints_for(InstanceKlass* k) {
       
   787   if (!k->is_unsafe_anonymous()) {
       
   788     SharedDictionaryEntry* entry = ((SharedDictionary*)(k->class_loader_data()->dictionary()))->find_entry_for(k);
       
   789     entry->finalize_verification_constraints();
       
   790   }
       
   791 }
       
   792 
   785 void SystemDictionaryShared::finalize_verification_constraints() {
   793 void SystemDictionaryShared::finalize_verification_constraints() {
   786   boot_loader_dictionary()->finalize_verification_constraints();
   794   MutexLocker mcld(ClassLoaderDataGraph_lock);
       
   795   ClassLoaderDataGraph::dictionary_classes_do(finalize_verification_constraints_for);
   787 }
   796 }
   788 
   797 
   789 void SystemDictionaryShared::check_verification_constraints(InstanceKlass* klass,
   798 void SystemDictionaryShared::check_verification_constraints(InstanceKlass* klass,
   790                                                              TRAPS) {
   799                                                              TRAPS) {
   791   assert(!DumpSharedSpaces && UseSharedSpaces, "called at run time with CDS enabled only");
   800   assert(!DumpSharedSpaces && UseSharedSpaces, "called at run time with CDS enabled only");
   806       return entry;
   815       return entry;
   807     }
   816     }
   808   }
   817   }
   809 
   818 
   810   return NULL;
   819   return NULL;
   811 }
       
   812 
       
   813 void SharedDictionary::finalize_verification_constraints() {
       
   814   int bytes = 0, count = 0;
       
   815   for (int index = 0; index < table_size(); index++) {
       
   816     for (SharedDictionaryEntry *probe = bucket(index);
       
   817                                 probe != NULL;
       
   818                                probe = probe->next()) {
       
   819       int n = probe->finalize_verification_constraints();
       
   820       if (n > 0) {
       
   821         bytes += n;
       
   822         count ++;
       
   823       }
       
   824     }
       
   825   }
       
   826   if (log_is_enabled(Info, cds, verification)) {
       
   827     double avg = 0;
       
   828     if (count > 0) {
       
   829       avg = double(bytes) / double(count);
       
   830     }
       
   831     log_info(cds, verification)("Recorded verification constraints for %d classes = %d bytes (avg = %.2f bytes) ", count, bytes, avg);
       
   832   }
       
   833 }
   820 }
   834 
   821 
   835 void SharedDictionaryEntry::add_verification_constraint(Symbol* name,
   822 void SharedDictionaryEntry::add_verification_constraint(Symbol* name,
   836          Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {
   823          Symbol* from_name, bool from_field_is_protected, bool from_is_array, bool from_is_object) {
   837   if (_verifier_constraints == NULL) {
   824   if (_verifier_constraints == NULL) {