1 /* |
|
2 * Copyright (c) 2011, 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/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 "memory/specialized_oop_closures.hpp" |
|
34 #include "oops/instanceKlass.hpp" |
|
35 #include "oops/instanceClassLoaderKlass.hpp" |
|
36 #include "oops/instanceMirrorKlass.hpp" |
|
37 #include "oops/instanceOop.hpp" |
|
38 #include "oops/oop.inline.hpp" |
|
39 #include "oops/symbol.hpp" |
|
40 #include "runtime/handles.inline.hpp" |
|
41 #include "utilities/macros.hpp" |
|
42 #if INCLUDE_ALL_GCS |
|
43 #include "gc_implementation/parNew/parOopClosures.inline.hpp" |
|
44 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" |
|
45 #endif // INCLUDE_ALL_GCS |
|
46 |
|
47 // Macro to define InstanceClassLoaderKlass::oop_oop_iterate for virtual/nonvirtual for |
|
48 // all closures. Macros calling macros above for each oop size. |
|
49 // Since ClassLoader objects have only a pointer to the loader_data, they are not |
|
50 // compressed nor does the pointer move. |
|
51 |
|
52 #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)\ |
|
53 \ |
|
54 int InstanceClassLoaderKlass:: \ |
|
55 oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ |
|
56 /* Get size before changing pointers */ \ |
|
57 int size = InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \ |
|
58 \ |
|
59 if_do_metadata_checked(closure, nv_suffix) { \ |
|
60 ClassLoaderData* cld = java_lang_ClassLoader::loader_data(obj); \ |
|
61 /* cld can be null if we have a non-registered class loader. */ \ |
|
62 if (cld != NULL) { \ |
|
63 closure->do_class_loader_data(cld); \ |
|
64 } \ |
|
65 } \ |
|
66 \ |
|
67 return size; \ |
|
68 } |
|
69 |
|
70 #if INCLUDE_ALL_GCS |
|
71 #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \ |
|
72 \ |
|
73 int InstanceClassLoaderKlass:: \ |
|
74 oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \ |
|
75 /* Get size before changing pointers */ \ |
|
76 int size = InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \ |
|
77 return size; \ |
|
78 } |
|
79 #endif // INCLUDE_ALL_GCS |
|
80 |
|
81 |
|
82 #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \ |
|
83 \ |
|
84 int InstanceClassLoaderKlass:: \ |
|
85 oop_oop_iterate##nv_suffix##_m(oop obj, \ |
|
86 OopClosureType* closure, \ |
|
87 MemRegion mr) { \ |
|
88 int size = InstanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr); \ |
|
89 \ |
|
90 if_do_metadata_checked(closure, nv_suffix) { \ |
|
91 if (mr.contains(obj)) { \ |
|
92 ClassLoaderData* cld = java_lang_ClassLoader::loader_data(obj); \ |
|
93 /* cld can be null if we have a non-registered class loader. */ \ |
|
94 if (cld != NULL) { \ |
|
95 closure->do_class_loader_data(cld); \ |
|
96 } \ |
|
97 } \ |
|
98 } \ |
|
99 \ |
|
100 return size; \ |
|
101 } |
|
102 |
|
103 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN) |
|
104 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN) |
|
105 #if INCLUDE_ALL_GCS |
|
106 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) |
|
107 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) |
|
108 #endif // INCLUDE_ALL_GCS |
|
109 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m) |
|
110 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m) |
|
111 |
|
112 void InstanceClassLoaderKlass::oop_follow_contents(oop obj) { |
|
113 InstanceKlass::oop_follow_contents(obj); |
|
114 ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); |
|
115 |
|
116 // We must NULL check here, since the class loader |
|
117 // can be found before the loader data has been set up. |
|
118 if(loader_data != NULL) { |
|
119 MarkSweep::follow_class_loader(loader_data); |
|
120 } |
|
121 } |
|
122 |
|
123 #if INCLUDE_ALL_GCS |
|
124 void InstanceClassLoaderKlass::oop_follow_contents(ParCompactionManager* cm, |
|
125 oop obj) { |
|
126 InstanceKlass::oop_follow_contents(cm, obj); |
|
127 ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); |
|
128 if (loader_data != NULL) { |
|
129 PSParallelCompact::follow_class_loader(cm, loader_data); |
|
130 } |
|
131 } |
|
132 |
|
133 void InstanceClassLoaderKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { |
|
134 InstanceKlass::oop_push_contents(pm, obj); |
|
135 |
|
136 // This is called by the young collector. It will already have taken care of |
|
137 // all class loader data. So, we don't have to follow the class loader -> |
|
138 // class loader data link. |
|
139 } |
|
140 |
|
141 int InstanceClassLoaderKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { |
|
142 InstanceKlass::oop_update_pointers(cm, obj); |
|
143 return size_helper(); |
|
144 } |
|
145 #endif // INCLUDE_ALL_GCS |
|
146 |
|