OLD | NEW |
---|---|
(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 void StackTrace::merge(const StackTrace& other) | |
89 { | |
90 if (other.hasJavaScript()) { | |
91 m_hasJavaScript = true; | |
92 m_scriptValue = other.asJavaScript(); | |
93 m_v8ScriptState = other.v8ScriptState(); | |
vsm
2014/08/29 08:42:07
What if this StackTrace already hasJavaScript with
Jacob
2014/09/05 23:35:55
Rolled back the changes that made StackTrace confu
| |
94 } | |
95 | |
96 if (other.hasDart()) { | |
97 m_hasDart = true; | |
98 m_dartStackTrace = other.asDart(); | |
99 m_dartScriptState = other.dartScriptState(); | |
vsm
2014/08/29 08:42:07
Ditto - and what happens with multiple DOM isolate
Jacob
2014/09/05 23:35:55
Fixed. See previous comment.
| |
100 } | |
101 } | |
102 | |
103 StackTraceTimestamp::StackTraceTimestamp(size_t stackDepth) : m_stackDepth(stack Depth) | |
104 { | |
105 DEFINE_STATIC_LOCAL(int64_t, nextTimestamp, (0)); | |
vsm
2014/08/29 08:42:08
Maybe unsigned here?
Jacob
2014/09/05 23:35:55
Removed the timestamp tracker code with the switch
| |
106 m_timestamp = ++nextTimestamp; | |
vsm
2014/08/29 08:42:07
Overflow assert for good form? Might not trigger
Jacob
2014/09/05 23:35:55
this code was removed.
| |
107 } | |
108 | |
109 int64_t StackTraceTimestampTracker::getTimestamp(size_t frame) | |
110 { | |
111 // The timestamp for a frame is the timestamp of the sample with the | |
112 // largest stack depth that does not exceed the stack depth of the frame. | |
113 ASSERT(!m_samples.isEmpty()); | |
114 if (m_samples.isEmpty()) | |
115 return 0; | |
116 | |
117 // m_samples.size() will typically be less than 3 and will be at most | |
118 // kMaxRecursionDepth (20) so binary search isn't needed. | |
119 size_t i = 1; | |
120 while (i < m_samples.size() && m_samples[i].stackDepth() <= frame) | |
121 i++; | |
122 return m_samples[i-1].timestamp(); | |
123 } | |
124 | |
125 } // namespace WebCore | |
OLD | NEW |