1.1 --- a/src/share/vm/services/heapDumper.cpp Fri Aug 31 16:39:35 2012 -0700 1.2 +++ b/src/share/vm/services/heapDumper.cpp Sat Sep 01 13:25:18 2012 -0400 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -608,7 +608,7 @@ 1.11 static hprofTag type2tag(BasicType type); 1.12 1.13 // returns the size of the instance of the given class 1.14 - static u4 instance_size(klassOop k); 1.15 + static u4 instance_size(Klass* k); 1.16 1.17 // dump a jfloat 1.18 static void dump_float(DumpWriter* writer, jfloat f); 1.19 @@ -617,26 +617,26 @@ 1.20 // dumps the raw value of the given field 1.21 static void dump_field_value(DumpWriter* writer, char type, address addr); 1.22 // dumps static fields of the given class 1.23 - static void dump_static_fields(DumpWriter* writer, klassOop k); 1.24 + static void dump_static_fields(DumpWriter* writer, Klass* k); 1.25 // dump the raw values of the instance fields of the given object 1.26 static void dump_instance_fields(DumpWriter* writer, oop o); 1.27 // dumps the definition of the instance fields for a given class 1.28 - static void dump_instance_field_descriptors(DumpWriter* writer, klassOop k); 1.29 + static void dump_instance_field_descriptors(DumpWriter* writer, Klass* k); 1.30 // creates HPROF_GC_INSTANCE_DUMP record for the given object 1.31 static void dump_instance(DumpWriter* writer, oop o); 1.32 // creates HPROF_GC_CLASS_DUMP record for the given class and each of its 1.33 // array classes 1.34 - static void dump_class_and_array_classes(DumpWriter* writer, klassOop k); 1.35 + static void dump_class_and_array_classes(DumpWriter* writer, Klass* k); 1.36 // creates HPROF_GC_CLASS_DUMP record for a given primitive array 1.37 // class (and each multi-dimensional array class too) 1.38 - static void dump_basic_type_array_class(DumpWriter* writer, klassOop k); 1.39 + static void dump_basic_type_array_class(DumpWriter* writer, Klass* k); 1.40 1.41 // creates HPROF_GC_OBJ_ARRAY_DUMP record for the given object array 1.42 static void dump_object_array(DumpWriter* writer, objArrayOop array); 1.43 // creates HPROF_GC_PRIM_ARRAY_DUMP record for the given type array 1.44 static void dump_prim_array(DumpWriter* writer, typeArrayOop array); 1.45 // create HPROF_FRAME record for the given method and bci 1.46 - static void dump_stack_frame(DumpWriter* writer, int frame_serial_num, int class_serial_num, methodOop m, int bci); 1.47 + static void dump_stack_frame(DumpWriter* writer, int frame_serial_num, int class_serial_num, Method* m, int bci); 1.48 }; 1.49 1.50 // write a header of the given type 1.51 @@ -719,17 +719,8 @@ 1.52 } 1.53 1.54 // reflection and sun.misc.Unsafe classes may have a reference to a 1.55 - // klassOop so filter it out. 1.56 - if (o != NULL && o->is_klass()) { 1.57 - o = NULL; 1.58 - } 1.59 - 1.60 - // FIXME: When sharing is enabled we don't emit field references to objects 1.61 - // in shared spaces. We can remove this once we write records for the classes 1.62 - // and strings that are shared. 1.63 - if (o != NULL && o->is_shared()) { 1.64 - o = NULL; 1.65 - } 1.66 + // Klass* so filter it out. 1.67 + assert(o->is_oop_or_null(), "should always be an oop"); 1.68 writer->write_objectID(o); 1.69 break; 1.70 } 1.71 @@ -778,7 +769,7 @@ 1.72 } 1.73 1.74 // returns the size of the instance of the given class 1.75 -u4 DumperSupport::instance_size(klassOop k) { 1.76 +u4 DumperSupport::instance_size(Klass* k) { 1.77 HandleMark hm; 1.78 instanceKlassHandle ikh = instanceKlassHandle(Thread::current(), k); 1.79 1.80 @@ -811,7 +802,7 @@ 1.81 } 1.82 1.83 // dumps static fields of the given class 1.84 -void DumperSupport::dump_static_fields(DumpWriter* writer, klassOop k) { 1.85 +void DumperSupport::dump_static_fields(DumpWriter* writer, Klass* k) { 1.86 HandleMark hm; 1.87 instanceKlassHandle ikh = instanceKlassHandle(Thread::current(), k); 1.88 1.89 @@ -856,7 +847,7 @@ 1.90 } 1.91 1.92 // dumps the definition of the instance fields for a given class 1.93 -void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, klassOop k) { 1.94 +void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, Klass* k) { 1.95 HandleMark hm; 1.96 instanceKlassHandle ikh = instanceKlassHandle(Thread::current(), k); 1.97 1.98 @@ -881,7 +872,7 @@ 1.99 1.100 // creates HPROF_GC_INSTANCE_DUMP record for the given object 1.101 void DumperSupport::dump_instance(DumpWriter* writer, oop o) { 1.102 - klassOop k = o->klass(); 1.103 + Klass* k = o->klass(); 1.104 1.105 writer->write_u1(HPROF_GC_INSTANCE_DUMP); 1.106 writer->write_objectID(o); 1.107 @@ -899,10 +890,10 @@ 1.108 1.109 // creates HPROF_GC_CLASS_DUMP record for the given class and each of 1.110 // its array classes 1.111 -void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, klassOop k) { 1.112 +void DumperSupport::dump_class_and_array_classes(DumpWriter* writer, Klass* k) { 1.113 Klass* klass = Klass::cast(k); 1.114 - assert(klass->oop_is_instance(), "not an instanceKlass"); 1.115 - instanceKlass* ik = (instanceKlass*)klass; 1.116 + assert(klass->oop_is_instance(), "not an InstanceKlass"); 1.117 + InstanceKlass* ik = (InstanceKlass*)klass; 1.118 1.119 writer->write_u1(HPROF_GC_CLASS_DUMP); 1.120 1.121 @@ -911,9 +902,9 @@ 1.122 writer->write_u4(STACK_TRACE_ID); 1.123 1.124 // super class ID 1.125 - klassOop java_super = ik->java_super(); 1.126 + Klass* java_super = ik->java_super(); 1.127 if (java_super == NULL) { 1.128 - writer->write_objectID(NULL); 1.129 + writer->write_objectID(oop(NULL)); 1.130 } else { 1.131 writer->write_classID(Klass::cast(java_super)); 1.132 } 1.133 @@ -923,8 +914,8 @@ 1.134 writer->write_objectID(ik->protection_domain()); 1.135 1.136 // reserved 1.137 - writer->write_objectID(NULL); 1.138 - writer->write_objectID(NULL); 1.139 + writer->write_objectID(oop(NULL)); 1.140 + writer->write_objectID(oop(NULL)); 1.141 1.142 // instance size 1.143 writer->write_u4(DumperSupport::instance_size(k)); 1.144 @@ -957,8 +948,8 @@ 1.145 writer->write_objectID(ik->signers()); 1.146 writer->write_objectID(ik->protection_domain()); 1.147 1.148 - writer->write_objectID(NULL); // reserved 1.149 - writer->write_objectID(NULL); 1.150 + writer->write_objectID(oop(NULL)); // reserved 1.151 + writer->write_objectID(oop(NULL)); 1.152 writer->write_u4(0); // instance size 1.153 writer->write_u2(0); // constant pool 1.154 writer->write_u2(0); // static fields 1.155 @@ -971,7 +962,7 @@ 1.156 1.157 // creates HPROF_GC_CLASS_DUMP record for a given primitive array 1.158 // class (and each multi-dimensional array class too) 1.159 -void DumperSupport::dump_basic_type_array_class(DumpWriter* writer, klassOop k) { 1.160 +void DumperSupport::dump_basic_type_array_class(DumpWriter* writer, Klass* k) { 1.161 // array classes 1.162 while (k != NULL) { 1.163 Klass* klass = Klass::cast(k); 1.164 @@ -981,16 +972,16 @@ 1.165 writer->write_u4(STACK_TRACE_ID); 1.166 1.167 // super class of array classes is java.lang.Object 1.168 - klassOop java_super = klass->java_super(); 1.169 + Klass* java_super = klass->java_super(); 1.170 assert(java_super != NULL, "checking"); 1.171 writer->write_classID(Klass::cast(java_super)); 1.172 1.173 - writer->write_objectID(NULL); // loader 1.174 - writer->write_objectID(NULL); // signers 1.175 - writer->write_objectID(NULL); // protection domain 1.176 + writer->write_objectID(oop(NULL)); // loader 1.177 + writer->write_objectID(oop(NULL)); // signers 1.178 + writer->write_objectID(oop(NULL)); // protection domain 1.179 1.180 - writer->write_objectID(NULL); // reserved 1.181 - writer->write_objectID(NULL); 1.182 + writer->write_objectID(oop(NULL)); // reserved 1.183 + writer->write_objectID(oop(NULL)); 1.184 writer->write_u4(0); // instance size 1.185 writer->write_u2(0); // constant pool 1.186 writer->write_u2(0); // static fields 1.187 @@ -1004,9 +995,6 @@ 1.188 // creates HPROF_GC_OBJ_ARRAY_DUMP record for the given object array 1.189 void DumperSupport::dump_object_array(DumpWriter* writer, objArrayOop array) { 1.190 1.191 - // filter this 1.192 - if (array->klass() == Universe::systemObjArrayKlassObj()) return; 1.193 - 1.194 writer->write_u1(HPROF_GC_OBJ_ARRAY_DUMP); 1.195 writer->write_objectID(array); 1.196 writer->write_u4(STACK_TRACE_ID); 1.197 @@ -1111,11 +1099,11 @@ 1.198 } 1.199 } 1.200 1.201 -// create a HPROF_FRAME record of the given methodOop and bci 1.202 +// create a HPROF_FRAME record of the given Method* and bci 1.203 void DumperSupport::dump_stack_frame(DumpWriter* writer, 1.204 int frame_serial_num, 1.205 int class_serial_num, 1.206 - methodOop m, 1.207 + Method* m, 1.208 int bci) { 1.209 int line_number; 1.210 if (m->is_native()) { 1.211 @@ -1129,8 +1117,8 @@ 1.212 writer->write_symbolID(m->name()); // method's name 1.213 writer->write_symbolID(m->signature()); // method's signature 1.214 1.215 - assert(Klass::cast(m->method_holder())->oop_is_instance(), "not instanceKlass"); 1.216 - writer->write_symbolID(instanceKlass::cast(m->method_holder())->source_file_name()); // source file name 1.217 + assert(Klass::cast(m->method_holder())->oop_is_instance(), "not InstanceKlass"); 1.218 + writer->write_symbolID(InstanceKlass::cast(m->method_holder())->source_file_name()); // source file name 1.219 writer->write_u4(class_serial_num); // class serial number 1.220 writer->write_u4((u4) line_number); // line number 1.221 } 1.222 @@ -1242,7 +1230,7 @@ 1.223 1.224 // Support class used to generate HPROF_GC_ROOT_STICKY_CLASS records 1.225 1.226 -class StickyClassDumper : public OopClosure { 1.227 +class StickyClassDumper : public KlassClosure { 1.228 private: 1.229 DumpWriter* _writer; 1.230 DumpWriter* writer() const { return _writer; } 1.231 @@ -1250,23 +1238,14 @@ 1.232 StickyClassDumper(DumpWriter* writer) { 1.233 _writer = writer; 1.234 } 1.235 - void do_oop(oop* obj_p); 1.236 - void do_oop(narrowOop* obj_p) { ShouldNotReachHere(); } 1.237 -}; 1.238 - 1.239 -void StickyClassDumper::do_oop(oop* obj_p) { 1.240 - if (*obj_p != NULL) { 1.241 - oop o = *obj_p; 1.242 - if (o->is_klass()) { 1.243 - klassOop k = klassOop(o); 1.244 - if (Klass::cast(k)->oop_is_instance()) { 1.245 - instanceKlass* ik = instanceKlass::cast(k); 1.246 + void do_klass(Klass* k) { 1.247 + if (k->oop_is_instance()) { 1.248 + InstanceKlass* ik = InstanceKlass::cast(k); 1.249 writer()->write_u1(HPROF_GC_ROOT_STICKY_CLASS); 1.250 writer()->write_classID(ik); 1.251 } 1.252 } 1.253 - } 1.254 -} 1.255 +}; 1.256 1.257 1.258 class VM_HeapDumper; 1.259 @@ -1298,9 +1277,6 @@ 1.260 // hide the sentinel for deleted handles 1.261 if (o == JNIHandles::deleted_handle()) return; 1.262 1.263 - // ignore KlassKlass objects 1.264 - if (o->is_klass()) return; 1.265 - 1.266 // skip classes as these emitted as HPROF_GC_CLASS_DUMP records 1.267 if (o->klass() == SystemDictionary::Class_klass()) { 1.268 if (!java_lang_Class::is_primitive(o)) { 1.269 @@ -1334,7 +1310,7 @@ 1.270 static DumpWriter* _global_writer; 1.271 DumpWriter* _local_writer; 1.272 JavaThread* _oome_thread; 1.273 - methodOop _oome_constructor; 1.274 + Method* _oome_constructor; 1.275 bool _gc_before_heap_dump; 1.276 bool _is_segmented_dump; 1.277 jlong _dump_start; 1.278 @@ -1364,15 +1340,15 @@ 1.279 bool skip_operation() const; 1.280 1.281 // writes a HPROF_LOAD_CLASS record 1.282 - static void do_load_class(klassOop k); 1.283 + static void do_load_class(Klass* k); 1.284 1.285 // writes a HPROF_GC_CLASS_DUMP record for the given class 1.286 // (and each array class too) 1.287 - static void do_class_dump(klassOop k); 1.288 + static void do_class_dump(Klass* k); 1.289 1.290 // writes a HPROF_GC_CLASS_DUMP records for a given basic type 1.291 // array (and each multi-dimensional array too) 1.292 - static void do_basic_type_array_class_dump(klassOop k); 1.293 + static void do_basic_type_array_class_dump(Klass* k); 1.294 1.295 // HPROF_GC_ROOT_THREAD_OBJ records 1.296 int do_thread(JavaThread* thread, u4 thread_serial_num); 1.297 @@ -1411,7 +1387,7 @@ 1.298 if (oome) { 1.299 assert(!Thread::current()->is_VM_thread(), "Dump from OutOfMemoryError cannot be called by the VMThread"); 1.300 // get OutOfMemoryError zero-parameter constructor 1.301 - instanceKlass* oome_ik = instanceKlass::cast(SystemDictionary::OutOfMemoryError_klass()); 1.302 + InstanceKlass* oome_ik = InstanceKlass::cast(SystemDictionary::OutOfMemoryError_klass()); 1.303 _oome_constructor = oome_ik->find_method(vmSymbols::object_initializer_name(), 1.304 vmSymbols::void_method_signature()); 1.305 // get thread throwing OOME when generating the heap dump at OOME 1.306 @@ -1535,7 +1511,7 @@ 1.307 1.308 // writes a HPROF_LOAD_CLASS record for the class (and each of its 1.309 // array classes) 1.310 -void VM_HeapDumper::do_load_class(klassOop k) { 1.311 +void VM_HeapDumper::do_load_class(Klass* k) { 1.312 static u4 class_serial_num = 0; 1.313 1.314 // len of HPROF_LOAD_CLASS record 1.315 @@ -1552,7 +1528,7 @@ 1.316 Klass* klass = Klass::cast(k); 1.317 writer()->write_classID(klass); 1.318 1.319 - // add the klassOop and class serial number pair 1.320 + // add the Klass* and class serial number pair 1.321 dumper()->add_class_serial_number(klass, class_serial_num); 1.322 1.323 writer()->write_u4(STACK_TRACE_ID); 1.324 @@ -1567,13 +1543,13 @@ 1.325 } 1.326 1.327 // writes a HPROF_GC_CLASS_DUMP record for the given class 1.328 -void VM_HeapDumper::do_class_dump(klassOop k) { 1.329 +void VM_HeapDumper::do_class_dump(Klass* k) { 1.330 DumperSupport::dump_class_and_array_classes(writer(), k); 1.331 } 1.332 1.333 // writes a HPROF_GC_CLASS_DUMP records for a given basic type 1.334 // array (and each multi-dimensional array too) 1.335 -void VM_HeapDumper::do_basic_type_array_class_dump(klassOop k) { 1.336 +void VM_HeapDumper::do_basic_type_array_class_dump(Klass* k) { 1.337 DumperSupport::dump_basic_type_array_class(writer(), k); 1.338 } 1.339 1.340 @@ -1785,7 +1761,7 @@ 1.341 1.342 // HPROF_GC_ROOT_STICKY_CLASS 1.343 StickyClassDumper class_dumper(writer()); 1.344 - SystemDictionary::always_strong_oops_do(&class_dumper); 1.345 + SystemDictionary::always_strong_classes_do(&class_dumper); 1.346 1.347 // fixes up the length of the dump record. In the case of a segmented 1.348 // heap then the HPROF_HEAP_DUMP_END record is also written. 1.349 @@ -1829,7 +1805,7 @@ 1.350 } 1.351 for (int j=0; j < depth; j++) { 1.352 StackFrameInfo* frame = stack_trace->stack_frame_at(j); 1.353 - methodOop m = frame->method(); 1.354 + Method* m = frame->method(); 1.355 int class_serial_num = _klass_map->find(Klass::cast(m->method_holder())); 1.356 // the class serial number starts from 1 1.357 assert(class_serial_num > 0, "class not found");