comparison src/share/vm/oops/constantPoolKlass.cpp @ 2177:3582bf76420e

6990754: Use native memory and reference counting to implement SymbolTable Summary: move symbols from permgen into C heap and reference count them Reviewed-by: never, acorn, jmasa, stefank
author coleenp
date Thu, 27 Jan 2011 16:11:27 -0800
parents dad31fc330cd
children c5a923563727
comparison
equal deleted inserted replaced
2176:27e4ea99855d 2177:3582bf76420e
31 #include "memory/universe.inline.hpp" 31 #include "memory/universe.inline.hpp"
32 #include "oops/constantPoolKlass.hpp" 32 #include "oops/constantPoolKlass.hpp"
33 #include "oops/constantPoolOop.hpp" 33 #include "oops/constantPoolOop.hpp"
34 #include "oops/oop.inline.hpp" 34 #include "oops/oop.inline.hpp"
35 #include "oops/oop.inline2.hpp" 35 #include "oops/oop.inline2.hpp"
36 #include "oops/symbolOop.hpp" 36 #include "oops/symbol.hpp"
37 #include "runtime/handles.inline.hpp" 37 #include "runtime/handles.inline.hpp"
38 #ifdef TARGET_OS_FAMILY_linux 38 #ifdef TARGET_OS_FAMILY_linux
39 # include "thread_linux.inline.hpp" 39 # include "thread_linux.inline.hpp"
40 #endif 40 #endif
41 #ifdef TARGET_OS_FAMILY_solaris 41 #ifdef TARGET_OS_FAMILY_solaris
386 cp->symbol_at(index)->print_value_on(st); 386 cp->symbol_at(index)->print_value_on(st);
387 break; 387 break;
388 case JVM_CONSTANT_UnresolvedClass : // fall-through 388 case JVM_CONSTANT_UnresolvedClass : // fall-through
389 case JVM_CONSTANT_UnresolvedClassInError: { 389 case JVM_CONSTANT_UnresolvedClassInError: {
390 // unresolved_klass_at requires lock or safe world. 390 // unresolved_klass_at requires lock or safe world.
391 oop entry = *cp->obj_at_addr(index); 391 CPSlot entry = cp->slot_at(index);
392 entry->print_value_on(st); 392 if (entry.is_oop()) {
393 entry.get_oop()->print_value_on(st);
394 } else {
395 entry.get_symbol()->print_value_on(st);
396 }
393 } 397 }
394 break; 398 break;
395 case JVM_CONSTANT_MethodHandle : 399 case JVM_CONSTANT_MethodHandle :
396 st->print("ref_kind=%d", cp->method_handle_ref_kind_at(index)); 400 st->print("ref_kind=%d", cp->method_handle_ref_kind_at(index));
397 st->print(" ref_index=%d", cp->method_handle_index_at(index)); 401 st->print(" ref_index=%d", cp->method_handle_index_at(index));
448 Klass::oop_verify_on(obj, st); 452 Klass::oop_verify_on(obj, st);
449 guarantee(obj->is_constantPool(), "object must be constant pool"); 453 guarantee(obj->is_constantPool(), "object must be constant pool");
450 constantPoolOop cp = constantPoolOop(obj); 454 constantPoolOop cp = constantPoolOop(obj);
451 guarantee(cp->is_perm(), "should be in permspace"); 455 guarantee(cp->is_perm(), "should be in permspace");
452 if (!cp->partially_loaded()) { 456 if (!cp->partially_loaded()) {
453 oop* base = (oop*)cp->base();
454 for (int i = 0; i< cp->length(); i++) { 457 for (int i = 0; i< cp->length(); i++) {
458 CPSlot entry = cp->slot_at(i);
455 if (cp->tag_at(i).is_klass()) { 459 if (cp->tag_at(i).is_klass()) {
456 guarantee((*base)->is_perm(), "should be in permspace"); 460 if (entry.is_oop()) {
457 guarantee((*base)->is_klass(), "should be klass"); 461 guarantee(entry.get_oop()->is_perm(), "should be in permspace");
462 guarantee(entry.get_oop()->is_klass(), "should be klass");
463 }
458 } 464 }
459 if (cp->tag_at(i).is_unresolved_klass()) { 465 if (cp->tag_at(i).is_unresolved_klass()) {
460 guarantee((*base)->is_perm(), "should be in permspace"); 466 if (entry.is_oop()) {
461 guarantee((*base)->is_symbol() || (*base)->is_klass(), 467 guarantee(entry.get_oop()->is_perm(), "should be in permspace");
462 "should be symbol or klass"); 468 guarantee(entry.get_oop()->is_klass(), "should be klass");
469 }
463 } 470 }
464 if (cp->tag_at(i).is_symbol()) { 471 if (cp->tag_at(i).is_symbol()) {
465 guarantee((*base)->is_perm(), "should be in permspace"); 472 guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count");
466 guarantee((*base)->is_symbol(), "should be symbol");
467 } 473 }
468 if (cp->tag_at(i).is_unresolved_string()) { 474 if (cp->tag_at(i).is_unresolved_string()) {
469 guarantee((*base)->is_perm(), "should be in permspace"); 475 if (entry.is_oop()) {
470 guarantee((*base)->is_symbol() || (*base)->is_instance(), 476 guarantee(entry.get_oop()->is_perm(), "should be in permspace");
471 "should be symbol or instance"); 477 guarantee(entry.get_oop()->is_instance(), "should be instance");
478 }
479 else {
480 guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count");
481 }
472 } 482 }
473 if (cp->tag_at(i).is_string()) { 483 if (cp->tag_at(i).is_string()) {
474 if (!cp->has_pseudo_string()) { 484 if (!cp->has_pseudo_string()) {
475 guarantee((*base)->is_perm(), "should be in permspace"); 485 if (entry.is_oop()) {
476 guarantee((*base)->is_instance(), "should be instance"); 486 guarantee(entry.get_oop()->is_perm(), "should be in permspace");
487 guarantee(entry.get_oop()->is_instance(), "should be instance");
488 }
477 } else { 489 } else {
478 // can be non-perm, can be non-instance (array) 490 // can be non-perm, can be non-instance (array)
479 } 491 }
480 } 492 }
481 // FIXME: verify JSR 292 tags JVM_CONSTANT_MethodHandle, etc. 493 // FIXME: verify JSR 292 tags JVM_CONSTANT_MethodHandle, etc.
482 base++;
483 } 494 }
484 guarantee(cp->tags()->is_perm(), "should be in permspace"); 495 guarantee(cp->tags()->is_perm(), "should be in permspace");
485 guarantee(cp->tags()->is_typeArray(), "should be type array"); 496 guarantee(cp->tags()->is_typeArray(), "should be type array");
486 if (cp->cache() != NULL) { 497 if (cp->cache() != NULL) {
487 // Note: cache() can be NULL before a class is completely setup or 498 // Note: cache() can be NULL before a class is completely setup or