Mercurial > hg > truffle
comparison src/share/vm/oops/instanceClassLoaderKlass.cpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | |
children | aed758eda82a |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | |
2 * Copyright (c) 2011, 2012, 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/oopFactory.hpp" | |
32 #include "oops/instanceKlass.hpp" | |
33 #include "oops/instanceClassLoaderKlass.hpp" | |
34 #include "oops/instanceMirrorKlass.hpp" | |
35 #include "oops/instanceOop.hpp" | |
36 #include "oops/oop.inline.hpp" | |
37 #include "oops/symbol.hpp" | |
38 #include "runtime/handles.inline.hpp" | |
39 #ifndef SERIALGC | |
40 #include "gc_implementation/parNew/parOopClosures.inline.hpp" | |
41 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" | |
42 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" | |
43 #include "oops/oop.pcgc.inline.hpp" | |
44 #endif | |
45 | |
46 #define if_do_metadata_checked(closure, nv_suffix) \ | |
47 /* Make sure the non-virtual and the virtual versions match. */ \ | |
48 assert(closure->do_metadata##nv_suffix() == closure->do_metadata(), \ | |
49 "Inconsistency in do_metadata"); \ | |
50 if (closure->do_metadata##nv_suffix()) | |
51 | |
52 // Macro to define instanceClassLoaderKlass::oop_oop_iterate for virtual/nonvirtual for | |
53 // all closures. Macros calling macros above for each oop size. | |
54 // Since ClassLoader objects have only a pointer to the loader_data, they are not | |
55 // compressed nor does the pointer move. | |
56 | |
57 #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)\ | |
58 \ | |
59 int instanceClassLoaderKlass:: \ | |
60 oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) { \ | |
61 /* Get size before changing pointers */ \ | |
62 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\ | |
63 int size = InstanceKlass::oop_oop_iterate##nv_suffix(obj, closure); \ | |
64 \ | |
65 if_do_metadata_checked(closure, nv_suffix) { \ | |
66 ClassLoaderData* cld = java_lang_ClassLoader::loader_data(obj); \ | |
67 /* cld can be null if we have a non-registered class loader. */ \ | |
68 if (cld != NULL) { \ | |
69 closure->do_class_loader_data(cld); \ | |
70 } \ | |
71 } \ | |
72 \ | |
73 return size; \ | |
74 } | |
75 | |
76 #ifndef SERIALGC | |
77 #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \ | |
78 \ | |
79 int instanceClassLoaderKlass:: \ | |
80 oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) { \ | |
81 /* Get size before changing pointers */ \ | |
82 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\ | |
83 int size = InstanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure); \ | |
84 return size; \ | |
85 } | |
86 #endif // !SERIALGC | |
87 | |
88 | |
89 #define InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix) \ | |
90 \ | |
91 int instanceClassLoaderKlass:: \ | |
92 oop_oop_iterate##nv_suffix##_m(oop obj, \ | |
93 OopClosureType* closure, \ | |
94 MemRegion mr) { \ | |
95 SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);\ | |
96 \ | |
97 int size = InstanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr); \ | |
98 \ | |
99 if_do_metadata_checked(closure, nv_suffix) { \ | |
100 if (mr.contains(obj)) { \ | |
101 ClassLoaderData* cld = java_lang_ClassLoader::loader_data(obj); \ | |
102 /* cld can be null if we have a non-registered class loader. */ \ | |
103 if (cld != NULL) { \ | |
104 closure->do_class_loader_data(cld); \ | |
105 } \ | |
106 } \ | |
107 } \ | |
108 \ | |
109 return size; \ | |
110 } | |
111 | |
112 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN) | |
113 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN) | |
114 #ifndef SERIALGC | |
115 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) | |
116 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceClassLoaderKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) | |
117 #endif // SERIALGC | |
118 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m) | |
119 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceClassLoaderKlass_OOP_OOP_ITERATE_DEFN_m) | |
120 | |
121 void instanceClassLoaderKlass::oop_follow_contents(oop obj) { | |
122 InstanceKlass::oop_follow_contents(obj); | |
123 ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); | |
124 | |
125 // We must NULL check here, since the class loader | |
126 // can be found before the loader data has been set up. | |
127 if(loader_data != NULL) { | |
128 MarkSweep::follow_class_loader(loader_data); | |
129 } | |
130 } | |
131 | |
132 #ifndef SERIALGC | |
133 void instanceClassLoaderKlass::oop_follow_contents(ParCompactionManager* cm, | |
134 oop obj) { | |
135 InstanceKlass::oop_follow_contents(cm, obj); | |
136 ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); | |
137 if (loader_data != NULL) { | |
138 PSParallelCompact::follow_class_loader(cm, loader_data); | |
139 } | |
140 } | |
141 | |
142 void instanceClassLoaderKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
143 InstanceKlass::oop_push_contents(pm, obj); | |
144 | |
145 // This is called by the young collector. It will already have taken care of | |
146 // all class loader data. So, we don't have to follow the class loader -> | |
147 // class loader data link. | |
148 } | |
149 | |
150 int instanceClassLoaderKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
151 InstanceKlass::oop_update_pointers(cm, obj); | |
152 ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); | |
153 if (loader_data != NULL) { | |
154 PSParallelCompact::adjust_class_loader(cm, loader_data); | |
155 } | |
156 return size_helper(); | |
157 } | |
158 #endif // SERIALGC | |
159 |