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

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

Issue 3108004: Fix CPU profiler crash in start / stop sequence when non-existent name is passed (Closed)
Patch Set: Created 10 years, 4 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/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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 static_cast<uint32_t>(profile->uid()), 535 static_cast<uint32_t>(profile->uid()),
536 true); 536 true);
537 ASSERT(entry->value == NULL); 537 ASSERT(entry->value == NULL);
538 entry->value = reinterpret_cast<void*>(unabridged_list->length() - 1); 538 entry->value = reinterpret_cast<void*>(unabridged_list->length() - 1);
539 return GetProfile(security_token_id, profile->uid()); 539 return GetProfile(security_token_id, profile->uid());
540 } 540 }
541 return NULL; 541 return NULL;
542 } 542 }
543 543
544 544
545 CpuProfile* CpuProfilesCollection::StopProfiling(int security_token_id,
546 String* title,
547 double actual_sampling_rate) {
548 return StopProfiling(security_token_id, GetName(title), actual_sampling_rate);
549 }
550
551
552 CpuProfile* CpuProfilesCollection::GetProfile(int security_token_id, 545 CpuProfile* CpuProfilesCollection::GetProfile(int security_token_id,
553 unsigned uid) { 546 unsigned uid) {
554 HashMap::Entry* entry = profiles_uids_.Lookup(reinterpret_cast<void*>(uid), 547 HashMap::Entry* entry = profiles_uids_.Lookup(reinterpret_cast<void*>(uid),
555 static_cast<uint32_t>(uid), 548 static_cast<uint32_t>(uid),
556 false); 549 false);
557 int index; 550 int index;
558 if (entry != NULL) { 551 if (entry != NULL) {
559 index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value)); 552 index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
560 } else { 553 } else {
561 return NULL; 554 return NULL;
562 } 555 }
563 List<CpuProfile*>* unabridged_list = 556 List<CpuProfile*>* unabridged_list =
564 profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)]; 557 profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
565 if (security_token_id == TokenEnumerator::kNoSecurityToken) { 558 if (security_token_id == TokenEnumerator::kNoSecurityToken) {
566 return unabridged_list->at(index); 559 return unabridged_list->at(index);
567 } 560 }
568 List<CpuProfile*>* list = GetProfilesList(security_token_id); 561 List<CpuProfile*>* list = GetProfilesList(security_token_id);
569 if (list->at(index) == NULL) { 562 if (list->at(index) == NULL) {
570 list->at(index) = 563 list->at(index) =
571 unabridged_list->at(index)->FilteredClone(security_token_id); 564 unabridged_list->at(index)->FilteredClone(security_token_id);
572 } 565 }
573 return list->at(index); 566 return list->at(index);
574 } 567 }
575 568
576 569
570 bool CpuProfilesCollection::IsLastProfile(const char* title) {
571 // Called from VM thread, and only it can mutate the list,
572 // so no locking is needed here.
573 if (current_profiles_.length() != 1) return false;
574 return StrLength(title) == 0
575 || strcmp(current_profiles_[0]->title(), title) == 0;
576 }
577
578
577 int CpuProfilesCollection::TokenToIndex(int security_token_id) { 579 int CpuProfilesCollection::TokenToIndex(int security_token_id) {
578 ASSERT(TokenEnumerator::kNoSecurityToken == -1); 580 ASSERT(TokenEnumerator::kNoSecurityToken == -1);
579 return security_token_id + 1; // kNoSecurityToken -> 0, 0 -> 1, ... 581 return security_token_id + 1; // kNoSecurityToken -> 0, 0 -> 1, ...
580 } 582 }
581 583
582 584
583 List<CpuProfile*>* CpuProfilesCollection::GetProfilesList( 585 List<CpuProfile*>* CpuProfilesCollection::GetProfilesList(
584 int security_token_id) { 586 int security_token_id) {
585 const int index = TokenToIndex(security_token_id); 587 const int index = TokenToIndex(security_token_id);
586 const int lists_to_add = index - profiles_by_token_.length() + 1; 588 const int lists_to_add = index - profiles_by_token_.length() + 1;
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 HeapEntry* entry = added_entries[i]; 2131 HeapEntry* entry = added_entries[i];
2130 if (entry->painted_reachable()) 2132 if (entry->painted_reachable())
2131 diff->AddAddedEntry(add_child_index++, added_entry_index++, entry); 2133 diff->AddAddedEntry(add_child_index++, added_entry_index++, entry);
2132 } 2134 }
2133 return diff; 2135 return diff;
2134 } 2136 }
2135 2137
2136 } } // namespace v8::internal 2138 } } // namespace v8::internal
2137 2139
2138 #endif // ENABLE_LOGGING_AND_PROFILING 2140 #endif // ENABLE_LOGGING_AND_PROFILING
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