|
1 /* |
|
2 /* |
|
3 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 * |
|
6 * This code is free software; you can redistribute it and/or modify it |
|
7 * under the terms of the GNU General Public License version 2 only, as |
|
8 * published by the Free Software Foundation. |
|
9 * |
|
10 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 * version 2 for more details (a copy is included in the LICENSE file that |
|
14 * accompanied this code). |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License version |
|
17 * 2 along with this work; if not, write to the Free Software Foundation, |
|
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 * |
|
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 * or visit www.oracle.com if you need additional information or have any |
|
22 * questions. |
|
23 * |
|
24 */ |
|
25 |
|
26 #ifndef SHARE_VM_OOPS_INSTANCECLASSLOADERKLASS_INLINE_HPP |
|
27 #define SHARE_VM_OOPS_INSTANCECLASSLOADERKLASS_INLINE_HPP |
|
28 |
|
29 #include "classfile/javaClasses.hpp" |
|
30 #include "oops/instanceClassLoaderKlass.hpp" |
|
31 #include "oops/instanceKlass.inline.hpp" |
|
32 #include "oops/oop.inline.hpp" |
|
33 #include "utilities/debug.hpp" |
|
34 #include "utilities/globalDefinitions.hpp" |
|
35 #include "utilities/macros.hpp" |
|
36 |
|
37 template <bool nv, class OopClosureType> |
|
38 inline int InstanceClassLoaderKlass::oop_oop_iterate(oop obj, OopClosureType* closure) { |
|
39 int size = InstanceKlass::oop_oop_iterate<nv>(obj, closure); |
|
40 |
|
41 if (Devirtualizer<nv>::do_metadata(closure)) { |
|
42 ClassLoaderData* cld = java_lang_ClassLoader::loader_data(obj); |
|
43 // cld can be null if we have a non-registered class loader. |
|
44 if (cld != NULL) { |
|
45 closure->do_class_loader_data(cld); |
|
46 } |
|
47 } |
|
48 |
|
49 return size; |
|
50 } |
|
51 |
|
52 #if INCLUDE_ALL_GCS |
|
53 template <bool nv, class OopClosureType> |
|
54 inline int InstanceClassLoaderKlass::oop_oop_iterate_reverse(oop obj, OopClosureType* closure) { |
|
55 int size = InstanceKlass::oop_oop_iterate_reverse<nv>(obj, closure); |
|
56 |
|
57 assert(!Devirtualizer<nv>::do_metadata(closure), |
|
58 "Code to handle metadata is not implemented"); |
|
59 |
|
60 return size; |
|
61 } |
|
62 #endif // INCLUDE_ALL_GCS |
|
63 |
|
64 |
|
65 template <bool nv, class OopClosureType> |
|
66 inline int InstanceClassLoaderKlass::oop_oop_iterate_bounded(oop obj, OopClosureType* closure, MemRegion mr) { |
|
67 int size = InstanceKlass::oop_oop_iterate_bounded<nv>(obj, closure, mr); |
|
68 |
|
69 if (Devirtualizer<nv>::do_metadata(closure)) { |
|
70 if (mr.contains(obj)) { |
|
71 ClassLoaderData* cld = java_lang_ClassLoader::loader_data(obj); |
|
72 // cld can be null if we have a non-registered class loader. |
|
73 if (cld != NULL) { |
|
74 closure->do_class_loader_data(cld); |
|
75 } |
|
76 } |
|
77 } |
|
78 |
|
79 return size; |
|
80 } |
|
81 |
|
82 |
|
83 #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ |
|
84 \ |
|
85 int InstanceClassLoaderKlass::oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ |
|
86 return oop_oop_iterate<nvs_to_bool(nv_suffix)>(obj, closure); \ |
|
87 } |
|
88 |
|
89 #if INCLUDE_ALL_GCS |
|
90 #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \ |
|
91 \ |
|
92 int InstanceClassLoaderKlass::oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \ |
|
93 return oop_oop_iterate_reverse<nvs_to_bool(nv_suffix)>(obj, closure); \ |
|
94 } |
|
95 #else |
|
96 #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) |
|
97 #endif |
|
98 |
|
99 |
|
100 #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \ |
|
101 \ |
|
102 int InstanceClassLoaderKlass::oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* closure, MemRegion mr) { \ |
|
103 return oop_oop_iterate_bounded<nvs_to_bool(nv_suffix)>(obj, closure, mr); \ |
|
104 } |
|
105 |
|
106 #define ALL_INSTANCE_CLASS_LOADER_KLASS_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \ |
|
107 InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN( OopClosureType, nv_suffix) \ |
|
108 InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m( OopClosureType, nv_suffix) \ |
|
109 InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) |
|
110 |
|
111 #endif // SHARE_VM_OOPS_INSTANCECLASSLOADERKLASS_INLINE_HPP |