< prev index next >

src/hotspot/share/services/heapDumper.cpp

Print this page




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


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




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


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


< prev index next >