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

Side by Side Diff: src/heap-profiler.cc

Issue 22852024: Track JS allocations as they arrive with no affection on performance when tracking is switched off (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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
OLDNEW
1 // Copyright 2009-2010 the V8 project authors. All rights reserved. 1 // Copyright 2009-2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 17 matching lines...) Expand all
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "heap-profiler.h" 30 #include "heap-profiler.h"
31 #include "heap-snapshot-generator-inl.h" 31 #include "heap-snapshot-generator-inl.h"
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 HeapProfiler::HeapProfiler(Heap* heap) 36 HeapProfiler::HeapProfiler(Heap* heap)
37 : snapshots_(new HeapSnapshotsCollection(heap)), 37 : snapshots_(new HeapSnapshotsCollection(heap)),
38 next_snapshot_uid_(1) { 38 next_snapshot_uid_(1),
39 is_tracking_allocations_(false) {
39 } 40 }
40 41
41 42
42 HeapProfiler::~HeapProfiler() { 43 HeapProfiler::~HeapProfiler() {
43 delete snapshots_; 44 delete snapshots_;
44 } 45 }
45 46
46 47
47 void HeapProfiler::DeleteAllSnapshots() { 48 void HeapProfiler::DeleteAllSnapshots() {
48 Heap* the_heap = heap(); 49 Heap* the_heap = heap();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 90
90 HeapSnapshot* HeapProfiler::TakeSnapshot( 91 HeapSnapshot* HeapProfiler::TakeSnapshot(
91 String* name, 92 String* name,
92 v8::ActivityControl* control, 93 v8::ActivityControl* control,
93 v8::HeapProfiler::ObjectNameResolver* resolver) { 94 v8::HeapProfiler::ObjectNameResolver* resolver) {
94 return TakeSnapshot(snapshots_->names()->GetName(name), control, resolver); 95 return TakeSnapshot(snapshots_->names()->GetName(name), control, resolver);
95 } 96 }
96 97
97 98
98 void HeapProfiler::StartHeapObjectsTracking() { 99 void HeapProfiler::StartHeapObjectsTracking() {
100 is_tracking_allocations_ = true;
99 snapshots_->StartHeapObjectsTracking(); 101 snapshots_->StartHeapObjectsTracking();
100 } 102 }
101 103
102 104
103 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) { 105 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) {
104 return snapshots_->PushHeapObjectsStats(stream); 106 return snapshots_->PushHeapObjectsStats(stream);
105 } 107 }
106 108
107 109
108 void HeapProfiler::StopHeapObjectsTracking() { 110 void HeapProfiler::StopHeapObjectsTracking() {
109 snapshots_->StopHeapObjectsTracking(); 111 snapshots_->StopHeapObjectsTracking();
112 is_tracking_allocations_ = false;
110 } 113 }
111 114
112 115
113 size_t HeapProfiler::GetMemorySizeUsedByProfiler() { 116 size_t HeapProfiler::GetMemorySizeUsedByProfiler() {
114 return snapshots_->GetUsedMemorySize(); 117 return snapshots_->GetUsedMemorySize();
115 } 118 }
116 119
117 120
118 int HeapProfiler::GetSnapshotsCount() { 121 int HeapProfiler::GetSnapshotsCount() {
119 return snapshots_->snapshots()->length(); 122 return snapshots_->snapshots()->length();
120 } 123 }
121 124
122 125
123 HeapSnapshot* HeapProfiler::GetSnapshot(int index) { 126 HeapSnapshot* HeapProfiler::GetSnapshot(int index) {
124 return snapshots_->snapshots()->at(index); 127 return snapshots_->snapshots()->at(index);
125 } 128 }
126 129
127 130
128 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Object> obj) { 131 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Object> obj) {
129 if (!obj->IsHeapObject()) 132 if (!obj->IsHeapObject())
130 return v8::HeapProfiler::kUnknownObjectId; 133 return v8::HeapProfiler::kUnknownObjectId;
131 return snapshots_->FindObjectId(HeapObject::cast(*obj)->address()); 134 return snapshots_->FindObjectId(HeapObject::cast(*obj)->address());
132 } 135 }
133 136
134 137
135 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { 138 void HeapProfiler::ObjectMoveEvent(Address from, Address to, int size) {
136 snapshots_->ObjectMoveEvent(from, to); 139 snapshots_->ObjectMoveEvent(from, to, size);
137 } 140 }
138 141
142
143 void HeapProfiler::NewObjectEvent(Address addr, int size) {
144 snapshots_->NewObjectEvent(addr, size);
145 }
146
147
139 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, 148 void HeapProfiler::SetRetainedObjectInfo(UniqueId id,
140 RetainedObjectInfo* info) { 149 RetainedObjectInfo* info) {
141 // TODO(yurus, marja): Don't route this information through GlobalHandles. 150 // TODO(yurus, marja): Don't route this information through GlobalHandles.
142 heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info); 151 heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info);
143 } 152 }
144 153
154
155 bool* HeapProfiler::is_tracking_allocations_address() {
156 return &is_tracking_allocations_;
157 }
158
159
160 void HeapProfiler::RecordObjectAllocationFromMasm(Isolate* isolate,
161 Address obj,
162 int size) {
163 isolate->heap_profiler()->NewObjectEvent(obj, size);
164 }
165
166
167 int HeapProfiler::FindUntrackedObjects() {
168 return snapshots_->FindUntrackedObjects();
169 }
170
171
145 } } // namespace v8::internal 172 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698