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

Side by Side Diff: src/cpu-profiler.h

Issue 18053004: CpuProfiler: eliminate 2 layers of 4 for CodeCreateEvent calls. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: win32 compile error was fixed 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 | « no previous file | src/cpu-profiler.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 public: 56 public:
57 #define DECLARE_TYPE(type, ignore) type, 57 #define DECLARE_TYPE(type, ignore) type,
58 enum Type { 58 enum Type {
59 NONE = 0, 59 NONE = 0,
60 CODE_EVENTS_TYPE_LIST(DECLARE_TYPE) 60 CODE_EVENTS_TYPE_LIST(DECLARE_TYPE)
61 NUMBER_OF_TYPES 61 NUMBER_OF_TYPES
62 }; 62 };
63 #undef DECLARE_TYPE 63 #undef DECLARE_TYPE
64 64
65 Type type; 65 Type type;
66 unsigned order; 66 mutable unsigned order;
67 }; 67 };
68 68
69 69
70 class CodeCreateEventRecord : public CodeEventRecord { 70 class CodeCreateEventRecord : public CodeEventRecord {
71 public: 71 public:
72 Address start; 72 Address start;
73 CodeEntry* entry; 73 CodeEntry* entry;
74 unsigned size; 74 unsigned size;
75 Address shared; 75 Address shared;
76 76
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 int filler; 115 int filler;
116 unsigned order; 116 unsigned order;
117 TickSample sample; 117 TickSample sample;
118 118
119 static TickSampleEventRecord* cast(void* value) { 119 static TickSampleEventRecord* cast(void* value) {
120 return reinterpret_cast<TickSampleEventRecord*>(value); 120 return reinterpret_cast<TickSampleEventRecord*>(value);
121 } 121 }
122 }; 122 };
123 123
124 124
125 class CodeEventsContainer {
126 public:
127 explicit CodeEventsContainer(
128 CodeEventRecord::Type type = CodeEventRecord::NONE) {
129 generic.type = type;
130 }
131 union {
132 CodeEventRecord generic;
133 #define DECLARE_CLASS(ignore, type) type type##_;
134 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS)
135 #undef DECLARE_TYPE
136 };
137 };
138
139
125 // This class implements both the profile events processor thread and 140 // This class implements both the profile events processor thread and
126 // methods called by event producers: VM and stack sampler threads. 141 // methods called by event producers: VM and stack sampler threads.
127 class ProfilerEventsProcessor : public Thread { 142 class ProfilerEventsProcessor : public Thread {
128 public: 143 public:
129 ProfilerEventsProcessor(ProfileGenerator* generator, 144 ProfilerEventsProcessor(ProfileGenerator* generator,
130 CpuProfilesCollection* profiles); 145 CpuProfilesCollection* profiles);
131 virtual ~ProfilerEventsProcessor() {} 146 virtual ~ProfilerEventsProcessor() {}
132 147
133 // Thread control. 148 // Thread control.
134 virtual void Run(); 149 virtual void Run();
135 inline void Stop() { running_ = false; } 150 inline void Stop() { running_ = false; }
136 INLINE(bool running()) { return running_; } 151 INLINE(bool running()) { return running_; }
152 void Enqueue(const CodeEventsContainer& event);
137 153
138 // Events adding methods. Called by VM threads.
139 void CallbackCreateEvent(Logger::LogEventsAndTags tag,
140 const char* prefix, Name* name,
141 Address start);
142 void CodeCreateEvent(Logger::LogEventsAndTags tag,
143 Name* name,
144 String* resource_name, int line_number,
145 Address start, unsigned size,
146 Address shared,
147 CompilationInfo* info);
148 void CodeCreateEvent(Logger::LogEventsAndTags tag,
149 const char* name,
150 Address start, unsigned size);
151 void CodeCreateEvent(Logger::LogEventsAndTags tag,
152 int args_count,
153 Address start, unsigned size);
154 void CodeMoveEvent(Address from, Address to);
155 void CodeDeleteEvent(Address from);
156 void SharedFunctionInfoMoveEvent(Address from, Address to);
157 void RegExpCodeCreateEvent(Logger::LogEventsAndTags tag,
158 const char* prefix, String* name,
159 Address start, unsigned size);
160 // Puts current stack into tick sample events buffer. 154 // Puts current stack into tick sample events buffer.
161 void AddCurrentStack(); 155 void AddCurrentStack();
162 156
163 // Tick sample events are filled directly in the buffer of the circular 157 // 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 158 // 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 159 // stack frame entries are filled.) This method returns a pointer to the
166 // next record of the buffer. 160 // next record of the buffer.
167 INLINE(TickSample* TickSampleEvent()); 161 INLINE(TickSample* TickSampleEvent());
168 162
169 private: 163 private:
170 union CodeEventsContainer {
171 CodeEventRecord generic;
172 #define DECLARE_CLASS(ignore, type) type type##_;
173 CODE_EVENTS_TYPE_LIST(DECLARE_CLASS)
174 #undef DECLARE_TYPE
175 };
176
177 // Called from events processing thread (Run() method.) 164 // Called from events processing thread (Run() method.)
178 bool ProcessCodeEvent(unsigned* dequeue_order); 165 bool ProcessCodeEvent(unsigned* dequeue_order);
179 bool ProcessTicks(unsigned dequeue_order); 166 bool ProcessTicks(unsigned dequeue_order);
180 167
181 INLINE(static bool FilterOutCodeCreateEvent(Logger::LogEventsAndTags tag));
182
183 ProfileGenerator* generator_; 168 ProfileGenerator* generator_;
184 CpuProfilesCollection* profiles_; 169 CpuProfilesCollection* profiles_;
185 bool running_; 170 bool running_;
186 UnboundQueue<CodeEventsContainer> events_buffer_; 171 UnboundQueue<CodeEventsContainer> events_buffer_;
187 SamplingCircularQueue ticks_buffer_; 172 SamplingCircularQueue ticks_buffer_;
188 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; 173 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_;
189 unsigned enqueue_order_; 174 unsigned enqueue_order_;
190 }; 175 };
191 176
192 177
193 #define PROFILE(IsolateGetter, Call) \ 178 #define PROFILE(IsolateGetter, Call) \
194 do { \ 179 do { \
195 Isolate* cpu_profiler_isolate = (IsolateGetter); \ 180 Isolate* cpu_profiler_isolate = (IsolateGetter); \
196 LOG_CODE_EVENT(cpu_profiler_isolate, Call); \ 181 LOG_CODE_EVENT(cpu_profiler_isolate, Call); \
197 CpuProfiler* cpu_profiler = cpu_profiler_isolate->cpu_profiler(); \ 182 CpuProfiler* cpu_profiler = cpu_profiler_isolate->cpu_profiler(); \
198 if (cpu_profiler->is_profiling()) { \ 183 if (cpu_profiler->is_profiling()) { \
199 cpu_profiler->Call; \ 184 cpu_profiler->Call; \
200 } \ 185 } \
201 } while (false) 186 } while (false)
202 187
203 188
204 class CpuProfiler { 189 class CpuProfiler {
205 public: 190 public:
206 explicit CpuProfiler(Isolate* isolate); 191 explicit CpuProfiler(Isolate* isolate);
192
193 CpuProfiler(Isolate* isolate,
194 CpuProfilesCollection* test_collection,
195 ProfileGenerator* test_generator,
196 ProfilerEventsProcessor* test_processor);
197
207 ~CpuProfiler(); 198 ~CpuProfiler();
208 199
209 void StartProfiling(const char* title, bool record_samples = false); 200 void StartProfiling(const char* title, bool record_samples = false);
210 void StartProfiling(String* title, bool record_samples); 201 void StartProfiling(String* title, bool record_samples);
211 CpuProfile* StopProfiling(const char* title); 202 CpuProfile* StopProfiling(const char* title);
212 CpuProfile* StopProfiling(Object* security_token, String* title); 203 CpuProfile* StopProfiling(Object* security_token, String* title);
213 int GetProfilesCount(); 204 int GetProfilesCount();
214 CpuProfile* GetProfile(Object* security_token, int index); 205 CpuProfile* GetProfile(Object* security_token, int index);
215 CpuProfile* FindProfile(Object* security_token, unsigned uid); 206 CpuProfile* FindProfile(Object* security_token, unsigned uid);
216 void DeleteAllProfiles(); 207 void DeleteAllProfiles();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 bool is_profiling_; 260 bool is_profiling_;
270 261
271 private: 262 private:
272 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); 263 DISALLOW_COPY_AND_ASSIGN(CpuProfiler);
273 }; 264 };
274 265
275 } } // namespace v8::internal 266 } } // namespace v8::internal
276 267
277 268
278 #endif // V8_CPU_PROFILER_H_ 269 #endif // V8_CPU_PROFILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698