< prev index next >

src/share/vm/services/heapDumper.cpp

Print this page




 839         case JVM_SIGNATURE_DOUBLE  : size += 8; break;
 840 
 841         default : ShouldNotReachHere();
 842       }
 843     }
 844   }
 845   return size;
 846 }
 847 
 848 // dumps static fields of the given class
 849 void DumperSupport::dump_static_fields(DumpWriter* writer, Klass* k) {
 850   HandleMark hm;
 851   InstanceKlass* ik = InstanceKlass::cast(k);
 852 
 853   // pass 1 - count the static fields
 854   u2 field_count = 0;
 855   for (FieldStream fldc(ik, true, true); !fldc.eos(); fldc.next()) {
 856     if (fldc.access_flags().is_static()) field_count++;
 857   }
 858 























 859   writer->write_u2(field_count);
 860 
 861   // pass 2 - dump the field descriptors and raw values
 862   for (FieldStream fld(ik, true, true); !fld.eos(); fld.next()) {
 863     if (fld.access_flags().is_static()) {
 864       Symbol* sig = fld.signature();
 865 
 866       writer->write_symbolID(fld.name());   // name
 867       writer->write_u1(sig2tag(sig));       // type
 868 
 869       // value
 870       int offset = fld.offset();
 871       address addr = (address)ik->java_mirror() + offset;
 872 
 873       dump_field_value(writer, sig->byte_at(0), addr);
 874     }
 875   }























 876 }
 877 
 878 // dump the raw values of the instance fields of the given object
 879 void DumperSupport::dump_instance_fields(DumpWriter* writer, oop o) {
 880   HandleMark hm;
 881   InstanceKlass* ik = InstanceKlass::cast(o->klass());
 882 
 883   for (FieldStream fld(ik, false, false); !fld.eos(); fld.next()) {
 884     if (!fld.access_flags().is_static()) {
 885       Symbol* sig = fld.signature();
 886       address addr = (address)o + fld.offset();
 887 
 888       dump_field_value(writer, sig->byte_at(0), addr);
 889     }
 890   }
 891 }
 892 
 893 // dumps the definition of the instance fields for a given class
 894 void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, Klass* k) {
 895   HandleMark hm;


1805   // After each sub-record is written check_segment_length will be invoked
1806   // to check if the current segment exceeds a threshold. If so, a new
1807   // segment is started.
1808   // The HPROF_GC_CLASS_DUMP and HPROF_GC_INSTANCE_DUMP are the vast bulk
1809   // of the heap dump.
1810   HeapObjectDumper obj_dumper(this, writer());
1811   Universe::heap()->safe_object_iterate(&obj_dumper);
1812 
1813   // HPROF_GC_ROOT_THREAD_OBJ + frames + jni locals
1814   do_threads();
1815   check_segment_length();
1816 
1817   // HPROF_GC_ROOT_MONITOR_USED
1818   MonitorUsedDumper mon_dumper(writer());
1819   ObjectSynchronizer::oops_do(&mon_dumper);
1820   check_segment_length();
1821 
1822   // HPROF_GC_ROOT_JNI_GLOBAL
1823   JNIGlobalsDumper jni_dumper(writer());
1824   JNIHandles::oops_do(&jni_dumper);


1825   check_segment_length();
1826 
1827   // HPROF_GC_ROOT_STICKY_CLASS
1828   // These should be classes in the NULL class loader data, and not all classes
1829   // if !ClassUnloading
1830   StickyClassDumper class_dumper(writer());
1831   ClassLoaderData::the_null_class_loader_data()->classes_do(&class_dumper);
1832 
1833   // fixes up the length of the dump record and writes the HPROF_HEAP_DUMP_END record.
1834   DumperSupport::end_of_dump(writer());
1835 
1836   // Now we clear the global variables, so that a future dumper might run.
1837   clear_global_dumper();
1838   clear_global_writer();
1839 }
1840 
1841 void VM_HeapDumper::dump_stack_traces() {
1842   // write a HPROF_TRACE record without any frames to be referenced as object alloc sites
1843   DumperSupport::write_header(writer(), HPROF_TRACE, 3*sizeof(u4));
1844   writer()->write_u4((u4) STACK_TRACE_ID);




 839         case JVM_SIGNATURE_DOUBLE  : size += 8; break;
 840 
 841         default : ShouldNotReachHere();
 842       }
 843     }
 844   }
 845   return size;
 846 }
 847 
 848 // dumps static fields of the given class
 849 void DumperSupport::dump_static_fields(DumpWriter* writer, Klass* k) {
 850   HandleMark hm;
 851   InstanceKlass* ik = InstanceKlass::cast(k);
 852 
 853   // pass 1 - count the static fields
 854   u2 field_count = 0;
 855   for (FieldStream fldc(ik, true, true); !fldc.eos(); fldc.next()) {
 856     if (fldc.access_flags().is_static()) field_count++;
 857   }
 858 
 859   // Add in resolved_references which is referenced by the cpCache
 860   // The resolved_references is an array per InstanceKlass holding the
 861   // strings and other oops resolved from the constant pool.
 862   oop resolved_references = ik->constants()->resolved_references();
 863   if (resolved_references != NULL) {
 864     field_count++;
 865 
 866     // Add in the resolved_references of the used previous versions of the class
 867     // in the case of RedefineClasses
 868     InstanceKlass* prev = ik->previous_versions();
 869     while (prev != NULL && prev->constants()->resolved_references() != NULL) {
 870       field_count++;
 871       prev = prev->previous_versions();
 872     }
 873   }
 874 
 875   // Also provide a pointer to the init_lock if present, so there aren't unreferenced int[0]
 876   // arrays.
 877   oop init_lock = ik->init_lock();
 878   if (init_lock != NULL) {
 879     field_count++;
 880   }
 881 
 882   writer->write_u2(field_count);
 883 
 884   // pass 2 - dump the field descriptors and raw values
 885   for (FieldStream fld(ik, true, true); !fld.eos(); fld.next()) {
 886     if (fld.access_flags().is_static()) {
 887       Symbol* sig = fld.signature();
 888 
 889       writer->write_symbolID(fld.name());   // name
 890       writer->write_u1(sig2tag(sig));       // type
 891 
 892       // value
 893       int offset = fld.offset();
 894       address addr = (address)ik->java_mirror() + offset;
 895 
 896       dump_field_value(writer, sig->byte_at(0), addr);
 897     }
 898   }
 899 
 900   // Add resolved_references for each class that has them
 901   if (resolved_references != NULL) {
 902     writer->write_symbolID(vmSymbols::resolved_references_name());  // name
 903     writer->write_u1(sig2tag(vmSymbols::object_array_signature())); // type
 904     writer->write_objectID(resolved_references);
 905 
 906     // Also write any previous versions
 907     InstanceKlass* prev = ik->previous_versions();
 908     while (prev != NULL && prev->constants()->resolved_references() != NULL) {
 909       writer->write_symbolID(vmSymbols::resolved_references_name());  // name
 910       writer->write_u1(sig2tag(vmSymbols::object_array_signature())); // type
 911       writer->write_objectID(prev->constants()->resolved_references());
 912       prev = prev->previous_versions();
 913     }
 914   }
 915 
 916   // Add init lock to the end if the class is not yet initialized
 917   if (init_lock != NULL) {
 918     writer->write_symbolID(vmSymbols::init_lock_name());         // name
 919     writer->write_u1(sig2tag(vmSymbols::int_array_signature())); // type
 920     writer->write_objectID(init_lock);
 921   }
 922 }
 923 
 924 // dump the raw values of the instance fields of the given object
 925 void DumperSupport::dump_instance_fields(DumpWriter* writer, oop o) {
 926   HandleMark hm;
 927   InstanceKlass* ik = InstanceKlass::cast(o->klass());
 928 
 929   for (FieldStream fld(ik, false, false); !fld.eos(); fld.next()) {
 930     if (!fld.access_flags().is_static()) {
 931       Symbol* sig = fld.signature();
 932       address addr = (address)o + fld.offset();
 933 
 934       dump_field_value(writer, sig->byte_at(0), addr);
 935     }
 936   }
 937 }
 938 
 939 // dumps the definition of the instance fields for a given class
 940 void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, Klass* k) {
 941   HandleMark hm;


1851   // After each sub-record is written check_segment_length will be invoked
1852   // to check if the current segment exceeds a threshold. If so, a new
1853   // segment is started.
1854   // The HPROF_GC_CLASS_DUMP and HPROF_GC_INSTANCE_DUMP are the vast bulk
1855   // of the heap dump.
1856   HeapObjectDumper obj_dumper(this, writer());
1857   Universe::heap()->safe_object_iterate(&obj_dumper);
1858 
1859   // HPROF_GC_ROOT_THREAD_OBJ + frames + jni locals
1860   do_threads();
1861   check_segment_length();
1862 
1863   // HPROF_GC_ROOT_MONITOR_USED
1864   MonitorUsedDumper mon_dumper(writer());
1865   ObjectSynchronizer::oops_do(&mon_dumper);
1866   check_segment_length();
1867 
1868   // HPROF_GC_ROOT_JNI_GLOBAL
1869   JNIGlobalsDumper jni_dumper(writer());
1870   JNIHandles::oops_do(&jni_dumper);
1871   Universe::oops_do(&jni_dumper);  // technically not jni roots, but global roots
1872                                    // for things like preallocated throwable backtraces
1873   check_segment_length();
1874 
1875   // HPROF_GC_ROOT_STICKY_CLASS
1876   // These should be classes in the NULL class loader data, and not all classes
1877   // if !ClassUnloading
1878   StickyClassDumper class_dumper(writer());
1879   ClassLoaderData::the_null_class_loader_data()->classes_do(&class_dumper);
1880 
1881   // fixes up the length of the dump record and writes the HPROF_HEAP_DUMP_END record.
1882   DumperSupport::end_of_dump(writer());
1883 
1884   // Now we clear the global variables, so that a future dumper might run.
1885   clear_global_dumper();
1886   clear_global_writer();
1887 }
1888 
1889 void VM_HeapDumper::dump_stack_traces() {
1890   // write a HPROF_TRACE record without any frames to be referenced as object alloc sites
1891   DumperSupport::write_header(writer(), HPROF_TRACE, 3*sizeof(u4));
1892   writer()->write_u4((u4) STACK_TRACE_ID);


< prev index next >