Mercurial > hg > truffle
annotate src/share/vm/oops/klassKlass.cpp @ 4597:8bc6f680a88d
fixed visual studio project files
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Tue, 14 Feb 2012 15:01:36 -0800 |
parents | 75a99b4f1c98 |
children | 18a5539bf19b |
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 | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
44 #include "gc_implementation/parNew/parOopClosures.inline.hpp" |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
45 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
46 #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
47 #include "memory/cardTableRS.hpp" |
1972 | 48 #include "oops/oop.pcgc.inline.hpp" |
49 #endif | |
0 | 50 |
51 int klassKlass::oop_size(oop obj) const { | |
52 assert (obj->is_klass(), "must be a klassOop"); | |
53 return klassOop(obj)->klass_part()->klass_oop_size(); | |
54 } | |
55 | |
56 klassOop klassKlass::create_klass(TRAPS) { | |
57 KlassHandle h_this_klass; | |
58 klassKlass o; | |
59 // for bootstrapping, handles may not be available yet. | |
60 klassOop k = base_create_klass_oop(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL); | |
61 k->set_klass(k); // point to thyself | |
62 // Do not try to allocate mirror, java.lang.Class not loaded at this point. | |
63 // See Universe::fixup_mirrors() | |
64 return k; | |
65 } | |
66 | |
67 void klassKlass::oop_follow_contents(oop obj) { | |
68 Klass* k = Klass::cast(klassOop(obj)); | |
69 // If we are alive it is valid to keep our superclass and subtype caches alive | |
70 MarkSweep::mark_and_push(k->adr_super()); | |
71 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
72 MarkSweep::mark_and_push(k->adr_primary_supers()+i); | |
73 MarkSweep::mark_and_push(k->adr_secondary_super_cache()); | |
74 MarkSweep::mark_and_push(k->adr_secondary_supers()); | |
75 MarkSweep::mark_and_push(k->adr_java_mirror()); | |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2491
diff
changeset
|
76 MarkSweep::mark_and_push(k->adr_graal_mirror()); |
0 | 77 // We follow the subklass and sibling links at the end of the |
78 // marking phase, since otherwise following them will prevent | |
79 // class unloading (all classes are transitively linked from | |
80 // java.lang.Object). | |
81 MarkSweep::revisit_weak_klass_link(k); | |
82 obj->follow_header(); | |
83 } | |
84 | |
85 #ifndef SERIALGC | |
86 void klassKlass::oop_follow_contents(ParCompactionManager* cm, | |
87 oop obj) { | |
88 Klass* k = Klass::cast(klassOop(obj)); | |
89 // If we are alive it is valid to keep our superclass and subtype caches alive | |
90 PSParallelCompact::mark_and_push(cm, k->adr_super()); | |
91 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
92 PSParallelCompact::mark_and_push(cm, k->adr_primary_supers()+i); | |
93 PSParallelCompact::mark_and_push(cm, k->adr_secondary_super_cache()); | |
94 PSParallelCompact::mark_and_push(cm, k->adr_secondary_supers()); | |
95 PSParallelCompact::mark_and_push(cm, k->adr_java_mirror()); | |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2491
diff
changeset
|
96 PSParallelCompact::mark_and_push(cm, k->adr_graal_mirror()); |
0 | 97 // We follow the subklass and sibling links at the end of the |
98 // marking phase, since otherwise following them will prevent | |
99 // class unloading (all classes are transitively linked from | |
100 // java.lang.Object). | |
101 PSParallelCompact::revisit_weak_klass_link(cm, k); | |
102 obj->follow_header(cm); | |
103 } | |
104 #endif // SERIALGC | |
105 | |
106 int klassKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
107 // Get size before changing pointers | |
108 int size = oop_size(obj); | |
109 Klass* k = Klass::cast(klassOop(obj)); | |
110 blk->do_oop(k->adr_super()); | |
111 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
112 blk->do_oop(k->adr_primary_supers()+i); | |
113 blk->do_oop(k->adr_secondary_super_cache()); | |
114 blk->do_oop(k->adr_secondary_supers()); | |
115 blk->do_oop(k->adr_java_mirror()); | |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2491
diff
changeset
|
116 blk->do_oop(k->adr_graal_mirror()); |
0 | 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); | |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2491
diff
changeset
|
150 adr = k->adr_graal_mirror(); |
1941
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 // The following are "weak links" in the perm gen and are |
153 // treated specially in a later phase of a perm gen collection. | |
154 assert(oop(k)->is_perm(), "should be in perm"); | |
155 assert(oop(k->adr_subklass())->is_perm(), "should be in perm"); | |
156 assert(oop(k->adr_next_sibling())->is_perm(), "should be in perm"); | |
157 if (blk->should_remember_klasses() | |
158 && (mr.contains(k->adr_subklass()) | |
159 || mr.contains(k->adr_next_sibling()))) { | |
160 blk->remember_klass(k); | |
161 } | |
162 obj->oop_iterate_header(blk, mr); | |
163 return size; | |
164 } | |
165 | |
166 | |
167 int klassKlass::oop_adjust_pointers(oop obj) { | |
168 // Get size before changing pointers | |
169 int size = oop_size(obj); | |
170 obj->adjust_header(); | |
171 | |
172 Klass* k = Klass::cast(klassOop(obj)); | |
173 | |
174 MarkSweep::adjust_pointer(k->adr_super()); | |
175 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
176 MarkSweep::adjust_pointer(k->adr_primary_supers()+i); | |
177 MarkSweep::adjust_pointer(k->adr_secondary_super_cache()); | |
178 MarkSweep::adjust_pointer(k->adr_secondary_supers()); | |
179 MarkSweep::adjust_pointer(k->adr_java_mirror()); | |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2491
diff
changeset
|
180 MarkSweep::adjust_pointer(k->adr_graal_mirror()); |
0 | 181 MarkSweep::adjust_pointer(k->adr_subklass()); |
182 MarkSweep::adjust_pointer(k->adr_next_sibling()); | |
183 return size; | |
184 } | |
185 | |
186 #ifndef SERIALGC | |
187 void klassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
188 Klass* k = Klass::cast(klassOop(obj)); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
189 |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
190 oop* p = k->adr_java_mirror(); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
191 if (PSScavenge::should_scavenge(p)) { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
192 pm->claim_or_forward_depth(p); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
193 } |
0 | 194 } |
195 | |
196 int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
197 Klass* k = Klass::cast(klassOop(obj)); | |
198 | |
199 oop* const beg_oop = k->oop_block_beg(); | |
200 oop* const end_oop = k->oop_block_end(); | |
201 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
202 PSParallelCompact::adjust_pointer(cur_oop); | |
203 } | |
204 | |
205 return oop_size(obj); | |
206 } | |
207 #endif // SERIALGC | |
208 | |
209 | |
210 // Printing | |
211 | |
212 void klassKlass::oop_print_on(oop obj, outputStream* st) { | |
213 Klass::oop_print_on(obj, st); | |
214 } | |
215 | |
216 void klassKlass::oop_print_value_on(oop obj, outputStream* st) { | |
217 Klass::oop_print_value_on(obj, st); | |
218 } | |
219 | |
220 const char* klassKlass::internal_name() const { | |
221 return "{other class}"; | |
222 } | |
223 | |
224 | |
225 // Verification | |
226 | |
227 void klassKlass::oop_verify_on(oop obj, outputStream* st) { | |
228 Klass::oop_verify_on(obj, st); | |
229 guarantee(obj->is_perm(), "should be in permspace"); | |
230 guarantee(obj->is_klass(), "should be klass"); | |
231 | |
232 Klass* k = Klass::cast(klassOop(obj)); | |
233 if (k->super() != NULL) { | |
234 guarantee(k->super()->is_perm(), "should be in permspace"); | |
235 guarantee(k->super()->is_klass(), "should be klass"); | |
236 } | |
237 klassOop ko = k->secondary_super_cache(); | |
238 if( ko != NULL ) { | |
239 guarantee(ko->is_perm(), "should be in permspace"); | |
240 guarantee(ko->is_klass(), "should be klass"); | |
241 } | |
242 for( uint i = 0; i < primary_super_limit(); i++ ) { | |
243 oop ko = k->adr_primary_supers()[i]; // Cannot use normal accessor because it asserts | |
244 if( ko != NULL ) { | |
245 guarantee(ko->is_perm(), "should be in permspace"); | |
246 guarantee(ko->is_klass(), "should be klass"); | |
247 } | |
248 } | |
249 | |
250 if (k->java_mirror() != NULL || (k->oop_is_instance() && instanceKlass::cast(klassOop(obj))->is_loaded())) { | |
251 guarantee(k->java_mirror() != NULL, "should be allocated"); | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2227
diff
changeset
|
252 guarantee(k->java_mirror()->is_perm() || !JavaObjectsInPerm, "should be in permspace"); |
0 | 253 guarantee(k->java_mirror()->is_instance(), "should be instance"); |
254 } | |
255 } |