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

Side by Side Diff: src/sampler.h

Issue 18620002: Do not store fp and sp values in TickSample (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed SIMULATOR compilation Created 7 years, 5 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
« no previous file with comments | « src/log.cc ('k') | src/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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 26 matching lines...) Expand all
37 37
38 class Isolate; 38 class Isolate;
39 39
40 // ---------------------------------------------------------------------------- 40 // ----------------------------------------------------------------------------
41 // Sampler 41 // Sampler
42 // 42 //
43 // A sampler periodically samples the state of the VM and optionally 43 // A sampler periodically samples the state of the VM and optionally
44 // (if used for profiling) the program counter and stack pointer for 44 // (if used for profiling) the program counter and stack pointer for
45 // the thread that created it. 45 // the thread that created it.
46 46
47 struct RegisterState {
48 RegisterState() : pc(NULL), sp(NULL), fp(NULL) {}
49 Address pc; // Instruction pointer.
50 Address sp; // Stack pointer.
51 Address fp; // Frame pointer.
52 };
53
47 // TickSample captures the information collected for each sample. 54 // TickSample captures the information collected for each sample.
48 struct TickSample { 55 struct TickSample {
49 TickSample() 56 TickSample()
50 : state(OTHER), 57 : state(OTHER),
51 pc(NULL), 58 pc(NULL),
52 sp(NULL),
53 fp(NULL),
54 external_callback(NULL), 59 external_callback(NULL),
55 frames_count(0), 60 frames_count(0),
56 has_external_callback(false), 61 has_external_callback(false),
57 top_frame_type(StackFrame::NONE) {} 62 top_frame_type(StackFrame::NONE) {}
58 void Trace(Isolate* isolate); 63 void Init(Isolate* isolate, const RegisterState& state);
59 StateTag state; // The state of the VM. 64 StateTag state; // The state of the VM.
60 Address pc; // Instruction pointer. 65 Address pc; // Instruction pointer.
61 Address sp; // Stack pointer.
62 Address fp; // Frame pointer.
63 union { 66 union {
64 Address tos; // Top stack value (*sp). 67 Address tos; // Top stack value (*sp).
65 Address external_callback; 68 Address external_callback;
66 }; 69 };
67 static const int kMaxFramesCount = 64; 70 static const int kMaxFramesCount = 64;
68 Address stack[kMaxFramesCount]; // Call stack. 71 Address stack[kMaxFramesCount]; // Call stack.
69 int frames_count : 8; // Number of captured frames. 72 int frames_count : 8; // Number of captured frames.
70 bool has_external_callback : 1; 73 bool has_external_callback : 1;
71 StackFrame::Type top_frame_type : 4; 74 StackFrame::Type top_frame_type : 4;
72 }; 75 };
73 76
74 class Sampler { 77 class Sampler {
75 public: 78 public:
76 // Initializes the Sampler support. Called once at VM startup. 79 // Initializes the Sampler support. Called once at VM startup.
77 static void SetUp(); 80 static void SetUp();
78 static void TearDown(); 81 static void TearDown();
79 82
80 // Initialize sampler. 83 // Initialize sampler.
81 Sampler(Isolate* isolate, int interval); 84 Sampler(Isolate* isolate, int interval);
82 virtual ~Sampler(); 85 virtual ~Sampler();
83 86
84 Isolate* isolate() const { return isolate_; } 87 Isolate* isolate() const { return isolate_; }
85 int interval() const { return interval_; } 88 int interval() const { return interval_; }
86 89
87 // Performs stack sampling. 90 // Performs stack sampling.
88 void SampleStack(TickSample* sample); 91 void SampleStack(const RegisterState& regs);
89
90 // This method is called for each sampling period with the current
91 // program counter.
92 virtual void Tick(TickSample* sample) = 0;
93 92
94 // Start and stop sampler. 93 // Start and stop sampler.
95 void Start(); 94 void Start();
96 void Stop(); 95 void Stop();
97 96
98 // Is the sampler used for profiling? 97 // Is the sampler used for profiling?
99 bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; } 98 bool IsProfiling() const { return NoBarrier_Load(&profiling_) > 0; }
100 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); } 99 void IncreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, 1); }
101 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); } 100 void DecreaseProfilingDepth() { NoBarrier_AtomicIncrement(&profiling_, -1); }
102 101
103 // Whether the sampler is running (that is, consumes resources). 102 // Whether the sampler is running (that is, consumes resources).
104 bool IsActive() const { return NoBarrier_Load(&active_); } 103 bool IsActive() const { return NoBarrier_Load(&active_); }
105 104
106 // Used in tests to make sure that stack sampling is performed. 105 // Used in tests to make sure that stack sampling is performed.
107 int samples_taken() const { return samples_taken_; } 106 int samples_taken() const { return samples_taken_; }
108 void ResetSamplesTaken() { samples_taken_ = 0; } 107 void ResetSamplesTaken() { samples_taken_ = 0; }
109 108
110 class PlatformData; 109 class PlatformData;
111 PlatformData* platform_data() const { return data_; } 110 PlatformData* platform_data() const { return data_; }
112 111
112 protected:
113 // This method is called for each sampling period with the current
114 // program counter.
115 virtual void Tick(TickSample* sample) = 0;
116
113 private: 117 private:
114 void SetActive(bool value) { NoBarrier_Store(&active_, value); } 118 void SetActive(bool value) { NoBarrier_Store(&active_, value); }
115 119
116 Isolate* isolate_; 120 Isolate* isolate_;
117 const int interval_; 121 const int interval_;
118 Atomic32 profiling_; 122 Atomic32 profiling_;
119 Atomic32 active_; 123 Atomic32 active_;
120 PlatformData* data_; // Platform specific data. 124 PlatformData* data_; // Platform specific data.
121 int samples_taken_; // Counts stack samples taken. 125 int samples_taken_; // Counts stack samples taken.
122 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 126 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
123 }; 127 };
124 128
125 129
126 } } // namespace v8::internal 130 } } // namespace v8::internal
127 131
128 #endif // V8_SAMPLER_H_ 132 #endif // V8_SAMPLER_H_
OLDNEW
« no previous file with comments | « src/log.cc ('k') | src/sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698