Mercurial > hg > truffle
annotate src/share/vm/oops/klassKlass.cpp @ 2490:29246b1d2d3c
Renamed project HotSpotVM => Runtime
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 22 Apr 2011 15:22:45 +0200 |
parents | 2ab52cda08e5 |
children | 0654ee04b214 |
rev | line source |
---|---|
0 | 1 /* |
2227 | 2 * Copyright (c) 1997, 2011, 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" | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
40 #include "oops/symbol.hpp" |
1972 | 41 #include "oops/typeArrayKlass.hpp" |
42 #include "runtime/handles.inline.hpp" | |
43 #ifndef SERIALGC | |
44 #include "oops/oop.pcgc.inline.hpp" | |
45 #endif | |
0 | 46 |
47 int klassKlass::oop_size(oop obj) const { | |
48 assert (obj->is_klass(), "must be a klassOop"); | |
49 return klassOop(obj)->klass_part()->klass_oop_size(); | |
50 } | |
51 | |
52 klassOop klassKlass::create_klass(TRAPS) { | |
53 KlassHandle h_this_klass; | |
54 klassKlass o; | |
55 // for bootstrapping, handles may not be available yet. | |
56 klassOop k = base_create_klass_oop(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL); | |
57 k->set_klass(k); // point to thyself | |
58 // Do not try to allocate mirror, java.lang.Class not loaded at this point. | |
59 // See Universe::fixup_mirrors() | |
60 return k; | |
61 } | |
62 | |
63 void klassKlass::oop_follow_contents(oop obj) { | |
64 Klass* k = Klass::cast(klassOop(obj)); | |
65 // If we are alive it is valid to keep our superclass and subtype caches alive | |
66 MarkSweep::mark_and_push(k->adr_super()); | |
67 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
68 MarkSweep::mark_and_push(k->adr_primary_supers()+i); | |
69 MarkSweep::mark_and_push(k->adr_secondary_super_cache()); | |
70 MarkSweep::mark_and_push(k->adr_secondary_supers()); | |
71 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
|
72 MarkSweep::mark_and_push(k->adr_c1x_mirror()); |
0 | 73 // We follow the subklass and sibling links at the end of the |
74 // marking phase, since otherwise following them will prevent | |
75 // class unloading (all classes are transitively linked from | |
76 // java.lang.Object). | |
77 MarkSweep::revisit_weak_klass_link(k); | |
78 obj->follow_header(); | |
79 } | |
80 | |
81 #ifndef SERIALGC | |
82 void klassKlass::oop_follow_contents(ParCompactionManager* cm, | |
83 oop obj) { | |
84 Klass* k = Klass::cast(klassOop(obj)); | |
85 // If we are alive it is valid to keep our superclass and subtype caches alive | |
86 PSParallelCompact::mark_and_push(cm, k->adr_super()); | |
87 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
88 PSParallelCompact::mark_and_push(cm, k->adr_primary_supers()+i); | |
89 PSParallelCompact::mark_and_push(cm, k->adr_secondary_super_cache()); | |
90 PSParallelCompact::mark_and_push(cm, k->adr_secondary_supers()); | |
91 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
|
92 PSParallelCompact::mark_and_push(cm, k->adr_c1x_mirror()); |
0 | 93 // We follow the subklass and sibling links at the end of the |
94 // marking phase, since otherwise following them will prevent | |
95 // class unloading (all classes are transitively linked from | |
96 // java.lang.Object). | |
97 PSParallelCompact::revisit_weak_klass_link(cm, k); | |
98 obj->follow_header(cm); | |
99 } | |
100 #endif // SERIALGC | |
101 | |
102 int klassKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
103 // Get size before changing pointers | |
104 int size = oop_size(obj); | |
105 Klass* k = Klass::cast(klassOop(obj)); | |
106 blk->do_oop(k->adr_super()); | |
107 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
108 blk->do_oop(k->adr_primary_supers()+i); | |
109 blk->do_oop(k->adr_secondary_super_cache()); | |
110 blk->do_oop(k->adr_secondary_supers()); | |
111 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
|
112 blk->do_oop(k->adr_c1x_mirror()); |
0 | 113 // The following are in the perm gen and are treated |
114 // specially in a later phase of a perm gen collection; ... | |
115 assert(oop(k)->is_perm(), "should be in perm"); | |
116 assert(oop(k->subklass())->is_perm_or_null(), "should be in perm"); | |
117 assert(oop(k->next_sibling())->is_perm_or_null(), "should be in perm"); | |
118 // ... don't scan them normally, but remember this klassKlass | |
119 // for later (see, for instance, oop_follow_contents above | |
120 // for what MarkSweep does with it. | |
121 if (blk->should_remember_klasses()) { | |
122 blk->remember_klass(k); | |
123 } | |
124 obj->oop_iterate_header(blk); | |
125 return size; | |
126 } | |
127 | |
128 | |
129 int klassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { | |
130 // Get size before changing pointers | |
131 int size = oop_size(obj); | |
132 Klass* k = Klass::cast(klassOop(obj)); | |
133 oop* adr; | |
134 adr = k->adr_super(); | |
135 if (mr.contains(adr)) blk->do_oop(adr); | |
136 for (juint i = 0; i < Klass::primary_super_limit(); i++) { | |
137 adr = k->adr_primary_supers()+i; | |
138 if (mr.contains(adr)) blk->do_oop(adr); | |
139 } | |
140 adr = k->adr_secondary_super_cache(); | |
141 if (mr.contains(adr)) blk->do_oop(adr); | |
142 adr = k->adr_secondary_supers(); | |
143 if (mr.contains(adr)) blk->do_oop(adr); | |
144 adr = k->adr_java_mirror(); | |
145 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
|
146 adr = k->adr_c1x_mirror(); |
79d04223b8a5
Added caching for resolved types and resolved fields.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1713
diff
changeset
|
147 if (mr.contains(adr)) blk->do_oop(adr); |
0 | 148 // The following are "weak links" in the perm gen and are |
149 // treated specially in a later phase of a perm gen collection. | |
150 assert(oop(k)->is_perm(), "should be in perm"); | |
151 assert(oop(k->adr_subklass())->is_perm(), "should be in perm"); | |
152 assert(oop(k->adr_next_sibling())->is_perm(), "should be in perm"); | |
153 if (blk->should_remember_klasses() | |
154 && (mr.contains(k->adr_subklass()) | |
155 || mr.contains(k->adr_next_sibling()))) { | |
156 blk->remember_klass(k); | |
157 } | |
158 obj->oop_iterate_header(blk, mr); | |
159 return size; | |
160 } | |
161 | |
162 | |
163 int klassKlass::oop_adjust_pointers(oop obj) { | |
164 // Get size before changing pointers | |
165 int size = oop_size(obj); | |
166 obj->adjust_header(); | |
167 | |
168 Klass* k = Klass::cast(klassOop(obj)); | |
169 | |
170 MarkSweep::adjust_pointer(k->adr_super()); | |
171 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
172 MarkSweep::adjust_pointer(k->adr_primary_supers()+i); | |
173 MarkSweep::adjust_pointer(k->adr_secondary_super_cache()); | |
174 MarkSweep::adjust_pointer(k->adr_secondary_supers()); | |
175 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
|
176 MarkSweep::adjust_pointer(k->adr_c1x_mirror()); |
0 | 177 MarkSweep::adjust_pointer(k->adr_subklass()); |
178 MarkSweep::adjust_pointer(k->adr_next_sibling()); | |
179 return size; | |
180 } | |
181 | |
182 #ifndef SERIALGC | |
183 void klassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
184 } | |
185 | |
186 int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
187 Klass* k = Klass::cast(klassOop(obj)); | |
188 | |
189 oop* const beg_oop = k->oop_block_beg(); | |
190 oop* const end_oop = k->oop_block_end(); | |
191 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
192 PSParallelCompact::adjust_pointer(cur_oop); | |
193 } | |
194 | |
195 return oop_size(obj); | |
196 } | |
197 #endif // SERIALGC | |
198 | |
199 | |
200 // Printing | |
201 | |
202 void klassKlass::oop_print_on(oop obj, outputStream* st) { | |
203 Klass::oop_print_on(obj, st); | |
204 } | |
205 | |
206 void klassKlass::oop_print_value_on(oop obj, outputStream* st) { | |
207 Klass::oop_print_value_on(obj, st); | |
208 } | |
209 | |
210 const char* klassKlass::internal_name() const { | |
211 return "{other class}"; | |
212 } | |
213 | |
214 | |
215 // Verification | |
216 | |
217 void klassKlass::oop_verify_on(oop obj, outputStream* st) { | |
218 Klass::oop_verify_on(obj, st); | |
219 guarantee(obj->is_perm(), "should be in permspace"); | |
220 guarantee(obj->is_klass(), "should be klass"); | |
221 | |
222 Klass* k = Klass::cast(klassOop(obj)); | |
223 if (k->super() != NULL) { | |
224 guarantee(k->super()->is_perm(), "should be in permspace"); | |
225 guarantee(k->super()->is_klass(), "should be klass"); | |
226 } | |
227 klassOop ko = k->secondary_super_cache(); | |
228 if( ko != NULL ) { | |
229 guarantee(ko->is_perm(), "should be in permspace"); | |
230 guarantee(ko->is_klass(), "should be klass"); | |
231 } | |
232 for( uint i = 0; i < primary_super_limit(); i++ ) { | |
233 oop ko = k->adr_primary_supers()[i]; // Cannot use normal accessor because it asserts | |
234 if( ko != NULL ) { | |
235 guarantee(ko->is_perm(), "should be in permspace"); | |
236 guarantee(ko->is_klass(), "should be klass"); | |
237 } | |
238 } | |
239 | |
240 if (k->java_mirror() != NULL || (k->oop_is_instance() && instanceKlass::cast(klassOop(obj))->is_loaded())) { | |
241 guarantee(k->java_mirror() != NULL, "should be allocated"); | |
242 guarantee(k->java_mirror()->is_perm(), "should be in permspace"); | |
243 guarantee(k->java_mirror()->is_instance(), "should be instance"); | |
244 } | |
245 } |