1 /*
   2  * Copyright (c) 2011, 2013, 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/javaClasses.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "gc_implementation/shared/markSweep.inline.hpp"
  29 #include "gc_interface/collectedHeap.inline.hpp"
  30 #include "memory/genOopClosures.inline.hpp"
  31 #include "memory/iterator.inline.hpp"
  32 #include "memory/oopFactory.hpp"
  33 #include "oops/instanceKlass.hpp"
  34 #include "oops/instanceClassLoaderKlass.hpp"
  35 #if INCLUDE_ALL_GCS
  36 #include "gc_implementation/parallelScavenge/psParallelCompact.hpp"
  37 #endif
  38 
  39 InstanceClassLoaderKlass::InstanceClassLoaderKlass(int vtable_len, int itable_len, int static_field_size, int nonstatic_oop_map_size, ReferenceType rt, AccessFlags access_flags, bool is_anonymous)
  40     : InstanceKlass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, access_flags, is_anonymous, _instance_class_loader) {}
  41 
  42 void InstanceClassLoaderKlass::oop_follow_contents(oop obj) {
  43   InstanceKlass::oop_follow_contents(obj);
  44   ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj);
  45 
  46   // We must NULL check here, since the class loader
  47   // can be found before the loader data has been set up.
  48   if(loader_data != NULL) {
  49     MarkSweep::follow_class_loader(loader_data);
  50   }
  51 }
  52 
  53 #if INCLUDE_ALL_GCS
  54 void InstanceClassLoaderKlass::oop_follow_contents(ParCompactionManager* cm,
  55         oop obj) {
  56   InstanceKlass::oop_follow_contents(cm, obj);
  57   ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj);
  58   if (loader_data != NULL) {
  59     PSParallelCompact::follow_class_loader(cm, loader_data);
  60   }
  61 }
  62 
  63 void InstanceClassLoaderKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
  64   InstanceKlass::oop_push_contents(pm, obj);
  65 
  66   // This is called by the young collector. It will already have taken care of
  67   // all class loader data. So, we don't have to follow the class loader ->
  68   // class loader data link.
  69 }
  70 
  71 int InstanceClassLoaderKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
  72   InstanceKlass::oop_update_pointers(cm, obj);
  73   return size_helper();
  74 }
  75 
  76 #endif // INCLUDE_ALL_GCS
  77