Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Side by Side Diff: runtime/vm/heap_profiler.cc

Issue 11881010: - Dump Smi objects into the heap profile. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/heap_profiler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/heap_profiler.h" 5 #include "vm/heap_profiler.h"
6 6
7 #include "vm/dart_api_state.h" 7 #include "vm/dart_api_state.h"
8 #include "vm/object.h" 8 #include "vm/object.h"
9 #include "vm/raw_object.h" 9 #include "vm/raw_object.h"
10 #include "vm/stack_frame.h" 10 #include "vm/stack_frame.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 : write_callback_(callback), 117 : write_callback_(callback),
118 output_stream_(stream), 118 output_stream_(stream),
119 heap_dump_record_(NULL) { 119 heap_dump_record_(NULL) {
120 WriteHeader(); 120 WriteHeader();
121 WriteStackTrace(); 121 WriteStackTrace();
122 heap_dump_record_ = new Record(kHeapDump, this); 122 heap_dump_record_ = new Record(kHeapDump, this);
123 } 123 }
124 124
125 125
126 HeapProfiler::~HeapProfiler() { 126 HeapProfiler::~HeapProfiler() {
127 for (std::set<const RawSmi*>::iterator it = smi_table_.begin();
cshapiro 2013/01/12 02:52:26 You might consider using this idiom... for_each
128 it != smi_table_.end();
129 ++it) {
130 WriteSmiDump(*it);
131 }
127 delete heap_dump_record_; 132 delete heap_dump_record_;
128 } 133 }
129 134
130 135
131 const RawObject* HeapProfiler::ObjectId(const RawObject* raw_obj) { 136 const RawObject* HeapProfiler::ObjectId(const RawObject* raw_obj) {
132 if (!raw_obj->IsHeapObject()) { 137 if (!raw_obj->IsHeapObject()) {
133 // To describe an immediate object in HPROF we record its value 138 // To describe an immediate object in HPROF we record its value
134 // and write fake INSTANCE_DUMP subrecord in the HEAP_DUMP record. 139 // and write fake INSTANCE_DUMP subrecord in the HEAP_DUMP record.
135 const RawSmi* raw_smi = reinterpret_cast<const RawSmi*>(raw_obj); 140 const RawSmi* raw_smi = reinterpret_cast<const RawSmi*>(raw_obj);
136 if (smi_table_.find(raw_smi) == smi_table_.end()) { 141 if (smi_table_.find(raw_smi) == smi_table_.end()) {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 ASSERT(raw_field->ptr()->name_ != String::null()); 564 ASSERT(raw_field->ptr()->name_ != String::null());
560 // field name string ID 565 // field name string ID
561 sub.WriteObjectId(StringId(raw_field->ptr()->name_)); 566 sub.WriteObjectId(StringId(raw_field->ptr()->name_));
562 // type of field 567 // type of field
563 sub.Write8(kObject); 568 sub.Write8(kObject);
564 } 569 }
565 } 570 }
566 } 571 }
567 } 572 }
568 573
574 // INSTANCE DUMP - 0x21
cshapiro 2013/01/12 02:52:26 We probably do not need to repeat this documentati
Ivan Posva 2013/01/14 23:38:42 Done.
575 //
576 // Format:
577 // ID - object ID
578 // u4 - stack trace serial number
579 // ID - class object ID
580 // u4 - number of bytes that follow
581 // [value]* - instance field values (this class, followed by super class, etc)
582 void HeapProfiler::WriteSmiDump(const RawSmi* raw_smi) {
583 ASSERT(!raw_smi->IsHeapObject());
584 SubRecord sub(kInstanceDump, this);
585 // object ID
586 sub.WriteObjectId(raw_smi);
siva 2013/01/14 23:50:13 Since we are writing out smi values as an object i
Ivan Posva 2013/01/14 23:53:38 IDs from the heap profiler dump perspective are th
cshapiro 2013/01/14 23:55:22 It should not. We use an object's address as its
587 // stack trace serial number
588 sub.Write32(0);
589 // class object ID
590 sub.WriteObjectId(Isolate::Current()->class_table()->At(kSmiCid));
591 // number of bytes that follow
592 sub.Write32(0);
593 }
594
569 595
570 // INSTANCE DUMP - 0x21 596 // INSTANCE DUMP - 0x21
571 // 597 //
572 // Format: 598 // Format:
573 // ID - object ID 599 // ID - object ID
574 // u4 - stack trace serial number 600 // u4 - stack trace serial number
575 // ID - class object ID 601 // ID - class object ID
576 // u4 - number of bytes that follow 602 // u4 - number of bytes that follow
577 // [value]* - instance field values (this class, followed by super class, etc) 603 // [value]* - instance field values (this class, followed by super class, etc)
578 void HeapProfiler::WriteInstanceDump(const RawObject* raw_obj) { 604 void HeapProfiler::WriteInstanceDump(const RawObject* raw_obj) {
605 ASSERT(raw_obj->IsHeapObject());
579 SubRecord sub(kInstanceDump, this); 606 SubRecord sub(kInstanceDump, this);
580 // object ID 607 // object ID
581 sub.WriteObjectId(raw_obj); 608 sub.WriteObjectId(raw_obj);
582 // stack trace serial number 609 // stack trace serial number
583 sub.Write32(0); 610 sub.Write32(0);
584 // class object ID 611 // class object ID
585 sub.WriteObjectId(ClassId(GetClass(raw_obj))); 612 sub.WriteObjectId(ClassId(GetClass(raw_obj)));
586 // number of bytes that follow 613 // number of bytes that follow
587 intptr_t num_instance_fields = 0; 614 intptr_t num_instance_fields = 0;
588 for (const RawClass* cls = GetClass(raw_obj); 615 for (const RawClass* cls = GetClass(raw_obj);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 RawObject* raw_obj = handle->raw(); 746 RawObject* raw_obj = handle->raw();
720 visitor_->VisitPointer(&raw_obj); 747 visitor_->VisitPointer(&raw_obj);
721 } 748 }
722 749
723 750
724 void HeapProfilerObjectVisitor::VisitObject(RawObject* raw_obj) { 751 void HeapProfilerObjectVisitor::VisitObject(RawObject* raw_obj) {
725 profiler_->WriteObject(raw_obj); 752 profiler_->WriteObject(raw_obj);
726 } 753 }
727 754
728 } // namespace dart 755 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap_profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698