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

Side by Side Diff: src/profiler/profile-generator.cc

Issue 2056253003: Remove Isolate::cpu_profiler() usage in api.cc (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
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/profiler/profile-generator.h" 5 #include "src/profiler/profile-generator.h"
6 6
7 #include "src/ast/scopeinfo.h" 7 #include "src/ast/scopeinfo.h"
8 #include "src/base/adapters.h" 8 #include "src/base/adapters.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
11 #include "src/global-handles.h" 11 #include "src/global-handles.h"
12 #include "src/profiler/cpu-profiler.h"
12 #include "src/profiler/profile-generator-inl.h" 13 #include "src/profiler/profile-generator-inl.h"
13 #include "src/profiler/tick-sample.h" 14 #include "src/profiler/tick-sample.h"
14 #include "src/unicode.h" 15 #include "src/unicode.h"
15 16
16 namespace v8 { 17 namespace v8 {
17 namespace internal { 18 namespace internal {
18 19
19 20
20 JITLineInfoTable::JITLineInfoTable() {} 21 JITLineInfoTable::JITLineInfoTable() {}
21 22
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 Position& parent = stack[stack.length() - 2]; 359 Position& parent = stack[stack.length() - 2];
359 callback->AfterChildTraversed(parent.node, current.node); 360 callback->AfterChildTraversed(parent.node, current.node);
360 parent.next_child(); 361 parent.next_child();
361 } 362 }
362 // Remove child from the stack. 363 // Remove child from the stack.
363 stack.RemoveLast(); 364 stack.RemoveLast();
364 } 365 }
365 } 366 }
366 } 367 }
367 368
368 369 CpuProfile::CpuProfile(CpuProfiler* profiler, const char* title,
369 CpuProfile::CpuProfile(Isolate* isolate, const char* title, bool record_samples) 370 bool record_samples)
370 : title_(title), 371 : title_(title),
371 record_samples_(record_samples), 372 record_samples_(record_samples),
372 start_time_(base::TimeTicks::HighResolutionNow()), 373 start_time_(base::TimeTicks::HighResolutionNow()),
373 top_down_(isolate) {} 374 top_down_(profiler->isolate()),
375 profiler_(profiler) {}
374 376
375 void CpuProfile::AddPath(base::TimeTicks timestamp, 377 void CpuProfile::AddPath(base::TimeTicks timestamp,
376 const std::vector<CodeEntry*>& path, int src_line, 378 const std::vector<CodeEntry*>& path, int src_line,
377 bool update_stats) { 379 bool update_stats) {
378 ProfileNode* top_frame_node = 380 ProfileNode* top_frame_node =
379 top_down_.AddPathFromEnd(path, src_line, update_stats); 381 top_down_.AddPathFromEnd(path, src_line, update_stats);
380 if (record_samples_ && !timestamp.IsNull()) { 382 if (record_samples_ && !timestamp.IsNull()) {
381 timestamps_.Add(timestamp); 383 timestamps_.Add(timestamp);
382 samples_.Add(top_frame_node); 384 samples_.Add(top_frame_node);
383 } 385 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 AddCode(to, info.entry, info.size); 427 AddCode(to, info.entry, info.size);
426 } 428 }
427 429
428 void CodeMap::Print() { 430 void CodeMap::Print() {
429 for (auto it = code_map_.begin(); it != code_map_.end(); ++it) { 431 for (auto it = code_map_.begin(); it != code_map_.end(); ++it) {
430 base::OS::Print("%p %5d %s\n", static_cast<void*>(it->first), 432 base::OS::Print("%p %5d %s\n", static_cast<void*>(it->first),
431 it->second.size, it->second.entry->name()); 433 it->second.size, it->second.entry->name());
432 } 434 }
433 } 435 }
434 436
435 CpuProfilesCollection::CpuProfilesCollection(Heap* heap) 437 CpuProfilesCollection::CpuProfilesCollection(Isolate* isolate)
436 : function_and_resource_names_(heap), 438 : function_and_resource_names_(isolate->heap()),
437 isolate_(heap->isolate()), 439 profiler_(nullptr),
438 current_profiles_semaphore_(1) {} 440 current_profiles_semaphore_(1) {}
439 441
440
441 static void DeleteCodeEntry(CodeEntry** entry_ptr) { 442 static void DeleteCodeEntry(CodeEntry** entry_ptr) {
442 delete *entry_ptr; 443 delete *entry_ptr;
443 } 444 }
444 445
445 446
446 static void DeleteCpuProfile(CpuProfile** profile_ptr) { 447 static void DeleteCpuProfile(CpuProfile** profile_ptr) {
447 delete *profile_ptr; 448 delete *profile_ptr;
448 } 449 }
449 450
450 451
(...skipping 12 matching lines...) Expand all
463 return false; 464 return false;
464 } 465 }
465 for (int i = 0; i < current_profiles_.length(); ++i) { 466 for (int i = 0; i < current_profiles_.length(); ++i) {
466 if (strcmp(current_profiles_[i]->title(), title) == 0) { 467 if (strcmp(current_profiles_[i]->title(), title) == 0) {
467 // Ignore attempts to start profile with the same title... 468 // Ignore attempts to start profile with the same title...
468 current_profiles_semaphore_.Signal(); 469 current_profiles_semaphore_.Signal();
469 // ... though return true to force it collect a sample. 470 // ... though return true to force it collect a sample.
470 return true; 471 return true;
471 } 472 }
472 } 473 }
473 current_profiles_.Add(new CpuProfile(isolate_, title, record_samples)); 474 current_profiles_.Add(new CpuProfile(profiler_, title, record_samples));
474 current_profiles_semaphore_.Signal(); 475 current_profiles_semaphore_.Signal();
475 return true; 476 return true;
476 } 477 }
477 478
478 479
479 CpuProfile* CpuProfilesCollection::StopProfiling(const char* title) { 480 CpuProfile* CpuProfilesCollection::StopProfiling(const char* title) {
480 const int title_len = StrLength(title); 481 const int title_len = StrLength(title);
481 CpuProfile* profile = NULL; 482 CpuProfile* profile = NULL;
482 current_profiles_semaphore_.Wait(); 483 current_profiles_semaphore_.Wait();
483 for (int i = current_profiles_.length() - 1; i >= 0; --i) { 484 for (int i = current_profiles_.length() - 1; i >= 0; --i) {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 case EXTERNAL: 685 case EXTERNAL:
685 return program_entry_; 686 return program_entry_;
686 case IDLE: 687 case IDLE:
687 return idle_entry_; 688 return idle_entry_;
688 default: return NULL; 689 default: return NULL;
689 } 690 }
690 } 691 }
691 692
692 } // namespace internal 693 } // namespace internal
693 } // namespace v8 694 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698