< prev index next >

src/share/vm/ci/ciInstanceKlass.cpp

Print this page




 687 protected:
 688   outputStream* _out;
 689 public:
 690   StaticFieldPrinter(outputStream* out) :
 691     _out(out) {
 692   }
 693   void do_field_helper(fieldDescriptor* fd, oop obj, bool flattened);
 694 };
 695 
 696 class StaticFinalFieldPrinter : public StaticFieldPrinter {
 697   const char*   _holder;
 698  public:
 699   StaticFinalFieldPrinter(outputStream* out, const char* holder) :
 700     StaticFieldPrinter(out), _holder(holder) {
 701   }
 702   void do_field(fieldDescriptor* fd) {
 703     if (fd->is_final() && !fd->has_initial_value()) {
 704       ResourceMark rm;
 705       InstanceKlass* holder = fd->field_holder();
 706       oop mirror = holder->java_mirror();
 707       _out->print("staticfield %s %s %s ", _holder, fd->name()->as_quoted_ascii(), fd->signature()->as_quoted_ascii());




 708       do_field_helper(fd, mirror, false);
 709       _out->cr();
 710     }
 711   }
 712 };
 713 
 714 class ValueTypeFieldPrinter : public StaticFieldPrinter {
 715   oop _obj;
 716 public:
 717   ValueTypeFieldPrinter(outputStream* out, oop obj) :
 718     StaticFieldPrinter(out), _obj(obj) {
 719   }
 720   void do_field(fieldDescriptor* fd) {
 721     do_field_helper(fd, _obj, true);
 722     _out->print(" ");
 723   }
 724 };
 725 
 726 void StaticFieldPrinter::do_field_helper(fieldDescriptor* fd, oop mirror, bool flattened) {
 727   switch (fd->field_type()) {
 728     case T_BYTE:    _out->print_cr("%d", mirror->byte_field(fd->offset()));   break;

 729     case T_BOOLEAN: _out->print("%d", mirror->bool_field(fd->offset()));   break;
 730     case T_SHORT:   _out->print("%d", mirror->short_field(fd->offset()));  break;
 731     case T_CHAR:    _out->print("%d", mirror->char_field(fd->offset()));   break;
 732     case T_INT:     _out->print("%d", mirror->int_field(fd->offset()));    break;
 733     case T_LONG:    _out->print(INT64_FORMAT, (int64_t)(mirror->long_field(fd->offset())));   break;
 734     case T_FLOAT: {
 735       float f = mirror->float_field(fd->offset());
 736       _out->print("%d", *(int*)&f);
 737       break;
 738     }
 739     case T_DOUBLE: {
 740       double d = mirror->double_field(fd->offset());
 741       _out->print(INT64_FORMAT, *(int64_t*)&d);
 742       break;
 743     }
 744     case T_ARRAY: {
 745       oop value =  mirror->obj_field_acquire(fd->offset());
 746       if (value == NULL) {
 747         _out->print("null");
 748       } else {
 749         typeArrayOop ta = (typeArrayOop)value;
 750         _out->print("%d", ta->length());
 751         if (value->is_objArray()) {
 752           objArrayOop oa = (objArrayOop)value;
 753           const char* klass_name  = value->klass()->name()->as_quoted_ascii();
 754           _out->print(" %s", klass_name);
 755         }
 756       }
 757       break;
 758     }
 759     case T_OBJECT: {
 760       oop value =  mirror->obj_field_acquire(fd->offset());
 761       if (value == NULL) {
 762         _out->print("null");
 763       } else if (value->is_instance()) {





 764         if (value->is_a(SystemDictionary::String_klass())) {
 765           _out->print("\"");
 766           _out->print_raw(java_lang_String::as_quoted_ascii(value));
 767           _out->print("\"");
 768         } else {
 769           const char* klass_name  = value->klass()->name()->as_quoted_ascii();
 770           _out->print("%s", klass_name);
 771         }
 772       } else {
 773         ShouldNotReachHere();
 774       }
 775       break;
 776     }
 777     case T_VALUETYPE: {
 778       ResetNoHandleMark rnhm;
 779       Thread* THREAD = Thread::current();
 780       SignatureStream ss(fd->signature(), false);
 781       Symbol* name = ss.as_symbol(THREAD);
 782       assert(!HAS_PENDING_EXCEPTION, "can resolve klass?");
 783       InstanceKlass* holder = fd->field_holder();
 784       Klass* k = SystemDictionary::find(name, Handle(THREAD, holder->class_loader()),
 785                                         Handle(THREAD, holder->protection_domain()), THREAD);
 786       assert(k != NULL && !HAS_PENDING_EXCEPTION, "can resolve klass?");
 787       ValueKlass* vk = ValueKlass::cast(k);
 788       oop obj;
 789       if (flattened) {
 790         int field_offset = fd->offset() - vk->first_field_offset();
 791         obj = (oop)((address)mirror + field_offset);
 792       } else {
 793         obj =  mirror->obj_field_acquire(fd->offset());




 687 protected:
 688   outputStream* _out;
 689 public:
 690   StaticFieldPrinter(outputStream* out) :
 691     _out(out) {
 692   }
 693   void do_field_helper(fieldDescriptor* fd, oop obj, bool flattened);
 694 };
 695 
 696 class StaticFinalFieldPrinter : public StaticFieldPrinter {
 697   const char*   _holder;
 698  public:
 699   StaticFinalFieldPrinter(outputStream* out, const char* holder) :
 700     StaticFieldPrinter(out), _holder(holder) {
 701   }
 702   void do_field(fieldDescriptor* fd) {
 703     if (fd->is_final() && !fd->has_initial_value()) {
 704       ResourceMark rm;
 705       InstanceKlass* holder = fd->field_holder();
 706       oop mirror = holder->java_mirror();
 707       _out->print("staticfield %s %s ", _holder, fd->name()->as_quoted_ascii());
 708       BasicType bt = fd->field_type();
 709       if (bt != T_OBJECT && bt != T_ARRAY) {
 710         _out->print("%s ", fd->signature()->as_quoted_ascii());
 711       }
 712       do_field_helper(fd, mirror, false);
 713       _out->cr();
 714     }
 715   }
 716 };
 717 
 718 class ValueTypeFieldPrinter : public StaticFieldPrinter {
 719   oop _obj;
 720 public:
 721   ValueTypeFieldPrinter(outputStream* out, oop obj) :
 722     StaticFieldPrinter(out), _obj(obj) {
 723   }
 724   void do_field(fieldDescriptor* fd) {
 725     do_field_helper(fd, _obj, true);
 726     _out->print(" ");
 727   }
 728 };
 729 
 730 void StaticFieldPrinter::do_field_helper(fieldDescriptor* fd, oop mirror, bool flattened) {
 731   BasicType bt = fd->field_type();
 732   switch (bt) {
 733     case T_BYTE:    _out->print("%d", mirror->byte_field(fd->offset()));   break;
 734     case T_BOOLEAN: _out->print("%d", mirror->bool_field(fd->offset()));   break;
 735     case T_SHORT:   _out->print("%d", mirror->short_field(fd->offset()));  break;
 736     case T_CHAR:    _out->print("%d", mirror->char_field(fd->offset()));   break;
 737     case T_INT:     _out->print("%d", mirror->int_field(fd->offset()));    break;
 738     case T_LONG:    _out->print(INT64_FORMAT, (int64_t)(mirror->long_field(fd->offset())));   break;
 739     case T_FLOAT: {
 740       float f = mirror->float_field(fd->offset());
 741       _out->print("%d", *(int*)&f);
 742       break;
 743     }
 744     case T_DOUBLE: {
 745       double d = mirror->double_field(fd->offset());
 746       _out->print(INT64_FORMAT, *(int64_t*)&d);
 747       break;
 748     }
 749     case T_ARRAY:














 750     case T_OBJECT: {
 751       oop value =  mirror->obj_field_acquire(fd->offset());
 752       if (value == NULL) {
 753         _out->print("null");
 754       } else {
 755         _out->print("%s", value->klass()->signature_name());
 756         if (value->is_array()) {
 757           _out->print(" %d", ((arrayOop)value)->length());
 758         } else {
 759           assert(value->is_instance() && bt == T_OBJECT, "what else?");
 760           if (value->is_a(SystemDictionary::String_klass())) {
 761             _out->print(" \"");
 762             _out->print_raw(java_lang_String::as_quoted_ascii(value));
 763             _out->print("\"");



 764           }          
 765         }

 766       }
 767       break;
 768     }
 769     case T_VALUETYPE: {
 770       ResetNoHandleMark rnhm;
 771       Thread* THREAD = Thread::current();
 772       SignatureStream ss(fd->signature(), false);
 773       Symbol* name = ss.as_symbol(THREAD);
 774       assert(!HAS_PENDING_EXCEPTION, "can resolve klass?");
 775       InstanceKlass* holder = fd->field_holder();
 776       Klass* k = SystemDictionary::find(name, Handle(THREAD, holder->class_loader()),
 777                                         Handle(THREAD, holder->protection_domain()), THREAD);
 778       assert(k != NULL && !HAS_PENDING_EXCEPTION, "can resolve klass?");
 779       ValueKlass* vk = ValueKlass::cast(k);
 780       oop obj;
 781       if (flattened) {
 782         int field_offset = fd->offset() - vk->first_field_offset();
 783         obj = (oop)((address)mirror + field_offset);
 784       } else {
 785         obj =  mirror->obj_field_acquire(fd->offset());


< prev index next >