OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 Address start; | 98 Address start; |
99 CodeEntry* entry; | 99 CodeEntry* entry; |
100 Address code_start; | 100 Address code_start; |
101 | 101 |
102 INLINE(void UpdateCodeMap(CodeMap* code_map)); | 102 INLINE(void UpdateCodeMap(CodeMap* code_map)); |
103 }; | 103 }; |
104 | 104 |
105 | 105 |
106 class TickSampleEventRecord BASE_EMBEDDED { | 106 class TickSampleEventRecord BASE_EMBEDDED { |
107 public: | 107 public: |
| 108 TickSampleEventRecord() |
| 109 : filler(1) { |
| 110 ASSERT(filler != SamplingCircularQueue::kClear); |
| 111 } |
| 112 |
108 // The first machine word of a TickSampleEventRecord must not ever | 113 // The first machine word of a TickSampleEventRecord must not ever |
109 // become equal to SamplingCircularQueue::kClear. As both order and | 114 // become equal to SamplingCircularQueue::kClear. As both order and |
110 // TickSample's first field are not reliable in this sense (order | 115 // TickSample's first field are not reliable in this sense (order |
111 // can overflow, TickSample can have all fields reset), we are | 116 // can overflow, TickSample can have all fields reset), we are |
112 // forced to use an artificial filler field. | 117 // forced to use an artificial filler field. |
113 int filler; | 118 int filler; |
114 unsigned order; | 119 unsigned order; |
115 TickSample sample; | 120 TickSample sample; |
116 | 121 |
117 static TickSampleEventRecord* cast(void* value) { | 122 static TickSampleEventRecord* cast(void* value) { |
118 return reinterpret_cast<TickSampleEventRecord*>(value); | 123 return reinterpret_cast<TickSampleEventRecord*>(value); |
119 } | 124 } |
120 | 125 |
121 INLINE(static TickSampleEventRecord* init(void* value)); | 126 INLINE(static TickSampleEventRecord* init(void* value)); |
122 | |
123 private: | |
124 DISALLOW_IMPLICIT_CONSTRUCTORS(TickSampleEventRecord); | |
125 }; | 127 }; |
126 | 128 |
127 | 129 |
128 // This class implements both the profile events processor thread and | 130 // This class implements both the profile events processor thread and |
129 // methods called by event producers: VM and stack sampler threads. | 131 // methods called by event producers: VM and stack sampler threads. |
130 class ProfilerEventsProcessor : public Thread { | 132 class ProfilerEventsProcessor : public Thread { |
131 public: | 133 public: |
132 explicit ProfilerEventsProcessor(ProfileGenerator* generator); | 134 explicit ProfilerEventsProcessor(ProfileGenerator* generator); |
133 virtual ~ProfilerEventsProcessor() { } | 135 virtual ~ProfilerEventsProcessor() { } |
134 | 136 |
(...skipping 17 matching lines...) Expand all Loading... |
152 int args_count, | 154 int args_count, |
153 Address start, unsigned size); | 155 Address start, unsigned size); |
154 void CodeMoveEvent(Address from, Address to); | 156 void CodeMoveEvent(Address from, Address to); |
155 void CodeDeleteEvent(Address from); | 157 void CodeDeleteEvent(Address from); |
156 void FunctionCreateEvent(Address alias, Address start, int security_token_id); | 158 void FunctionCreateEvent(Address alias, Address start, int security_token_id); |
157 void FunctionMoveEvent(Address from, Address to); | 159 void FunctionMoveEvent(Address from, Address to); |
158 void FunctionDeleteEvent(Address from); | 160 void FunctionDeleteEvent(Address from); |
159 void RegExpCodeCreateEvent(Logger::LogEventsAndTags tag, | 161 void RegExpCodeCreateEvent(Logger::LogEventsAndTags tag, |
160 const char* prefix, String* name, | 162 const char* prefix, String* name, |
161 Address start, unsigned size); | 163 Address start, unsigned size); |
| 164 // Puts current stack into tick sample events buffer. |
| 165 void AddCurrentStack(); |
162 | 166 |
163 // Tick sample events are filled directly in the buffer of the circular | 167 // Tick sample events are filled directly in the buffer of the circular |
164 // queue (because the structure is of fixed width, but usually not all | 168 // queue (because the structure is of fixed width, but usually not all |
165 // stack frame entries are filled.) This method returns a pointer to the | 169 // stack frame entries are filled.) This method returns a pointer to the |
166 // next record of the buffer. | 170 // next record of the buffer. |
167 INLINE(TickSample* TickSampleEvent()); | 171 INLINE(TickSample* TickSampleEvent()); |
168 | 172 |
169 private: | 173 private: |
170 union CodeEventsContainer { | 174 union CodeEventsContainer { |
171 CodeEventRecord generic; | 175 CodeEventRecord generic; |
172 #define DECLARE_CLASS(ignore, type) type type##_; | 176 #define DECLARE_CLASS(ignore, type) type type##_; |
173 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) | 177 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS) |
174 #undef DECLARE_TYPE | 178 #undef DECLARE_TYPE |
175 }; | 179 }; |
176 | 180 |
177 // Called from events processing thread (Run() method.) | 181 // Called from events processing thread (Run() method.) |
178 bool ProcessCodeEvent(unsigned* dequeue_order); | 182 bool ProcessCodeEvent(unsigned* dequeue_order); |
179 bool ProcessTicks(unsigned dequeue_order); | 183 bool ProcessTicks(unsigned dequeue_order); |
180 | 184 |
181 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); | 185 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag)); |
182 | 186 |
183 ProfileGenerator* generator_; | 187 ProfileGenerator* generator_; |
184 bool running_; | 188 bool running_; |
185 UnboundQueue<CodeEventsContainer> events_buffer_; | 189 UnboundQueue<CodeEventsContainer> events_buffer_; |
186 SamplingCircularQueue ticks_buffer_; | 190 SamplingCircularQueue ticks_buffer_; |
| 191 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; |
187 unsigned enqueue_order_; | 192 unsigned enqueue_order_; |
188 }; | 193 }; |
189 | 194 |
190 } } // namespace v8::internal | 195 } } // namespace v8::internal |
191 | 196 |
192 | 197 |
193 #define PROFILE(Call) \ | 198 #define PROFILE(Call) \ |
194 LOG(Call); \ | 199 LOG(Call); \ |
195 do { \ | 200 do { \ |
196 if (v8::internal::CpuProfiler::is_profiling()) { \ | 201 if (v8::internal::CpuProfiler::is_profiling()) { \ |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 #endif // ENABLE_LOGGING_AND_PROFILING | 276 #endif // ENABLE_LOGGING_AND_PROFILING |
272 | 277 |
273 private: | 278 private: |
274 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 279 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
275 }; | 280 }; |
276 | 281 |
277 } } // namespace v8::internal | 282 } } // namespace v8::internal |
278 | 283 |
279 | 284 |
280 #endif // V8_CPU_PROFILER_H_ | 285 #endif // V8_CPU_PROFILER_H_ |
OLD | NEW |