src/share/vm/oops/klass.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File classload.01 Sdiff src/share/vm/oops

src/share/vm/oops/klass.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/dictionary.hpp"
  27 #include "classfile/javaClasses.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "gc/shared/collectedHeap.inline.hpp"
  31 #include "memory/heapInspection.hpp"
  32 #include "memory/metadataFactory.hpp"
  33 #include "memory/oopFactory.hpp"
  34 #include "memory/resourceArea.hpp"
  35 #include "oops/instanceKlass.hpp"
  36 #include "oops/klass.inline.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "runtime/atomic.inline.hpp"
  39 #include "runtime/orderAccess.inline.hpp"
  40 #include "trace/traceMacros.hpp"
  41 #include "utilities/macros.hpp"
  42 #include "utilities/stack.inline.hpp"

  43 #if INCLUDE_ALL_GCS
  44 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  45 #endif // INCLUDE_ALL_GCS
  46 
  47 void Klass::set_name(Symbol* n) {
  48   _name = n;
  49   if (_name != NULL) _name->increment_refcount();
  50 }
  51 
  52 bool Klass::is_subclass_of(const Klass* k) const {
  53   // Run up the super chain and check
  54   if (this == k) return true;
  55 
  56   Klass* t = const_cast<Klass*>(this)->super();
  57 
  58   while (t != NULL) {
  59     if (t == k) return true;
  60     t = t->super();
  61   }
  62   return false;


 369 }
 370 
 371 void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses) {
 372   if (!ClassUnloading) {
 373     return;
 374   }
 375 
 376   Klass* root = SystemDictionary::Object_klass();
 377   Stack<Klass*, mtGC> stack;
 378 
 379   stack.push(root);
 380   while (!stack.is_empty()) {
 381     Klass* current = stack.pop();
 382 
 383     assert(current->is_loader_alive(is_alive), "just checking, this should be live");
 384 
 385     // Find and set the first alive subklass
 386     Klass* sub = current->subklass();
 387     while (sub != NULL && !sub->is_loader_alive(is_alive)) {
 388 #ifndef PRODUCT
 389       if (TraceClassUnloading && WizardMode) {
 390         ResourceMark rm;
 391         tty->print_cr("[Unlinking class (subclass) %s]", sub->external_name());
 392       }
 393 #endif
 394       sub = sub->next_sibling();
 395     }
 396     current->set_subklass(sub);
 397     if (sub != NULL) {
 398       stack.push(sub);
 399     }
 400 
 401     // Find and set the first alive sibling
 402     Klass* sibling = current->next_sibling();
 403     while (sibling != NULL && !sibling->is_loader_alive(is_alive)) {
 404       if (TraceClassUnloading && WizardMode) {
 405         ResourceMark rm;
 406         tty->print_cr("[Unlinking class (sibling) %s]", sibling->external_name());
 407       }
 408       sibling = sibling->next_sibling();
 409     }
 410     current->set_next_sibling(sibling);
 411     if (sibling != NULL) {
 412       stack.push(sibling);
 413     }
 414 
 415     // Clean the implementors list and method data.
 416     if (clean_alive_klasses && current->is_instance_klass()) {
 417       InstanceKlass* ik = InstanceKlass::cast(current);
 418       ik->clean_weak_instanceklass_links(is_alive);
 419     }
 420   }
 421 }
 422 
 423 void Klass::klass_update_barrier_set(oop v) {
 424   record_modified_oops();
 425 }
 426 


   1 /*
   2  * Copyright (c) 1997, 2016, 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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/dictionary.hpp"
  27 #include "classfile/javaClasses.hpp"
  28 #include "classfile/systemDictionary.hpp"
  29 #include "classfile/vmSymbols.hpp"
  30 #include "gc/shared/collectedHeap.inline.hpp"
  31 #include "memory/heapInspection.hpp"
  32 #include "memory/metadataFactory.hpp"
  33 #include "memory/oopFactory.hpp"
  34 #include "memory/resourceArea.hpp"
  35 #include "oops/instanceKlass.hpp"
  36 #include "oops/klass.inline.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "runtime/atomic.inline.hpp"
  39 #include "runtime/orderAccess.inline.hpp"
  40 #include "trace/traceMacros.hpp"
  41 #include "utilities/macros.hpp"
  42 #include "utilities/stack.inline.hpp"
  43 #include "logging/log.hpp"
  44 #if INCLUDE_ALL_GCS
  45 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  46 #endif // INCLUDE_ALL_GCS
  47 
  48 void Klass::set_name(Symbol* n) {
  49   _name = n;
  50   if (_name != NULL) _name->increment_refcount();
  51 }
  52 
  53 bool Klass::is_subclass_of(const Klass* k) const {
  54   // Run up the super chain and check
  55   if (this == k) return true;
  56 
  57   Klass* t = const_cast<Klass*>(this)->super();
  58 
  59   while (t != NULL) {
  60     if (t == k) return true;
  61     t = t->super();
  62   }
  63   return false;


 370 }
 371 
 372 void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive_klasses) {
 373   if (!ClassUnloading) {
 374     return;
 375   }
 376 
 377   Klass* root = SystemDictionary::Object_klass();
 378   Stack<Klass*, mtGC> stack;
 379 
 380   stack.push(root);
 381   while (!stack.is_empty()) {
 382     Klass* current = stack.pop();
 383 
 384     assert(current->is_loader_alive(is_alive), "just checking, this should be live");
 385 
 386     // Find and set the first alive subklass
 387     Klass* sub = current->subklass();
 388     while (sub != NULL && !sub->is_loader_alive(is_alive)) {
 389 #ifndef PRODUCT
 390       if (log_is_enabled(Trace, classunload)) {
 391         ResourceMark rm;
 392         log_trace(classunload)("[Unlinking class (subclass) %s]", sub->external_name());
 393       }
 394 #endif
 395       sub = sub->next_sibling();
 396     }
 397     current->set_subklass(sub);
 398     if (sub != NULL) {
 399       stack.push(sub);
 400     }
 401 
 402     // Find and set the first alive sibling
 403     Klass* sibling = current->next_sibling();
 404     while (sibling != NULL && !sibling->is_loader_alive(is_alive)) {
 405       if (log_is_enabled(Trace, classunload)) {
 406         ResourceMark rm;
 407         log_trace(classunload)("[Unlinking class (sibling) %s]", sibling->external_name());
 408       }
 409       sibling = sibling->next_sibling();
 410     }
 411     current->set_next_sibling(sibling);
 412     if (sibling != NULL) {
 413       stack.push(sibling);
 414     }
 415 
 416     // Clean the implementors list and method data.
 417     if (clean_alive_klasses && current->is_instance_klass()) {
 418       InstanceKlass* ik = InstanceKlass::cast(current);
 419       ik->clean_weak_instanceklass_links(is_alive);
 420     }
 421   }
 422 }
 423 
 424 void Klass::klass_update_barrier_set(oop v) {
 425   record_modified_oops();
 426 }
 427 


src/share/vm/oops/klass.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File