Mercurial > hg > graal-jvmci-8
annotate src/share/vm/oops/klassKlass.cpp @ 2357:8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
Summary: package and class renaming only; delete unused methods and classes
Reviewed-by: twisti
author | jrose |
---|---|
date | Fri, 11 Mar 2011 22:34:57 -0800 |
parents | e5383553fd4e |
children | 2ab52cda08e5 c7f3d0b4570f |
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()); | |
72 // We follow the subklass and sibling links at the end of the | |
73 // marking phase, since otherwise following them will prevent | |
74 // class unloading (all classes are transitively linked from | |
75 // java.lang.Object). | |
76 MarkSweep::revisit_weak_klass_link(k); | |
77 obj->follow_header(); | |
78 } | |
79 | |
80 #ifndef SERIALGC | |
81 void klassKlass::oop_follow_contents(ParCompactionManager* cm, | |
82 oop obj) { | |
83 Klass* k = Klass::cast(klassOop(obj)); | |
84 // If we are alive it is valid to keep our superclass and subtype caches alive | |
85 PSParallelCompact::mark_and_push(cm, k->adr_super()); | |
86 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
87 PSParallelCompact::mark_and_push(cm, k->adr_primary_supers()+i); | |
88 PSParallelCompact::mark_and_push(cm, k->adr_secondary_super_cache()); | |
89 PSParallelCompact::mark_and_push(cm, k->adr_secondary_supers()); | |
90 PSParallelCompact::mark_and_push(cm, k->adr_java_mirror()); | |
91 // We follow the subklass and sibling links at the end of the | |
92 // marking phase, since otherwise following them will prevent | |
93 // class unloading (all classes are transitively linked from | |
94 // java.lang.Object). | |
95 PSParallelCompact::revisit_weak_klass_link(cm, k); | |
96 obj->follow_header(cm); | |
97 } | |
98 #endif // SERIALGC | |
99 | |
100 int klassKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
101 // Get size before changing pointers | |
102 int size = oop_size(obj); | |
103 Klass* k = Klass::cast(klassOop(obj)); | |
104 blk->do_oop(k->adr_super()); | |
105 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
106 blk->do_oop(k->adr_primary_supers()+i); | |
107 blk->do_oop(k->adr_secondary_super_cache()); | |
108 blk->do_oop(k->adr_secondary_supers()); | |
109 blk->do_oop(k->adr_java_mirror()); | |
110 // The following are in the perm gen and are treated | |
111 // specially in a later phase of a perm gen collection; ... | |
112 assert(oop(k)->is_perm(), "should be in perm"); | |
113 assert(oop(k->subklass())->is_perm_or_null(), "should be in perm"); | |
114 assert(oop(k->next_sibling())->is_perm_or_null(), "should be in perm"); | |
115 // ... don't scan them normally, but remember this klassKlass | |
116 // for later (see, for instance, oop_follow_contents above | |
117 // for what MarkSweep does with it. | |
118 if (blk->should_remember_klasses()) { | |
119 blk->remember_klass(k); | |
120 } | |
121 obj->oop_iterate_header(blk); | |
122 return size; | |
123 } | |
124 | |
125 | |
126 int klassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { | |
127 // Get size before changing pointers | |
128 int size = oop_size(obj); | |
129 Klass* k = Klass::cast(klassOop(obj)); | |
130 oop* adr; | |
131 adr = k->adr_super(); | |
132 if (mr.contains(adr)) blk->do_oop(adr); | |
133 for (juint i = 0; i < Klass::primary_super_limit(); i++) { | |
134 adr = k->adr_primary_supers()+i; | |
135 if (mr.contains(adr)) blk->do_oop(adr); | |
136 } | |
137 adr = k->adr_secondary_super_cache(); | |
138 if (mr.contains(adr)) blk->do_oop(adr); | |
139 adr = k->adr_secondary_supers(); | |
140 if (mr.contains(adr)) blk->do_oop(adr); | |
141 adr = k->adr_java_mirror(); | |
142 if (mr.contains(adr)) blk->do_oop(adr); | |
143 // The following are "weak links" in the perm gen and are | |
144 // treated specially in a later phase of a perm gen collection. | |
145 assert(oop(k)->is_perm(), "should be in perm"); | |
146 assert(oop(k->adr_subklass())->is_perm(), "should be in perm"); | |
147 assert(oop(k->adr_next_sibling())->is_perm(), "should be in perm"); | |
148 if (blk->should_remember_klasses() | |
149 && (mr.contains(k->adr_subklass()) | |
150 || mr.contains(k->adr_next_sibling()))) { | |
151 blk->remember_klass(k); | |
152 } | |
153 obj->oop_iterate_header(blk, mr); | |
154 return size; | |
155 } | |
156 | |
157 | |
158 int klassKlass::oop_adjust_pointers(oop obj) { | |
159 // Get size before changing pointers | |
160 int size = oop_size(obj); | |
161 obj->adjust_header(); | |
162 | |
163 Klass* k = Klass::cast(klassOop(obj)); | |
164 | |
165 MarkSweep::adjust_pointer(k->adr_super()); | |
166 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
167 MarkSweep::adjust_pointer(k->adr_primary_supers()+i); | |
168 MarkSweep::adjust_pointer(k->adr_secondary_super_cache()); | |
169 MarkSweep::adjust_pointer(k->adr_secondary_supers()); | |
170 MarkSweep::adjust_pointer(k->adr_java_mirror()); | |
171 MarkSweep::adjust_pointer(k->adr_subklass()); | |
172 MarkSweep::adjust_pointer(k->adr_next_sibling()); | |
173 return size; | |
174 } | |
175 | |
176 #ifndef SERIALGC | |
177 void klassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
178 } | |
179 | |
180 int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
181 Klass* k = Klass::cast(klassOop(obj)); | |
182 | |
183 oop* const beg_oop = k->oop_block_beg(); | |
184 oop* const end_oop = k->oop_block_end(); | |
185 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
186 PSParallelCompact::adjust_pointer(cur_oop); | |
187 } | |
188 | |
189 return oop_size(obj); | |
190 } | |
191 #endif // SERIALGC | |
192 | |
193 | |
194 // Printing | |
195 | |
196 void klassKlass::oop_print_on(oop obj, outputStream* st) { | |
197 Klass::oop_print_on(obj, st); | |
198 } | |
199 | |
200 void klassKlass::oop_print_value_on(oop obj, outputStream* st) { | |
201 Klass::oop_print_value_on(obj, st); | |
202 } | |
203 | |
204 const char* klassKlass::internal_name() const { | |
205 return "{other class}"; | |
206 } | |
207 | |
208 | |
209 // Verification | |
210 | |
211 void klassKlass::oop_verify_on(oop obj, outputStream* st) { | |
212 Klass::oop_verify_on(obj, st); | |
213 guarantee(obj->is_perm(), "should be in permspace"); | |
214 guarantee(obj->is_klass(), "should be klass"); | |
215 | |
216 Klass* k = Klass::cast(klassOop(obj)); | |
217 if (k->super() != NULL) { | |
218 guarantee(k->super()->is_perm(), "should be in permspace"); | |
219 guarantee(k->super()->is_klass(), "should be klass"); | |
220 } | |
221 klassOop ko = k->secondary_super_cache(); | |
222 if( ko != NULL ) { | |
223 guarantee(ko->is_perm(), "should be in permspace"); | |
224 guarantee(ko->is_klass(), "should be klass"); | |
225 } | |
226 for( uint i = 0; i < primary_super_limit(); i++ ) { | |
227 oop ko = k->adr_primary_supers()[i]; // Cannot use normal accessor because it asserts | |
228 if( ko != NULL ) { | |
229 guarantee(ko->is_perm(), "should be in permspace"); | |
230 guarantee(ko->is_klass(), "should be klass"); | |
231 } | |
232 } | |
233 | |
234 if (k->java_mirror() != NULL || (k->oop_is_instance() && instanceKlass::cast(klassOop(obj))->is_loaded())) { | |
235 guarantee(k->java_mirror() != NULL, "should be allocated"); | |
236 guarantee(k->java_mirror()->is_perm(), "should be in permspace"); | |
237 guarantee(k->java_mirror()->is_instance(), "should be instance"); | |
238 } | |
239 } |