Mercurial > hg > truffle
annotate src/share/vm/oops/klassKlass.cpp @ 1941:79d04223b8a5
Added caching for resolved types and resolved fields.
This is crucial, because the local load elimination will lead to wrong results, if field equality (of two RiField objects with the same object and the same RiType) is not given. The caching makes sure that the default equals implementation is sufficient.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 28 Dec 2010 18:33:26 +0100 |
parents | 7fcd5f39bd7a |
children | 06f017f7daa7 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1155
diff
changeset
|
2 * Copyright (c) 1997, 2006, 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 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_klassKlass.cpp.incl" | |
27 | |
28 int klassKlass::oop_size(oop obj) const { | |
29 assert (obj->is_klass(), "must be a klassOop"); | |
30 return klassOop(obj)->klass_part()->klass_oop_size(); | |
31 } | |
32 | |
33 klassOop klassKlass::create_klass(TRAPS) { | |
34 KlassHandle h_this_klass; | |
35 klassKlass o; | |
36 // for bootstrapping, handles may not be available yet. | |
37 klassOop k = base_create_klass_oop(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL); | |
38 k->set_klass(k); // point to thyself | |
39 // Do not try to allocate mirror, java.lang.Class not loaded at this point. | |
40 // See Universe::fixup_mirrors() | |
41 return k; | |
42 } | |
43 | |
44 void klassKlass::oop_follow_contents(oop obj) { | |
45 Klass* k = Klass::cast(klassOop(obj)); | |
46 // If we are alive it is valid to keep our superclass and subtype caches alive | |
47 MarkSweep::mark_and_push(k->adr_super()); | |
48 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
49 MarkSweep::mark_and_push(k->adr_primary_supers()+i); | |
50 MarkSweep::mark_and_push(k->adr_secondary_super_cache()); | |
51 MarkSweep::mark_and_push(k->adr_secondary_supers()); | |
52 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
|
53 MarkSweep::mark_and_push(k->adr_c1x_mirror()); |
0 | 54 MarkSweep::mark_and_push(k->adr_name()); |
55 // We follow the subklass and sibling links at the end of the | |
56 // marking phase, since otherwise following them will prevent | |
57 // class unloading (all classes are transitively linked from | |
58 // java.lang.Object). | |
59 MarkSweep::revisit_weak_klass_link(k); | |
60 obj->follow_header(); | |
61 } | |
62 | |
63 #ifndef SERIALGC | |
64 void klassKlass::oop_follow_contents(ParCompactionManager* cm, | |
65 oop obj) { | |
66 Klass* k = Klass::cast(klassOop(obj)); | |
67 // If we are alive it is valid to keep our superclass and subtype caches alive | |
68 PSParallelCompact::mark_and_push(cm, k->adr_super()); | |
69 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
70 PSParallelCompact::mark_and_push(cm, k->adr_primary_supers()+i); | |
71 PSParallelCompact::mark_and_push(cm, k->adr_secondary_super_cache()); | |
72 PSParallelCompact::mark_and_push(cm, k->adr_secondary_supers()); | |
73 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
|
74 PSParallelCompact::mark_and_push(cm, k->adr_c1x_mirror()); |
0 | 75 PSParallelCompact::mark_and_push(cm, k->adr_name()); |
76 // We follow the subklass and sibling links at the end of the | |
77 // marking phase, since otherwise following them will prevent | |
78 // class unloading (all classes are transitively linked from | |
79 // java.lang.Object). | |
80 PSParallelCompact::revisit_weak_klass_link(cm, k); | |
81 obj->follow_header(cm); | |
82 } | |
83 #endif // SERIALGC | |
84 | |
85 int klassKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
86 // Get size before changing pointers | |
87 int size = oop_size(obj); | |
88 Klass* k = Klass::cast(klassOop(obj)); | |
89 blk->do_oop(k->adr_super()); | |
90 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
91 blk->do_oop(k->adr_primary_supers()+i); | |
92 blk->do_oop(k->adr_secondary_super_cache()); | |
93 blk->do_oop(k->adr_secondary_supers()); | |
94 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
|
95 blk->do_oop(k->adr_c1x_mirror()); |
0 | 96 blk->do_oop(k->adr_name()); |
97 // The following are in the perm gen and are treated | |
98 // specially in a later phase of a perm gen collection; ... | |
99 assert(oop(k)->is_perm(), "should be in perm"); | |
100 assert(oop(k->subklass())->is_perm_or_null(), "should be in perm"); | |
101 assert(oop(k->next_sibling())->is_perm_or_null(), "should be in perm"); | |
102 // ... don't scan them normally, but remember this klassKlass | |
103 // for later (see, for instance, oop_follow_contents above | |
104 // for what MarkSweep does with it. | |
105 if (blk->should_remember_klasses()) { | |
106 blk->remember_klass(k); | |
107 } | |
108 obj->oop_iterate_header(blk); | |
109 return size; | |
110 } | |
111 | |
112 | |
113 int klassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { | |
114 // Get size before changing pointers | |
115 int size = oop_size(obj); | |
116 Klass* k = Klass::cast(klassOop(obj)); | |
117 oop* adr; | |
118 adr = k->adr_super(); | |
119 if (mr.contains(adr)) blk->do_oop(adr); | |
120 for (juint i = 0; i < Klass::primary_super_limit(); i++) { | |
121 adr = k->adr_primary_supers()+i; | |
122 if (mr.contains(adr)) blk->do_oop(adr); | |
123 } | |
124 adr = k->adr_secondary_super_cache(); | |
125 if (mr.contains(adr)) blk->do_oop(adr); | |
126 adr = k->adr_secondary_supers(); | |
127 if (mr.contains(adr)) blk->do_oop(adr); | |
128 adr = k->adr_java_mirror(); | |
129 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
|
130 adr = k->adr_c1x_mirror(); |
79d04223b8a5
Added caching for resolved types and resolved fields.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1713
diff
changeset
|
131 if (mr.contains(adr)) blk->do_oop(adr); |
0 | 132 adr = k->adr_name(); |
133 if (mr.contains(adr)) blk->do_oop(adr); | |
134 // The following are "weak links" in the perm gen and are | |
135 // treated specially in a later phase of a perm gen collection. | |
136 assert(oop(k)->is_perm(), "should be in perm"); | |
137 assert(oop(k->adr_subklass())->is_perm(), "should be in perm"); | |
138 assert(oop(k->adr_next_sibling())->is_perm(), "should be in perm"); | |
139 if (blk->should_remember_klasses() | |
140 && (mr.contains(k->adr_subklass()) | |
141 || mr.contains(k->adr_next_sibling()))) { | |
142 blk->remember_klass(k); | |
143 } | |
144 obj->oop_iterate_header(blk, mr); | |
145 return size; | |
146 } | |
147 | |
148 | |
149 int klassKlass::oop_adjust_pointers(oop obj) { | |
150 // Get size before changing pointers | |
151 int size = oop_size(obj); | |
152 obj->adjust_header(); | |
153 | |
154 Klass* k = Klass::cast(klassOop(obj)); | |
155 | |
156 MarkSweep::adjust_pointer(k->adr_super()); | |
157 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
158 MarkSweep::adjust_pointer(k->adr_primary_supers()+i); | |
159 MarkSweep::adjust_pointer(k->adr_secondary_super_cache()); | |
160 MarkSweep::adjust_pointer(k->adr_secondary_supers()); | |
161 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
|
162 MarkSweep::adjust_pointer(k->adr_c1x_mirror()); |
0 | 163 MarkSweep::adjust_pointer(k->adr_name()); |
164 MarkSweep::adjust_pointer(k->adr_subklass()); | |
165 MarkSweep::adjust_pointer(k->adr_next_sibling()); | |
166 return size; | |
167 } | |
168 | |
169 #ifndef SERIALGC | |
170 void klassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
171 } | |
172 | |
173 int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
174 Klass* k = Klass::cast(klassOop(obj)); | |
175 | |
176 oop* const beg_oop = k->oop_block_beg(); | |
177 oop* const end_oop = k->oop_block_end(); | |
178 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
179 PSParallelCompact::adjust_pointer(cur_oop); | |
180 } | |
181 | |
182 return oop_size(obj); | |
183 } | |
184 | |
185 int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, | |
186 HeapWord* beg_addr, HeapWord* end_addr) { | |
187 Klass* k = Klass::cast(klassOop(obj)); | |
188 | |
189 oop* const beg_oop = MAX2((oop*)beg_addr, k->oop_block_beg()); | |
190 oop* const end_oop = MIN2((oop*)end_addr, 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 if (k->name() != NULL) { | |
246 guarantee(Universe::heap()->is_in_permanent(k->name()), | |
247 "should be in permspace"); | |
248 guarantee(k->name()->is_symbol(), "should be symbol"); | |
249 } | |
250 } |