Thu, 23 Jun 2011 17:14:06 -0700
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
Reviewed-by: never
duke@435 | 1 | /* |
stefank@2534 | 2 | * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "classfile/javaClasses.hpp" |
stefank@2314 | 27 | #include "gc_implementation/shared/markSweep.inline.hpp" |
stefank@2314 | 28 | #include "gc_interface/collectedHeap.inline.hpp" |
stefank@2314 | 29 | #include "memory/oopFactory.hpp" |
stefank@2314 | 30 | #include "memory/permGen.hpp" |
stefank@2314 | 31 | #include "memory/universe.inline.hpp" |
stefank@2314 | 32 | #include "oops/constantPoolKlass.hpp" |
stefank@2314 | 33 | #include "oops/constantPoolOop.hpp" |
stefank@2314 | 34 | #include "oops/oop.inline.hpp" |
stefank@2314 | 35 | #include "oops/oop.inline2.hpp" |
coleenp@2497 | 36 | #include "oops/symbol.hpp" |
stefank@2314 | 37 | #include "runtime/handles.inline.hpp" |
stefank@2314 | 38 | #ifdef TARGET_OS_FAMILY_linux |
stefank@2314 | 39 | # include "thread_linux.inline.hpp" |
stefank@2314 | 40 | #endif |
stefank@2314 | 41 | #ifdef TARGET_OS_FAMILY_solaris |
stefank@2314 | 42 | # include "thread_solaris.inline.hpp" |
stefank@2314 | 43 | #endif |
stefank@2314 | 44 | #ifdef TARGET_OS_FAMILY_windows |
stefank@2314 | 45 | # include "thread_windows.inline.hpp" |
stefank@2314 | 46 | #endif |
stefank@2314 | 47 | #ifndef SERIALGC |
stefank@2314 | 48 | #include "gc_implementation/parNew/parOopClosures.inline.hpp" |
stefank@2314 | 49 | #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" |
stefank@2314 | 50 | #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" |
stefank@2314 | 51 | #include "memory/cardTableRS.hpp" |
stefank@2314 | 52 | #include "oops/oop.pcgc.inline.hpp" |
stefank@2314 | 53 | #endif |
duke@435 | 54 | |
jmasa@953 | 55 | constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS) { |
duke@435 | 56 | int size = constantPoolOopDesc::object_size(length); |
duke@435 | 57 | KlassHandle klass (THREAD, as_klassOop()); |
ysr@2536 | 58 | assert(klass()->is_oop(), "Can't be null, else handlizing of c below won't work"); |
ysr@2536 | 59 | constantPoolHandle pool; |
ysr@2536 | 60 | { |
ysr@2536 | 61 | constantPoolOop c = |
ysr@2536 | 62 | (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); |
ysr@2536 | 63 | assert(c->klass_or_null() != NULL, "Handlizing below won't work"); |
ysr@2536 | 64 | pool = constantPoolHandle(THREAD, c); |
ysr@2536 | 65 | } |
duke@435 | 66 | |
ysr@2536 | 67 | pool->set_length(length); |
ysr@2536 | 68 | pool->set_tags(NULL); |
ysr@2536 | 69 | pool->set_cache(NULL); |
ysr@2536 | 70 | pool->set_operands(NULL); |
ysr@2536 | 71 | pool->set_pool_holder(NULL); |
ysr@2536 | 72 | pool->set_flags(0); |
duke@435 | 73 | // only set to non-zero if constant pool is merged by RedefineClasses |
ysr@2536 | 74 | pool->set_orig_length(0); |
jmasa@953 | 75 | // if constant pool may change during RedefineClasses, it is created |
jmasa@953 | 76 | // unsafe for GC concurrent processing. |
ysr@2536 | 77 | pool->set_is_conc_safe(is_conc_safe); |
duke@435 | 78 | // all fields are initialized; needed for GC |
duke@435 | 79 | |
ysr@2533 | 80 | // Note: because we may be in this "conc_unsafe" state when allocating |
ysr@2533 | 81 | // t_oop below, which may in turn cause a GC, it is imperative that our |
ysr@2533 | 82 | // size be correct, consistent and henceforth stable, at this stage. |
ysr@2536 | 83 | assert(pool->is_oop() && pool->is_parsable(), "Else size() below is unreliable"); |
ysr@2536 | 84 | assert(size == pool->size(), "size() is wrong"); |
ysr@2533 | 85 | |
duke@435 | 86 | // initialize tag array |
duke@435 | 87 | typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL); |
duke@435 | 88 | typeArrayHandle tags (THREAD, t_oop); |
duke@435 | 89 | for (int index = 0; index < length; index++) { |
duke@435 | 90 | tags()->byte_at_put(index, JVM_CONSTANT_Invalid); |
duke@435 | 91 | } |
duke@435 | 92 | pool->set_tags(tags()); |
duke@435 | 93 | |
ysr@2533 | 94 | // Check that our size was stable at its old value. |
ysr@2536 | 95 | assert(size == pool->size(), "size() changed"); |
duke@435 | 96 | return pool(); |
duke@435 | 97 | } |
duke@435 | 98 | |
duke@435 | 99 | klassOop constantPoolKlass::create_klass(TRAPS) { |
duke@435 | 100 | constantPoolKlass o; |
coleenp@548 | 101 | KlassHandle h_this_klass(THREAD, Universe::klassKlassObj()); |
coleenp@548 | 102 | KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL); |
coleenp@548 | 103 | // Make sure size calculation is right |
coleenp@548 | 104 | assert(k()->size() == align_object_size(header_size()), "wrong size for object"); |
coleenp@548 | 105 | java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror |
duke@435 | 106 | return k(); |
duke@435 | 107 | } |
duke@435 | 108 | |
duke@435 | 109 | int constantPoolKlass::oop_size(oop obj) const { |
duke@435 | 110 | assert(obj->is_constantPool(), "must be constantPool"); |
duke@435 | 111 | return constantPoolOop(obj)->object_size(); |
duke@435 | 112 | } |
duke@435 | 113 | |
duke@435 | 114 | |
duke@435 | 115 | void constantPoolKlass::oop_follow_contents(oop obj) { |
duke@435 | 116 | assert (obj->is_constantPool(), "obj must be constant pool"); |
duke@435 | 117 | constantPoolOop cp = (constantPoolOop) obj; |
duke@435 | 118 | // Performance tweak: We skip iterating over the klass pointer since we |
duke@435 | 119 | // know that Universe::constantPoolKlassObj never moves. |
duke@435 | 120 | |
duke@435 | 121 | // If the tags array is null we are in the middle of allocating this constant pool |
duke@435 | 122 | if (cp->tags() != NULL) { |
duke@435 | 123 | // gc of constant pool contents |
duke@435 | 124 | oop* base = (oop*)cp->base(); |
duke@435 | 125 | for (int i = 0; i < cp->length(); i++) { |
duke@435 | 126 | if (cp->is_pointer_entry(i)) { |
duke@435 | 127 | if (*base != NULL) MarkSweep::mark_and_push(base); |
duke@435 | 128 | } |
duke@435 | 129 | base++; |
duke@435 | 130 | } |
duke@435 | 131 | // gc of constant pool instance variables |
duke@435 | 132 | MarkSweep::mark_and_push(cp->tags_addr()); |
duke@435 | 133 | MarkSweep::mark_and_push(cp->cache_addr()); |
jrose@2268 | 134 | MarkSweep::mark_and_push(cp->operands_addr()); |
duke@435 | 135 | MarkSweep::mark_and_push(cp->pool_holder_addr()); |
duke@435 | 136 | } |
duke@435 | 137 | } |
duke@435 | 138 | |
duke@435 | 139 | #ifndef SERIALGC |
duke@435 | 140 | void constantPoolKlass::oop_follow_contents(ParCompactionManager* cm, |
duke@435 | 141 | oop obj) { |
duke@435 | 142 | assert (obj->is_constantPool(), "obj must be constant pool"); |
duke@435 | 143 | constantPoolOop cp = (constantPoolOop) obj; |
duke@435 | 144 | // Performance tweak: We skip iterating over the klass pointer since we |
duke@435 | 145 | // know that Universe::constantPoolKlassObj never moves. |
duke@435 | 146 | |
duke@435 | 147 | // If the tags array is null we are in the middle of allocating this constant |
duke@435 | 148 | // pool. |
duke@435 | 149 | if (cp->tags() != NULL) { |
duke@435 | 150 | // gc of constant pool contents |
duke@435 | 151 | oop* base = (oop*)cp->base(); |
duke@435 | 152 | for (int i = 0; i < cp->length(); i++) { |
duke@435 | 153 | if (cp->is_pointer_entry(i)) { |
duke@435 | 154 | if (*base != NULL) PSParallelCompact::mark_and_push(cm, base); |
duke@435 | 155 | } |
duke@435 | 156 | base++; |
duke@435 | 157 | } |
duke@435 | 158 | // gc of constant pool instance variables |
duke@435 | 159 | PSParallelCompact::mark_and_push(cm, cp->tags_addr()); |
duke@435 | 160 | PSParallelCompact::mark_and_push(cm, cp->cache_addr()); |
jrose@2268 | 161 | PSParallelCompact::mark_and_push(cm, cp->operands_addr()); |
duke@435 | 162 | PSParallelCompact::mark_and_push(cm, cp->pool_holder_addr()); |
duke@435 | 163 | } |
duke@435 | 164 | } |
duke@435 | 165 | #endif // SERIALGC |
duke@435 | 166 | |
duke@435 | 167 | |
duke@435 | 168 | int constantPoolKlass::oop_adjust_pointers(oop obj) { |
duke@435 | 169 | assert (obj->is_constantPool(), "obj must be constant pool"); |
duke@435 | 170 | constantPoolOop cp = (constantPoolOop) obj; |
duke@435 | 171 | // Get size before changing pointers. |
duke@435 | 172 | // Don't call size() or oop_size() since that is a virtual call. |
duke@435 | 173 | int size = cp->object_size(); |
duke@435 | 174 | // Performance tweak: We skip iterating over the klass pointer since we |
duke@435 | 175 | // know that Universe::constantPoolKlassObj never moves. |
duke@435 | 176 | |
duke@435 | 177 | // If the tags array is null we are in the middle of allocating this constant |
duke@435 | 178 | // pool. |
duke@435 | 179 | if (cp->tags() != NULL) { |
duke@435 | 180 | oop* base = (oop*)cp->base(); |
duke@435 | 181 | for (int i = 0; i< cp->length(); i++) { |
duke@435 | 182 | if (cp->is_pointer_entry(i)) { |
duke@435 | 183 | MarkSweep::adjust_pointer(base); |
duke@435 | 184 | } |
duke@435 | 185 | base++; |
duke@435 | 186 | } |
duke@435 | 187 | } |
duke@435 | 188 | MarkSweep::adjust_pointer(cp->tags_addr()); |
duke@435 | 189 | MarkSweep::adjust_pointer(cp->cache_addr()); |
jrose@2268 | 190 | MarkSweep::adjust_pointer(cp->operands_addr()); |
duke@435 | 191 | MarkSweep::adjust_pointer(cp->pool_holder_addr()); |
duke@435 | 192 | return size; |
duke@435 | 193 | } |
duke@435 | 194 | |
duke@435 | 195 | |
duke@435 | 196 | int constantPoolKlass::oop_oop_iterate(oop obj, OopClosure* blk) { |
duke@435 | 197 | assert (obj->is_constantPool(), "obj must be constant pool"); |
duke@435 | 198 | // Performance tweak: We skip iterating over the klass pointer since we |
duke@435 | 199 | // know that Universe::constantPoolKlassObj never moves. |
duke@435 | 200 | constantPoolOop cp = (constantPoolOop) obj; |
duke@435 | 201 | // Get size before changing pointers. |
duke@435 | 202 | // Don't call size() or oop_size() since that is a virtual call. |
duke@435 | 203 | int size = cp->object_size(); |
duke@435 | 204 | |
duke@435 | 205 | // If the tags array is null we are in the middle of allocating this constant |
duke@435 | 206 | // pool. |
duke@435 | 207 | if (cp->tags() != NULL) { |
duke@435 | 208 | oop* base = (oop*)cp->base(); |
duke@435 | 209 | for (int i = 0; i < cp->length(); i++) { |
duke@435 | 210 | if (cp->is_pointer_entry(i)) { |
duke@435 | 211 | blk->do_oop(base); |
duke@435 | 212 | } |
duke@435 | 213 | base++; |
duke@435 | 214 | } |
duke@435 | 215 | } |
duke@435 | 216 | blk->do_oop(cp->tags_addr()); |
duke@435 | 217 | blk->do_oop(cp->cache_addr()); |
jrose@2268 | 218 | blk->do_oop(cp->operands_addr()); |
duke@435 | 219 | blk->do_oop(cp->pool_holder_addr()); |
duke@435 | 220 | return size; |
duke@435 | 221 | } |
duke@435 | 222 | |
duke@435 | 223 | |
duke@435 | 224 | int constantPoolKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) { |
duke@435 | 225 | assert (obj->is_constantPool(), "obj must be constant pool"); |
duke@435 | 226 | // Performance tweak: We skip iterating over the klass pointer since we |
duke@435 | 227 | // know that Universe::constantPoolKlassObj never moves. |
duke@435 | 228 | constantPoolOop cp = (constantPoolOop) obj; |
duke@435 | 229 | // Get size before changing pointers. |
duke@435 | 230 | // Don't call size() or oop_size() since that is a virtual call. |
duke@435 | 231 | int size = cp->object_size(); |
duke@435 | 232 | |
duke@435 | 233 | // If the tags array is null we are in the middle of allocating this constant |
duke@435 | 234 | // pool. |
duke@435 | 235 | if (cp->tags() != NULL) { |
duke@435 | 236 | oop* base = (oop*)cp->base(); |
duke@435 | 237 | for (int i = 0; i < cp->length(); i++) { |
duke@435 | 238 | if (mr.contains(base)) { |
duke@435 | 239 | if (cp->is_pointer_entry(i)) { |
duke@435 | 240 | blk->do_oop(base); |
duke@435 | 241 | } |
duke@435 | 242 | } |
duke@435 | 243 | base++; |
duke@435 | 244 | } |
duke@435 | 245 | } |
duke@435 | 246 | oop* addr; |
duke@435 | 247 | addr = cp->tags_addr(); |
ysr@2709 | 248 | if (mr.contains(addr)) blk->do_oop(addr); |
duke@435 | 249 | addr = cp->cache_addr(); |
ysr@2709 | 250 | if (mr.contains(addr)) blk->do_oop(addr); |
jrose@2268 | 251 | addr = cp->operands_addr(); |
ysr@2709 | 252 | if (mr.contains(addr)) blk->do_oop(addr); |
duke@435 | 253 | addr = cp->pool_holder_addr(); |
ysr@2709 | 254 | if (mr.contains(addr)) blk->do_oop(addr); |
duke@435 | 255 | return size; |
duke@435 | 256 | } |
duke@435 | 257 | |
jmasa@953 | 258 | bool constantPoolKlass::oop_is_conc_safe(oop obj) const { |
jmasa@953 | 259 | assert(obj->is_constantPool(), "must be constantPool"); |
jmasa@953 | 260 | return constantPoolOop(obj)->is_conc_safe(); |
jmasa@953 | 261 | } |
jmasa@953 | 262 | |
duke@435 | 263 | #ifndef SERIALGC |
duke@435 | 264 | int constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { |
duke@435 | 265 | assert (obj->is_constantPool(), "obj must be constant pool"); |
duke@435 | 266 | constantPoolOop cp = (constantPoolOop) obj; |
duke@435 | 267 | |
duke@435 | 268 | // If the tags array is null we are in the middle of allocating this constant |
duke@435 | 269 | // pool. |
duke@435 | 270 | if (cp->tags() != NULL) { |
duke@435 | 271 | oop* base = (oop*)cp->base(); |
duke@435 | 272 | for (int i = 0; i < cp->length(); ++i, ++base) { |
duke@435 | 273 | if (cp->is_pointer_entry(i)) { |
duke@435 | 274 | PSParallelCompact::adjust_pointer(base); |
duke@435 | 275 | } |
duke@435 | 276 | } |
duke@435 | 277 | } |
duke@435 | 278 | PSParallelCompact::adjust_pointer(cp->tags_addr()); |
duke@435 | 279 | PSParallelCompact::adjust_pointer(cp->cache_addr()); |
jrose@2268 | 280 | PSParallelCompact::adjust_pointer(cp->operands_addr()); |
duke@435 | 281 | PSParallelCompact::adjust_pointer(cp->pool_holder_addr()); |
duke@435 | 282 | return cp->object_size(); |
duke@435 | 283 | } |
duke@435 | 284 | |
duke@435 | 285 | void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { |
duke@435 | 286 | assert(obj->is_constantPool(), "should be constant pool"); |
jrose@866 | 287 | constantPoolOop cp = (constantPoolOop) obj; |
never@2900 | 288 | if (cp->tags() != NULL) { |
jcoomes@2661 | 289 | for (int i = 1; i < cp->length(); ++i) { |
never@2900 | 290 | if (cp->is_pointer_entry(i)) { |
jcoomes@2661 | 291 | oop* base = cp->obj_at_addr_raw(i); |
jrose@866 | 292 | if (PSScavenge::should_scavenge(base)) { |
jrose@866 | 293 | pm->claim_or_forward_depth(base); |
jrose@866 | 294 | } |
jrose@866 | 295 | } |
jrose@866 | 296 | } |
jrose@866 | 297 | } |
duke@435 | 298 | } |
duke@435 | 299 | #endif // SERIALGC |
duke@435 | 300 | |
duke@435 | 301 | // Printing |
duke@435 | 302 | |
duke@435 | 303 | void constantPoolKlass::oop_print_on(oop obj, outputStream* st) { |
duke@435 | 304 | EXCEPTION_MARK; |
duke@435 | 305 | oop anObj; |
duke@435 | 306 | assert(obj->is_constantPool(), "must be constantPool"); |
coleenp@548 | 307 | Klass::oop_print_on(obj, st); |
duke@435 | 308 | constantPoolOop cp = constantPoolOop(obj); |
jrose@866 | 309 | if (cp->flags() != 0) { |
jrose@1928 | 310 | st->print(" - flags: 0x%x", cp->flags()); |
jrose@866 | 311 | if (cp->has_pseudo_string()) st->print(" has_pseudo_string"); |
jrose@1161 | 312 | if (cp->has_invokedynamic()) st->print(" has_invokedynamic"); |
jrose@2982 | 313 | if (cp->has_preresolution()) st->print(" has_preresolution"); |
jrose@866 | 314 | st->cr(); |
jrose@866 | 315 | } |
jrose@2982 | 316 | if (cp->pool_holder() != NULL) { |
jrose@2982 | 317 | bool extra = (instanceKlass::cast(cp->pool_holder())->constants() != cp); |
jrose@2982 | 318 | st->print_cr(" - holder: " INTPTR_FORMAT "%s", cp->pool_holder(), (extra? " (extra)" : "")); |
jrose@2982 | 319 | } |
jrose@1928 | 320 | st->print_cr(" - cache: " INTPTR_FORMAT, cp->cache()); |
duke@435 | 321 | for (int index = 1; index < cp->length(); index++) { // Index 0 is unused |
duke@435 | 322 | st->print(" - %3d : ", index); |
duke@435 | 323 | cp->tag_at(index).print_on(st); |
duke@435 | 324 | st->print(" : "); |
duke@435 | 325 | switch (cp->tag_at(index).value()) { |
duke@435 | 326 | case JVM_CONSTANT_Class : |
duke@435 | 327 | { anObj = cp->klass_at(index, CATCH); |
duke@435 | 328 | anObj->print_value_on(st); |
duke@435 | 329 | st->print(" {0x%lx}", (address)anObj); |
duke@435 | 330 | } |
duke@435 | 331 | break; |
duke@435 | 332 | case JVM_CONSTANT_Fieldref : |
duke@435 | 333 | case JVM_CONSTANT_Methodref : |
duke@435 | 334 | case JVM_CONSTANT_InterfaceMethodref : |
jrose@1928 | 335 | st->print("klass_index=%d", cp->uncached_klass_ref_index_at(index)); |
jrose@1928 | 336 | st->print(" name_and_type_index=%d", cp->uncached_name_and_type_ref_index_at(index)); |
duke@435 | 337 | break; |
duke@435 | 338 | case JVM_CONSTANT_UnresolvedString : |
duke@435 | 339 | case JVM_CONSTANT_String : |
jrose@866 | 340 | if (cp->is_pseudo_string_at(index)) { |
jrose@866 | 341 | anObj = cp->pseudo_string_at(index); |
jrose@866 | 342 | } else { |
jrose@866 | 343 | anObj = cp->string_at(index, CATCH); |
jrose@866 | 344 | } |
duke@435 | 345 | anObj->print_value_on(st); |
duke@435 | 346 | st->print(" {0x%lx}", (address)anObj); |
duke@435 | 347 | break; |
never@2900 | 348 | case JVM_CONSTANT_Object : |
never@2900 | 349 | anObj = cp->object_at(index); |
never@2900 | 350 | anObj->print_value_on(st); |
never@2900 | 351 | st->print(" {0x%lx}", (address)anObj); |
never@2900 | 352 | break; |
duke@435 | 353 | case JVM_CONSTANT_Integer : |
duke@435 | 354 | st->print("%d", cp->int_at(index)); |
duke@435 | 355 | break; |
duke@435 | 356 | case JVM_CONSTANT_Float : |
duke@435 | 357 | st->print("%f", cp->float_at(index)); |
duke@435 | 358 | break; |
duke@435 | 359 | case JVM_CONSTANT_Long : |
duke@435 | 360 | st->print_jlong(cp->long_at(index)); |
duke@435 | 361 | index++; // Skip entry following eigth-byte constant |
duke@435 | 362 | break; |
duke@435 | 363 | case JVM_CONSTANT_Double : |
duke@435 | 364 | st->print("%lf", cp->double_at(index)); |
duke@435 | 365 | index++; // Skip entry following eigth-byte constant |
duke@435 | 366 | break; |
duke@435 | 367 | case JVM_CONSTANT_NameAndType : |
duke@435 | 368 | st->print("name_index=%d", cp->name_ref_index_at(index)); |
duke@435 | 369 | st->print(" signature_index=%d", cp->signature_ref_index_at(index)); |
duke@435 | 370 | break; |
duke@435 | 371 | case JVM_CONSTANT_Utf8 : |
duke@435 | 372 | cp->symbol_at(index)->print_value_on(st); |
duke@435 | 373 | break; |
duke@435 | 374 | case JVM_CONSTANT_UnresolvedClass : // fall-through |
duke@435 | 375 | case JVM_CONSTANT_UnresolvedClassInError: { |
duke@435 | 376 | // unresolved_klass_at requires lock or safe world. |
coleenp@2497 | 377 | CPSlot entry = cp->slot_at(index); |
coleenp@2497 | 378 | if (entry.is_oop()) { |
coleenp@2497 | 379 | entry.get_oop()->print_value_on(st); |
coleenp@2497 | 380 | } else { |
coleenp@2497 | 381 | entry.get_symbol()->print_value_on(st); |
coleenp@2497 | 382 | } |
duke@435 | 383 | } |
duke@435 | 384 | break; |
jrose@1957 | 385 | case JVM_CONSTANT_MethodHandle : |
jrose@1957 | 386 | st->print("ref_kind=%d", cp->method_handle_ref_kind_at(index)); |
jrose@1957 | 387 | st->print(" ref_index=%d", cp->method_handle_index_at(index)); |
jrose@1957 | 388 | break; |
jrose@1957 | 389 | case JVM_CONSTANT_MethodType : |
jrose@1957 | 390 | st->print("signature_index=%d", cp->method_type_index_at(index)); |
jrose@1957 | 391 | break; |
jrose@2015 | 392 | case JVM_CONSTANT_InvokeDynamic : |
jrose@2268 | 393 | { |
jrose@2268 | 394 | st->print("bootstrap_method_index=%d", cp->invoke_dynamic_bootstrap_method_ref_index_at(index)); |
jrose@2268 | 395 | st->print(" name_and_type_index=%d", cp->invoke_dynamic_name_and_type_ref_index_at(index)); |
jrose@2268 | 396 | int argc = cp->invoke_dynamic_argument_count_at(index); |
jrose@2268 | 397 | if (argc > 0) { |
jrose@2268 | 398 | for (int arg_i = 0; arg_i < argc; arg_i++) { |
jrose@2268 | 399 | int arg = cp->invoke_dynamic_argument_index_at(index, arg_i); |
jrose@2268 | 400 | st->print((arg_i == 0 ? " arguments={%d" : ", %d"), arg); |
jrose@2268 | 401 | } |
jrose@2268 | 402 | st->print("}"); |
jrose@2268 | 403 | } |
jrose@2268 | 404 | } |
jrose@2015 | 405 | break; |
duke@435 | 406 | default: |
duke@435 | 407 | ShouldNotReachHere(); |
duke@435 | 408 | break; |
duke@435 | 409 | } |
duke@435 | 410 | st->cr(); |
duke@435 | 411 | } |
duke@435 | 412 | st->cr(); |
duke@435 | 413 | } |
duke@435 | 414 | |
jrose@1590 | 415 | void constantPoolKlass::oop_print_value_on(oop obj, outputStream* st) { |
jrose@1590 | 416 | assert(obj->is_constantPool(), "must be constantPool"); |
jrose@1590 | 417 | constantPoolOop cp = constantPoolOop(obj); |
jrose@1590 | 418 | st->print("constant pool [%d]", cp->length()); |
jrose@1590 | 419 | if (cp->has_pseudo_string()) st->print("/pseudo_string"); |
jrose@1590 | 420 | if (cp->has_invokedynamic()) st->print("/invokedynamic"); |
jrose@2982 | 421 | if (cp->has_preresolution()) st->print("/preresolution"); |
jrose@2268 | 422 | if (cp->operands() != NULL) st->print("/operands[%d]", cp->operands()->length()); |
jrose@1590 | 423 | cp->print_address_on(st); |
jrose@1590 | 424 | st->print(" for "); |
jrose@1590 | 425 | cp->pool_holder()->print_value_on(st); |
jrose@2982 | 426 | if (cp->pool_holder() != NULL) { |
jrose@2982 | 427 | bool extra = (instanceKlass::cast(cp->pool_holder())->constants() != cp); |
jrose@2982 | 428 | if (extra) st->print(" (extra)"); |
jrose@2982 | 429 | } |
jrose@1928 | 430 | if (cp->cache() != NULL) { |
jrose@1928 | 431 | st->print(" cache=" PTR_FORMAT, cp->cache()); |
jrose@1928 | 432 | } |
jrose@1590 | 433 | } |
duke@435 | 434 | |
duke@435 | 435 | const char* constantPoolKlass::internal_name() const { |
duke@435 | 436 | return "{constant pool}"; |
duke@435 | 437 | } |
duke@435 | 438 | |
duke@435 | 439 | // Verification |
duke@435 | 440 | |
duke@435 | 441 | void constantPoolKlass::oop_verify_on(oop obj, outputStream* st) { |
duke@435 | 442 | Klass::oop_verify_on(obj, st); |
duke@435 | 443 | guarantee(obj->is_constantPool(), "object must be constant pool"); |
duke@435 | 444 | constantPoolOop cp = constantPoolOop(obj); |
duke@435 | 445 | guarantee(cp->is_perm(), "should be in permspace"); |
duke@435 | 446 | if (!cp->partially_loaded()) { |
duke@435 | 447 | for (int i = 0; i< cp->length(); i++) { |
never@2900 | 448 | constantTag tag = cp->tag_at(i); |
coleenp@2497 | 449 | CPSlot entry = cp->slot_at(i); |
never@2900 | 450 | if (tag.is_klass()) { |
coleenp@2497 | 451 | if (entry.is_oop()) { |
coleenp@2497 | 452 | guarantee(entry.get_oop()->is_perm(), "should be in permspace"); |
coleenp@2497 | 453 | guarantee(entry.get_oop()->is_klass(), "should be klass"); |
coleenp@2497 | 454 | } |
never@2900 | 455 | } else if (tag.is_unresolved_klass()) { |
coleenp@2497 | 456 | if (entry.is_oop()) { |
coleenp@2497 | 457 | guarantee(entry.get_oop()->is_perm(), "should be in permspace"); |
coleenp@2497 | 458 | guarantee(entry.get_oop()->is_klass(), "should be klass"); |
coleenp@2497 | 459 | } |
never@2900 | 460 | } else if (tag.is_symbol()) { |
coleenp@2497 | 461 | guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count"); |
never@2900 | 462 | } else if (tag.is_unresolved_string()) { |
coleenp@2497 | 463 | if (entry.is_oop()) { |
coleenp@2497 | 464 | guarantee(entry.get_oop()->is_perm(), "should be in permspace"); |
coleenp@2497 | 465 | guarantee(entry.get_oop()->is_instance(), "should be instance"); |
coleenp@2497 | 466 | } |
coleenp@2497 | 467 | else { |
coleenp@2497 | 468 | guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count"); |
coleenp@2497 | 469 | } |
never@2900 | 470 | } else if (tag.is_string()) { |
jrose@866 | 471 | if (!cp->has_pseudo_string()) { |
coleenp@2497 | 472 | if (entry.is_oop()) { |
jcoomes@2661 | 473 | guarantee(!JavaObjectsInPerm || entry.get_oop()->is_perm(), |
jcoomes@2661 | 474 | "should be in permspace"); |
coleenp@2497 | 475 | guarantee(entry.get_oop()->is_instance(), "should be instance"); |
coleenp@2497 | 476 | } |
jrose@866 | 477 | } else { |
jrose@866 | 478 | // can be non-perm, can be non-instance (array) |
jrose@866 | 479 | } |
never@2900 | 480 | } else if (tag.is_object()) { |
never@2900 | 481 | assert(entry.get_oop()->is_oop(), "should be some valid oop"); |
never@2900 | 482 | } else { |
never@2900 | 483 | assert(!cp->is_pointer_entry(i), "unhandled oop type in constantPoolKlass::verify_on"); |
duke@435 | 484 | } |
duke@435 | 485 | } |
duke@435 | 486 | guarantee(cp->tags()->is_perm(), "should be in permspace"); |
duke@435 | 487 | guarantee(cp->tags()->is_typeArray(), "should be type array"); |
duke@435 | 488 | if (cp->cache() != NULL) { |
duke@435 | 489 | // Note: cache() can be NULL before a class is completely setup or |
duke@435 | 490 | // in temporary constant pools used during constant pool merging |
duke@435 | 491 | guarantee(cp->cache()->is_perm(), "should be in permspace"); |
duke@435 | 492 | guarantee(cp->cache()->is_constantPoolCache(), "should be constant pool cache"); |
duke@435 | 493 | } |
jrose@2268 | 494 | if (cp->operands() != NULL) { |
jrose@2268 | 495 | guarantee(cp->operands()->is_perm(), "should be in permspace"); |
jrose@2268 | 496 | guarantee(cp->operands()->is_typeArray(), "should be type array"); |
jrose@2268 | 497 | } |
duke@435 | 498 | if (cp->pool_holder() != NULL) { |
duke@435 | 499 | // Note: pool_holder() can be NULL in temporary constant pools |
duke@435 | 500 | // used during constant pool merging |
duke@435 | 501 | guarantee(cp->pool_holder()->is_perm(), "should be in permspace"); |
duke@435 | 502 | guarantee(cp->pool_holder()->is_klass(), "should be klass"); |
duke@435 | 503 | } |
duke@435 | 504 | } |
duke@435 | 505 | } |
duke@435 | 506 | |
duke@435 | 507 | bool constantPoolKlass::oop_partially_loaded(oop obj) const { |
duke@435 | 508 | assert(obj->is_constantPool(), "object must be constant pool"); |
duke@435 | 509 | constantPoolOop cp = constantPoolOop(obj); |
duke@435 | 510 | return cp->tags() == NULL || cp->pool_holder() == (klassOop) cp; // Check whether pool holder points to self |
duke@435 | 511 | } |
duke@435 | 512 | |
duke@435 | 513 | |
duke@435 | 514 | void constantPoolKlass::oop_set_partially_loaded(oop obj) { |
duke@435 | 515 | assert(obj->is_constantPool(), "object must be constant pool"); |
duke@435 | 516 | constantPoolOop cp = constantPoolOop(obj); |
duke@435 | 517 | assert(cp->pool_holder() == NULL, "just checking"); |
duke@435 | 518 | cp->set_pool_holder((klassOop) cp); // Temporarily set pool holder to point to self |
duke@435 | 519 | } |
duke@435 | 520 | |
duke@435 | 521 | #ifndef PRODUCT |
duke@435 | 522 | // CompileTheWorld support. Preload all classes loaded references in the passed in constantpool |
duke@435 | 523 | void constantPoolKlass::preload_and_initialize_all_classes(oop obj, TRAPS) { |
duke@435 | 524 | guarantee(obj->is_constantPool(), "object must be constant pool"); |
duke@435 | 525 | constantPoolHandle cp(THREAD, (constantPoolOop)obj); |
duke@435 | 526 | guarantee(!cp->partially_loaded(), "must be fully loaded"); |
duke@435 | 527 | |
duke@435 | 528 | for (int i = 0; i< cp->length(); i++) { |
duke@435 | 529 | if (cp->tag_at(i).is_unresolved_klass()) { |
duke@435 | 530 | // This will force loading of the class |
duke@435 | 531 | klassOop klass = cp->klass_at(i, CHECK); |
duke@435 | 532 | if (klass->is_instance()) { |
duke@435 | 533 | // Force initialization of class |
duke@435 | 534 | instanceKlass::cast(klass)->initialize(CHECK); |
duke@435 | 535 | } |
duke@435 | 536 | } |
duke@435 | 537 | } |
duke@435 | 538 | } |
duke@435 | 539 | |
duke@435 | 540 | #endif |