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

Side by Side Diff: Source/bindings/common/StackTrace.cpp

Issue 466243002: Support merged Dart-JS callstacks (Closed) Base URL: svn://svn.chromium.org/blink/branches/dart/dartium
Patch Set: Created 6 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
(Empty)
1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "bindings/common/StackTrace.h"
33
34 namespace WebCore {
35
36 StackTrace::StackTrace() :
37 m_hasJavaScript(false),
38 m_hasDart(false),
39 m_dartStackTrace(0),
40 m_v8ScriptState(0),
41 m_dartScriptState(0)
42 {
43 }
44
45 StackTrace::StackTrace(const StackTrace& javaScriptStackTrace, const StackTrace& dartStackTrace)
46 {
47 ASSERT(!javaScriptStackTrace.hasDart() && !dartStackTrace.hasJavaScript());
48
49 if (javaScriptStackTrace.hasJavaScript()) {
50 m_hasJavaScript = true;
51 m_scriptValue = javaScriptStackTrace.asJavaScript();
52 m_v8ScriptState = javaScriptStackTrace.v8ScriptState();
53 } else {
54 m_hasJavaScript = false;
55 m_v8ScriptState = 0;
56 }
57
58 if (dartStackTrace.hasDart()) {
59 m_hasDart = true;
60 m_dartStackTrace = dartStackTrace.asDart();
61 m_dartScriptState = dartStackTrace.dartScriptState();
62 } else {
63 m_hasDart = false;
64 m_dartStackTrace = 0;
65 m_dartScriptState = 0;
66 }
67 }
68
69 StackTrace::StackTrace(const ScriptValue& stackTrace, V8ScriptState* v8ScriptSta te) :
70 m_hasJavaScript(!stackTrace.isEmpty()),
71 m_hasDart(false),
72 m_scriptValue(stackTrace),
73 m_dartStackTrace(0),
74 m_v8ScriptState(v8ScriptState),
75 m_dartScriptState(0)
76 {
77 }
78
79 StackTrace::StackTrace(Dart_StackTrace stackTrace, DartScriptState* dartScriptSt ate) :
80 m_hasJavaScript(false),
81 m_hasDart(!!stackTrace),
82 m_dartStackTrace(stackTrace),
83 m_v8ScriptState(0),
84 m_dartScriptState(dartScriptState)
85 {
86 }
87
88 StackTraceTimestamp::StackTraceTimestamp(size_t stackDepth) : m_stackDepth(stack Depth)
89 {
90 DEFINE_STATIC_LOCAL(int64_t, nextTimestamp, (0));
91 m_timestamp = ++nextTimestamp;
92 }
93
94 int64_t StackTraceTimestampTracker::getTimestamp(size_t frame)
vsm 2014/08/13 14:26:45 Can you add a comment here? Not really grokking w
Jacob 2014/08/13 21:36:15 Done.
95 {
96 ASSERT(!m_samples.isEmpty());
97 if (m_samples.isEmpty())
98 return 0;
99
100 // m_samples.size() will typically be less than 3 and will be at most
101 // kMaxRecursionDepth (20) so binary search isn't needed.
102 size_t i = 1;
103 while (i < m_samples.size() && m_samples[i].stackDepth() <= frame)
104 i++;
105 return m_samples[i-1].timestamp();
106 }
107
108 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698