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

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

Issue 12475016: Maintain API compatibility with older versions of V8. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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/profile-generator-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 // 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 }; 289 };
290 290
291 291
292 ProfileTree::ProfileTree() 292 ProfileTree::ProfileTree()
293 : root_entry_(Logger::FUNCTION_TAG, 293 : root_entry_(Logger::FUNCTION_TAG,
294 "", 294 "",
295 "(root)", 295 "(root)",
296 "", 296 "",
297 0, 297 0,
298 TokenEnumerator::kNoSecurityToken), 298 TokenEnumerator::kNoSecurityToken),
299 next_node_id_(1),
300 root_(new ProfileNode(this, &root_entry_)) { 299 root_(new ProfileNode(this, &root_entry_)) {
301 } 300 }
302 301
303 302
304 ProfileTree::~ProfileTree() { 303 ProfileTree::~ProfileTree() {
305 DeleteNodesCallback cb; 304 DeleteNodesCallback cb;
306 TraverseDepthFirst(&cb); 305 TraverseDepthFirst(&cb);
307 } 306 }
308 307
309 308
310 ProfileNode* ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path) { 309 void ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path) {
311 ProfileNode* node = root_; 310 ProfileNode* node = root_;
312 for (CodeEntry** entry = path.start() + path.length() - 1; 311 for (CodeEntry** entry = path.start() + path.length() - 1;
313 entry != path.start() - 1; 312 entry != path.start() - 1;
314 --entry) { 313 --entry) {
315 if (*entry != NULL) { 314 if (*entry != NULL) {
316 node = node->FindOrAddChild(*entry); 315 node = node->FindOrAddChild(*entry);
317 } 316 }
318 } 317 }
319 node->IncrementSelfTicks(); 318 node->IncrementSelfTicks();
320 return node;
321 } 319 }
322 320
323 321
324 void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path) { 322 void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path) {
325 ProfileNode* node = root_; 323 ProfileNode* node = root_;
326 for (CodeEntry** entry = path.start(); 324 for (CodeEntry** entry = path.start();
327 entry != path.start() + path.length(); 325 entry != path.start() + path.length();
328 ++entry) { 326 ++entry) {
329 if (*entry != NULL) { 327 if (*entry != NULL) {
330 node = node->FindOrAddChild(*entry); 328 node = node->FindOrAddChild(*entry);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 460
463 461
464 void ProfileTree::ShortPrint() { 462 void ProfileTree::ShortPrint() {
465 OS::Print("root: %u %u %.2fms %.2fms\n", 463 OS::Print("root: %u %u %.2fms %.2fms\n",
466 root_->total_ticks(), root_->self_ticks(), 464 root_->total_ticks(), root_->self_ticks(),
467 root_->GetTotalMillis(), root_->GetSelfMillis()); 465 root_->GetTotalMillis(), root_->GetSelfMillis());
468 } 466 }
469 467
470 468
471 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) { 469 void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {
472 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path); 470 top_down_.AddPathFromEnd(path);
473 if (record_samples_) samples_.Add(top_frame_node);
474 } 471 }
475 472
476 473
477 void CpuProfile::CalculateTotalTicks() { 474 void CpuProfile::CalculateTotalTicks() {
478 top_down_.CalculateTotalTicks(); 475 top_down_.CalculateTotalTicks();
479 } 476 }
480 477
481 478
482 void CpuProfile::SetActualSamplingRate(double actual_sampling_rate) { 479 void CpuProfile::SetActualSamplingRate(double actual_sampling_rate) {
483 top_down_.SetTickRatePerMs(actual_sampling_rate); 480 top_down_.SetTickRatePerMs(actual_sampling_rate);
484 } 481 }
485 482
486 483
487 CpuProfile* CpuProfile::FilteredClone(int security_token_id) { 484 CpuProfile* CpuProfile::FilteredClone(int security_token_id) {
488 ASSERT(security_token_id != TokenEnumerator::kNoSecurityToken); 485 ASSERT(security_token_id != TokenEnumerator::kNoSecurityToken);
489 CpuProfile* clone = new CpuProfile(title_, uid_, false); 486 CpuProfile* clone = new CpuProfile(title_, uid_);
490 clone->top_down_.FilteredClone(&top_down_, security_token_id); 487 clone->top_down_.FilteredClone(&top_down_, security_token_id);
491 return clone; 488 return clone;
492 } 489 }
493 490
494 491
495 void CpuProfile::ShortPrint() { 492 void CpuProfile::ShortPrint() {
496 OS::Print("top down "); 493 OS::Print("top down ");
497 top_down_.ShortPrint(); 494 top_down_.ShortPrint();
498 } 495 }
499 496
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 602
606 CpuProfilesCollection::~CpuProfilesCollection() { 603 CpuProfilesCollection::~CpuProfilesCollection() {
607 delete current_profiles_semaphore_; 604 delete current_profiles_semaphore_;
608 current_profiles_.Iterate(DeleteCpuProfile); 605 current_profiles_.Iterate(DeleteCpuProfile);
609 detached_profiles_.Iterate(DeleteCpuProfile); 606 detached_profiles_.Iterate(DeleteCpuProfile);
610 profiles_by_token_.Iterate(DeleteProfilesList); 607 profiles_by_token_.Iterate(DeleteProfilesList);
611 code_entries_.Iterate(DeleteCodeEntry); 608 code_entries_.Iterate(DeleteCodeEntry);
612 } 609 }
613 610
614 611
615 bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid, 612 bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid) {
616 bool record_samples) {
617 ASSERT(uid > 0); 613 ASSERT(uid > 0);
618 current_profiles_semaphore_->Wait(); 614 current_profiles_semaphore_->Wait();
619 if (current_profiles_.length() >= kMaxSimultaneousProfiles) { 615 if (current_profiles_.length() >= kMaxSimultaneousProfiles) {
620 current_profiles_semaphore_->Signal(); 616 current_profiles_semaphore_->Signal();
621 return false; 617 return false;
622 } 618 }
623 for (int i = 0; i < current_profiles_.length(); ++i) { 619 for (int i = 0; i < current_profiles_.length(); ++i) {
624 if (strcmp(current_profiles_[i]->title(), title) == 0) { 620 if (strcmp(current_profiles_[i]->title(), title) == 0) {
625 // Ignore attempts to start profile with the same title. 621 // Ignore attempts to start profile with the same title.
626 current_profiles_semaphore_->Signal(); 622 current_profiles_semaphore_->Signal();
627 return false; 623 return false;
628 } 624 }
629 } 625 }
630 current_profiles_.Add(new CpuProfile(title, uid, record_samples)); 626 current_profiles_.Add(new CpuProfile(title, uid));
631 current_profiles_semaphore_->Signal(); 627 current_profiles_semaphore_->Signal();
632 return true; 628 return true;
633 } 629 }
634 630
635 631
632 bool CpuProfilesCollection::StartProfiling(String* title, unsigned uid) {
633 return StartProfiling(GetName(title), uid);
634 }
635
636
636 CpuProfile* CpuProfilesCollection::StopProfiling(int security_token_id, 637 CpuProfile* CpuProfilesCollection::StopProfiling(int security_token_id,
637 const char* title, 638 const char* title,
638 double actual_sampling_rate) { 639 double actual_sampling_rate) {
639 const int title_len = StrLength(title); 640 const int title_len = StrLength(title);
640 CpuProfile* profile = NULL; 641 CpuProfile* profile = NULL;
641 current_profiles_semaphore_->Wait(); 642 current_profiles_semaphore_->Wait();
642 for (int i = current_profiles_.length() - 1; i >= 0; --i) { 643 for (int i = current_profiles_.length() - 1; i >= 0; --i) {
643 if (title_len == 0 || strcmp(current_profiles_[i]->title(), title) == 0) { 644 if (title_len == 0 || strcmp(current_profiles_[i]->title(), title) == 0) {
644 profile = current_profiles_.Remove(i); 645 profile = current_profiles_.Remove(i);
645 break; 646 break;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 if (no_symbolized_entries) { 931 if (no_symbolized_entries) {
931 *entry++ = EntryForVMState(sample.state); 932 *entry++ = EntryForVMState(sample.state);
932 } 933 }
933 } 934 }
934 935
935 profiles_->AddPathToCurrentProfiles(entries); 936 profiles_->AddPathToCurrentProfiles(entries);
936 } 937 }
937 938
938 939
939 } } // namespace v8::internal 940 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/profile-generator.h ('k') | src/profile-generator-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698