libv8 5.3.332.38.5-universal-darwin-16 → 5.7.492.65.0beta1-universal-darwin-16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libv8/arch.rb +5 -5
- data/lib/libv8/version.rb +1 -1
- data/vendor/v8/include/libplatform/libplatform-export.h +29 -0
- data/vendor/v8/include/libplatform/libplatform.h +25 -3
- data/vendor/v8/include/libplatform/v8-tracing.h +270 -0
- data/vendor/v8/include/v8-debug.h +43 -51
- data/vendor/v8/include/v8-experimental.h +4 -0
- data/vendor/v8/include/v8-inspector-protocol.h +13 -0
- data/vendor/v8/include/v8-inspector.h +267 -0
- data/vendor/v8/include/v8-platform.h +57 -9
- data/vendor/v8/include/v8-profiler.h +113 -3
- data/vendor/v8/include/v8-version-string.h +33 -0
- data/vendor/v8/include/v8-version.h +3 -3
- data/vendor/v8/include/v8.h +1334 -370
- data/vendor/v8/include/v8config.h +0 -4
- data/vendor/v8/out/x64.release/libv8_base.a +0 -0
- data/vendor/v8/out/x64.release/libv8_libbase.a +0 -0
- data/vendor/v8/out/x64.release/libv8_libplatform.a +0 -0
- data/vendor/v8/out/x64.release/libv8_libsampler.a +0 -0
- data/vendor/v8/out/x64.release/libv8_nosnapshot.a +0 -0
- data/vendor/v8/out/x64.release/libv8_snapshot.a +0 -0
- metadata +9 -4
@@ -31,13 +31,17 @@ class V8_EXPORT FastAccessorBuilder {
|
|
31
31
|
ValueId IntegerConstant(int int_constant);
|
32
32
|
ValueId GetReceiver();
|
33
33
|
ValueId LoadInternalField(ValueId value_id, int field_no);
|
34
|
+
ValueId LoadInternalFieldUnchecked(ValueId value_id, int field_no);
|
34
35
|
ValueId LoadValue(ValueId value_id, int offset);
|
35
36
|
ValueId LoadObject(ValueId value_id, int offset);
|
37
|
+
ValueId ToSmi(ValueId value_id);
|
38
|
+
|
36
39
|
void ReturnValue(ValueId value_id);
|
37
40
|
void CheckFlagSetOrReturnNull(ValueId value_id, int mask);
|
38
41
|
void CheckNotZeroOrReturnNull(ValueId value_id);
|
39
42
|
LabelId MakeLabel();
|
40
43
|
void SetLabel(LabelId label_id);
|
44
|
+
void Goto(LabelId label_id);
|
41
45
|
void CheckNotZeroOrJump(ValueId value_id, LabelId label_id);
|
42
46
|
ValueId Call(v8::FunctionCallback callback, ValueId value_id);
|
43
47
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Copyright 2016 the V8 project authors. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
3
|
+
// found in the LICENSE file.
|
4
|
+
|
5
|
+
#ifndef V8_V8_INSPECTOR_PROTOCOL_H_
|
6
|
+
#define V8_V8_INSPECTOR_PROTOCOL_H_
|
7
|
+
|
8
|
+
#include "inspector/Debugger.h" // NOLINT(build/include)
|
9
|
+
#include "inspector/Runtime.h" // NOLINT(build/include)
|
10
|
+
#include "inspector/Schema.h" // NOLINT(build/include)
|
11
|
+
#include "v8-inspector.h" // NOLINT(build/include)
|
12
|
+
|
13
|
+
#endif // V8_V8_INSPECTOR_PROTOCOL_H_
|
@@ -0,0 +1,267 @@
|
|
1
|
+
// Copyright 2016 the V8 project authors. All rights reserved.
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
3
|
+
// found in the LICENSE file.
|
4
|
+
|
5
|
+
#ifndef V8_V8_INSPECTOR_H_
|
6
|
+
#define V8_V8_INSPECTOR_H_
|
7
|
+
|
8
|
+
#include <stdint.h>
|
9
|
+
#include <cctype>
|
10
|
+
|
11
|
+
#include <memory>
|
12
|
+
|
13
|
+
#include "v8.h" // NOLINT(build/include)
|
14
|
+
|
15
|
+
namespace v8_inspector {
|
16
|
+
|
17
|
+
namespace protocol {
|
18
|
+
namespace Debugger {
|
19
|
+
namespace API {
|
20
|
+
class SearchMatch;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
namespace Runtime {
|
24
|
+
namespace API {
|
25
|
+
class RemoteObject;
|
26
|
+
class StackTrace;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
namespace Schema {
|
30
|
+
namespace API {
|
31
|
+
class Domain;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
} // namespace protocol
|
35
|
+
|
36
|
+
class V8_EXPORT StringView {
|
37
|
+
public:
|
38
|
+
StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {}
|
39
|
+
|
40
|
+
StringView(const uint8_t* characters, size_t length)
|
41
|
+
: m_is8Bit(true), m_length(length), m_characters8(characters) {}
|
42
|
+
|
43
|
+
StringView(const uint16_t* characters, size_t length)
|
44
|
+
: m_is8Bit(false), m_length(length), m_characters16(characters) {}
|
45
|
+
|
46
|
+
bool is8Bit() const { return m_is8Bit; }
|
47
|
+
size_t length() const { return m_length; }
|
48
|
+
|
49
|
+
// TODO(dgozman): add DCHECK(m_is8Bit) to accessors once platform can be used
|
50
|
+
// here.
|
51
|
+
const uint8_t* characters8() const { return m_characters8; }
|
52
|
+
const uint16_t* characters16() const { return m_characters16; }
|
53
|
+
|
54
|
+
private:
|
55
|
+
bool m_is8Bit;
|
56
|
+
size_t m_length;
|
57
|
+
union {
|
58
|
+
const uint8_t* m_characters8;
|
59
|
+
const uint16_t* m_characters16;
|
60
|
+
};
|
61
|
+
};
|
62
|
+
|
63
|
+
class V8_EXPORT StringBuffer {
|
64
|
+
public:
|
65
|
+
virtual ~StringBuffer() {}
|
66
|
+
virtual const StringView& string() = 0;
|
67
|
+
// This method copies contents.
|
68
|
+
static std::unique_ptr<StringBuffer> create(const StringView&);
|
69
|
+
};
|
70
|
+
|
71
|
+
class V8_EXPORT V8ContextInfo {
|
72
|
+
public:
|
73
|
+
V8ContextInfo(v8::Local<v8::Context> context, int contextGroupId,
|
74
|
+
const StringView& humanReadableName)
|
75
|
+
: context(context),
|
76
|
+
contextGroupId(contextGroupId),
|
77
|
+
humanReadableName(humanReadableName),
|
78
|
+
hasMemoryOnConsole(false) {}
|
79
|
+
|
80
|
+
v8::Local<v8::Context> context;
|
81
|
+
// Each v8::Context is a part of a group. The group id must be non-zero.
|
82
|
+
int contextGroupId;
|
83
|
+
StringView humanReadableName;
|
84
|
+
StringView origin;
|
85
|
+
StringView auxData;
|
86
|
+
bool hasMemoryOnConsole;
|
87
|
+
|
88
|
+
private:
|
89
|
+
// Disallow copying and allocating this one.
|
90
|
+
enum NotNullTagEnum { NotNullLiteral };
|
91
|
+
void* operator new(size_t) = delete;
|
92
|
+
void* operator new(size_t, NotNullTagEnum, void*) = delete;
|
93
|
+
void* operator new(size_t, void*) = delete;
|
94
|
+
V8ContextInfo(const V8ContextInfo&) = delete;
|
95
|
+
V8ContextInfo& operator=(const V8ContextInfo&) = delete;
|
96
|
+
};
|
97
|
+
|
98
|
+
class V8_EXPORT V8StackTrace {
|
99
|
+
public:
|
100
|
+
virtual bool isEmpty() const = 0;
|
101
|
+
virtual StringView topSourceURL() const = 0;
|
102
|
+
virtual int topLineNumber() const = 0;
|
103
|
+
virtual int topColumnNumber() const = 0;
|
104
|
+
virtual StringView topScriptId() const = 0;
|
105
|
+
virtual StringView topFunctionName() const = 0;
|
106
|
+
|
107
|
+
virtual ~V8StackTrace() {}
|
108
|
+
virtual std::unique_ptr<protocol::Runtime::API::StackTrace>
|
109
|
+
buildInspectorObject() const = 0;
|
110
|
+
virtual std::unique_ptr<StringBuffer> toString() const = 0;
|
111
|
+
|
112
|
+
// Safe to pass between threads, drops async chain.
|
113
|
+
virtual std::unique_ptr<V8StackTrace> clone() = 0;
|
114
|
+
};
|
115
|
+
|
116
|
+
class V8_EXPORT V8InspectorSession {
|
117
|
+
public:
|
118
|
+
virtual ~V8InspectorSession() {}
|
119
|
+
|
120
|
+
// Cross-context inspectable values (DOM nodes in different worlds, etc.).
|
121
|
+
class V8_EXPORT Inspectable {
|
122
|
+
public:
|
123
|
+
virtual v8::Local<v8::Value> get(v8::Local<v8::Context>) = 0;
|
124
|
+
virtual ~Inspectable() {}
|
125
|
+
};
|
126
|
+
virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0;
|
127
|
+
|
128
|
+
// Dispatching protocol messages.
|
129
|
+
static bool canDispatchMethod(const StringView& method);
|
130
|
+
virtual void dispatchProtocolMessage(const StringView& message) = 0;
|
131
|
+
virtual std::unique_ptr<StringBuffer> stateJSON() = 0;
|
132
|
+
virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
|
133
|
+
supportedDomains() = 0;
|
134
|
+
|
135
|
+
// Debugger actions.
|
136
|
+
virtual void schedulePauseOnNextStatement(const StringView& breakReason,
|
137
|
+
const StringView& breakDetails) = 0;
|
138
|
+
virtual void cancelPauseOnNextStatement() = 0;
|
139
|
+
virtual void breakProgram(const StringView& breakReason,
|
140
|
+
const StringView& breakDetails) = 0;
|
141
|
+
virtual void setSkipAllPauses(bool) = 0;
|
142
|
+
virtual void resume() = 0;
|
143
|
+
virtual void stepOver() = 0;
|
144
|
+
virtual std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>>
|
145
|
+
searchInTextByLines(const StringView& text, const StringView& query,
|
146
|
+
bool caseSensitive, bool isRegex) = 0;
|
147
|
+
|
148
|
+
// Remote objects.
|
149
|
+
virtual std::unique_ptr<protocol::Runtime::API::RemoteObject> wrapObject(
|
150
|
+
v8::Local<v8::Context>, v8::Local<v8::Value>,
|
151
|
+
const StringView& groupName) = 0;
|
152
|
+
virtual bool unwrapObject(std::unique_ptr<StringBuffer>* error,
|
153
|
+
const StringView& objectId, v8::Local<v8::Value>*,
|
154
|
+
v8::Local<v8::Context>*,
|
155
|
+
std::unique_ptr<StringBuffer>* objectGroup) = 0;
|
156
|
+
virtual void releaseObjectGroup(const StringView&) = 0;
|
157
|
+
};
|
158
|
+
|
159
|
+
enum class V8ConsoleAPIType { kClear, kDebug, kLog, kInfo, kWarning, kError };
|
160
|
+
|
161
|
+
class V8_EXPORT V8InspectorClient {
|
162
|
+
public:
|
163
|
+
virtual ~V8InspectorClient() {}
|
164
|
+
|
165
|
+
virtual void runMessageLoopOnPause(int contextGroupId) {}
|
166
|
+
virtual void quitMessageLoopOnPause() {}
|
167
|
+
virtual void runIfWaitingForDebugger(int contextGroupId) {}
|
168
|
+
|
169
|
+
virtual void muteMetrics(int contextGroupId) {}
|
170
|
+
virtual void unmuteMetrics(int contextGroupId) {}
|
171
|
+
|
172
|
+
virtual void beginUserGesture() {}
|
173
|
+
virtual void endUserGesture() {}
|
174
|
+
|
175
|
+
virtual std::unique_ptr<StringBuffer> valueSubtype(v8::Local<v8::Value>) {
|
176
|
+
return nullptr;
|
177
|
+
}
|
178
|
+
virtual bool formatAccessorsAsProperties(v8::Local<v8::Value>) {
|
179
|
+
return false;
|
180
|
+
}
|
181
|
+
virtual bool isInspectableHeapObject(v8::Local<v8::Object>) { return true; }
|
182
|
+
|
183
|
+
virtual v8::Local<v8::Context> ensureDefaultContextInGroup(
|
184
|
+
int contextGroupId) {
|
185
|
+
return v8::Local<v8::Context>();
|
186
|
+
}
|
187
|
+
virtual void beginEnsureAllContextsInGroup(int contextGroupId) {}
|
188
|
+
virtual void endEnsureAllContextsInGroup(int contextGroupId) {}
|
189
|
+
|
190
|
+
virtual void installAdditionalCommandLineAPI(v8::Local<v8::Context>,
|
191
|
+
v8::Local<v8::Object>) {}
|
192
|
+
virtual void consoleAPIMessage(int contextGroupId, V8ConsoleAPIType,
|
193
|
+
const StringView& message,
|
194
|
+
const StringView& url, unsigned lineNumber,
|
195
|
+
unsigned columnNumber, V8StackTrace*) {}
|
196
|
+
virtual v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*,
|
197
|
+
v8::Local<v8::Context>) {
|
198
|
+
return v8::MaybeLocal<v8::Value>();
|
199
|
+
}
|
200
|
+
|
201
|
+
virtual void consoleTime(const StringView& title) {}
|
202
|
+
virtual void consoleTimeEnd(const StringView& title) {}
|
203
|
+
virtual void consoleTimeStamp(const StringView& title) {}
|
204
|
+
virtual double currentTimeMS() { return 0; }
|
205
|
+
typedef void (*TimerCallback)(void*);
|
206
|
+
virtual void startRepeatingTimer(double, TimerCallback, void* data) {}
|
207
|
+
virtual void cancelTimer(void* data) {}
|
208
|
+
|
209
|
+
// TODO(dgozman): this was added to support service worker shadow page. We
|
210
|
+
// should not connect at all.
|
211
|
+
virtual bool canExecuteScripts(int contextGroupId) { return true; }
|
212
|
+
};
|
213
|
+
|
214
|
+
class V8_EXPORT V8Inspector {
|
215
|
+
public:
|
216
|
+
static std::unique_ptr<V8Inspector> create(v8::Isolate*, V8InspectorClient*);
|
217
|
+
virtual ~V8Inspector() {}
|
218
|
+
|
219
|
+
// Contexts instrumentation.
|
220
|
+
virtual void contextCreated(const V8ContextInfo&) = 0;
|
221
|
+
virtual void contextDestroyed(v8::Local<v8::Context>) = 0;
|
222
|
+
virtual void resetContextGroup(int contextGroupId) = 0;
|
223
|
+
|
224
|
+
// Various instrumentation.
|
225
|
+
virtual void willExecuteScript(v8::Local<v8::Context>, int scriptId) = 0;
|
226
|
+
virtual void didExecuteScript(v8::Local<v8::Context>) = 0;
|
227
|
+
virtual void idleStarted() = 0;
|
228
|
+
virtual void idleFinished() = 0;
|
229
|
+
|
230
|
+
// Async stack traces instrumentation.
|
231
|
+
virtual void asyncTaskScheduled(const StringView& taskName, void* task,
|
232
|
+
bool recurring) = 0;
|
233
|
+
virtual void asyncTaskCanceled(void* task) = 0;
|
234
|
+
virtual void asyncTaskStarted(void* task) = 0;
|
235
|
+
virtual void asyncTaskFinished(void* task) = 0;
|
236
|
+
virtual void allAsyncTasksCanceled() = 0;
|
237
|
+
|
238
|
+
// Exceptions instrumentation.
|
239
|
+
virtual unsigned exceptionThrown(
|
240
|
+
v8::Local<v8::Context>, const StringView& message,
|
241
|
+
v8::Local<v8::Value> exception, const StringView& detailedMessage,
|
242
|
+
const StringView& url, unsigned lineNumber, unsigned columnNumber,
|
243
|
+
std::unique_ptr<V8StackTrace>, int scriptId) = 0;
|
244
|
+
virtual void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId,
|
245
|
+
const StringView& message) = 0;
|
246
|
+
|
247
|
+
// Connection.
|
248
|
+
class V8_EXPORT Channel {
|
249
|
+
public:
|
250
|
+
virtual ~Channel() {}
|
251
|
+
virtual void sendResponse(int callId,
|
252
|
+
std::unique_ptr<StringBuffer> message) = 0;
|
253
|
+
virtual void sendNotification(std::unique_ptr<StringBuffer> message) = 0;
|
254
|
+
virtual void flushProtocolNotifications() = 0;
|
255
|
+
};
|
256
|
+
virtual std::unique_ptr<V8InspectorSession> connect(
|
257
|
+
int contextGroupId, Channel*, const StringView& state) = 0;
|
258
|
+
|
259
|
+
// API methods.
|
260
|
+
virtual std::unique_ptr<V8StackTrace> createStackTrace(
|
261
|
+
v8::Local<v8::StackTrace>) = 0;
|
262
|
+
virtual std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) = 0;
|
263
|
+
};
|
264
|
+
|
265
|
+
} // namespace v8_inspector
|
266
|
+
|
267
|
+
#endif // V8_V8_INSPECTOR_H_
|
@@ -7,6 +7,8 @@
|
|
7
7
|
|
8
8
|
#include <stddef.h>
|
9
9
|
#include <stdint.h>
|
10
|
+
#include <memory>
|
11
|
+
#include <string>
|
10
12
|
|
11
13
|
namespace v8 {
|
12
14
|
|
@@ -17,24 +19,38 @@ class Isolate;
|
|
17
19
|
*/
|
18
20
|
class Task {
|
19
21
|
public:
|
20
|
-
virtual ~Task()
|
22
|
+
virtual ~Task() = default;
|
21
23
|
|
22
24
|
virtual void Run() = 0;
|
23
25
|
};
|
24
26
|
|
25
|
-
|
26
27
|
/**
|
27
|
-
* An IdleTask represents a unit of work to be performed in idle time.
|
28
|
-
* The Run method is invoked with an argument that specifies the deadline in
|
29
|
-
* seconds returned by MonotonicallyIncreasingTime().
|
30
|
-
* The idle task is expected to complete by this deadline.
|
31
|
-
*/
|
28
|
+
* An IdleTask represents a unit of work to be performed in idle time.
|
29
|
+
* The Run method is invoked with an argument that specifies the deadline in
|
30
|
+
* seconds returned by MonotonicallyIncreasingTime().
|
31
|
+
* The idle task is expected to complete by this deadline.
|
32
|
+
*/
|
32
33
|
class IdleTask {
|
33
34
|
public:
|
34
|
-
virtual ~IdleTask()
|
35
|
+
virtual ~IdleTask() = default;
|
35
36
|
virtual void Run(double deadline_in_seconds) = 0;
|
36
37
|
};
|
37
38
|
|
39
|
+
/**
|
40
|
+
* The interface represents complex arguments to trace events.
|
41
|
+
*/
|
42
|
+
class ConvertableToTraceFormat {
|
43
|
+
public:
|
44
|
+
virtual ~ConvertableToTraceFormat() = default;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Append the class info to the provided |out| string. The appended
|
48
|
+
* data must be a valid JSON object. Strings must be properly quoted, and
|
49
|
+
* escaped. There is no processing applied to the content after it is
|
50
|
+
* appended.
|
51
|
+
*/
|
52
|
+
virtual void AppendAsTraceFormat(std::string* out) const = 0;
|
53
|
+
};
|
38
54
|
|
39
55
|
/**
|
40
56
|
* V8 Platform abstraction layer.
|
@@ -54,7 +70,7 @@ class Platform {
|
|
54
70
|
kLongRunningTask
|
55
71
|
};
|
56
72
|
|
57
|
-
virtual ~Platform()
|
73
|
+
virtual ~Platform() = default;
|
58
74
|
|
59
75
|
/**
|
60
76
|
* Gets the number of threads that are used to execute background tasks. Is
|
@@ -158,12 +174,44 @@ class Platform {
|
|
158
174
|
return 0;
|
159
175
|
}
|
160
176
|
|
177
|
+
/**
|
178
|
+
* Adds a trace event to the platform tracing system. This function call is
|
179
|
+
* usually the result of a TRACE_* macro from trace_event_common.h when
|
180
|
+
* tracing and the category of the particular trace are enabled. It is not
|
181
|
+
* advisable to call this function on its own; it is really only meant to be
|
182
|
+
* used by the trace macros. The returned handle can be used by
|
183
|
+
* UpdateTraceEventDuration to update the duration of COMPLETE events.
|
184
|
+
*/
|
185
|
+
virtual uint64_t AddTraceEvent(
|
186
|
+
char phase, const uint8_t* category_enabled_flag, const char* name,
|
187
|
+
const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
|
188
|
+
const char** arg_names, const uint8_t* arg_types,
|
189
|
+
const uint64_t* arg_values,
|
190
|
+
std::unique_ptr<ConvertableToTraceFormat>* arg_convertables,
|
191
|
+
unsigned int flags) {
|
192
|
+
return AddTraceEvent(phase, category_enabled_flag, name, scope, id, bind_id,
|
193
|
+
num_args, arg_names, arg_types, arg_values, flags);
|
194
|
+
}
|
195
|
+
|
161
196
|
/**
|
162
197
|
* Sets the duration field of a COMPLETE trace event. It must be called with
|
163
198
|
* the handle returned from AddTraceEvent().
|
164
199
|
**/
|
165
200
|
virtual void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
|
166
201
|
const char* name, uint64_t handle) {}
|
202
|
+
|
203
|
+
class TraceStateObserver {
|
204
|
+
public:
|
205
|
+
virtual ~TraceStateObserver() = default;
|
206
|
+
virtual void OnTraceEnabled() = 0;
|
207
|
+
virtual void OnTraceDisabled() = 0;
|
208
|
+
};
|
209
|
+
|
210
|
+
/** Adds tracing state change observer. */
|
211
|
+
virtual void AddTraceStateObserver(TraceStateObserver*) {}
|
212
|
+
|
213
|
+
/** Removes tracing state change observer. */
|
214
|
+
virtual void RemoveTraceStateObserver(TraceStateObserver*) {}
|
167
215
|
};
|
168
216
|
|
169
217
|
} // namespace v8
|
@@ -46,6 +46,89 @@ template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>;
|
|
46
46
|
|
47
47
|
namespace v8 {
|
48
48
|
|
49
|
+
/**
|
50
|
+
* TracingCpuProfiler monitors tracing being enabled/disabled
|
51
|
+
* and emits CpuProfile trace events once v8.cpu_profiler tracing category
|
52
|
+
* is enabled. It has no overhead unless the category is enabled.
|
53
|
+
*/
|
54
|
+
class V8_EXPORT TracingCpuProfiler {
|
55
|
+
public:
|
56
|
+
static std::unique_ptr<TracingCpuProfiler> Create(Isolate*);
|
57
|
+
virtual ~TracingCpuProfiler() = default;
|
58
|
+
|
59
|
+
protected:
|
60
|
+
TracingCpuProfiler() = default;
|
61
|
+
};
|
62
|
+
|
63
|
+
// TickSample captures the information collected for each sample.
|
64
|
+
struct TickSample {
|
65
|
+
// Internal profiling (with --prof + tools/$OS-tick-processor) wants to
|
66
|
+
// include the runtime function we're calling. Externally exposed tick
|
67
|
+
// samples don't care.
|
68
|
+
enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame };
|
69
|
+
|
70
|
+
TickSample()
|
71
|
+
: state(OTHER),
|
72
|
+
pc(nullptr),
|
73
|
+
external_callback_entry(nullptr),
|
74
|
+
frames_count(0),
|
75
|
+
has_external_callback(false),
|
76
|
+
update_stats(true) {}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Initialize a tick sample from the isolate.
|
80
|
+
* \param isolate The isolate.
|
81
|
+
* \param state Execution state.
|
82
|
+
* \param record_c_entry_frame Include or skip the runtime function.
|
83
|
+
* \param update_stats Whether update the sample to the aggregated stats.
|
84
|
+
* \param use_simulator_reg_state When set to true and V8 is running under a
|
85
|
+
* simulator, the method will use the simulator
|
86
|
+
* register state rather than the one provided
|
87
|
+
* with |state| argument. Otherwise the method
|
88
|
+
* will use provided register |state| as is.
|
89
|
+
*/
|
90
|
+
void Init(Isolate* isolate, const v8::RegisterState& state,
|
91
|
+
RecordCEntryFrame record_c_entry_frame, bool update_stats,
|
92
|
+
bool use_simulator_reg_state = true);
|
93
|
+
/**
|
94
|
+
* Get a call stack sample from the isolate.
|
95
|
+
* \param isolate The isolate.
|
96
|
+
* \param state Register state.
|
97
|
+
* \param record_c_entry_frame Include or skip the runtime function.
|
98
|
+
* \param frames Caller allocated buffer to store stack frames.
|
99
|
+
* \param frames_limit Maximum number of frames to capture. The buffer must
|
100
|
+
* be large enough to hold the number of frames.
|
101
|
+
* \param sample_info The sample info is filled up by the function
|
102
|
+
* provides number of actual captured stack frames and
|
103
|
+
* the current VM state.
|
104
|
+
* \param use_simulator_reg_state When set to true and V8 is running under a
|
105
|
+
* simulator, the method will use the simulator
|
106
|
+
* register state rather than the one provided
|
107
|
+
* with |state| argument. Otherwise the method
|
108
|
+
* will use provided register |state| as is.
|
109
|
+
* \note GetStackSample is thread and signal safe and should only be called
|
110
|
+
* when the JS thread is paused or interrupted.
|
111
|
+
* Otherwise the behavior is undefined.
|
112
|
+
*/
|
113
|
+
static bool GetStackSample(Isolate* isolate, v8::RegisterState* state,
|
114
|
+
RecordCEntryFrame record_c_entry_frame,
|
115
|
+
void** frames, size_t frames_limit,
|
116
|
+
v8::SampleInfo* sample_info,
|
117
|
+
bool use_simulator_reg_state = true);
|
118
|
+
StateTag state; // The state of the VM.
|
119
|
+
void* pc; // Instruction pointer.
|
120
|
+
union {
|
121
|
+
void* tos; // Top stack value (*sp).
|
122
|
+
void* external_callback_entry;
|
123
|
+
};
|
124
|
+
static const unsigned kMaxFramesCountLog2 = 8;
|
125
|
+
static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1;
|
126
|
+
void* stack[kMaxFramesCount]; // Call stack.
|
127
|
+
unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames.
|
128
|
+
bool has_external_callback : 1;
|
129
|
+
bool update_stats : 1; // Whether the sample should update aggregated stats.
|
130
|
+
};
|
131
|
+
|
49
132
|
/**
|
50
133
|
* CpuProfileNode represents a node in a call graph.
|
51
134
|
*/
|
@@ -62,12 +145,26 @@ class V8_EXPORT CpuProfileNode {
|
|
62
145
|
/** Returns function name (empty string for anonymous functions.) */
|
63
146
|
Local<String> GetFunctionName() const;
|
64
147
|
|
148
|
+
/**
|
149
|
+
* Returns function name (empty string for anonymous functions.)
|
150
|
+
* The string ownership is *not* passed to the caller. It stays valid until
|
151
|
+
* profile is deleted. The function is thread safe.
|
152
|
+
*/
|
153
|
+
const char* GetFunctionNameStr() const;
|
154
|
+
|
65
155
|
/** Returns id of the script where function is located. */
|
66
156
|
int GetScriptId() const;
|
67
157
|
|
68
158
|
/** Returns resource name for script from where the function originates. */
|
69
159
|
Local<String> GetScriptResourceName() const;
|
70
160
|
|
161
|
+
/**
|
162
|
+
* Returns resource name for script from where the function originates.
|
163
|
+
* The string ownership is *not* passed to the caller. It stays valid until
|
164
|
+
* profile is deleted. The function is thread safe.
|
165
|
+
*/
|
166
|
+
const char* GetScriptResourceNameStr() const;
|
167
|
+
|
71
168
|
/**
|
72
169
|
* Returns the number, 1-based, of the line where the function originates.
|
73
170
|
* kNoLineNumberInfo if no line number information is available.
|
@@ -103,7 +200,9 @@ class V8_EXPORT CpuProfileNode {
|
|
103
200
|
unsigned GetHitCount() const;
|
104
201
|
|
105
202
|
/** Returns function entry UID. */
|
106
|
-
|
203
|
+
V8_DEPRECATE_SOON(
|
204
|
+
"Use GetScriptId, GetLineNumber, and GetColumnNumber instead.",
|
205
|
+
unsigned GetCallUid() const);
|
107
206
|
|
108
207
|
/** Returns id of the node. The id is unique within the tree */
|
109
208
|
unsigned GetNodeId() const;
|
@@ -173,13 +272,24 @@ class V8_EXPORT CpuProfile {
|
|
173
272
|
void Delete();
|
174
273
|
};
|
175
274
|
|
176
|
-
|
177
275
|
/**
|
178
276
|
* Interface for controlling CPU profiling. Instance of the
|
179
|
-
* profiler can be
|
277
|
+
* profiler can be created using v8::CpuProfiler::New method.
|
180
278
|
*/
|
181
279
|
class V8_EXPORT CpuProfiler {
|
182
280
|
public:
|
281
|
+
/**
|
282
|
+
* Creates a new CPU profiler for the |isolate|. The isolate must be
|
283
|
+
* initialized. The profiler object must be disposed after use by calling
|
284
|
+
* |Dispose| method.
|
285
|
+
*/
|
286
|
+
static CpuProfiler* New(Isolate* isolate);
|
287
|
+
|
288
|
+
/**
|
289
|
+
* Disposes the CPU profiler object.
|
290
|
+
*/
|
291
|
+
void Dispose();
|
292
|
+
|
183
293
|
/**
|
184
294
|
* Changes default CPU profiler sampling interval to the specified number
|
185
295
|
* of microseconds. Default interval is 1000us. This method must be called
|