OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011, Google Inc. All rights reserved. | 2 * Copyright (c) 2011, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return; | 70 return; |
71 v8::HandleScope handleScope(isolate); | 71 v8::HandleScope handleScope(isolate); |
72 profiler->StartCpuProfiling(v8String(isolate, title), true); | 72 profiler->StartCpuProfiling(v8String(isolate, title), true); |
73 } | 73 } |
74 | 74 |
75 PassRefPtr<ScriptProfile> ScriptProfiler::stop(const String& title) | 75 PassRefPtr<ScriptProfile> ScriptProfiler::stop(const String& title) |
76 { | 76 { |
77 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 77 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
78 v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); | 78 v8::CpuProfiler* profiler = isolate->GetCpuProfiler(); |
79 if (!profiler) | 79 if (!profiler) |
80 return 0; | 80 return nullptr; |
81 v8::HandleScope handleScope(isolate); | 81 v8::HandleScope handleScope(isolate); |
82 const v8::CpuProfile* profile = profiler->StopCpuProfiling(v8String(isolate,
title)); | 82 const v8::CpuProfile* profile = profiler->StopCpuProfiling(v8String(isolate,
title)); |
83 if (!profile) | 83 if (!profile) |
84 return 0; | 84 return nullptr; |
85 | 85 |
86 String profileTitle = toCoreString(profile->GetTitle()); | 86 String profileTitle = toCoreString(profile->GetTitle()); |
87 double idleTime = 0.0; | 87 double idleTime = 0.0; |
88 ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProf
ileNameIdleTimeMap(); | 88 ProfileNameIdleTimeMap* profileNameIdleTimeMap = ScriptProfiler::currentProf
ileNameIdleTimeMap(); |
89 ProfileNameIdleTimeMap::iterator profileIdleTime = profileNameIdleTimeMap->f
ind(profileTitle); | 89 ProfileNameIdleTimeMap::iterator profileIdleTime = profileNameIdleTimeMap->f
ind(profileTitle); |
90 if (profileIdleTime != profileNameIdleTimeMap->end()) { | 90 if (profileIdleTime != profileNameIdleTimeMap->end()) { |
91 idleTime = profileIdleTime->value * 1000.0; | 91 idleTime = profileIdleTime->value * 1000.0; |
92 profileNameIdleTimeMap->remove(profileIdleTime); | 92 profileNameIdleTimeMap->remove(profileIdleTime); |
93 } | 93 } |
94 | 94 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 { | 226 { |
227 v8::Isolate::GetCurrent()->GetHeapProfiler()->StopTrackingHeapObjects(); | 227 v8::Isolate::GetCurrent()->GetHeapProfiler()->StopTrackingHeapObjects(); |
228 } | 228 } |
229 | 229 |
230 // FIXME: This method should receive a ScriptState, from which we should retriev
e an Isolate. | 230 // FIXME: This method should receive a ScriptState, from which we should retriev
e an Isolate. |
231 PassRefPtr<ScriptHeapSnapshot> ScriptProfiler::takeHeapSnapshot(const String& ti
tle, HeapSnapshotProgress* control) | 231 PassRefPtr<ScriptHeapSnapshot> ScriptProfiler::takeHeapSnapshot(const String& ti
tle, HeapSnapshotProgress* control) |
232 { | 232 { |
233 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 233 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
234 v8::HeapProfiler* profiler = isolate->GetHeapProfiler(); | 234 v8::HeapProfiler* profiler = isolate->GetHeapProfiler(); |
235 if (!profiler) | 235 if (!profiler) |
236 return 0; | 236 return nullptr; |
237 v8::HandleScope handleScope(isolate); | 237 v8::HandleScope handleScope(isolate); |
238 ASSERT(control); | 238 ASSERT(control); |
239 ActivityControlAdapter adapter(control); | 239 ActivityControlAdapter adapter(control); |
240 GlobalObjectNameResolver resolver; | 240 GlobalObjectNameResolver resolver; |
241 const v8::HeapSnapshot* snapshot = profiler->TakeHeapSnapshot(v8String(isola
te, title), &adapter, &resolver); | 241 const v8::HeapSnapshot* snapshot = profiler->TakeHeapSnapshot(v8String(isola
te, title), &adapter, &resolver); |
242 return snapshot ? ScriptHeapSnapshot::create(snapshot) : 0; | 242 return snapshot ? ScriptHeapSnapshot::create(snapshot) : nullptr; |
243 } | 243 } |
244 | 244 |
245 static v8::RetainedObjectInfo* retainedDOMInfo(uint16_t classId, v8::Handle<v8::
Value> wrapper) | 245 static v8::RetainedObjectInfo* retainedDOMInfo(uint16_t classId, v8::Handle<v8::
Value> wrapper) |
246 { | 246 { |
247 ASSERT(classId == v8DOMNodeClassId); | 247 ASSERT(classId == v8DOMNodeClassId); |
248 if (!wrapper->IsObject()) | 248 if (!wrapper->IsObject()) |
249 return 0; | 249 return 0; |
250 Node* node = V8Node::toNative(wrapper.As<v8::Object>()); | 250 Node* node = V8Node::toNative(wrapper.As<v8::Object>()); |
251 return node ? new RetainedDOMInfo(node) : 0; | 251 return node ? new RetainedDOMInfo(node) : 0; |
252 } | 252 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 301 } |
302 | 302 |
303 void ScriptProfiler::setIdle(bool isIdle) | 303 void ScriptProfiler::setIdle(bool isIdle) |
304 { | 304 { |
305 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 305 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
306 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler()) | 306 if (v8::CpuProfiler* profiler = isolate->GetCpuProfiler()) |
307 profiler->SetIdle(isIdle); | 307 profiler->SetIdle(isIdle); |
308 } | 308 } |
309 | 309 |
310 } // namespace WebCore | 310 } // namespace WebCore |
OLD | NEW |