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

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: Make separate API for JS allocations recording, add example of checking JS allocations recording in… Created 7 years, 3 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 126 }
126 127
127 128
128 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Object> obj) { 129 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Object> obj) {
129 if (!obj->IsHeapObject()) 130 if (!obj->IsHeapObject())
130 return v8::HeapProfiler::kUnknownObjectId; 131 return v8::HeapProfiler::kUnknownObjectId;
131 return snapshots_->FindObjectId(HeapObject::cast(*obj)->address()); 132 return snapshots_->FindObjectId(HeapObject::cast(*obj)->address());
132 } 133 }
133 134
134 135
135 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { 136 void HeapProfiler::ObjectMoveEvent(Address from, Address to, int size) {
136 snapshots_->ObjectMoveEvent(from, to); 137 snapshots_->ObjectMoveEvent(from, to, size);
137 } 138 }
138 139
140
141 void HeapProfiler::NewObjectEvent(Address addr, int size) {
142 snapshots_->NewObjectEvent(addr, size);
143 }
144
145
139 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, 146 void HeapProfiler::SetRetainedObjectInfo(UniqueId id,
140 RetainedObjectInfo* info) { 147 RetainedObjectInfo* info) {
141 // TODO(yurus, marja): Don't route this information through GlobalHandles. 148 // TODO(yurus, marja): Don't route this information through GlobalHandles.
142 heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info); 149 heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info);
143 } 150 }
144 151
152
153 bool* HeapProfiler::is_tracking_allocations_address() {
154 return &is_tracking_allocations_;
155 }
156
157
158 void HeapProfiler::StartHeapAllocationsRecording() {
159 StartHeapObjectsTracking();
160 is_tracking_allocations_ = true;
161 }
162
163
164 void HeapProfiler::StopHeapAllocationsRecording() {
165 StopHeapObjectsTracking();
166 is_tracking_allocations_ = false;
167 }
168
169
170 void HeapProfiler::RecordObjectAllocationFromMasm(Isolate* isolate,
171 Address obj,
172 int size) {
173 isolate->heap_profiler()->NewObjectEvent(obj, size);
174 }
175
176
177 int HeapProfiler::FindUntrackedObjects() {
178 return snapshots_->FindUntrackedObjects();
179 }
180
181
145 } } // namespace v8::internal 182 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698