src/share/vm/services/classLoadingService.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 8059557_open Sdiff src/share/vm/services

src/share/vm/services/classLoadingService.cpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 164   class_size += k->size();
 165 
 166   if (k->oop_is_instance()) {
 167     class_size += k->methods()->size();
 168     // FIXME: Need to count the contents of methods
 169     class_size += k->constants()->size();
 170     class_size += k->local_interfaces()->size();
 171     class_size += k->transitive_interfaces()->size();
 172     // We do not have to count implementors, since we only store one!
 173     // FIXME: How should these be accounted for, now when they have moved.
 174     //class_size += k->fields()->size();
 175   }
 176   return class_size * oopSize;
 177 }
 178 
 179 
 180 bool ClassLoadingService::set_verbose(bool verbose) {
 181   MutexLocker m(Management_lock);
 182 
 183   // verbose will be set to the previous value
 184   bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassLoading", &verbose, Flag::MANAGEMENT);
 185   assert(succeed, "Setting TraceClassLoading flag fails");
 186   reset_trace_class_unloading();
 187 
 188   return verbose;
 189 }
 190 
 191 // Caller to this function must own Management_lock
 192 void ClassLoadingService::reset_trace_class_unloading() {
 193   assert(Management_lock->owned_by_self(), "Must own the Management_lock");
 194   bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose();
 195   bool succeed = CommandLineFlags::boolAtPut((char*)"TraceClassUnloading", &value, Flag::MANAGEMENT);
 196   assert(succeed, "Setting TraceClassUnLoading flag fails");
 197 }
 198 
 199 GrowableArray<KlassHandle>* LoadedClassesEnumerator::_loaded_classes = NULL;
 200 Thread* LoadedClassesEnumerator::_current_thread = NULL;
 201 
 202 LoadedClassesEnumerator::LoadedClassesEnumerator(Thread* cur_thread) {
 203   assert(cur_thread == Thread::current(), "Check current thread");
 204 
 205   int init_size = ClassLoadingService::loaded_class_count();
 206   _klass_handle_array = new GrowableArray<KlassHandle>(init_size);
 207 
 208   // For consistency of the loaded classes, grab the SystemDictionary lock
 209   MutexLocker sd_mutex(SystemDictionary_lock);
 210 
 211   // Set _loaded_classes and _current_thread and begin enumerating all classes.
 212   // Only one thread will do the enumeration at a time.
 213   // These static variables are needed and they are used by the static method
 214   // add_loaded_class called from classes_do().
 215   _loaded_classes = _klass_handle_array;
   1 /*
   2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 164   class_size += k->size();
 165 
 166   if (k->oop_is_instance()) {
 167     class_size += k->methods()->size();
 168     // FIXME: Need to count the contents of methods
 169     class_size += k->constants()->size();
 170     class_size += k->local_interfaces()->size();
 171     class_size += k->transitive_interfaces()->size();
 172     // We do not have to count implementors, since we only store one!
 173     // FIXME: How should these be accounted for, now when they have moved.
 174     //class_size += k->fields()->size();
 175   }
 176   return class_size * oopSize;
 177 }
 178 
 179 
 180 bool ClassLoadingService::set_verbose(bool verbose) {
 181   MutexLocker m(Management_lock);
 182 
 183   // verbose will be set to the previous value
 184   bool succeed = (CommandLineFlags::boolAtPut((char*)"TraceClassLoading", &verbose, Flag::MANAGEMENT) == Flag::SUCCESS);
 185   assert(succeed, "Setting TraceClassLoading flag fails");
 186   reset_trace_class_unloading();
 187 
 188   return verbose;
 189 }
 190 
 191 // Caller to this function must own Management_lock
 192 void ClassLoadingService::reset_trace_class_unloading() {
 193   assert(Management_lock->owned_by_self(), "Must own the Management_lock");
 194   bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose();
 195   bool succeed = (CommandLineFlags::boolAtPut((char*)"TraceClassUnloading", &value, Flag::MANAGEMENT) == Flag::SUCCESS);
 196   assert(succeed, "Setting TraceClassUnLoading flag fails");
 197 }
 198 
 199 GrowableArray<KlassHandle>* LoadedClassesEnumerator::_loaded_classes = NULL;
 200 Thread* LoadedClassesEnumerator::_current_thread = NULL;
 201 
 202 LoadedClassesEnumerator::LoadedClassesEnumerator(Thread* cur_thread) {
 203   assert(cur_thread == Thread::current(), "Check current thread");
 204 
 205   int init_size = ClassLoadingService::loaded_class_count();
 206   _klass_handle_array = new GrowableArray<KlassHandle>(init_size);
 207 
 208   // For consistency of the loaded classes, grab the SystemDictionary lock
 209   MutexLocker sd_mutex(SystemDictionary_lock);
 210 
 211   // Set _loaded_classes and _current_thread and begin enumerating all classes.
 212   // Only one thread will do the enumeration at a time.
 213   // These static variables are needed and they are used by the static method
 214   // add_loaded_class called from classes_do().
 215   _loaded_classes = _klass_handle_array;
src/share/vm/services/classLoadingService.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File