| OLD | NEW |
| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/profile-generator-inl.h" | 7 #include "src/profile-generator-inl.h" |
| 8 | 8 |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/debug.h" | 10 #include "src/debug.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 // New node added. | 201 // New node added. |
| 202 ProfileNode* new_node = new ProfileNode(tree_, entry); | 202 ProfileNode* new_node = new ProfileNode(tree_, entry); |
| 203 map_entry->value = new_node; | 203 map_entry->value = new_node; |
| 204 children_list_.Add(new_node); | 204 children_list_.Add(new_node); |
| 205 } | 205 } |
| 206 return reinterpret_cast<ProfileNode*>(map_entry->value); | 206 return reinterpret_cast<ProfileNode*>(map_entry->value); |
| 207 } | 207 } |
| 208 | 208 |
| 209 | 209 |
| 210 void ProfileNode::Print(int indent) { | 210 void ProfileNode::Print(int indent) { |
| 211 OS::Print("%5u %*s %s%s %d #%d %s", | 211 base::OS::Print("%5u %*s %s%s %d #%d %s", self_ticks_, indent, "", |
| 212 self_ticks_, | 212 entry_->name_prefix(), entry_->name(), entry_->script_id(), |
| 213 indent, "", | 213 id(), entry_->bailout_reason()); |
| 214 entry_->name_prefix(), | |
| 215 entry_->name(), | |
| 216 entry_->script_id(), | |
| 217 id(), | |
| 218 entry_->bailout_reason()); | |
| 219 if (entry_->resource_name()[0] != '\0') | 214 if (entry_->resource_name()[0] != '\0') |
| 220 OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number()); | 215 base::OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number()); |
| 221 OS::Print("\n"); | 216 base::OS::Print("\n"); |
| 222 for (HashMap::Entry* p = children_.Start(); | 217 for (HashMap::Entry* p = children_.Start(); |
| 223 p != NULL; | 218 p != NULL; |
| 224 p = children_.Next(p)) { | 219 p = children_.Next(p)) { |
| 225 reinterpret_cast<ProfileNode*>(p->value)->Print(indent + 2); | 220 reinterpret_cast<ProfileNode*>(p->value)->Print(indent + 2); |
| 226 } | 221 } |
| 227 } | 222 } |
| 228 | 223 |
| 229 | 224 |
| 230 class DeleteNodesCallback { | 225 class DeleteNodesCallback { |
| 231 public: | 226 public: |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 // Remove child from the stack. | 320 // Remove child from the stack. |
| 326 stack.RemoveLast(); | 321 stack.RemoveLast(); |
| 327 } | 322 } |
| 328 } | 323 } |
| 329 } | 324 } |
| 330 | 325 |
| 331 | 326 |
| 332 CpuProfile::CpuProfile(const char* title, bool record_samples) | 327 CpuProfile::CpuProfile(const char* title, bool record_samples) |
| 333 : title_(title), | 328 : title_(title), |
| 334 record_samples_(record_samples), | 329 record_samples_(record_samples), |
| 335 start_time_(TimeTicks::HighResolutionNow()) { | 330 start_time_(base::TimeTicks::HighResolutionNow()) { |
| 336 } | 331 } |
| 337 | 332 |
| 338 | 333 |
| 339 void CpuProfile::AddPath(TimeTicks timestamp, const Vector<CodeEntry*>& path) { | 334 void CpuProfile::AddPath(base::TimeTicks timestamp, |
| 335 const Vector<CodeEntry*>& path) { |
| 340 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path); | 336 ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path); |
| 341 if (record_samples_) { | 337 if (record_samples_) { |
| 342 timestamps_.Add(timestamp); | 338 timestamps_.Add(timestamp); |
| 343 samples_.Add(top_frame_node); | 339 samples_.Add(top_frame_node); |
| 344 } | 340 } |
| 345 } | 341 } |
| 346 | 342 |
| 347 | 343 |
| 348 void CpuProfile::CalculateTotalTicksAndSamplingRate() { | 344 void CpuProfile::CalculateTotalTicksAndSamplingRate() { |
| 349 end_time_ = TimeTicks::HighResolutionNow(); | 345 end_time_ = base::TimeTicks::HighResolutionNow(); |
| 350 } | 346 } |
| 351 | 347 |
| 352 | 348 |
| 353 void CpuProfile::Print() { | 349 void CpuProfile::Print() { |
| 354 OS::Print("[Top down]:\n"); | 350 base::OS::Print("[Top down]:\n"); |
| 355 top_down_.Print(); | 351 top_down_.Print(); |
| 356 } | 352 } |
| 357 | 353 |
| 358 | 354 |
| 359 CodeEntry* const CodeMap::kSharedFunctionCodeEntry = NULL; | 355 CodeEntry* const CodeMap::kSharedFunctionCodeEntry = NULL; |
| 360 const CodeMap::CodeTreeConfig::Key CodeMap::CodeTreeConfig::kNoKey = NULL; | 356 const CodeMap::CodeTreeConfig::Key CodeMap::CodeTreeConfig::kNoKey = NULL; |
| 361 | 357 |
| 362 | 358 |
| 363 void CodeMap::AddCode(Address addr, CodeEntry* entry, unsigned size) { | 359 void CodeMap::AddCode(Address addr, CodeEntry* entry, unsigned size) { |
| 364 DeleteAllCoveredCode(addr, addr + size); | 360 DeleteAllCoveredCode(addr, addr + size); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 CodeEntryInfo entry = locator.value(); | 417 CodeEntryInfo entry = locator.value(); |
| 422 tree_.Remove(from); | 418 tree_.Remove(from); |
| 423 AddCode(to, entry.entry, entry.size); | 419 AddCode(to, entry.entry, entry.size); |
| 424 } | 420 } |
| 425 | 421 |
| 426 | 422 |
| 427 void CodeMap::CodeTreePrinter::Call( | 423 void CodeMap::CodeTreePrinter::Call( |
| 428 const Address& key, const CodeMap::CodeEntryInfo& value) { | 424 const Address& key, const CodeMap::CodeEntryInfo& value) { |
| 429 // For shared function entries, 'size' field is used to store their IDs. | 425 // For shared function entries, 'size' field is used to store their IDs. |
| 430 if (value.entry == kSharedFunctionCodeEntry) { | 426 if (value.entry == kSharedFunctionCodeEntry) { |
| 431 OS::Print("%p SharedFunctionInfo %d\n", key, value.size); | 427 base::OS::Print("%p SharedFunctionInfo %d\n", key, value.size); |
| 432 } else { | 428 } else { |
| 433 OS::Print("%p %5d %s\n", key, value.size, value.entry->name()); | 429 base::OS::Print("%p %5d %s\n", key, value.size, value.entry->name()); |
| 434 } | 430 } |
| 435 } | 431 } |
| 436 | 432 |
| 437 | 433 |
| 438 void CodeMap::Print() { | 434 void CodeMap::Print() { |
| 439 CodeTreePrinter printer; | 435 CodeTreePrinter printer; |
| 440 tree_.ForEach(&printer); | 436 tree_.ForEach(&printer); |
| 441 } | 437 } |
| 442 | 438 |
| 443 | 439 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 if (profile == finished_profiles_[i]) { | 514 if (profile == finished_profiles_[i]) { |
| 519 finished_profiles_.Remove(i); | 515 finished_profiles_.Remove(i); |
| 520 return; | 516 return; |
| 521 } | 517 } |
| 522 } | 518 } |
| 523 UNREACHABLE(); | 519 UNREACHABLE(); |
| 524 } | 520 } |
| 525 | 521 |
| 526 | 522 |
| 527 void CpuProfilesCollection::AddPathToCurrentProfiles( | 523 void CpuProfilesCollection::AddPathToCurrentProfiles( |
| 528 TimeTicks timestamp, const Vector<CodeEntry*>& path) { | 524 base::TimeTicks timestamp, const Vector<CodeEntry*>& path) { |
| 529 // As starting / stopping profiles is rare relatively to this | 525 // As starting / stopping profiles is rare relatively to this |
| 530 // method, we don't bother minimizing the duration of lock holding, | 526 // method, we don't bother minimizing the duration of lock holding, |
| 531 // e.g. copying contents of the list to a local vector. | 527 // e.g. copying contents of the list to a local vector. |
| 532 current_profiles_semaphore_.Wait(); | 528 current_profiles_semaphore_.Wait(); |
| 533 for (int i = 0; i < current_profiles_.length(); ++i) { | 529 for (int i = 0; i < current_profiles_.length(); ++i) { |
| 534 current_profiles_[i]->AddPath(timestamp, path); | 530 current_profiles_[i]->AddPath(timestamp, path); |
| 535 } | 531 } |
| 536 current_profiles_semaphore_.Signal(); | 532 current_profiles_semaphore_.Signal(); |
| 537 } | 533 } |
| 538 | 534 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 case OTHER: | 666 case OTHER: |
| 671 case EXTERNAL: | 667 case EXTERNAL: |
| 672 return program_entry_; | 668 return program_entry_; |
| 673 case IDLE: | 669 case IDLE: |
| 674 return idle_entry_; | 670 return idle_entry_; |
| 675 default: return NULL; | 671 default: return NULL; |
| 676 } | 672 } |
| 677 } | 673 } |
| 678 | 674 |
| 679 } } // namespace v8::internal | 675 } } // namespace v8::internal |
| OLD | NEW |