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

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: Fix style + rebase Created 7 years, 2 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 | « src/heap-profiler.h ('k') | src/heap-snapshot-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "deoptimizer.h"
30 #include "heap-profiler.h" 31 #include "heap-profiler.h"
31 #include "heap-snapshot-generator-inl.h" 32 #include "heap-snapshot-generator-inl.h"
32 33
33 namespace v8 { 34 namespace v8 {
34 namespace internal { 35 namespace internal {
35 36
36 HeapProfiler::HeapProfiler(Heap* heap) 37 HeapProfiler::HeapProfiler(Heap* heap)
37 : snapshots_(new HeapSnapshotsCollection(heap)), 38 : snapshots_(new HeapSnapshotsCollection(heap)),
38 next_snapshot_uid_(1) { 39 next_snapshot_uid_(1),
40 is_tracking_allocations_(false) {
39 } 41 }
40 42
41 43
42 HeapProfiler::~HeapProfiler() { 44 HeapProfiler::~HeapProfiler() {
43 delete snapshots_; 45 delete snapshots_;
44 } 46 }
45 47
46 48
47 void HeapProfiler::DeleteAllSnapshots() { 49 void HeapProfiler::DeleteAllSnapshots() {
48 Heap* the_heap = heap(); 50 Heap* the_heap = heap();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 127 }
126 128
127 129
128 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Object> obj) { 130 SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Object> obj) {
129 if (!obj->IsHeapObject()) 131 if (!obj->IsHeapObject())
130 return v8::HeapProfiler::kUnknownObjectId; 132 return v8::HeapProfiler::kUnknownObjectId;
131 return snapshots_->FindObjectId(HeapObject::cast(*obj)->address()); 133 return snapshots_->FindObjectId(HeapObject::cast(*obj)->address());
132 } 134 }
133 135
134 136
135 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { 137 void HeapProfiler::ObjectMoveEvent(Address from, Address to, int size) {
136 snapshots_->ObjectMoveEvent(from, to); 138 snapshots_->ObjectMoveEvent(from, to, size);
137 } 139 }
138 140
141
142 void HeapProfiler::NewObjectEvent(Address addr, int size) {
143 snapshots_->NewObjectEvent(addr, size);
144 }
145
146
147 void HeapProfiler::UpdateObjectSizeEvent(Address addr, int size) {
148 snapshots_->UpdateObjectSizeEvent(addr, size);
149 }
150
151
139 void HeapProfiler::SetRetainedObjectInfo(UniqueId id, 152 void HeapProfiler::SetRetainedObjectInfo(UniqueId id,
140 RetainedObjectInfo* info) { 153 RetainedObjectInfo* info) {
141 // TODO(yurus, marja): Don't route this information through GlobalHandles. 154 // TODO(yurus, marja): Don't route this information through GlobalHandles.
142 heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info); 155 heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info);
143 } 156 }
144 157
158
159 void HeapProfiler::StartHeapAllocationsRecording() {
160 StartHeapObjectsTracking();
161 is_tracking_allocations_ = true;
162 DropCompiledCode();
163 snapshots_->UpdateHeapObjectsMap();
164 }
165
166
167 void HeapProfiler::StopHeapAllocationsRecording() {
168 StopHeapObjectsTracking();
169 is_tracking_allocations_ = false;
170 DropCompiledCode();
171 }
172
173
174 void HeapProfiler::RecordObjectAllocationFromMasm(Isolate* isolate,
175 Address obj,
176 int size) {
177 isolate->heap_profiler()->NewObjectEvent(obj, size);
178 }
179
180
181 void HeapProfiler::DropCompiledCode() {
182 Isolate* isolate = heap()->isolate();
183 HandleScope scope(isolate);
184
185 if (FLAG_concurrent_recompilation) {
186 isolate->optimizing_compiler_thread()->Flush();
187 }
188
189 Deoptimizer::DeoptimizeAll(isolate);
190
191 Handle<Code> lazy_compile =
192 Handle<Code>(isolate->builtins()->builtin(Builtins::kLazyCompile));
193
194 heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask,
195 "switch allocations tracking");
196
197 DisallowHeapAllocation no_allocation;
198
199 HeapIterator iterator(heap());
200 HeapObject* obj = NULL;
201 while (((obj = iterator.next()) != NULL)) {
202 if (obj->IsJSFunction()) {
203 JSFunction* function = JSFunction::cast(obj);
204 SharedFunctionInfo* shared = function->shared();
205
206 if (!shared->allows_lazy_compilation()) continue;
207 if (!shared->script()->IsScript()) continue;
208
209 Code::Kind kind = function->code()->kind();
210 if (kind == Code::FUNCTION || kind == Code::BUILTIN) {
211 function->set_code(*lazy_compile);
212 shared->set_code(*lazy_compile);
213 }
214 }
215 }
216 }
217
218
145 } } // namespace v8::internal 219 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-profiler.h ('k') | src/heap-snapshot-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698