Mercurial > hg > truffle
annotate src/share/vm/oops/klassKlass.cpp @ 2045:9c96c873c42b
Fix includes to match new hotspot mechanism.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Fri, 07 Jan 2011 18:45:09 +0100 |
parents | 06f017f7daa7 |
children | d25d4ca69222 |
rev | line source |
---|---|
0 | 1 /* |
1972 | 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "gc_implementation/shared/markSweep.inline.hpp" | |
27 #include "gc_interface/collectedHeap.hpp" | |
28 #include "gc_interface/collectedHeap.inline.hpp" | |
29 #include "memory/oopFactory.hpp" | |
30 #include "memory/permGen.hpp" | |
31 #include "oops/constantPoolKlass.hpp" | |
32 #include "oops/instanceKlass.hpp" | |
33 #include "oops/instanceOop.hpp" | |
34 #include "oops/klassKlass.hpp" | |
35 #include "oops/klassOop.hpp" | |
36 #include "oops/methodKlass.hpp" | |
37 #include "oops/objArrayKlass.hpp" | |
38 #include "oops/oop.inline.hpp" | |
39 #include "oops/oop.inline2.hpp" | |
40 #include "oops/symbolKlass.hpp" | |
41 #include "oops/symbolOop.hpp" | |
42 #include "oops/typeArrayKlass.hpp" | |
43 #include "runtime/handles.inline.hpp" | |
44 #ifndef SERIALGC | |
45 #include "oops/oop.pcgc.inline.hpp" | |
46 #endif | |
0 | 47 |
48 int klassKlass::oop_size(oop obj) const { | |
49 assert (obj->is_klass(), "must be a klassOop"); | |
50 return klassOop(obj)->klass_part()->klass_oop_size(); | |
51 } | |
52 | |
53 klassOop klassKlass::create_klass(TRAPS) { | |
54 KlassHandle h_this_klass; | |
55 klassKlass o; | |
56 // for bootstrapping, handles may not be available yet. | |
57 klassOop k = base_create_klass_oop(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL); | |
58 k->set_klass(k); // point to thyself | |
59 // Do not try to allocate mirror, java.lang.Class not loaded at this point. | |
60 // See Universe::fixup_mirrors() | |
61 return k; | |
62 } | |
63 | |
64 void klassKlass::oop_follow_contents(oop obj) { | |
65 Klass* k = Klass::cast(klassOop(obj)); | |
66 // If we are alive it is valid to keep our superclass and subtype caches alive | |
67 MarkSweep::mark_and_push(k->adr_super()); | |
68 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
69 MarkSweep::mark_and_push(k->adr_primary_supers()+i); | |
70 MarkSweep::mark_and_push(k->adr_secondary_super_cache()); | |
71 MarkSweep::mark_and_push(k->adr_secondary_supers()); | |
72 MarkSweep::mark_and_push(k->adr_java_mirror()); | |
1941
79d04223b8a5
Added caching for resolved types and resolved fields.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1713
diff
changeset
|
73 MarkSweep::mark_and_push(k->adr_c1x_mirror()); |
0 | 74 MarkSweep::mark_and_push(k->adr_name()); |
75 // We follow the subklass and sibling links at the end of the | |
76 // marking phase, since otherwise following them will prevent | |
77 // class unloading (all classes are transitively linked from | |
78 // java.lang.Object). | |
79 MarkSweep::revisit_weak_klass_link(k); | |
80 obj->follow_header(); | |
81 } | |
82 | |
83 #ifndef SERIALGC | |
84 void klassKlass::oop_follow_contents(ParCompactionManager* cm, | |
85 oop obj) { | |
86 Klass* k = Klass::cast(klassOop(obj)); | |
87 // If we are alive it is valid to keep our superclass and subtype caches alive | |
88 PSParallelCompact::mark_and_push(cm, k->adr_super()); | |
89 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
90 PSParallelCompact::mark_and_push(cm, k->adr_primary_supers()+i); | |
91 PSParallelCompact::mark_and_push(cm, k->adr_secondary_super_cache()); | |
92 PSParallelCompact::mark_and_push(cm, k->adr_secondary_supers()); | |
93 PSParallelCompact::mark_and_push(cm, k->adr_java_mirror()); | |
1941
79d04223b8a5
Added caching for resolved types and resolved fields.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1713
diff
changeset
|
94 PSParallelCompact::mark_and_push(cm, k->adr_c1x_mirror()); |
0 | 95 PSParallelCompact::mark_and_push(cm, k->adr_name()); |
96 // We follow the subklass and sibling links at the end of the | |
97 // marking phase, since otherwise following them will prevent | |
98 // class unloading (all classes are transitively linked from | |
99 // java.lang.Object). | |
100 PSParallelCompact::revisit_weak_klass_link(cm, k); | |
101 obj->follow_header(cm); | |
102 } | |
103 #endif // SERIALGC | |
104 | |
105 int klassKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
106 // Get size before changing pointers | |
107 int size = oop_size(obj); | |
108 Klass* k = Klass::cast(klassOop(obj)); | |
109 blk->do_oop(k->adr_super()); | |
110 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
111 blk->do_oop(k->adr_primary_supers()+i); | |
112 blk->do_oop(k->adr_secondary_super_cache()); | |
113 blk->do_oop(k->adr_secondary_supers()); | |
114 blk->do_oop(k->adr_java_mirror()); | |
1941
79d04223b8a5
Added caching for resolved types and resolved fields.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1713
diff
changeset
|
115 blk->do_oop(k->adr_c1x_mirror()); |
0 | 116 blk->do_oop(k->adr_name()); |
117 // The following are in the perm gen and are treated | |
118 // specially in a later phase of a perm gen collection; ... | |
119 assert(oop(k)->is_perm(), "should be in perm"); | |
120 assert(oop(k->subklass())->is_perm_or_null(), "should be in perm"); | |
121 assert(oop(k->next_sibling())->is_perm_or_null(), "should be in perm"); | |
122 // ... don't scan them normally, but remember this klassKlass | |
123 // for later (see, for instance, oop_follow_contents above | |
124 // for what MarkSweep does with it. | |
125 if (blk->should_remember_klasses()) { | |
126 blk->remember_klass(k); | |
127 } | |
128 obj->oop_iterate_header(blk); | |
129 return size; | |
130 } | |
131 | |
132 | |
133 int klassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { | |
134 // Get size before changing pointers | |
135 int size = oop_size(obj); | |
136 Klass* k = Klass::cast(klassOop(obj)); | |
137 oop* adr; | |
138 adr = k->adr_super(); | |
139 if (mr.contains(adr)) blk->do_oop(adr); | |
140 for (juint i = 0; i < Klass::primary_super_limit(); i++) { | |
141 adr = k->adr_primary_supers()+i; | |
142 if (mr.contains(adr)) blk->do_oop(adr); | |
143 } | |
144 adr = k->adr_secondary_super_cache(); | |
145 if (mr.contains(adr)) blk->do_oop(adr); | |
146 adr = k->adr_secondary_supers(); | |
147 if (mr.contains(adr)) blk->do_oop(adr); | |
148 adr = k->adr_java_mirror(); | |
149 if (mr.contains(adr)) blk->do_oop(adr); | |
1941
79d04223b8a5
Added caching for resolved types and resolved fields.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1713
diff
changeset
|
150 adr = k->adr_c1x_mirror(); |
79d04223b8a5
Added caching for resolved types and resolved fields.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1713
diff
changeset
|
151 if (mr.contains(adr)) blk->do_oop(adr); |
0 | 152 adr = k->adr_name(); |
153 if (mr.contains(adr)) blk->do_oop(adr); | |
154 // The following are "weak links" in the perm gen and are | |
155 // treated specially in a later phase of a perm gen collection. | |
156 assert(oop(k)->is_perm(), "should be in perm"); | |
157 assert(oop(k->adr_subklass())->is_perm(), "should be in perm"); | |
158 assert(oop(k->adr_next_sibling())->is_perm(), "should be in perm"); | |
159 if (blk->should_remember_klasses() | |
160 && (mr.contains(k->adr_subklass()) | |
161 || mr.contains(k->adr_next_sibling()))) { | |
162 blk->remember_klass(k); | |
163 } | |
164 obj->oop_iterate_header(blk, mr); | |
165 return size; | |
166 } | |
167 | |
168 | |
169 int klassKlass::oop_adjust_pointers(oop obj) { | |
170 // Get size before changing pointers | |
171 int size = oop_size(obj); | |
172 obj->adjust_header(); | |
173 | |
174 Klass* k = Klass::cast(klassOop(obj)); | |
175 | |
176 MarkSweep::adjust_pointer(k->adr_super()); | |
177 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
178 MarkSweep::adjust_pointer(k->adr_primary_supers()+i); | |
179 MarkSweep::adjust_pointer(k->adr_secondary_super_cache()); | |
180 MarkSweep::adjust_pointer(k->adr_secondary_supers()); | |
181 MarkSweep::adjust_pointer(k->adr_java_mirror()); | |
1941
79d04223b8a5
Added caching for resolved types and resolved fields.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1713
diff
changeset
|
182 MarkSweep::adjust_pointer(k->adr_c1x_mirror()); |
0 | 183 MarkSweep::adjust_pointer(k->adr_name()); |
184 MarkSweep::adjust_pointer(k->adr_subklass()); | |
185 MarkSweep::adjust_pointer(k->adr_next_sibling()); | |
186 return size; | |
187 } | |
188 | |
189 #ifndef SERIALGC | |
190 void klassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
191 } | |
192 | |
193 int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
194 Klass* k = Klass::cast(klassOop(obj)); | |
195 | |
196 oop* const beg_oop = k->oop_block_beg(); | |
197 oop* const end_oop = k->oop_block_end(); | |
198 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
199 PSParallelCompact::adjust_pointer(cur_oop); | |
200 } | |
201 | |
202 return oop_size(obj); | |
203 } | |
204 | |
205 int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, | |
206 HeapWord* beg_addr, HeapWord* end_addr) { | |
207 Klass* k = Klass::cast(klassOop(obj)); | |
208 | |
209 oop* const beg_oop = MAX2((oop*)beg_addr, k->oop_block_beg()); | |
210 oop* const end_oop = MIN2((oop*)end_addr, k->oop_block_end()); | |
211 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
212 PSParallelCompact::adjust_pointer(cur_oop); | |
213 } | |
214 | |
215 return oop_size(obj); | |
216 } | |
217 #endif // SERIALGC | |
218 | |
219 | |
220 // Printing | |
221 | |
222 void klassKlass::oop_print_on(oop obj, outputStream* st) { | |
223 Klass::oop_print_on(obj, st); | |
224 } | |
225 | |
226 void klassKlass::oop_print_value_on(oop obj, outputStream* st) { | |
227 Klass::oop_print_value_on(obj, st); | |
228 } | |
229 | |
230 const char* klassKlass::internal_name() const { | |
231 return "{other class}"; | |
232 } | |
233 | |
234 | |
235 // Verification | |
236 | |
237 void klassKlass::oop_verify_on(oop obj, outputStream* st) { | |
238 Klass::oop_verify_on(obj, st); | |
239 guarantee(obj->is_perm(), "should be in permspace"); | |
240 guarantee(obj->is_klass(), "should be klass"); | |
241 | |
242 Klass* k = Klass::cast(klassOop(obj)); | |
243 if (k->super() != NULL) { | |
244 guarantee(k->super()->is_perm(), "should be in permspace"); | |
245 guarantee(k->super()->is_klass(), "should be klass"); | |
246 } | |
247 klassOop ko = k->secondary_super_cache(); | |
248 if( ko != NULL ) { | |
249 guarantee(ko->is_perm(), "should be in permspace"); | |
250 guarantee(ko->is_klass(), "should be klass"); | |
251 } | |
252 for( uint i = 0; i < primary_super_limit(); i++ ) { | |
253 oop ko = k->adr_primary_supers()[i]; // Cannot use normal accessor because it asserts | |
254 if( ko != NULL ) { | |
255 guarantee(ko->is_perm(), "should be in permspace"); | |
256 guarantee(ko->is_klass(), "should be klass"); | |
257 } | |
258 } | |
259 | |
260 if (k->java_mirror() != NULL || (k->oop_is_instance() && instanceKlass::cast(klassOop(obj))->is_loaded())) { | |
261 guarantee(k->java_mirror() != NULL, "should be allocated"); | |
262 guarantee(k->java_mirror()->is_perm(), "should be in permspace"); | |
263 guarantee(k->java_mirror()->is_instance(), "should be instance"); | |
264 } | |
265 if (k->name() != NULL) { | |
266 guarantee(Universe::heap()->is_in_permanent(k->name()), | |
267 "should be in permspace"); | |
268 guarantee(k->name()->is_symbol(), "should be symbol"); | |
269 } | |
270 } |