185 class_size += k->size(); 186 187 if (k->oop_is_instance()) { 188 class_size += k->methods()->size(); 189 // FIXME: Need to count the contents of methods 190 class_size += k->constants()->size(); 191 class_size += k->local_interfaces()->size(); 192 class_size += k->transitive_interfaces()->size(); 193 // We do not have to count implementors, since we only store one! 194 // FIXME: How should these be accounted for, now when they have moved. 195 //class_size += k->fields()->size(); 196 } 197 return class_size * oopSize; 198 } 199 200 201 bool ClassLoadingService::set_verbose(bool verbose) { 202 MutexLocker m(Management_lock); 203 204 // verbose will be set to the previous value 205 bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassLoading", &verbose, MANAGEMENT); 206 assert(succeed, "Setting TraceClassLoading flag fails"); 207 reset_trace_class_unloading(); 208 209 return verbose; 210 } 211 212 // Caller to this function must own Management_lock 213 void ClassLoadingService::reset_trace_class_unloading() { 214 assert(Management_lock->owned_by_self(), "Must own the Management_lock"); 215 bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose(); 216 bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassUnloading", &value, MANAGEMENT); 217 assert(succeed, "Setting TraceClassUnLoading flag fails"); 218 } 219 220 GrowableArray<KlassHandle>* LoadedClassesEnumerator::_loaded_classes = NULL; 221 Thread* LoadedClassesEnumerator::_current_thread = NULL; 222 223 LoadedClassesEnumerator::LoadedClassesEnumerator(Thread* cur_thread) { 224 assert(cur_thread == Thread::current(), "Check current thread"); 225 226 int init_size = ClassLoadingService::loaded_class_count(); 227 _klass_handle_array = new GrowableArray<KlassHandle>(init_size); 228 229 // For consistency of the loaded classes, grab the SystemDictionary lock 230 MutexLocker sd_mutex(SystemDictionary_lock); 231 232 // Set _loaded_classes and _current_thread and begin enumerating all classes. 233 // Only one thread will do the enumeration at a time. 234 // These static variables are needed and they are used by the static method 235 // add_loaded_class called from classes_do(). 236 _loaded_classes = _klass_handle_array; | 185 class_size += k->size(); 186 187 if (k->oop_is_instance()) { 188 class_size += k->methods()->size(); 189 // FIXME: Need to count the contents of methods 190 class_size += k->constants()->size(); 191 class_size += k->local_interfaces()->size(); 192 class_size += k->transitive_interfaces()->size(); 193 // We do not have to count implementors, since we only store one! 194 // FIXME: How should these be accounted for, now when they have moved. 195 //class_size += k->fields()->size(); 196 } 197 return class_size * oopSize; 198 } 199 200 201 bool ClassLoadingService::set_verbose(bool verbose) { 202 MutexLocker m(Management_lock); 203 204 // verbose will be set to the previous value 205 bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassLoading", &verbose, Flag::MANAGEMENT); 206 assert(succeed, "Setting TraceClassLoading flag fails"); 207 reset_trace_class_unloading(); 208 209 return verbose; 210 } 211 212 // Caller to this function must own Management_lock 213 void ClassLoadingService::reset_trace_class_unloading() { 214 assert(Management_lock->owned_by_self(), "Must own the Management_lock"); 215 bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose(); 216 bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassUnloading", &value, Flag::MANAGEMENT); 217 assert(succeed, "Setting TraceClassUnLoading flag fails"); 218 } 219 220 GrowableArray<KlassHandle>* LoadedClassesEnumerator::_loaded_classes = NULL; 221 Thread* LoadedClassesEnumerator::_current_thread = NULL; 222 223 LoadedClassesEnumerator::LoadedClassesEnumerator(Thread* cur_thread) { 224 assert(cur_thread == Thread::current(), "Check current thread"); 225 226 int init_size = ClassLoadingService::loaded_class_count(); 227 _klass_handle_array = new GrowableArray<KlassHandle>(init_size); 228 229 // For consistency of the loaded classes, grab the SystemDictionary lock 230 MutexLocker sd_mutex(SystemDictionary_lock); 231 232 // Set _loaded_classes and _current_thread and begin enumerating all classes. 233 // Only one thread will do the enumeration at a time. 234 // These static variables are needed and they are used by the static method 235 // add_loaded_class called from classes_do(). 236 _loaded_classes = _klass_handle_array; |