OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/inspector/V8ProfilerAgentImpl.h" | 5 #include "src/inspector/V8ProfilerAgentImpl.h" |
6 | 6 |
7 #include "src/inspector/Atomics.h" | 7 #include "src/base/atomicops.h" |
8 #include "src/inspector/StringUtil.h" | 8 #include "src/inspector/StringUtil.h" |
9 #include "src/inspector/V8Debugger.h" | 9 #include "src/inspector/V8Debugger.h" |
10 #include "src/inspector/V8InspectorImpl.h" | 10 #include "src/inspector/V8InspectorImpl.h" |
11 #include "src/inspector/V8InspectorSessionImpl.h" | 11 #include "src/inspector/V8InspectorSessionImpl.h" |
12 #include "src/inspector/V8StackTraceImpl.h" | 12 #include "src/inspector/V8StackTraceImpl.h" |
13 #include "src/inspector/protocol/Protocol.h" | 13 #include "src/inspector/protocol/Protocol.h" |
14 | 14 |
15 #include "include/v8-profiler.h" | 15 #include "include/v8-profiler.h" |
16 | 16 |
17 #include <vector> | 17 #include <vector> |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 stopProfiling(m_frontendInitiatedProfileId, !!profile); | 272 stopProfiling(m_frontendInitiatedProfileId, !!profile); |
273 if (profile) { | 273 if (profile) { |
274 *profile = std::move(cpuProfile); | 274 *profile = std::move(cpuProfile); |
275 if (!profile->get() && errorString) *errorString = "Profile is not found"; | 275 if (!profile->get() && errorString) *errorString = "Profile is not found"; |
276 } | 276 } |
277 m_frontendInitiatedProfileId = String16(); | 277 m_frontendInitiatedProfileId = String16(); |
278 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); | 278 m_state->setBoolean(ProfilerAgentState::userInitiatedProfiling, false); |
279 } | 279 } |
280 | 280 |
281 String16 V8ProfilerAgentImpl::nextProfileId() { | 281 String16 V8ProfilerAgentImpl::nextProfileId() { |
282 return String16::fromInteger(atomicIncrement(&s_lastProfileId)); | 282 return String16::fromInteger( |
| 283 v8::base::NoBarrier_AtomicIncrement(&s_lastProfileId, 1)); |
283 } | 284 } |
284 | 285 |
285 void V8ProfilerAgentImpl::startProfiling(const String16& title) { | 286 void V8ProfilerAgentImpl::startProfiling(const String16& title) { |
286 v8::HandleScope handleScope(m_isolate); | 287 v8::HandleScope handleScope(m_isolate); |
287 m_profiler->StartProfiling(toV8String(m_isolate, title), true); | 288 m_profiler->StartProfiling(toV8String(m_isolate, title), true); |
288 } | 289 } |
289 | 290 |
290 std::unique_ptr<protocol::Profiler::Profile> V8ProfilerAgentImpl::stopProfiling( | 291 std::unique_ptr<protocol::Profiler::Profile> V8ProfilerAgentImpl::stopProfiling( |
291 const String16& title, bool serialize) { | 292 const String16& title, bool serialize) { |
292 v8::HandleScope handleScope(m_isolate); | 293 v8::HandleScope handleScope(m_isolate); |
293 v8::CpuProfile* profile = | 294 v8::CpuProfile* profile = |
294 m_profiler->StopProfiling(toV8String(m_isolate, title)); | 295 m_profiler->StopProfiling(toV8String(m_isolate, title)); |
295 if (!profile) return nullptr; | 296 if (!profile) return nullptr; |
296 std::unique_ptr<protocol::Profiler::Profile> result; | 297 std::unique_ptr<protocol::Profiler::Profile> result; |
297 if (serialize) result = createCPUProfile(m_isolate, profile); | 298 if (serialize) result = createCPUProfile(m_isolate, profile); |
298 profile->Delete(); | 299 profile->Delete(); |
299 return result; | 300 return result; |
300 } | 301 } |
301 | 302 |
302 bool V8ProfilerAgentImpl::isRecording() const { | 303 bool V8ProfilerAgentImpl::isRecording() const { |
303 return m_recordingCPUProfile || !m_startedProfiles.empty(); | 304 return m_recordingCPUProfile || !m_startedProfiles.empty(); |
304 } | 305 } |
305 | 306 |
306 } // namespace v8_inspector | 307 } // namespace v8_inspector |
OLD | NEW |