hotspot/src/share/vm/oops/oop.cpp
changeset 4584 e2a449e8cc6f
parent 2332 5c7b6f4ce0a1
child 5547 f4b087cbb361
equal deleted inserted replaced
4582:1a6662d11385 4584:e2a449e8cc6f
    29 
    29 
    30 BarrierSet* oopDesc::_bs = NULL;
    30 BarrierSet* oopDesc::_bs = NULL;
    31 
    31 
    32 #ifdef PRODUCT
    32 #ifdef PRODUCT
    33 void oopDesc::print_on(outputStream* st) const {}
    33 void oopDesc::print_on(outputStream* st) const {}
    34 void oopDesc::print_value_on(outputStream* st) const {}
       
    35 void oopDesc::print_address_on(outputStream* st) const {}
    34 void oopDesc::print_address_on(outputStream* st) const {}
    36 char* oopDesc::print_value_string() { return NULL; }
       
    37 char* oopDesc::print_string() { return NULL; }
    35 char* oopDesc::print_string() { return NULL; }
    38 void oopDesc::print()         {}
    36 void oopDesc::print()         {}
    39 void oopDesc::print_value()   {}
       
    40 void oopDesc::print_address() {}
    37 void oopDesc::print_address() {}
    41 #else
    38 
       
    39 #else //PRODUCT
       
    40 
    42 void oopDesc::print_on(outputStream* st) const {
    41 void oopDesc::print_on(outputStream* st) const {
    43   if (this == NULL) {
    42   if (this == NULL) {
    44     st->print_cr("NULL");
    43     st->print_cr("NULL");
    45   } else {
    44   } else {
    46     blueprint()->oop_print_on(oop(this), st);
    45     blueprint()->oop_print_on(oop(this), st);
    47   }
       
    48 }
       
    49 
       
    50 void oopDesc::print_value_on(outputStream* st) const {
       
    51   oop obj = oop(this);
       
    52   if (this == NULL) {
       
    53     st->print("NULL");
       
    54   } else if (java_lang_String::is_instance(obj)) {
       
    55     java_lang_String::print(obj, st);
       
    56     if (PrintOopAddress) print_address_on(st);
       
    57 #ifdef ASSERT
       
    58   } else if (!Universe::heap()->is_in(obj) || !Universe::heap()->is_in(klass())) {
       
    59     st->print("### BAD OOP %p ###", (address)obj);
       
    60 #endif
       
    61   } else {
       
    62     blueprint()->oop_print_value_on(obj, st);
       
    63   }
    46   }
    64 }
    47 }
    65 
    48 
    66 void oopDesc::print_address_on(outputStream* st) const {
    49 void oopDesc::print_address_on(outputStream* st) const {
    67   if (PrintOopAddress) {
    50   if (PrintOopAddress) {
    69   }
    52   }
    70 }
    53 }
    71 
    54 
    72 void oopDesc::print()         { print_on(tty);         }
    55 void oopDesc::print()         { print_on(tty);         }
    73 
    56 
    74 void oopDesc::print_value()   { print_value_on(tty);   }
       
    75 
       
    76 void oopDesc::print_address() { print_address_on(tty); }
    57 void oopDesc::print_address() { print_address_on(tty); }
    77 
    58 
    78 char* oopDesc::print_string() {
    59 char* oopDesc::print_string() {
    79   stringStream* st = new stringStream();
    60   stringStream st;
    80   print_on(st);
    61   print_on(&st);
    81   return st->as_string();
    62   return st.as_string();
       
    63 }
       
    64 
       
    65 #endif // PRODUCT
       
    66 
       
    67 // The print_value functions are present in all builds, to support the disassembler.
       
    68 
       
    69 void oopDesc::print_value() {
       
    70   print_value_on(tty);
    82 }
    71 }
    83 
    72 
    84 char* oopDesc::print_value_string() {
    73 char* oopDesc::print_value_string() {
    85   stringStream* st = new stringStream();
    74   char buf[100];
    86   print_value_on(st);
    75   stringStream st(buf, sizeof(buf));
    87   return st->as_string();
    76   print_value_on(&st);
       
    77   return st.as_string();
    88 }
    78 }
    89 
    79 
    90 #endif // PRODUCT
    80 void oopDesc::print_value_on(outputStream* st) const {
       
    81   oop obj = oop(this);
       
    82   if (this == NULL) {
       
    83     st->print("NULL");
       
    84   } else if (java_lang_String::is_instance(obj)) {
       
    85     java_lang_String::print(obj, st);
       
    86 #ifndef PRODUCT
       
    87     if (PrintOopAddress) print_address_on(st);
       
    88 #endif //PRODUCT
       
    89 #ifdef ASSERT
       
    90   } else if (!Universe::heap()->is_in(obj) || !Universe::heap()->is_in(klass())) {
       
    91     st->print("### BAD OOP %p ###", (address)obj);
       
    92 #endif //ASSERT
       
    93   } else {
       
    94     blueprint()->oop_print_value_on(obj, st);
       
    95   }
       
    96 }
       
    97 
    91 
    98 
    92 void oopDesc::verify_on(outputStream* st) {
    99 void oopDesc::verify_on(outputStream* st) {
    93   if (this != NULL) {
   100   if (this != NULL) {
    94     blueprint()->oop_verify_on(this, st);
   101     blueprint()->oop_verify_on(this, st);
    95   }
   102   }