coleenp@4037: /* coleenp@4037: * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. coleenp@4037: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. coleenp@4037: * coleenp@4037: * This code is free software; you can redistribute it and/or modify it coleenp@4037: * under the terms of the GNU General Public License version 2 only, as coleenp@4037: * published by the Free Software Foundation. coleenp@4037: * coleenp@4037: * This code is distributed in the hope that it will be useful, but WITHOUT coleenp@4037: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or coleenp@4037: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License coleenp@4037: * version 2 for more details (a copy is included in the LICENSE file that coleenp@4037: * accompanied this code). coleenp@4037: * coleenp@4037: * You should have received a copy of the GNU General Public License version coleenp@4037: * 2 along with this work; if not, write to the Free Software Foundation, coleenp@4037: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. coleenp@4037: * coleenp@4037: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA coleenp@4037: * or visit www.oracle.com if you need additional information or have any coleenp@4037: * questions. coleenp@4037: * coleenp@4037: */ coleenp@4037: coleenp@4037: #include "precompiled.hpp" coleenp@4037: #include "classfile/javaClasses.hpp" coleenp@4037: #include "classfile/systemDictionary.hpp" coleenp@4037: #include "gc_implementation/shared/markSweep.inline.hpp" coleenp@4037: #include "gc_interface/collectedHeap.inline.hpp" coleenp@4037: #include "memory/genOopClosures.inline.hpp" coleenp@4037: #include "memory/oopFactory.hpp" coleenp@4037: #include "oops/instanceKlass.hpp" coleenp@4037: #include "oops/instanceClassLoaderKlass.hpp" coleenp@4037: #include "oops/instanceMirrorKlass.hpp" coleenp@4037: #include "oops/instanceOop.hpp" coleenp@4037: #include "oops/oop.inline.hpp" coleenp@4037: #include "oops/symbol.hpp" coleenp@4037: #include "runtime/handles.inline.hpp" jprovino@4542: #include "utilities/macros.hpp" jprovino@4542: #if INCLUDE_ALL_GCS coleenp@4037: #include "gc_implementation/parNew/parOopClosures.inline.hpp" coleenp@4037: #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" coleenp@4037: #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" coleenp@4037: #include "oops/oop.pcgc.inline.hpp" jprovino@4542: #endif // INCLUDE_ALL_GCS coleenp@4037: coleenp@4037: #define if_do_metadata_checked(closure, nv_suffix) \ coleenp@4037: /* Make sure the non-virtual and the virtual versions match. */ \ coleenp@4037: assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \ coleenp@4037: "Inconsistency in do_metadata"); \ coleenp@4037: if (closure->do_metadata##nv_suffix()) coleenp@4037: coleenp@4047: // Macro to define InstanceClassLoaderKlass::oop_oop_iterate for virtual/nonvirtual for coleenp@4037: // all closures. Macros calling macros above for each oop size. coleenp@4037: // Since ClassLoader objects have only a pointer to the loader_data, they are not coleenp@4037: // compressed nor does the pointer move. coleenp@4037: coleenp@4037: #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)\ coleenp@4037: \ coleenp@4047: int InstanceClassLoaderKlass:: \ coleenp@4037: oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ coleenp@4037: /* Get size before changing pointers */ \ coleenp@4037: SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\ coleenp@4037: int size = InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \ coleenp@4037: \ coleenp@4037: if_do_metadata_checked(closure, nv_suffix) { \ coleenp@4037: ClassLoaderData* cld = java_lang_ClassLoader::loader_data(obj); \ coleenp@4037: /* cld can be null if we have a non-registered class loader. */ \ coleenp@4037: if (cld != NULL) { \ coleenp@4037: closure->do_class_loader_data(cld); \ coleenp@4037: } \ coleenp@4037: } \ coleenp@4037: \ coleenp@4037: return size; \ coleenp@4037: } coleenp@4037: jprovino@4542: #if INCLUDE_ALL_GCS coleenp@4037: #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \ coleenp@4037: \ coleenp@4047: int InstanceClassLoaderKlass:: \ coleenp@4037: oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \ coleenp@4037: /* Get size before changing pointers */ \ coleenp@4037: SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\ coleenp@4037: int size = InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \ coleenp@4037: return size; \ coleenp@4037: } jprovino@4542: #endif // INCLUDE_ALL_GCS coleenp@4037: coleenp@4037: coleenp@4037: #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \ coleenp@4037: \ coleenp@4047: int InstanceClassLoaderKlass:: \ coleenp@4037: oop_oop_iterate##nv_suffix##_m(oop obj, \ coleenp@4037: OopClosureType* closure, \ coleenp@4037: MemRegion mr) { \ coleenp@4037: SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\ coleenp@4037: \ coleenp@4037: int size = InstanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr); \ coleenp@4037: \ coleenp@4037: if_do_metadata_checked(closure, nv_suffix) { \ coleenp@4037: if (mr.contains(obj)) { \ coleenp@4037: ClassLoaderData* cld = java_lang_ClassLoader::loader_data(obj); \ coleenp@4037: /* cld can be null if we have a non-registered class loader. */ \ coleenp@4037: if (cld != NULL) { \ coleenp@4037: closure->do_class_loader_data(cld); \ coleenp@4037: } \ coleenp@4037: } \ coleenp@4037: } \ coleenp@4037: \ coleenp@4037: return size; \ coleenp@4037: } coleenp@4037: coleenp@4037: ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN) coleenp@4037: ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN) jprovino@4542: #if INCLUDE_ALL_GCS coleenp@4037: ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) coleenp@4037: ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) jprovino@4542: #endif // INCLUDE_ALL_GCS coleenp@4037: ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m) coleenp@4037: ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m) coleenp@4037: coleenp@4047: void InstanceClassLoaderKlass::oop_follow_contents(oop obj) { coleenp@4037: InstanceKlass::oop_follow_contents(obj); coleenp@4037: ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); coleenp@4037: coleenp@4037: // We must NULL check here, since the class loader coleenp@4037: // can be found before the loader data has been set up. coleenp@4037: if(loader_data != NULL) { coleenp@4037: MarkSweep::follow_class_loader(loader_data); coleenp@4037: } coleenp@4037: } coleenp@4037: jprovino@4542: #if INCLUDE_ALL_GCS coleenp@4047: void InstanceClassLoaderKlass::oop_follow_contents(ParCompactionManager* cm, coleenp@4037: oop obj) { coleenp@4037: InstanceKlass::oop_follow_contents(cm, obj); coleenp@4037: ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); coleenp@4037: if (loader_data != NULL) { coleenp@4037: PSParallelCompact::follow_class_loader(cm, loader_data); coleenp@4037: } coleenp@4037: } coleenp@4037: coleenp@4047: void InstanceClassLoaderKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { coleenp@4037: InstanceKlass::oop_push_contents(pm, obj); coleenp@4037: coleenp@4037: // This is called by the young collector. It will already have taken care of coleenp@4037: // all class loader data. So, we don't have to follow the class loader -> coleenp@4037: // class loader data link. coleenp@4037: } coleenp@4037: coleenp@4047: int InstanceClassLoaderKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { coleenp@4037: InstanceKlass::oop_update_pointers(cm, obj); coleenp@4037: ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); coleenp@4037: if (loader_data != NULL) { coleenp@4037: PSParallelCompact::adjust_class_loader(cm, loader_data); coleenp@4037: } coleenp@4037: return size_helper(); coleenp@4037: } jprovino@4542: #endif // INCLUDE_ALL_GCS coleenp@4037: