Mercurial > hg > truffle
annotate src/share/vm/oops/objArrayKlassKlass.cpp @ 2019:09b4dd4f152b
7004582: Add GetThisObject() function to JVMTI 1.2
Summary: Add 'GetThisObject' function
Reviewed-by: never, coleenp
author | kamg |
---|---|
date | Thu, 09 Dec 2010 15:04:26 -0500 |
parents | f95d63e2154a |
children | 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 "classfile/javaClasses.hpp" | |
27 #include "classfile/systemDictionary.hpp" | |
28 #include "gc_implementation/shared/markSweep.inline.hpp" | |
29 #include "gc_interface/collectedHeap.inline.hpp" | |
30 #include "oops/instanceKlass.hpp" | |
31 #include "oops/objArrayKlassKlass.hpp" | |
32 #include "oops/oop.inline.hpp" | |
33 #include "oops/oop.inline2.hpp" | |
0 | 34 |
35 klassOop objArrayKlassKlass::create_klass(TRAPS) { | |
36 objArrayKlassKlass o; | |
37 KlassHandle h_this_klass(THREAD, Universe::klassKlassObj()); | |
38 KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_0); | |
39 assert(k()->size() == align_object_size(header_size()), "wrong size for object"); | |
40 java_lang_Class::create_mirror(k, CHECK_0); // Allocate mirror | |
41 return k(); | |
42 } | |
43 | |
44 klassOop objArrayKlassKlass::allocate_system_objArray_klass(TRAPS) { | |
45 // system_objArrays have no instance klass, so allocate with fake class, then reset to NULL | |
46 KlassHandle kk(THREAD, Universe::intArrayKlassObj()); | |
47 klassOop k = allocate_objArray_klass(1, kk, CHECK_0); | |
48 objArrayKlass* tk = (objArrayKlass*) k->klass_part(); | |
49 tk->set_element_klass(NULL); | |
50 tk->set_bottom_klass(NULL); | |
51 return k; | |
52 } | |
53 | |
54 | |
55 klassOop objArrayKlassKlass::allocate_objArray_klass(int n, KlassHandle element_klass, TRAPS) { | |
56 objArrayKlassKlassHandle this_oop(THREAD, as_klassOop()); | |
57 return allocate_objArray_klass_impl(this_oop, n, element_klass, THREAD); | |
58 } | |
59 | |
60 klassOop objArrayKlassKlass::allocate_objArray_klass_impl(objArrayKlassKlassHandle this_oop, | |
61 int n, KlassHandle element_klass, TRAPS) { | |
62 | |
63 // Eagerly allocate the direct array supertype. | |
64 KlassHandle super_klass = KlassHandle(); | |
65 if (!Universe::is_bootstrapping()) { | |
66 KlassHandle element_super (THREAD, element_klass->super()); | |
67 if (element_super.not_null()) { | |
68 // The element type has a direct super. E.g., String[] has direct super of Object[]. | |
69 super_klass = KlassHandle(THREAD, element_super->array_klass_or_null()); | |
70 bool supers_exist = super_klass.not_null(); | |
71 // Also, see if the element has secondary supertypes. | |
72 // We need an array type for each. | |
73 objArrayHandle element_supers = objArrayHandle(THREAD, | |
74 element_klass->secondary_supers()); | |
75 for( int i = element_supers->length()-1; i >= 0; i-- ) { | |
76 klassOop elem_super = (klassOop) element_supers->obj_at(i); | |
77 if (Klass::cast(elem_super)->array_klass_or_null() == NULL) { | |
78 supers_exist = false; | |
79 break; | |
80 } | |
81 } | |
82 if (!supers_exist) { | |
83 // Oops. Not allocated yet. Back out, allocate it, and retry. | |
84 #ifndef PRODUCT | |
85 if (WizardMode) { | |
86 tty->print_cr("Must retry array klass creation for depth %d",n); | |
87 } | |
88 #endif | |
89 KlassHandle ek; | |
90 { | |
91 MutexUnlocker mu(MultiArray_lock); | |
92 MutexUnlocker mc(Compile_lock); // for vtables | |
93 klassOop sk = element_super->array_klass(CHECK_0); | |
94 super_klass = KlassHandle(THREAD, sk); | |
95 for( int i = element_supers->length()-1; i >= 0; i-- ) { | |
96 KlassHandle elem_super (THREAD, element_supers->obj_at(i)); | |
97 elem_super->array_klass(CHECK_0); | |
98 } | |
99 // Now retry from the beginning | |
100 klassOop klass_oop = element_klass->array_klass(n, CHECK_0); | |
101 // Create a handle because the enclosing brace, when locking | |
102 // can cause a gc. Better to have this function return a Handle. | |
103 ek = KlassHandle(THREAD, klass_oop); | |
104 } // re-lock | |
105 return ek(); | |
106 } | |
107 } else { | |
108 // The element type is already Object. Object[] has direct super of Object. | |
1142 | 109 super_klass = KlassHandle(THREAD, SystemDictionary::Object_klass()); |
0 | 110 } |
111 } | |
112 | |
113 // Create type name for klass (except for symbol arrays, since symbolKlass | |
114 // does not have a name). This will potentially allocate an object, cause | |
115 // GC, and all other kinds of things. Hence, this must be done before we | |
116 // get a handle to the new objArrayKlass we want to construct. We cannot | |
117 // block while holding a handling to a partly initialized object. | |
118 symbolHandle name = symbolHandle(); | |
119 | |
120 if (!element_klass->oop_is_symbol()) { | |
121 ResourceMark rm(THREAD); | |
122 char *name_str = element_klass->name()->as_C_string(); | |
123 int len = element_klass->name()->utf8_length(); | |
124 char *new_str = NEW_RESOURCE_ARRAY(char, len + 4); | |
125 int idx = 0; | |
126 new_str[idx++] = '['; | |
127 if (element_klass->oop_is_instance()) { // it could be an array or simple type | |
128 new_str[idx++] = 'L'; | |
129 } | |
130 memcpy(&new_str[idx], name_str, len * sizeof(char)); | |
131 idx += len; | |
132 if (element_klass->oop_is_instance()) { | |
133 new_str[idx++] = ';'; | |
134 } | |
135 new_str[idx++] = '\0'; | |
136 name = oopFactory::new_symbol_handle(new_str, CHECK_0); | |
137 } | |
138 | |
139 objArrayKlass o; | |
140 arrayKlassHandle k = arrayKlass::base_create_array_klass(o.vtbl_value(), | |
141 objArrayKlass::header_size(), | |
142 this_oop, | |
143 CHECK_0); | |
144 | |
145 | |
146 // Initialize instance variables | |
147 objArrayKlass* oak = objArrayKlass::cast(k()); | |
148 oak->set_dimension(n); | |
149 oak->set_element_klass(element_klass()); | |
150 oak->set_name(name()); | |
151 | |
152 klassOop bk; | |
153 if (element_klass->oop_is_objArray()) { | |
154 bk = objArrayKlass::cast(element_klass())->bottom_klass(); | |
155 } else { | |
156 bk = element_klass(); | |
157 } | |
158 assert(bk != NULL && (Klass::cast(bk)->oop_is_instance() || Klass::cast(bk)->oop_is_typeArray()), "invalid bottom klass"); | |
159 oak->set_bottom_klass(bk); | |
160 | |
161 oak->set_layout_helper(array_layout_helper(T_OBJECT)); | |
162 assert(oak->oop_is_javaArray(), "sanity"); | |
163 assert(oak->oop_is_objArray(), "sanity"); | |
164 | |
165 // Call complete_create_array_klass after all instance variables has been initialized. | |
166 arrayKlass::complete_create_array_klass(k, super_klass, CHECK_0); | |
167 | |
168 return k(); | |
169 } | |
170 | |
171 | |
172 void objArrayKlassKlass::oop_follow_contents(oop obj) { | |
173 assert(obj->is_klass(), "must be klass"); | |
174 assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array"); | |
175 | |
176 objArrayKlass* oak = objArrayKlass::cast((klassOop)obj); | |
177 MarkSweep::mark_and_push(oak->element_klass_addr()); | |
178 MarkSweep::mark_and_push(oak->bottom_klass_addr()); | |
179 | |
180 arrayKlassKlass::oop_follow_contents(obj); | |
181 } | |
182 | |
183 #ifndef SERIALGC | |
184 void objArrayKlassKlass::oop_follow_contents(ParCompactionManager* cm, | |
185 oop obj) { | |
186 assert(obj->is_klass(), "must be klass"); | |
187 assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array"); | |
188 | |
189 objArrayKlass* oak = objArrayKlass::cast((klassOop)obj); | |
190 PSParallelCompact::mark_and_push(cm, oak->element_klass_addr()); | |
191 PSParallelCompact::mark_and_push(cm, oak->bottom_klass_addr()); | |
192 | |
193 arrayKlassKlass::oop_follow_contents(cm, obj); | |
194 } | |
195 #endif // SERIALGC | |
196 | |
197 | |
198 int objArrayKlassKlass::oop_adjust_pointers(oop obj) { | |
199 assert(obj->is_klass(), "must be klass"); | |
200 assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array"); | |
201 | |
202 objArrayKlass* oak = objArrayKlass::cast((klassOop)obj); | |
203 MarkSweep::adjust_pointer(oak->element_klass_addr()); | |
204 MarkSweep::adjust_pointer(oak->bottom_klass_addr()); | |
205 | |
206 return arrayKlassKlass::oop_adjust_pointers(obj); | |
207 } | |
208 | |
209 | |
210 | |
211 int objArrayKlassKlass::oop_oop_iterate(oop obj, OopClosure* blk) { | |
212 assert(obj->is_klass(), "must be klass"); | |
213 assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array"); | |
214 | |
215 objArrayKlass* oak = objArrayKlass::cast((klassOop)obj); | |
216 blk->do_oop(oak->element_klass_addr()); | |
217 blk->do_oop(oak->bottom_klass_addr()); | |
218 | |
219 return arrayKlassKlass::oop_oop_iterate(obj, blk); | |
220 } | |
221 | |
222 | |
223 int | |
224 objArrayKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { | |
225 assert(obj->is_klass(), "must be klass"); | |
226 assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array"); | |
227 | |
228 objArrayKlass* oak = objArrayKlass::cast((klassOop)obj); | |
229 oop* addr; | |
230 addr = oak->element_klass_addr(); | |
231 if (mr.contains(addr)) blk->do_oop(addr); | |
232 addr = oak->bottom_klass_addr(); | |
233 if (mr.contains(addr)) blk->do_oop(addr); | |
234 | |
235 return arrayKlassKlass::oop_oop_iterate(obj, blk); | |
236 } | |
237 | |
238 #ifndef SERIALGC | |
239 void objArrayKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { | |
240 assert(obj->blueprint()->oop_is_objArrayKlass(),"must be an obj array klass"); | |
241 } | |
242 | |
243 int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { | |
244 assert(obj->is_klass(), "must be klass"); | |
245 assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array"); | |
246 | |
247 objArrayKlass* oak = objArrayKlass::cast((klassOop)obj); | |
248 PSParallelCompact::adjust_pointer(oak->element_klass_addr()); | |
249 PSParallelCompact::adjust_pointer(oak->bottom_klass_addr()); | |
250 | |
251 return arrayKlassKlass::oop_update_pointers(cm, obj); | |
252 } | |
253 | |
254 int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, | |
255 HeapWord* beg_addr, | |
256 HeapWord* end_addr) { | |
257 assert(obj->is_klass(), "must be klass"); | |
258 assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array"); | |
259 | |
260 oop* p; | |
261 objArrayKlass* oak = objArrayKlass::cast((klassOop)obj); | |
262 p = oak->element_klass_addr(); | |
263 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
264 p = oak->bottom_klass_addr(); | |
265 PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); | |
266 | |
267 return arrayKlassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr); | |
268 } | |
269 #endif // SERIALGC | |
270 | |
271 #ifndef PRODUCT | |
272 | |
273 // Printing | |
274 | |
275 void objArrayKlassKlass::oop_print_on(oop obj, outputStream* st) { | |
276 assert(obj->is_klass(), "must be klass"); | |
277 objArrayKlass* oak = (objArrayKlass*) klassOop(obj)->klass_part(); | |
278 klassKlass::oop_print_on(obj, st); | |
279 st->print(" - instance klass: "); | |
280 oak->element_klass()->print_value_on(st); | |
281 st->cr(); | |
282 } | |
283 | |
1155
4e6abf09f540
6912062: disassembler plugin needs to produce symbolic information in product mode
jrose
parents:
1142
diff
changeset
|
284 #endif //PRODUCT |
0 | 285 |
286 void objArrayKlassKlass::oop_print_value_on(oop obj, outputStream* st) { | |
287 assert(obj->is_klass(), "must be klass"); | |
288 objArrayKlass* oak = (objArrayKlass*) klassOop(obj)->klass_part(); | |
289 | |
290 oak->element_klass()->print_value_on(st); | |
291 st->print("[]"); | |
292 } | |
293 | |
294 const char* objArrayKlassKlass::internal_name() const { | |
295 return "{object array class}"; | |
296 } | |
297 | |
298 | |
299 // Verification | |
300 | |
301 void objArrayKlassKlass::oop_verify_on(oop obj, outputStream* st) { | |
302 klassKlass::oop_verify_on(obj, st); | |
303 objArrayKlass* oak = objArrayKlass::cast((klassOop)obj); | |
304 guarantee(oak->element_klass()->is_perm(), "should be in permspace"); | |
305 guarantee(oak->element_klass()->is_klass(), "should be klass"); | |
306 guarantee(oak->bottom_klass()->is_perm(), "should be in permspace"); | |
307 guarantee(oak->bottom_klass()->is_klass(), "should be klass"); | |
308 Klass* bk = Klass::cast(oak->bottom_klass()); | |
309 guarantee(bk->oop_is_instance() || bk->oop_is_typeArray(), "invalid bottom klass"); | |
310 } |