972
973 // creates HPROF_GC_CLASS_DUMP record for the given class and each of
974 // its array classes
975 void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) {
976 InstanceKlass* ik = InstanceKlass::cast(k);
977
978 // We can safepoint and do a heap dump at a point where we have a Klass,
979 // but no java mirror class has been setup for it. So we need to check
980 // that the class is at least loaded, to avoid crash from a null mirror.
981 if (!ik->is_loaded()) {
982 return;
983 }
984
985 writer->write_u1(HPROF_GC_CLASS_DUMP);
986
987 // class ID
988 writer->write_classID(ik);
989 writer->write_u4(STACK_TRACE_ID);
990
991 // super class ID
992 Klass* java_super = ik->java_super();
993 if (java_super == NULL) {
994 writer->write_objectID(oop(NULL));
995 } else {
996 writer->write_classID(java_super);
997 }
998
999 writer->write_objectID(ik->class_loader());
1000 writer->write_objectID(ik->signers());
1001 writer->write_objectID(ik->protection_domain());
1002
1003 // reserved
1004 writer->write_objectID(oop(NULL));
1005 writer->write_objectID(oop(NULL));
1006
1007 // instance size
1008 writer->write_u4(DumperSupport::instance_size(k));
1009
1010 // size of constant pool - ignored by HAT 1.1
1011 writer->write_u2(0);
1012
1042 writer->write_u2(0); // static fields
1043 writer->write_u2(0); // instance fields
1044
1045 // get the array class for the next rank
1046 k = klass->array_klass_or_null();
1047 }
1048 }
1049
1050 // creates HPROF_GC_CLASS_DUMP record for a given primitive array
1051 // class (and each multi-dimensional array class too)
1052 void DumperSupport::dump_basic_type_array_class(DumpWriter* writer, Klass* k) {
1053 // array classes
1054 while (k != NULL) {
1055 Klass* klass = k;
1056
1057 writer->write_u1(HPROF_GC_CLASS_DUMP);
1058 writer->write_classID(klass);
1059 writer->write_u4(STACK_TRACE_ID);
1060
1061 // super class of array classes is java.lang.Object
1062 Klass* java_super = klass->java_super();
1063 assert(java_super != NULL, "checking");
1064 writer->write_classID(java_super);
1065
1066 writer->write_objectID(oop(NULL)); // loader
1067 writer->write_objectID(oop(NULL)); // signers
1068 writer->write_objectID(oop(NULL)); // protection domain
1069
1070 writer->write_objectID(oop(NULL)); // reserved
1071 writer->write_objectID(oop(NULL));
1072 writer->write_u4(0); // instance size
1073 writer->write_u2(0); // constant pool
1074 writer->write_u2(0); // static fields
1075 writer->write_u2(0); // instance fields
1076
1077 // get the array class for the next rank
1078 k = klass->array_klass_or_null();
1079 }
1080 }
1081
1082 // Hprof uses an u4 as record length field,
|
972
973 // creates HPROF_GC_CLASS_DUMP record for the given class and each of
974 // its array classes
975 void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) {
976 InstanceKlass* ik = InstanceKlass::cast(k);
977
978 // We can safepoint and do a heap dump at a point where we have a Klass,
979 // but no java mirror class has been setup for it. So we need to check
980 // that the class is at least loaded, to avoid crash from a null mirror.
981 if (!ik->is_loaded()) {
982 return;
983 }
984
985 writer->write_u1(HPROF_GC_CLASS_DUMP);
986
987 // class ID
988 writer->write_classID(ik);
989 writer->write_u4(STACK_TRACE_ID);
990
991 // super class ID
992 InstanceKlass* java_super = ik->java_super();
993 if (java_super == NULL) {
994 writer->write_objectID(oop(NULL));
995 } else {
996 writer->write_classID(java_super);
997 }
998
999 writer->write_objectID(ik->class_loader());
1000 writer->write_objectID(ik->signers());
1001 writer->write_objectID(ik->protection_domain());
1002
1003 // reserved
1004 writer->write_objectID(oop(NULL));
1005 writer->write_objectID(oop(NULL));
1006
1007 // instance size
1008 writer->write_u4(DumperSupport::instance_size(k));
1009
1010 // size of constant pool - ignored by HAT 1.1
1011 writer->write_u2(0);
1012
1042 writer->write_u2(0); // static fields
1043 writer->write_u2(0); // instance fields
1044
1045 // get the array class for the next rank
1046 k = klass->array_klass_or_null();
1047 }
1048 }
1049
1050 // creates HPROF_GC_CLASS_DUMP record for a given primitive array
1051 // class (and each multi-dimensional array class too)
1052 void DumperSupport::dump_basic_type_array_class(DumpWriter* writer, Klass* k) {
1053 // array classes
1054 while (k != NULL) {
1055 Klass* klass = k;
1056
1057 writer->write_u1(HPROF_GC_CLASS_DUMP);
1058 writer->write_classID(klass);
1059 writer->write_u4(STACK_TRACE_ID);
1060
1061 // super class of array classes is java.lang.Object
1062 InstanceKlass* java_super = klass->java_super();
1063 assert(java_super != NULL, "checking");
1064 writer->write_classID(java_super);
1065
1066 writer->write_objectID(oop(NULL)); // loader
1067 writer->write_objectID(oop(NULL)); // signers
1068 writer->write_objectID(oop(NULL)); // protection domain
1069
1070 writer->write_objectID(oop(NULL)); // reserved
1071 writer->write_objectID(oop(NULL));
1072 writer->write_u4(0); // instance size
1073 writer->write_u2(0); // constant pool
1074 writer->write_u2(0); // static fields
1075 writer->write_u2(0); // instance fields
1076
1077 // get the array class for the next rank
1078 k = klass->array_klass_or_null();
1079 }
1080 }
1081
1082 // Hprof uses an u4 as record length field,
|