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

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

Issue 941973002: CpuProfiler: eliminate cpu-profiler dependency from heap-inl.h (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments addressed Created 5 years, 10 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/cpu-profiler.h ('k') | src/cpu-profiler-inl.h » ('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 // 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/cpu-profiler-inl.h" 7 #include "src/cpu-profiler-inl.h"
8 8
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 void CpuProfiler::CallbackEvent(Name* name, Address entry_point) { 195 void CpuProfiler::CallbackEvent(Name* name, Address entry_point) {
196 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return; 196 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return;
197 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 197 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
198 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 198 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
199 rec->start = entry_point; 199 rec->start = entry_point;
200 rec->entry = profiles_->NewCodeEntry( 200 rec->entry = profiles_->NewCodeEntry(
201 Logger::CALLBACK_TAG, 201 Logger::CALLBACK_TAG,
202 profiles_->GetName(name)); 202 profiles_->GetName(name));
203 rec->size = 1; 203 rec->size = 1;
204 rec->shared = NULL;
205 processor_->Enqueue(evt_rec); 204 processor_->Enqueue(evt_rec);
206 } 205 }
207 206
208 207
209 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, 208 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
210 Code* code, 209 Code* code,
211 const char* name) { 210 const char* name) {
212 if (FilterOutCodeCreateEvent(tag)) return; 211 if (FilterOutCodeCreateEvent(tag)) return;
213 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 212 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
214 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 213 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
215 rec->start = code->address(); 214 rec->start = code->address();
216 rec->entry = profiles_->NewCodeEntry( 215 rec->entry = profiles_->NewCodeEntry(
217 tag, profiles_->GetFunctionName(name), CodeEntry::kEmptyNamePrefix, 216 tag, profiles_->GetFunctionName(name), CodeEntry::kEmptyNamePrefix,
218 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, 217 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
219 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); 218 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start());
220 rec->size = code->ExecutableSize(); 219 rec->size = code->ExecutableSize();
221 rec->shared = NULL;
222 processor_->Enqueue(evt_rec); 220 processor_->Enqueue(evt_rec);
223 } 221 }
224 222
225 223
226 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, 224 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
227 Code* code, 225 Code* code,
228 Name* name) { 226 Name* name) {
229 if (FilterOutCodeCreateEvent(tag)) return; 227 if (FilterOutCodeCreateEvent(tag)) return;
230 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 228 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
231 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 229 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
232 rec->start = code->address(); 230 rec->start = code->address();
233 rec->entry = profiles_->NewCodeEntry( 231 rec->entry = profiles_->NewCodeEntry(
234 tag, profiles_->GetFunctionName(name), CodeEntry::kEmptyNamePrefix, 232 tag, profiles_->GetFunctionName(name), CodeEntry::kEmptyNamePrefix,
235 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, 233 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
236 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); 234 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start());
237 rec->size = code->ExecutableSize(); 235 rec->size = code->ExecutableSize();
238 rec->shared = NULL;
239 processor_->Enqueue(evt_rec); 236 processor_->Enqueue(evt_rec);
240 } 237 }
241 238
242 239
243 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, 240 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code,
244 SharedFunctionInfo* shared, 241 SharedFunctionInfo* shared,
245 CompilationInfo* info, Name* script_name) { 242 CompilationInfo* info, Name* script_name) {
246 if (FilterOutCodeCreateEvent(tag)) return; 243 if (FilterOutCodeCreateEvent(tag)) return;
247 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 244 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
248 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 245 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
249 rec->start = code->address(); 246 rec->start = code->address();
250 rec->entry = profiles_->NewCodeEntry( 247 rec->entry = profiles_->NewCodeEntry(
251 tag, profiles_->GetFunctionName(shared->DebugName()), 248 tag, profiles_->GetFunctionName(shared->DebugName()),
252 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), 249 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name),
253 CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo, 250 CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo,
254 NULL, code->instruction_start()); 251 NULL, code->instruction_start());
255 if (info) { 252 if (info) {
256 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); 253 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges());
257 } 254 }
258 if (shared->script()->IsScript()) { 255 rec->entry->FillFunctionInfo(shared);
259 DCHECK(Script::cast(shared->script()));
260 Script* script = Script::cast(shared->script());
261 rec->entry->set_script_id(script->id()->value());
262 rec->entry->set_bailout_reason(
263 GetBailoutReason(shared->disable_optimization_reason()));
264 }
265 rec->size = code->ExecutableSize(); 256 rec->size = code->ExecutableSize();
266 rec->shared = shared->address();
267 processor_->Enqueue(evt_rec); 257 processor_->Enqueue(evt_rec);
268 } 258 }
269 259
270 260
271 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, 261 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code,
272 SharedFunctionInfo* shared, 262 SharedFunctionInfo* shared,
273 CompilationInfo* info, Name* script_name, 263 CompilationInfo* info, Name* script_name,
274 int line, int column) { 264 int line, int column) {
275 if (FilterOutCodeCreateEvent(tag)) return; 265 if (FilterOutCodeCreateEvent(tag)) return;
276 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 266 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
(...skipping 15 matching lines...) Expand all
292 } 282 }
293 } 283 }
294 } 284 }
295 rec->entry = profiles_->NewCodeEntry( 285 rec->entry = profiles_->NewCodeEntry(
296 tag, profiles_->GetFunctionName(shared->DebugName()), 286 tag, profiles_->GetFunctionName(shared->DebugName()),
297 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), line, 287 CodeEntry::kEmptyNamePrefix, profiles_->GetName(script_name), line,
298 column, line_table, code->instruction_start()); 288 column, line_table, code->instruction_start());
299 if (info) { 289 if (info) {
300 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); 290 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges());
301 } 291 }
302 rec->entry->set_script_id(script->id()->value()); 292 rec->entry->FillFunctionInfo(shared);
303 rec->size = code->ExecutableSize(); 293 rec->size = code->ExecutableSize();
304 rec->shared = shared->address();
305 rec->entry->set_bailout_reason(
306 GetBailoutReason(shared->disable_optimization_reason()));
307 processor_->Enqueue(evt_rec); 294 processor_->Enqueue(evt_rec);
308 } 295 }
309 296
310 297
311 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, 298 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag,
312 Code* code, 299 Code* code,
313 int args_count) { 300 int args_count) {
314 if (FilterOutCodeCreateEvent(tag)) return; 301 if (FilterOutCodeCreateEvent(tag)) return;
315 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 302 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
316 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 303 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
317 rec->start = code->address(); 304 rec->start = code->address();
318 rec->entry = profiles_->NewCodeEntry( 305 rec->entry = profiles_->NewCodeEntry(
319 tag, profiles_->GetName(args_count), "args_count: ", 306 tag, profiles_->GetName(args_count), "args_count: ",
320 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, 307 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
321 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); 308 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start());
322 rec->size = code->ExecutableSize(); 309 rec->size = code->ExecutableSize();
323 rec->shared = NULL;
324 processor_->Enqueue(evt_rec); 310 processor_->Enqueue(evt_rec);
325 } 311 }
326 312
327 313
328 void CpuProfiler::CodeMoveEvent(Address from, Address to) { 314 void CpuProfiler::CodeMoveEvent(Address from, Address to) {
329 CodeEventsContainer evt_rec(CodeEventRecord::CODE_MOVE); 315 CodeEventsContainer evt_rec(CodeEventRecord::CODE_MOVE);
330 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_; 316 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_;
331 rec->from = from; 317 rec->from = from;
332 rec->to = to; 318 rec->to = to;
333 processor_->Enqueue(evt_rec); 319 processor_->Enqueue(evt_rec);
(...skipping 19 matching lines...) Expand all
353 rec->raw_position = info.raw_position; 339 rec->raw_position = info.raw_position;
354 processor_->Enqueue(evt_rec); 340 processor_->Enqueue(evt_rec);
355 processor_->AddDeoptStack(isolate_, pc, fp_to_sp_delta); 341 processor_->AddDeoptStack(isolate_, pc, fp_to_sp_delta);
356 } 342 }
357 343
358 344
359 void CpuProfiler::CodeDeleteEvent(Address from) { 345 void CpuProfiler::CodeDeleteEvent(Address from) {
360 } 346 }
361 347
362 348
363 void CpuProfiler::SharedFunctionInfoMoveEvent(Address from, Address to) {
364 CodeEventsContainer evt_rec(CodeEventRecord::SHARED_FUNC_MOVE);
365 SharedFunctionInfoMoveEventRecord* rec =
366 &evt_rec.SharedFunctionInfoMoveEventRecord_;
367 rec->from = from;
368 rec->to = to;
369 processor_->Enqueue(evt_rec);
370 }
371
372
373 void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) { 349 void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) {
374 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return; 350 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return;
375 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 351 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
376 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 352 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
377 rec->start = entry_point; 353 rec->start = entry_point;
378 rec->entry = profiles_->NewCodeEntry( 354 rec->entry = profiles_->NewCodeEntry(
379 Logger::CALLBACK_TAG, 355 Logger::CALLBACK_TAG,
380 profiles_->GetName(name), 356 profiles_->GetName(name),
381 "get "); 357 "get ");
382 rec->size = 1; 358 rec->size = 1;
383 rec->shared = NULL;
384 processor_->Enqueue(evt_rec); 359 processor_->Enqueue(evt_rec);
385 } 360 }
386 361
387 362
388 void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) { 363 void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) {
389 if (FilterOutCodeCreateEvent(Logger::REG_EXP_TAG)) return; 364 if (FilterOutCodeCreateEvent(Logger::REG_EXP_TAG)) return;
390 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 365 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
391 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 366 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
392 rec->start = code->address(); 367 rec->start = code->address();
393 rec->entry = profiles_->NewCodeEntry( 368 rec->entry = profiles_->NewCodeEntry(
394 Logger::REG_EXP_TAG, profiles_->GetName(source), "RegExp: ", 369 Logger::REG_EXP_TAG, profiles_->GetName(source), "RegExp: ",
395 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, 370 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo,
396 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); 371 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start());
397 rec->size = code->ExecutableSize(); 372 rec->size = code->ExecutableSize();
398 processor_->Enqueue(evt_rec); 373 processor_->Enqueue(evt_rec);
399 } 374 }
400 375
401 376
402 void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) { 377 void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) {
403 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return; 378 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return;
404 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); 379 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
405 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; 380 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
406 rec->start = entry_point; 381 rec->start = entry_point;
407 rec->entry = profiles_->NewCodeEntry( 382 rec->entry = profiles_->NewCodeEntry(
408 Logger::CALLBACK_TAG, 383 Logger::CALLBACK_TAG,
409 profiles_->GetName(name), 384 profiles_->GetName(name),
410 "set "); 385 "set ");
411 rec->size = 1; 386 rec->size = 1;
412 rec->shared = NULL;
413 processor_->Enqueue(evt_rec); 387 processor_->Enqueue(evt_rec);
414 } 388 }
415 389
416 390
417 CpuProfiler::CpuProfiler(Isolate* isolate) 391 CpuProfiler::CpuProfiler(Isolate* isolate)
418 : isolate_(isolate), 392 : isolate_(isolate),
419 sampling_interval_(base::TimeDelta::FromMicroseconds( 393 sampling_interval_(base::TimeDelta::FromMicroseconds(
420 FLAG_cpu_profiler_sampling_interval)), 394 FLAG_cpu_profiler_sampling_interval)),
421 profiles_(new CpuProfilesCollection(isolate->heap())), 395 profiles_(new CpuProfilesCollection(isolate->heap())),
422 generator_(NULL), 396 generator_(NULL),
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; 520 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_;
547 Builtins::Name id = static_cast<Builtins::Name>(i); 521 Builtins::Name id = static_cast<Builtins::Name>(i);
548 rec->start = builtins->builtin(id)->address(); 522 rec->start = builtins->builtin(id)->address();
549 rec->builtin_id = id; 523 rec->builtin_id = id;
550 processor_->Enqueue(evt_rec); 524 processor_->Enqueue(evt_rec);
551 } 525 }
552 } 526 }
553 527
554 528
555 } } // namespace v8::internal 529 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/cpu-profiler.h ('k') | src/cpu-profiler-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698