< prev index next >

src/hotspot/share/services/heapDumper.cpp

Print this page




1003   writer->write_objectID(ik->signers());
1004   writer->write_objectID(ik->protection_domain());
1005 
1006   // reserved
1007   writer->write_objectID(oop(NULL));
1008   writer->write_objectID(oop(NULL));
1009 
1010   // instance size
1011   writer->write_u4(DumperSupport::instance_size(k));
1012 
1013   // size of constant pool - ignored by HAT 1.1
1014   writer->write_u2(0);
1015 
1016   // number of static fields
1017   dump_static_fields(writer, k);
1018 
1019   // description of instance fields
1020   dump_instance_field_descriptors(writer, k);
1021 
1022   // array classes
1023   k = k->array_klass_or_null();
1024   while (k != NULL) {
1025     Klass* klass = k;
1026     assert(klass->is_objArray_klass(), "not an ObjArrayKlass");
1027 
1028     writer->write_u1(HPROF_GC_CLASS_DUMP);
1029     writer->write_classID(klass);
1030     writer->write_u4(STACK_TRACE_ID);
1031 
1032     // super class of array classes is java.lang.Object
1033     java_super = klass->java_super();
1034     assert(java_super != NULL, "checking");
1035     writer->write_classID(java_super);
1036 
1037     writer->write_objectID(ik->class_loader());
1038     writer->write_objectID(ik->signers());
1039     writer->write_objectID(ik->protection_domain());
1040 
1041     writer->write_objectID(oop(NULL));    // reserved
1042     writer->write_objectID(oop(NULL));
1043     writer->write_u4(0);             // instance size
1044     writer->write_u2(0);             // constant pool
1045     writer->write_u2(0);             // static fields
1046     writer->write_u2(0);             // instance fields
1047 
1048     // get the array class for the next rank
1049     k = klass->array_klass_or_null();
1050   }
1051 }
1052 
1053 // creates HPROF_GC_CLASS_DUMP record for a given primitive array
1054 // class (and each multi-dimensional array class too)
1055 void DumperSupport::dump_basic_type_array_class(DumpWriter* writer, Klass* k) {
1056  // array classes
1057  while (k != NULL) {
1058     Klass* klass = k;
1059 
1060     writer->write_u1(HPROF_GC_CLASS_DUMP);
1061     writer->write_classID(klass);
1062     writer->write_u4(STACK_TRACE_ID);
1063 
1064     // super class of array classes is java.lang.Object
1065     InstanceKlass* java_super = klass->java_super();
1066     assert(java_super != NULL, "checking");
1067     writer->write_classID(java_super);
1068 
1069     writer->write_objectID(oop(NULL));    // loader
1070     writer->write_objectID(oop(NULL));    // signers
1071     writer->write_objectID(oop(NULL));    // protection domain
1072 
1073     writer->write_objectID(oop(NULL));    // reserved
1074     writer->write_objectID(oop(NULL));
1075     writer->write_u4(0);             // instance size
1076     writer->write_u2(0);             // constant pool
1077     writer->write_u2(0);             // static fields
1078     writer->write_u2(0);             // instance fields
1079 
1080     // get the array class for the next rank
1081     k = klass->array_klass_or_null();
1082   }
1083 }
1084 
1085 // Hprof uses an u4 as record length field,
1086 // which means we need to truncate arrays that are too long.
1087 int DumperSupport::calculate_array_max_length(DumpWriter* writer, arrayOop array, short header_size) {
1088   BasicType type = ArrayKlass::cast(array->klass())->element_type();
1089   assert(type >= T_BOOLEAN && type <= T_OBJECT, "invalid array element type");
1090 
1091   int length = array->length();
1092 
1093   int type_size;
1094   if (type == T_OBJECT) {
1095     type_size = sizeof(address);
1096   } else {
1097     type_size = type2aelembytes(type);
1098   }
1099 
1100   size_t length_in_bytes = (size_t)length * type_size;
1101 


1616   do {
1617     DumperSupport::write_header(writer(), HPROF_LOAD_CLASS, remaining);
1618 
1619     // class serial number is just a number
1620     writer()->write_u4(++class_serial_num);
1621 
1622     // class ID
1623     Klass* klass = k;
1624     writer()->write_classID(klass);
1625 
1626     // add the Klass* and class serial number pair
1627     dumper()->add_class_serial_number(klass, class_serial_num);
1628 
1629     writer()->write_u4(STACK_TRACE_ID);
1630 
1631     // class name ID
1632     Symbol* name = klass->name();
1633     writer()->write_symbolID(name);
1634 
1635     // write a LOAD_CLASS record for the array type (if it exists)
1636     k = klass->array_klass_or_null();
1637   } while (k != NULL);
1638 }
1639 
1640 // writes a HPROF_GC_CLASS_DUMP record for the given class
1641 void VM_HeapDumper::do_class_dump(Klass* k) {
1642   if (k->is_instance_klass()) {
1643     DumperSupport::dump_class_and_array_classes(writer(), k);
1644   }
1645 }
1646 
1647 // writes a HPROF_GC_CLASS_DUMP records for a given basic type
1648 // array (and each multi-dimensional array too)
1649 void VM_HeapDumper::do_basic_type_array_class_dump(Klass* k) {
1650   DumperSupport::dump_basic_type_array_class(writer(), k);
1651 }
1652 
1653 // Walk the stack of the given thread.
1654 // Dumps a HPROF_GC_ROOT_JAVA_FRAME record for each local
1655 // Dumps a HPROF_GC_ROOT_JNI_LOCAL record for each JNI local
1656 //




1003   writer->write_objectID(ik->signers());
1004   writer->write_objectID(ik->protection_domain());
1005 
1006   // reserved
1007   writer->write_objectID(oop(NULL));
1008   writer->write_objectID(oop(NULL));
1009 
1010   // instance size
1011   writer->write_u4(DumperSupport::instance_size(k));
1012 
1013   // size of constant pool - ignored by HAT 1.1
1014   writer->write_u2(0);
1015 
1016   // number of static fields
1017   dump_static_fields(writer, k);
1018 
1019   // description of instance fields
1020   dump_instance_field_descriptors(writer, k);
1021 
1022   // array classes
1023   k = k->array_klass_or_null(ArrayStorageProperties::empty);
1024   while (k != NULL) {
1025     Klass* klass = k;
1026     assert(klass->is_objArray_klass(), "not an ObjArrayKlass");
1027 
1028     writer->write_u1(HPROF_GC_CLASS_DUMP);
1029     writer->write_classID(klass);
1030     writer->write_u4(STACK_TRACE_ID);
1031 
1032     // super class of array classes is java.lang.Object
1033     java_super = klass->java_super();
1034     assert(java_super != NULL, "checking");
1035     writer->write_classID(java_super);
1036 
1037     writer->write_objectID(ik->class_loader());
1038     writer->write_objectID(ik->signers());
1039     writer->write_objectID(ik->protection_domain());
1040 
1041     writer->write_objectID(oop(NULL));    // reserved
1042     writer->write_objectID(oop(NULL));
1043     writer->write_u4(0);             // instance size
1044     writer->write_u2(0);             // constant pool
1045     writer->write_u2(0);             // static fields
1046     writer->write_u2(0);             // instance fields
1047 
1048     // get the array class for the next rank
1049     k = klass->array_klass_or_null(ArrayStorageProperties::empty);
1050   }
1051 }
1052 
1053 // creates HPROF_GC_CLASS_DUMP record for a given primitive array
1054 // class (and each multi-dimensional array class too)
1055 void DumperSupport::dump_basic_type_array_class(DumpWriter* writer, Klass* k) {
1056  // array classes
1057  while (k != NULL) {
1058     Klass* klass = k;
1059 
1060     writer->write_u1(HPROF_GC_CLASS_DUMP);
1061     writer->write_classID(klass);
1062     writer->write_u4(STACK_TRACE_ID);
1063 
1064     // super class of array classes is java.lang.Object
1065     InstanceKlass* java_super = klass->java_super();
1066     assert(java_super != NULL, "checking");
1067     writer->write_classID(java_super);
1068 
1069     writer->write_objectID(oop(NULL));    // loader
1070     writer->write_objectID(oop(NULL));    // signers
1071     writer->write_objectID(oop(NULL));    // protection domain
1072 
1073     writer->write_objectID(oop(NULL));    // reserved
1074     writer->write_objectID(oop(NULL));
1075     writer->write_u4(0);             // instance size
1076     writer->write_u2(0);             // constant pool
1077     writer->write_u2(0);             // static fields
1078     writer->write_u2(0);             // instance fields
1079 
1080     // get the array class for the next rank
1081     k = klass->array_klass_or_null(ArrayStorageProperties::empty);
1082   }
1083 }
1084 
1085 // Hprof uses an u4 as record length field,
1086 // which means we need to truncate arrays that are too long.
1087 int DumperSupport::calculate_array_max_length(DumpWriter* writer, arrayOop array, short header_size) {
1088   BasicType type = ArrayKlass::cast(array->klass())->element_type();
1089   assert(type >= T_BOOLEAN && type <= T_OBJECT, "invalid array element type");
1090 
1091   int length = array->length();
1092 
1093   int type_size;
1094   if (type == T_OBJECT) {
1095     type_size = sizeof(address);
1096   } else {
1097     type_size = type2aelembytes(type);
1098   }
1099 
1100   size_t length_in_bytes = (size_t)length * type_size;
1101 


1616   do {
1617     DumperSupport::write_header(writer(), HPROF_LOAD_CLASS, remaining);
1618 
1619     // class serial number is just a number
1620     writer()->write_u4(++class_serial_num);
1621 
1622     // class ID
1623     Klass* klass = k;
1624     writer()->write_classID(klass);
1625 
1626     // add the Klass* and class serial number pair
1627     dumper()->add_class_serial_number(klass, class_serial_num);
1628 
1629     writer()->write_u4(STACK_TRACE_ID);
1630 
1631     // class name ID
1632     Symbol* name = klass->name();
1633     writer()->write_symbolID(name);
1634 
1635     // write a LOAD_CLASS record for the array type (if it exists)
1636     k = klass->array_klass_or_null(ArrayStorageProperties::empty);
1637   } while (k != NULL);
1638 }
1639 
1640 // writes a HPROF_GC_CLASS_DUMP record for the given class
1641 void VM_HeapDumper::do_class_dump(Klass* k) {
1642   if (k->is_instance_klass()) {
1643     DumperSupport::dump_class_and_array_classes(writer(), k);
1644   }
1645 }
1646 
1647 // writes a HPROF_GC_CLASS_DUMP records for a given basic type
1648 // array (and each multi-dimensional array too)
1649 void VM_HeapDumper::do_basic_type_array_class_dump(Klass* k) {
1650   DumperSupport::dump_basic_type_array_class(writer(), k);
1651 }
1652 
1653 // Walk the stack of the given thread.
1654 // Dumps a HPROF_GC_ROOT_JAVA_FRAME record for each local
1655 // Dumps a HPROF_GC_ROOT_JNI_LOCAL record for each JNI local
1656 //


< prev index next >