OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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_SAMPLER_H_ | |
6 #define V8_V8_SAMPLER_H_ | |
7 | |
8 #include "v8.h" | |
9 | |
10 /** | |
11 * Sampler API for the V8 JavaScript engine. | |
12 * The API to be consumed by any code which | |
13 * wants to build a sampling profiler for v8. | |
14 */ | |
15 namespace v8 { | |
16 typedef unsigned char* Address; | |
Benedikt Meurer
2014/08/14 04:20:23
We don't need this typedef at all. Just use const
gholap
2014/08/15 17:54:13
As I mentioned in the reply to your earlier commen
Benedikt Meurer
2014/08/18 04:22:03
Got it. But please add a TODO to the typedef, that
gholap
2014/08/18 19:51:59
Acknowledged.
| |
17 | |
18 /** | |
19 * A collected sample contains, | |
20 * - state : The state of the VM at the time of collecting the sample. | |
21 * - stack : An array of addresses. | |
22 * One address per stack frame. | |
23 * The address is the instruction pointer, | |
24 * pointing to the instruction which led to the | |
25 * creation of the stack frame. | |
26 * (for example, a function call) | |
27 * - frames_count: Number of stack frames that were captured. | |
28 * That is, stack[frames_count+i] might contain meaningless | |
29 * addresses for any i >= 0. | |
30 */ | |
31 struct Sample { | |
32 Sample() | |
33 : state(OTHER), | |
34 frames_count(0) {} | |
35 static const unsigned kMaxFramesCountLog2 = 8; | |
36 static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; | |
37 | |
38 StateTag state; // The state of the VM. | |
39 Address stack[kMaxFramesCount]; // Call stack. | |
40 unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames. | |
41 }; | |
42 | |
43 /** | |
44 * Interface for collecting execution stack samples. | |
45 */ | |
46 class V8_EXPORT Sampler { | |
47 public: | |
48 /** | |
49 * Obtain a sample from the isolate. | |
50 * Updates the sample pointer with the newly obtained | |
51 * sampling information. | |
52 * On success, returns the sample pointer. | |
53 * On failure, returns NULL. | |
54 */ | |
55 static Sample* GetSample(Isolate* isolate, | |
56 Sample* sample); | |
57 }; | |
58 } // namespace v8 | |
59 #endif // V8_V8_SAMPLER_H_ | |
OLD | NEW |