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

Side by Side Diff: src/profiler/sampler.h

Issue 1952393002: Split TickSample and Sampler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « src/profiler/profile-generator.cc ('k') | src/profiler/sampler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 #ifndef V8_PROFILER_SAMPLER_H_ 5 #ifndef V8_PROFILER_SAMPLER_H_
6 #define V8_PROFILER_SAMPLER_H_ 6 #define V8_PROFILER_SAMPLER_H_
7 7
8 #include "include/v8.h" 8 #include "include/v8.h"
9 9
10 #include "src/base/atomicops.h" 10 #include "src/base/atomicops.h"
11 #include "src/base/platform/time.h" 11 #include "src/base/macros.h"
12 #include "src/frames.h"
13 #include "src/globals.h"
14 12
15 namespace v8 { 13 namespace v8 {
16 namespace internal { 14 namespace internal {
17 15
18 class Isolate; 16 class Isolate;
17 struct TickSample;
19 18
20 // ---------------------------------------------------------------------------- 19 // ----------------------------------------------------------------------------
21 // Sampler 20 // Sampler
22 // 21 //
23 // A sampler periodically samples the state of the VM and optionally 22 // A sampler periodically samples the state of the VM and optionally
24 // (if used for profiling) the program counter and stack pointer for 23 // (if used for profiling) the program counter and stack pointer for
25 // the thread that created it. 24 // the thread that created it.
26 25
27 // TickSample captures the information collected for each sample.
28 struct TickSample {
29 // Internal profiling (with --prof + tools/$OS-tick-processor) wants to
30 // include the runtime function we're calling. Externally exposed tick
31 // samples don't care.
32 enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame };
33
34 TickSample()
35 : state(OTHER),
36 pc(NULL),
37 external_callback_entry(NULL),
38 frames_count(0),
39 has_external_callback(false),
40 update_stats(true),
41 top_frame_type(StackFrame::NONE) {}
42 void Init(Isolate* isolate, const v8::RegisterState& state,
43 RecordCEntryFrame record_c_entry_frame, bool update_stats);
44 static void GetStackSample(Isolate* isolate, const v8::RegisterState& state,
45 RecordCEntryFrame record_c_entry_frame,
46 void** frames, size_t frames_limit,
47 v8::SampleInfo* sample_info);
48 StateTag state; // The state of the VM.
49 Address pc; // Instruction pointer.
50 union {
51 Address tos; // Top stack value (*sp).
52 Address external_callback_entry;
53 };
54 static const unsigned kMaxFramesCountLog2 = 8;
55 static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1;
56 Address stack[kMaxFramesCount]; // Call stack.
57 base::TimeTicks timestamp;
58 unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames.
59 bool has_external_callback : 1;
60 bool update_stats : 1; // Whether the sample should update aggregated stats.
61 StackFrame::Type top_frame_type : 5;
62 };
63
64 class Sampler { 26 class Sampler {
65 public: 27 public:
66 // Initializes the Sampler support. Called once at VM startup. 28 // Initializes the Sampler support. Called once at VM startup.
67 static void SetUp(); 29 static void SetUp();
68 static void TearDown(); 30 static void TearDown();
69 31
70 // Initialize sampler. 32 // Initialize sampler.
71 Sampler(Isolate* isolate, int interval); 33 Sampler(Isolate* isolate, int interval);
72 virtual ~Sampler(); 34 virtual ~Sampler();
73 35
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 base::Atomic32 active_; 95 base::Atomic32 active_;
134 base::Atomic32 registered_; 96 base::Atomic32 registered_;
135 PlatformData* data_; // Platform specific data. 97 PlatformData* data_; // Platform specific data.
136 // Counts stack samples taken in various VM states. 98 // Counts stack samples taken in various VM states.
137 bool is_counting_samples_; 99 bool is_counting_samples_;
138 unsigned js_sample_count_; 100 unsigned js_sample_count_;
139 unsigned external_sample_count_; 101 unsigned external_sample_count_;
140 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 102 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
141 }; 103 };
142 104
143
144 #if defined(USE_SIMULATOR)
145 class SimulatorHelper : AllStatic {
146 public:
147 // Returns true if register values were successfully retrieved
148 // from the simulator, otherwise returns false.
149 static bool FillRegisters(Isolate* isolate, v8::RegisterState* state);
150 };
151 #endif // USE_SIMULATOR
152
153
154 } // namespace internal 105 } // namespace internal
155 } // namespace v8 106 } // namespace v8
156 107
157 #endif // V8_PROFILER_SAMPLER_H_ 108 #endif // V8_PROFILER_SAMPLER_H_
OLDNEW
« no previous file with comments | « src/profiler/profile-generator.cc ('k') | src/profiler/sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698