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

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

Issue 1474353002: Remove easy to remove calls to Isolate::Current() from api.cc (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update Created 5 years 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/debug/debug.h" 8 #include "src/debug/debug.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/global-handles.h" 10 #include "src/global-handles.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 void BeforeTraversingChild(ProfileNode*, ProfileNode*) { } 242 void BeforeTraversingChild(ProfileNode*, ProfileNode*) { }
243 243
244 void AfterAllChildrenTraversed(ProfileNode* node) { 244 void AfterAllChildrenTraversed(ProfileNode* node) {
245 delete node; 245 delete node;
246 } 246 }
247 247
248 void AfterChildTraversed(ProfileNode*, ProfileNode*) { } 248 void AfterChildTraversed(ProfileNode*, ProfileNode*) { }
249 }; 249 };
250 250
251 251
252 ProfileTree::ProfileTree() 252 ProfileTree::ProfileTree(Isolate* isolate)
253 : root_entry_(Logger::FUNCTION_TAG, "(root)"), 253 : root_entry_(Logger::FUNCTION_TAG, "(root)"),
254 next_node_id_(1), 254 next_node_id_(1),
255 root_(new ProfileNode(this, &root_entry_)), 255 root_(new ProfileNode(this, &root_entry_)),
256 isolate_(isolate),
256 next_function_id_(1), 257 next_function_id_(1),
257 function_ids_(ProfileNode::CodeEntriesMatch) {} 258 function_ids_(ProfileNode::CodeEntriesMatch) {}
258 259
259 260
260 ProfileTree::~ProfileTree() { 261 ProfileTree::~ProfileTree() {
261 DeleteNodesCallback cb; 262 DeleteNodesCallback cb;
262 TraverseDepthFirst(&cb); 263 TraverseDepthFirst(&cb);
263 } 264 }
264 265
265 266
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 callback->AfterChildTraversed(parent.node, current.node); 341 callback->AfterChildTraversed(parent.node, current.node);
341 parent.next_child(); 342 parent.next_child();
342 } 343 }
343 // Remove child from the stack. 344 // Remove child from the stack.
344 stack.RemoveLast(); 345 stack.RemoveLast();
345 } 346 }
346 } 347 }
347 } 348 }
348 349
349 350
350 CpuProfile::CpuProfile(const char* title, bool record_samples) 351 CpuProfile::CpuProfile(Isolate* isolate, const char* title, bool record_samples)
351 : title_(title), 352 : title_(title),
352 record_samples_(record_samples), 353 record_samples_(record_samples),
353 start_time_(base::TimeTicks::HighResolutionNow()) { 354 start_time_(base::TimeTicks::HighResolutionNow()),
354 } 355 top_down_(isolate) {}
355 356
356 357
357 void CpuProfile::AddPath(base::TimeTicks timestamp, 358 void CpuProfile::AddPath(base::TimeTicks timestamp,
358 const Vector<CodeEntry*>& path, int src_line) { 359 const Vector<CodeEntry*>& path, int src_line) {
359 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path, src_line); 360 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path, src_line);
360 if (record_samples_) { 361 if (record_samples_) {
361 timestamps_.Add(timestamp); 362 timestamps_.Add(timestamp);
362 samples_.Add(top_frame_node); 363 samples_.Add(top_frame_node);
363 } 364 }
364 } 365 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 434
434 435
435 void CodeMap::Print() { 436 void CodeMap::Print() {
436 CodeTreePrinter printer; 437 CodeTreePrinter printer;
437 tree_.ForEach(&printer); 438 tree_.ForEach(&printer);
438 } 439 }
439 440
440 441
441 CpuProfilesCollection::CpuProfilesCollection(Heap* heap) 442 CpuProfilesCollection::CpuProfilesCollection(Heap* heap)
442 : function_and_resource_names_(heap), 443 : function_and_resource_names_(heap),
443 current_profiles_semaphore_(1) { 444 isolate_(heap->isolate()),
444 } 445 current_profiles_semaphore_(1) {}
445 446
446 447
447 static void DeleteCodeEntry(CodeEntry** entry_ptr) { 448 static void DeleteCodeEntry(CodeEntry** entry_ptr) {
448 delete *entry_ptr; 449 delete *entry_ptr;
449 } 450 }
450 451
451 452
452 static void DeleteCpuProfile(CpuProfile** profile_ptr) { 453 static void DeleteCpuProfile(CpuProfile** profile_ptr) {
453 delete *profile_ptr; 454 delete *profile_ptr;
454 } 455 }
(...skipping 14 matching lines...) Expand all
469 return false; 470 return false;
470 } 471 }
471 for (int i = 0; i < current_profiles_.length(); ++i) { 472 for (int i = 0; i < current_profiles_.length(); ++i) {
472 if (strcmp(current_profiles_[i]->title(), title) == 0) { 473 if (strcmp(current_profiles_[i]->title(), title) == 0) {
473 // Ignore attempts to start profile with the same title... 474 // Ignore attempts to start profile with the same title...
474 current_profiles_semaphore_.Signal(); 475 current_profiles_semaphore_.Signal();
475 // ... though return true to force it collect a sample. 476 // ... though return true to force it collect a sample.
476 return true; 477 return true;
477 } 478 }
478 } 479 }
479 current_profiles_.Add(new CpuProfile(title, record_samples)); 480 current_profiles_.Add(new CpuProfile(isolate_, title, record_samples));
480 current_profiles_semaphore_.Signal(); 481 current_profiles_semaphore_.Signal();
481 return true; 482 return true;
482 } 483 }
483 484
484 485
485 CpuProfile* CpuProfilesCollection::StopProfiling(const char* title) { 486 CpuProfile* CpuProfilesCollection::StopProfiling(const char* title) {
486 const int title_len = StrLength(title); 487 const int title_len = StrLength(title);
487 CpuProfile* profile = NULL; 488 CpuProfile* profile = NULL;
488 current_profiles_semaphore_.Wait(); 489 current_profiles_semaphore_.Wait();
489 for (int i = current_profiles_.length() - 1; i >= 0; --i) { 490 for (int i = current_profiles_.length() - 1; i >= 0; --i) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 case EXTERNAL: 686 case EXTERNAL:
686 return program_entry_; 687 return program_entry_;
687 case IDLE: 688 case IDLE:
688 return idle_entry_; 689 return idle_entry_;
689 default: return NULL; 690 default: return NULL;
690 } 691 }
691 } 692 }
692 693
693 } // namespace internal 694 } // namespace internal
694 } // namespace v8 695 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698