< prev index next >

src/share/vm/classfile/systemDictionary.hpp

Print this page

        

*** 33,67 **** #include "runtime/java.hpp" #include "runtime/reflectionUtils.hpp" #include "utilities/hashtable.hpp" #include "utilities/hashtable.inline.hpp" ! // The system dictionary stores all loaded classes and maps: // ! // [class name,class loader] -> class i.e. [Symbol*,oop] -> Klass* // // Classes are loaded lazily. The default VM class loader is // represented as NULL. ! // The underlying data structure is an open hash table with a fixed number ! // of buckets. During loading the loader object is locked, (for the VM loader ! // a private lock object is used). Class loading can thus be done concurrently, ! // but only by different loaders. // // During loading a placeholder (name, loader) is temporarily placed in // a side data structure, and is used to detect ClassCircularityErrors // and to perform verification during GC. A GC can occur in the midst // of class loading, as we call out to Java, have to take locks, etc. // ! // When class loading is finished, a new entry is added to the system ! // dictionary and the place holder is removed. Note that the protection ! // domain field of the system dictionary has not yet been filled in when ! // the "real" system dictionary entry is created. // // Clients of this class who are interested in finding if a class has // been completely loaded -- not classes in the process of being loaded -- ! // can read the SystemDictionary unlocked. This is safe because // - entries are only deleted at safepoints // - readers cannot come to a safepoint while actively examining // an entry (an entry cannot be deleted from under a reader) // - entries must be fully formed before they are available to concurrent // readers (we must ensure write ordering) --- 33,70 ---- #include "runtime/java.hpp" #include "runtime/reflectionUtils.hpp" #include "utilities/hashtable.hpp" #include "utilities/hashtable.inline.hpp" ! // The dictionary in each ClassLoaderData stores all loaded classes, either ! // initiatied by its class loader or defined by its class loader: // ! // class loader -> ClassLoaderData -> [class, protection domain set] // // Classes are loaded lazily. The default VM class loader is // represented as NULL. ! // The underlying data structure is an open hash table (Dictionary) per ! // ClassLoaderData with a fixed number of buckets. During loading the ! // class loader object is locked, (for the VM loader a private lock object is used). ! // The global SystemDictionary_lock is held for all additions into the ClassLoaderData ! // dictionaries. TODO: fix lock granularity so that class loading can ! // be done concurrently, but only by different loaders. // // During loading a placeholder (name, loader) is temporarily placed in // a side data structure, and is used to detect ClassCircularityErrors // and to perform verification during GC. A GC can occur in the midst // of class loading, as we call out to Java, have to take locks, etc. // ! // When class loading is finished, a new entry is added to the dictionary ! // of the class loader and the placeholder is removed. Note that the protection ! // domain field of the dictionary entry has not yet been filled in when ! // the "real" dictionary entry is created. // // Clients of this class who are interested in finding if a class has // been completely loaded -- not classes in the process of being loaded -- ! // can read the dictionary unlocked. This is safe because // - entries are only deleted at safepoints // - readers cannot come to a safepoint while actively examining // an entry (an entry cannot be deleted from under a reader) // - entries must be fully formed before they are available to concurrent // readers (we must ensure write ordering)
*** 76,85 **** --- 79,90 ---- class PlaceholderTable; class LoaderConstraintTable; template <MEMFLAGS F> class HashtableBucket; class ResolutionErrorTable; class SymbolPropertyTable; + class ProtectionDomainCacheTable; + class ProtectionDomainCacheEntry; class GCTimer; // Certain classes are preloaded, such as java.lang.Object and java.lang.String. // They are all "well-known", in the sense that no class loader is allowed // to provide a different definition.
*** 279,289 **** Handle class_loader, Handle protection_domain, bool is_superclass, TRAPS); ! // Parse new stream. This won't update the system dictionary or // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses. // Also used by Unsafe_DefineAnonymousClass static InstanceKlass* parse_stream(Symbol* class_name, Handle class_loader, Handle protection_domain, --- 284,294 ---- Handle class_loader, Handle protection_domain, bool is_superclass, TRAPS); ! // Parse new stream. This won't update the dictionary or // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses. // Also used by Unsafe_DefineAnonymousClass static InstanceKlass* parse_stream(Symbol* class_name, Handle class_loader, Handle protection_domain,
*** 346,363 **** // to local linkage and access checks. static Klass* find_constrained_instance_or_array_klass(Symbol* class_name, Handle class_loader, TRAPS); - // Iterate over all klasses in dictionary - // Just the classes from defining class loaders - static void classes_do(void f(Klass*)); - // Added for initialize_itable_for_klass to handle exceptions - static void classes_do(void f(Klass*, TRAPS), TRAPS); - // All classes, and their class loaders, including initiating class loaders - static void classes_do(void f(Klass*, ClassLoaderData*)); - // Iterate over all methods in all klasses static void methods_do(void f(Method*)); // Garbage collection support --- 351,360 ----
*** 392,406 **** int number_of_entries); // Printing static void print(bool details = true); static void print_shared(bool details = true); - // Number of contained klasses - // This is both fully loaded classes and classes in the process - // of being loaded - static int number_of_classes(); - // Monotonically increasing counter which grows as classes are // loaded or modifications such as hot-swapping or setting/removing // of breakpoints are performed static inline int number_of_modifications() { assert_locked_or_safepoint(Compile_lock); return _number_of_modifications; } // Needed by evolution and breakpoint code --- 389,398 ----
*** 556,596 **** Symbol* message); static void delete_resolution_error(ConstantPool* pool); static Symbol* find_resolution_error(const constantPoolHandle& pool, int which, Symbol** message); protected: enum Constants { _loader_constraint_size = 107, // number of entries in constraint table _resolution_error_size = 107, // number of entries in resolution error table _invoke_method_size = 139, // number of entries in invoke method table ! _nof_buckets = 1009, // number of buckets in hash table for placeholders ! _old_default_sdsize = 1009, // backward compat for system dictionary size ! _prime_array_size = 8, // array of primes for system dictionary size ! _average_depth_goal = 3 // goal for lookup length }; ! // Static variables ! ! // hashtable sizes for system dictionary to allow growth ! // prime numbers for system dictionary size ! static int _sdgeneration; ! static const int _primelist[_prime_array_size]; ! ! // Hashtable holding loaded classes. ! static Dictionary* _dictionary; // Hashtable holding placeholders for classes being loaded. static PlaceholderTable* _placeholders; // Hashtable holding classes from the shared archive. static Dictionary* _shared_dictionary; // Monotonically increasing counter which grows with ! // _number_of_classes as well as hot-swapping and breakpoint setting // and removal. static int _number_of_modifications; // Lock object for system class loader static oop _system_loader_lock_obj; --- 548,581 ---- Symbol* message); static void delete_resolution_error(ConstantPool* pool); static Symbol* find_resolution_error(const constantPoolHandle& pool, int which, Symbol** message); + + static ProtectionDomainCacheEntry* cache_get(Handle protection_domain); + protected: enum Constants { _loader_constraint_size = 107, // number of entries in constraint table _resolution_error_size = 107, // number of entries in resolution error table _invoke_method_size = 139, // number of entries in invoke method table ! _shared_dictionary_size = 1009, // number of entries in shared dictionary ! _placeholder_table_size = 1009 // number of entries in hash table for placeholders }; ! // Static tables owned by the SystemDictionary // Hashtable holding placeholders for classes being loaded. static PlaceholderTable* _placeholders; // Hashtable holding classes from the shared archive. static Dictionary* _shared_dictionary; // Monotonically increasing counter which grows with ! // loading classes as well as hot-swapping and breakpoint setting // and removal. static int _number_of_modifications; // Lock object for system class loader static oop _system_loader_lock_obj;
*** 602,624 **** static ResolutionErrorTable* _resolution_errors; // Invoke methods (JSR 292) static SymbolPropertyTable* _invoke_method_table; ! public: ! // for VM_CounterDecay iteration support ! friend class CounterDecay; ! static Klass* try_get_next_class(); protected: static void validate_protection_domain(InstanceKlass* klass, Handle class_loader, Handle protection_domain, TRAPS); friend class VM_PopulateDumpSharedSpace; friend class TraversePlaceholdersClosure; - static Dictionary* dictionary() { return _dictionary; } static Dictionary* shared_dictionary() { return _shared_dictionary; } static PlaceholderTable* placeholders() { return _placeholders; } static LoaderConstraintTable* constraints() { return _loader_constraints; } static ResolutionErrorTable* resolution_errors() { return _resolution_errors; } static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; } --- 587,606 ---- static ResolutionErrorTable* _resolution_errors; // Invoke methods (JSR 292) static SymbolPropertyTable* _invoke_method_table; ! // ProtectionDomain cache ! static ProtectionDomainCacheTable* _pd_cache_table; protected: static void validate_protection_domain(InstanceKlass* klass, Handle class_loader, Handle protection_domain, TRAPS); friend class VM_PopulateDumpSharedSpace; friend class TraversePlaceholdersClosure; static Dictionary* shared_dictionary() { return _shared_dictionary; } static PlaceholderTable* placeholders() { return _placeholders; } static LoaderConstraintTable* constraints() { return _loader_constraints; } static ResolutionErrorTable* resolution_errors() { return _resolution_errors; } static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }
*** 664,674 **** // We pass in the hashtable index so we can calculate it outside of // the SystemDictionary_lock. // Basic find on loaded classes static InstanceKlass* find_class(int index, unsigned int hash, ! Symbol* name, ClassLoaderData* loader_data); static InstanceKlass* find_class(Symbol* class_name, ClassLoaderData* loader_data); // Basic find on classes in the midst of being loaded static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data); --- 646,656 ---- // We pass in the hashtable index so we can calculate it outside of // the SystemDictionary_lock. // Basic find on loaded classes static InstanceKlass* find_class(int index, unsigned int hash, ! Symbol* name, Dictionary* dictionary); static InstanceKlass* find_class(Symbol* class_name, ClassLoaderData* loader_data); // Basic find on classes in the midst of being loaded static Symbol* find_placeholder(Symbol* name, ClassLoaderData* loader_data);
< prev index next >