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

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

Issue 157503002: A64: Synchronize with r18444. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/profile-generator.h ('k') | src/property-details.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 // 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 callback->AfterChildTraversed(parent.node, current.node); 345 callback->AfterChildTraversed(parent.node, current.node);
346 parent.next_child(); 346 parent.next_child();
347 } 347 }
348 // Remove child from the stack. 348 // Remove child from the stack.
349 stack.RemoveLast(); 349 stack.RemoveLast();
350 } 350 }
351 } 351 }
352 } 352 }
353 353
354 354
355 CpuProfile::CpuProfile(const char* title, unsigned uid, bool record_samples) 355 CpuProfile::CpuProfile(const char* title, bool record_samples)
356 : title_(title), 356 : title_(title),
357 uid_(uid),
358 record_samples_(record_samples), 357 record_samples_(record_samples),
359 start_time_(Time::NowFromSystemTime()) { 358 start_time_(Time::NowFromSystemTime()) {
360 timer_.Start(); 359 timer_.Start();
361 } 360 }
362 361
363 362
364 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) { 363 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {
365 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path); 364 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path);
366 if (record_samples_) samples_.Add(top_frame_node); 365 if (record_samples_) samples_.Add(top_frame_node);
367 } 366 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 478 }
480 479
481 480
482 CpuProfilesCollection::~CpuProfilesCollection() { 481 CpuProfilesCollection::~CpuProfilesCollection() {
483 finished_profiles_.Iterate(DeleteCpuProfile); 482 finished_profiles_.Iterate(DeleteCpuProfile);
484 current_profiles_.Iterate(DeleteCpuProfile); 483 current_profiles_.Iterate(DeleteCpuProfile);
485 code_entries_.Iterate(DeleteCodeEntry); 484 code_entries_.Iterate(DeleteCodeEntry);
486 } 485 }
487 486
488 487
489 bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid, 488 bool CpuProfilesCollection::StartProfiling(const char* title,
490 bool record_samples) { 489 bool record_samples) {
491 ASSERT(uid > 0);
492 current_profiles_semaphore_.Wait(); 490 current_profiles_semaphore_.Wait();
493 if (current_profiles_.length() >= kMaxSimultaneousProfiles) { 491 if (current_profiles_.length() >= kMaxSimultaneousProfiles) {
494 current_profiles_semaphore_.Signal(); 492 current_profiles_semaphore_.Signal();
495 return false; 493 return false;
496 } 494 }
497 for (int i = 0; i < current_profiles_.length(); ++i) { 495 for (int i = 0; i < current_profiles_.length(); ++i) {
498 if (strcmp(current_profiles_[i]->title(), title) == 0) { 496 if (strcmp(current_profiles_[i]->title(), title) == 0) {
499 // Ignore attempts to start profile with the same title. 497 // Ignore attempts to start profile with the same title.
500 current_profiles_semaphore_.Signal(); 498 current_profiles_semaphore_.Signal();
501 return false; 499 return false;
502 } 500 }
503 } 501 }
504 current_profiles_.Add(new CpuProfile(title, uid, record_samples)); 502 current_profiles_.Add(new CpuProfile(title, record_samples));
505 current_profiles_semaphore_.Signal(); 503 current_profiles_semaphore_.Signal();
506 return true; 504 return true;
507 } 505 }
508 506
509 507
510 CpuProfile* CpuProfilesCollection::StopProfiling(const char* title) { 508 CpuProfile* CpuProfilesCollection::StopProfiling(const char* title) {
511 const int title_len = StrLength(title); 509 const int title_len = StrLength(title);
512 CpuProfile* profile = NULL; 510 CpuProfile* profile = NULL;
513 current_profiles_semaphore_.Wait(); 511 current_profiles_semaphore_.Wait();
514 for (int i = current_profiles_.length() - 1; i >= 0; --i) { 512 for (int i = current_profiles_.length() - 1; i >= 0; --i) {
(...skipping 15 matching lines...) Expand all
530 // Called from VM thread, and only it can mutate the list, 528 // Called from VM thread, and only it can mutate the list,
531 // so no locking is needed here. 529 // so no locking is needed here.
532 if (current_profiles_.length() != 1) return false; 530 if (current_profiles_.length() != 1) return false;
533 return StrLength(title) == 0 531 return StrLength(title) == 0
534 || strcmp(current_profiles_[0]->title(), title) == 0; 532 || strcmp(current_profiles_[0]->title(), title) == 0;
535 } 533 }
536 534
537 535
538 void CpuProfilesCollection::RemoveProfile(CpuProfile* profile) { 536 void CpuProfilesCollection::RemoveProfile(CpuProfile* profile) {
539 // Called from VM thread for a completed profile. 537 // Called from VM thread for a completed profile.
540 unsigned uid = profile->uid();
541 for (int i = 0; i < finished_profiles_.length(); i++) { 538 for (int i = 0; i < finished_profiles_.length(); i++) {
542 if (uid == finished_profiles_[i]->uid()) { 539 if (profile == finished_profiles_[i]) {
543 finished_profiles_.Remove(i); 540 finished_profiles_.Remove(i);
544 return; 541 return;
545 } 542 }
546 } 543 }
547 UNREACHABLE(); 544 UNREACHABLE();
548 } 545 }
549 546
550 547
551 void CpuProfilesCollection::AddPathToCurrentProfiles( 548 void CpuProfilesCollection::AddPathToCurrentProfiles(
552 const Vector<CodeEntry*>& path) { 549 const Vector<CodeEntry*>& path) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 case OTHER: 691 case OTHER:
695 case EXTERNAL: 692 case EXTERNAL:
696 return program_entry_; 693 return program_entry_;
697 case IDLE: 694 case IDLE:
698 return idle_entry_; 695 return idle_entry_;
699 default: return NULL; 696 default: return NULL;
700 } 697 }
701 } 698 }
702 699
703 } } // namespace v8::internal 700 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | src/property-details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698