Mercurial > hg > truffle
annotate src/share/vm/oops/klassKlass.cpp @ 2066:02895c6a2f82
7007769: VM crashes with SIGBUS writing PerfData if tmp space is full
Summary: Fill perfdata file with zeros to verify available disk space
Reviewed-by: coleenp, kamg
author | bobv |
---|---|
date | Mon, 20 Dec 2010 14:30:24 -0500 |
parents | f95d63e2154a |
children | 06f017f7daa7 3582bf76420e |
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()); | |
73 MarkSweep::mark_and_push(k->adr_name()); | |
74 // We follow the subklass and sibling links at the end of the | |
75 // marking phase, since otherwise following them will prevent | |
76 // class unloading (all classes are transitively linked from | |
77 // java.lang.Object). | |
78 MarkSweep::revisit_weak_klass_link(k); | |
79 obj->follow_header(); | |
80 } | |
81 | |
82 #ifndef SERIALGC | |
83 void klassKlass::oop_follow_contents(ParCompactionManager* cm, | |
84 oop obj) { | |
85 Klass* k = Klass::cast(klassOop(obj)); | |
86 // If we are alive it is valid to keep our superclass and subtype caches alive | |
87 PSParallelCompact::mark_and_push(cm, k->adr_super()); | |
88 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
89 PSParallelCompact::mark_and_push(cm, k->adr_primary_supers()+i); | |
90 PSParallelCompact::mark_and_push(cm, k->adr_secondary_super_cache()); | |
91 PSParallelCompact::mark_and_push(cm, k->adr_secondary_supers()); | |
92 PSParallelCompact::mark_and_push(cm, k->adr_java_mirror()); | |
93 PSParallelCompact::mark_and_push(cm, k->adr_name()); | |
94 // We follow the subklass and sibling links at the end of the | |
95 // marking phase, since otherwise following them will prevent | |
96 // class unloading (all classes are transitively linked from | |
97 // java.lang.Object). | |
98 PSParallelCompact::revisit_weak_klass_link(cm, k); | |
99 obj->follow_header(cm); | |
100 } | |
101 #endif // SERIALGC | |
102 | |
103 int klassKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
104 // Get size before changing pointers | |
105 int size = oop_size(obj); | |
106 Klass* k = Klass::cast(klassOop(obj)); | |
107 blk->do_oop(k->adr_super()); | |
108 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
109 blk->do_oop(k->adr_primary_supers()+i); | |
110 blk->do_oop(k->adr_secondary_super_cache()); | |
111 blk->do_oop(k->adr_secondary_supers()); | |
112 blk->do_oop(k->adr_java_mirror()); | |
113 blk->do_oop(k->adr_name()); | |
114 // The following are in the perm gen and are treated | |
115 // specially in a later phase of a perm gen collection; ... | |
116 assert(oop(k)->is_perm(), "should be in perm"); | |
117 assert(oop(k->subklass())->is_perm_or_null(), "should be in perm"); | |
118 assert(oop(k->next_sibling())->is_perm_or_null(), "should be in perm"); | |
119 // ... don't scan them normally, but remember this klassKlass | |
120 // for later (see, for instance, oop_follow_contents above | |
121 // for what MarkSweep does with it. | |
122 if (blk->should_remember_klasses()) { | |
123 blk->remember_klass(k); | |
124 } | |
125 obj->oop_iterate_header(blk); | |
126 return size; | |
127 } | |
128 | |
129 | |
130 int klassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { | |
131 // Get size before changing pointers | |
132 int size = oop_size(obj); | |
133 Klass* k = Klass::cast(klassOop(obj)); | |
134 oop* adr; | |
135 adr = k->adr_super(); | |
136 if (mr.contains(adr)) blk->do_oop(adr); | |
137 for (juint i = 0; i < Klass::primary_super_limit(); i++) { | |
138 adr = k->adr_primary_supers()+i; | |
139 if (mr.contains(adr)) blk->do_oop(adr); | |
140 } | |
141 adr = k->adr_secondary_super_cache(); | |
142 if (mr.contains(adr)) blk->do_oop(adr); | |
143 adr = k->adr_secondary_supers(); | |
144 if (mr.contains(adr)) blk->do_oop(adr); | |
145 adr = k->adr_java_mirror(); | |
146 if (mr.contains(adr)) blk->do_oop(adr); | |
147 adr = k->adr_name(); | |
148 if (mr.contains(adr)) blk->do_oop(adr); | |
149 // The following are "weak links" in the perm gen and are | |
150 // treated specially in a later phase of a perm gen collection. | |
151 assert(oop(k)->is_perm(), "should be in perm"); | |
152 assert(oop(k->adr_subklass())->is_perm(), "should be in perm"); | |
153 assert(oop(k->adr_next_sibling())->is_perm(), "should be in perm"); | |
154 if (blk->should_remember_klasses() | |
155 && (mr.contains(k->adr_subklass()) | |
156 || mr.contains(k->adr_next_sibling()))) { | |
157 blk->remember_klass(k); | |
158 } | |
159 obj->oop_iterate_header(blk, mr); | |
160 return size; | |
161 } | |
162 | |
163 | |
164 int klassKlass::oop_adjust_pointers(oop obj) { | |
165 // Get size before changing pointers | |
166 int size = oop_size(obj); | |
167 obj->adjust_header(); | |
168 | |
169 Klass* k = Klass::cast(klassOop(obj)); | |
170 | |
171 MarkSweep::adjust_pointer(k->adr_super()); | |
172 for (juint i = 0; i < Klass::primary_super_limit(); i++) | |
173 MarkSweep::adjust_pointer(k->adr_primary_supers()+i); | |
174 MarkSweep::adjust_pointer(k->adr_secondary_super_cache()); | |
175 MarkSweep::adjust_pointer(k->adr_secondary_supers()); | |
176 MarkSweep::adjust_pointer(k->adr_java_mirror()); | |
177 MarkSweep::adjust_pointer(k->adr_name()); | |
178 MarkSweep::adjust_pointer(k->adr_subklass()); | |
179 MarkSweep::adjust_pointer(k->adr_next_sibling()); | |
180 return size; | |
181 } | |
182 | |
183 #ifndef SERIALGC | |
184 void klassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
185 } | |
186 | |
187 int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
188 Klass* k = Klass::cast(klassOop(obj)); | |
189 | |
190 oop* const beg_oop = k->oop_block_beg(); | |
191 oop* const end_oop = k->oop_block_end(); | |
192 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
193 PSParallelCompact::adjust_pointer(cur_oop); | |
194 } | |
195 | |
196 return oop_size(obj); | |
197 } | |
198 | |
199 int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, | |
200 HeapWord* beg_addr, HeapWord* end_addr) { | |
201 Klass* k = Klass::cast(klassOop(obj)); | |
202 | |
203 oop* const beg_oop = MAX2((oop*)beg_addr, k->oop_block_beg()); | |
204 oop* const end_oop = MIN2((oop*)end_addr, k->oop_block_end()); | |
205 for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { | |
206 PSParallelCompact::adjust_pointer(cur_oop); | |
207 } | |
208 | |
209 return oop_size(obj); | |
210 } | |
211 #endif // SERIALGC | |
212 | |
213 | |
214 // Printing | |
215 | |
216 void klassKlass::oop_print_on(oop obj, outputStream* st) { | |
217 Klass::oop_print_on(obj, st); | |
218 } | |
219 | |
220 void klassKlass::oop_print_value_on(oop obj, outputStream* st) { | |
221 Klass::oop_print_value_on(obj, st); | |
222 } | |
223 | |
224 const char* klassKlass::internal_name() const { | |
225 return "{other class}"; | |
226 } | |
227 | |
228 | |
229 // Verification | |
230 | |
231 void klassKlass::oop_verify_on(oop obj, outputStream* st) { | |
232 Klass::oop_verify_on(obj, st); | |
233 guarantee(obj->is_perm(), "should be in permspace"); | |
234 guarantee(obj->is_klass(), "should be klass"); | |
235 | |
236 Klass* k = Klass::cast(klassOop(obj)); | |
237 if (k->super() != NULL) { | |
238 guarantee(k->super()->is_perm(), "should be in permspace"); | |
239 guarantee(k->super()->is_klass(), "should be klass"); | |
240 } | |
241 klassOop ko = k->secondary_super_cache(); | |
242 if( ko != NULL ) { | |
243 guarantee(ko->is_perm(), "should be in permspace"); | |
244 guarantee(ko->is_klass(), "should be klass"); | |
245 } | |
246 for( uint i = 0; i < primary_super_limit(); i++ ) { | |
247 oop ko = k->adr_primary_supers()[i]; // Cannot use normal accessor because it asserts | |
248 if( ko != NULL ) { | |
249 guarantee(ko->is_perm(), "should be in permspace"); | |
250 guarantee(ko->is_klass(), "should be klass"); | |
251 } | |
252 } | |
253 | |
254 if (k->java_mirror() != NULL || (k->oop_is_instance() && instanceKlass::cast(klassOop(obj))->is_loaded())) { | |
255 guarantee(k->java_mirror() != NULL, "should be allocated"); | |
256 guarantee(k->java_mirror()->is_perm(), "should be in permspace"); | |
257 guarantee(k->java_mirror()->is_instance(), "should be instance"); | |
258 } | |
259 if (k->name() != NULL) { | |
260 guarantee(Universe::heap()->is_in_permanent(k->name()), | |
261 "should be in permspace"); | |
262 guarantee(k->name()->is_symbol(), "should be symbol"); | |
263 } | |
264 } |