| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 "base/tracked_objects.h" | 5 #include "base/tracked_objects.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // This macro has no branching, so it is surely fast, and is equivalent to: | 109 // This macro has no branching, so it is surely fast, and is equivalent to: |
| 110 // if (assign_it) | 110 // if (assign_it) |
| 111 // target = source; | 111 // target = source; |
| 112 // We use a macro rather than a template to force this to inline. | 112 // We use a macro rather than a template to force this to inline. |
| 113 // Related code for calculating max is discussed on the web. | 113 // Related code for calculating max is discussed on the web. |
| 114 #define CONDITIONAL_ASSIGN(assign_it, target, source) \ | 114 #define CONDITIONAL_ASSIGN(assign_it, target, source) \ |
| 115 ((target) ^= ((target) ^ (source)) & -static_cast<int32>(assign_it)) | 115 ((target) ^= ((target) ^ (source)) & -static_cast<int32>(assign_it)) |
| 116 | 116 |
| 117 void DeathData::RecordDeath(const int32 queue_duration, | 117 void DeathData::RecordDeath(const int32 queue_duration, |
| 118 const int32 run_duration, | 118 const int32 run_duration, |
| 119 int32 random_number) { | 119 const uint32 random_number) { |
| 120 // We'll just clamp at INT_MAX, but we should note this in the UI as such. | 120 // We'll just clamp at INT_MAX, but we should note this in the UI as such. |
| 121 if (count_ < INT_MAX) | 121 if (count_ < INT_MAX) |
| 122 ++count_; | 122 ++count_; |
| 123 queue_duration_sum_ += queue_duration; | 123 queue_duration_sum_ += queue_duration; |
| 124 run_duration_sum_ += run_duration; | 124 run_duration_sum_ += run_duration; |
| 125 | 125 |
| 126 if (queue_duration_max_ < queue_duration) | 126 if (queue_duration_max_ < queue_duration) |
| 127 queue_duration_max_ = queue_duration; | 127 queue_duration_max_ = queue_duration; |
| 128 if (run_duration_max_ < run_duration) | 128 if (run_duration_max_ < run_duration) |
| 129 run_duration_max_ = run_duration; | 129 run_duration_max_ = run_duration; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 PushToHeadOfList(); // Which sets real incarnation_count_for_pool_. | 300 PushToHeadOfList(); // Which sets real incarnation_count_for_pool_. |
| 301 } | 301 } |
| 302 | 302 |
| 303 ThreadData::~ThreadData() {} | 303 ThreadData::~ThreadData() {} |
| 304 | 304 |
| 305 void ThreadData::PushToHeadOfList() { | 305 void ThreadData::PushToHeadOfList() { |
| 306 // Toss in a hint of randomness (atop the uniniitalized value). | 306 // Toss in a hint of randomness (atop the uniniitalized value). |
| 307 (void)VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(&random_number_, | 307 (void)VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(&random_number_, |
| 308 sizeof(random_number_)); | 308 sizeof(random_number_)); |
| 309 MSAN_UNPOISON(&random_number_, sizeof(random_number_)); | 309 MSAN_UNPOISON(&random_number_, sizeof(random_number_)); |
| 310 random_number_ += static_cast<int32>(this - static_cast<ThreadData*>(0)); | 310 random_number_ += static_cast<uint32>(this - static_cast<ThreadData*>(0)); |
| 311 random_number_ ^= (Now() - TrackedTime()).InMilliseconds(); | 311 random_number_ ^= (Now() - TrackedTime()).InMilliseconds(); |
| 312 | 312 |
| 313 DCHECK(!next_); | 313 DCHECK(!next_); |
| 314 base::AutoLock lock(*list_lock_.Pointer()); | 314 base::AutoLock lock(*list_lock_.Pointer()); |
| 315 incarnation_count_for_pool_ = incarnation_counter_; | 315 incarnation_count_for_pool_ = incarnation_counter_; |
| 316 next_ = all_thread_data_list_head_; | 316 next_ = all_thread_data_list_head_; |
| 317 all_thread_data_list_head_ = this; | 317 all_thread_data_list_head_ = this; |
| 318 } | 318 } |
| 319 | 319 |
| 320 // static | 320 // static |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 446 |
| 447 return child; | 447 return child; |
| 448 } | 448 } |
| 449 | 449 |
| 450 void ThreadData::TallyADeath(const Births& birth, | 450 void ThreadData::TallyADeath(const Births& birth, |
| 451 int32 queue_duration, | 451 int32 queue_duration, |
| 452 const TaskStopwatch& stopwatch) { | 452 const TaskStopwatch& stopwatch) { |
| 453 int32 run_duration = stopwatch.RunDurationMs(); | 453 int32 run_duration = stopwatch.RunDurationMs(); |
| 454 | 454 |
| 455 // Stir in some randomness, plus add constant in case durations are zero. | 455 // Stir in some randomness, plus add constant in case durations are zero. |
| 456 const int32 kSomePrimeNumber = 2147483647; | 456 const uint32 kSomePrimeNumber = 2147483647; |
| 457 random_number_ += queue_duration + run_duration + kSomePrimeNumber; | 457 random_number_ += queue_duration + run_duration + kSomePrimeNumber; |
| 458 // An address is going to have some randomness to it as well ;-). | 458 // An address is going to have some randomness to it as well ;-). |
| 459 random_number_ ^= static_cast<int32>(&birth - reinterpret_cast<Births*>(0)); | 459 random_number_ ^= static_cast<uint32>(&birth - reinterpret_cast<Births*>(0)); |
| 460 | 460 |
| 461 // We don't have queue durations without OS timer. OS timer is automatically | 461 // We don't have queue durations without OS timer. OS timer is automatically |
| 462 // used for task-post-timing, so the use of an alternate timer implies all | 462 // used for task-post-timing, so the use of an alternate timer implies all |
| 463 // queue times are invalid, unless it was explicitly said that we can trust | 463 // queue times are invalid, unless it was explicitly said that we can trust |
| 464 // the alternate timer. | 464 // the alternate timer. |
| 465 if (kAllowAlternateTimeSourceHandling && | 465 if (kAllowAlternateTimeSourceHandling && |
| 466 now_function_ && | 466 now_function_ && |
| 467 !now_function_is_time_) { | 467 !now_function_is_time_) { |
| 468 queue_duration = 0; | 468 queue_duration = 0; |
| 469 } | 469 } |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 : process_id(base::GetCurrentProcId()) { | 1000 : process_id(base::GetCurrentProcId()) { |
| 1001 #else | 1001 #else |
| 1002 : process_id(0) { | 1002 : process_id(0) { |
| 1003 #endif | 1003 #endif |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 ProcessDataSnapshot::~ProcessDataSnapshot() { | 1006 ProcessDataSnapshot::~ProcessDataSnapshot() { |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 } // namespace tracked_objects | 1009 } // namespace tracked_objects |
| OLD | NEW |