| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 cpu_profiler_nesting_(0), | 524 cpu_profiler_nesting_(0), |
| 525 log_(new Log(this)), | 525 log_(new Log(this)), |
| 526 name_buffer_(new NameBuffer), | 526 name_buffer_(new NameBuffer), |
| 527 address_to_name_map_(NULL), | 527 address_to_name_map_(NULL), |
| 528 is_initialized_(false), | 528 is_initialized_(false), |
| 529 code_event_handler_(NULL), | 529 code_event_handler_(NULL), |
| 530 last_address_(NULL), | 530 last_address_(NULL), |
| 531 prev_sp_(NULL), | 531 prev_sp_(NULL), |
| 532 prev_function_(NULL), | 532 prev_function_(NULL), |
| 533 prev_to_(NULL), | 533 prev_to_(NULL), |
| 534 prev_code_(NULL) { | 534 prev_code_(NULL), |
| 535 epoch_(0) { |
| 535 } | 536 } |
| 536 | 537 |
| 537 | 538 |
| 538 Logger::~Logger() { | 539 Logger::~Logger() { |
| 539 delete address_to_name_map_; | 540 delete address_to_name_map_; |
| 540 delete name_buffer_; | 541 delete name_buffer_; |
| 541 delete log_; | 542 delete log_; |
| 542 } | 543 } |
| 543 | 544 |
| 544 | 545 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 if (!log_->IsEnabled() || !FLAG_prof) return; | 698 if (!log_->IsEnabled() || !FLAG_prof) return; |
| 698 LogMessageBuilder msg(this); | 699 LogMessageBuilder msg(this); |
| 699 msg.Append("shared-library,\"%ls\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR "\n", | 700 msg.Append("shared-library,\"%ls\",0x%08" V8PRIxPTR ",0x%08" V8PRIxPTR "\n", |
| 700 library_path, | 701 library_path, |
| 701 start, | 702 start, |
| 702 end); | 703 end); |
| 703 msg.WriteToLogFile(); | 704 msg.WriteToLogFile(); |
| 704 } | 705 } |
| 705 | 706 |
| 706 | 707 |
| 708 void Logger::TimerEvent(const char* name, int64_t start, int64_t end) { |
| 709 ASSERT(FLAG_log_timer_events); |
| 710 LogMessageBuilder msg(this); |
| 711 int since_epoch = static_cast<int>(start - epoch_); |
| 712 int pause_time = static_cast<int>(end - start); |
| 713 msg.Append("timer-event,\"%s\",%ld,%ld\n", name, since_epoch, pause_time); |
| 714 msg.WriteToLogFile(); |
| 715 } |
| 716 |
| 717 |
| 707 void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { | 718 void Logger::LogRegExpSource(Handle<JSRegExp> regexp) { |
| 708 // Prints "/" + re.source + "/" + | 719 // Prints "/" + re.source + "/" + |
| 709 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") | 720 // (re.global?"g":"") + (re.ignorecase?"i":"") + (re.multiline?"m":"") |
| 710 LogMessageBuilder msg(this); | 721 LogMessageBuilder msg(this); |
| 711 | 722 |
| 712 Handle<Object> source = GetProperty(regexp, "source"); | 723 Handle<Object> source = GetProperty(regexp, "source"); |
| 713 if (!source->IsString()) { | 724 if (!source->IsString()) { |
| 714 msg.Append("no source"); | 725 msg.Append("no source"); |
| 715 return; | 726 return; |
| 716 } | 727 } |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1720 | 1731 |
| 1721 Isolate* isolate = Isolate::Current(); | 1732 Isolate* isolate = Isolate::Current(); |
| 1722 ticker_ = new Ticker(isolate, kSamplingIntervalMs); | 1733 ticker_ = new Ticker(isolate, kSamplingIntervalMs); |
| 1723 | 1734 |
| 1724 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) { | 1735 if (FLAG_sliding_state_window && sliding_state_window_ == NULL) { |
| 1725 sliding_state_window_ = new SlidingStateWindow(isolate); | 1736 sliding_state_window_ = new SlidingStateWindow(isolate); |
| 1726 } | 1737 } |
| 1727 | 1738 |
| 1728 bool start_logging = FLAG_log || FLAG_log_runtime || FLAG_log_api | 1739 bool start_logging = FLAG_log || FLAG_log_runtime || FLAG_log_api |
| 1729 || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect | 1740 || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect |
| 1730 || FLAG_log_regexp || FLAG_log_state_changes || FLAG_ll_prof; | 1741 || FLAG_log_regexp || FLAG_log_state_changes || FLAG_ll_prof |
| 1742 || FLAG_log_timer_events; |
| 1731 | 1743 |
| 1732 if (start_logging) { | 1744 if (start_logging) { |
| 1733 logging_nesting_ = 1; | 1745 logging_nesting_ = 1; |
| 1734 } | 1746 } |
| 1735 | 1747 |
| 1736 if (FLAG_prof) { | 1748 if (FLAG_prof) { |
| 1737 profiler_ = new Profiler(isolate); | 1749 profiler_ = new Profiler(isolate); |
| 1738 if (!FLAG_prof_auto) { | 1750 if (!FLAG_prof_auto) { |
| 1739 profiler_->pause(); | 1751 profiler_->pause(); |
| 1740 } else { | 1752 } else { |
| 1741 logging_nesting_ = 1; | 1753 logging_nesting_ = 1; |
| 1742 } | 1754 } |
| 1743 if (!FLAG_prof_lazy) { | 1755 if (!FLAG_prof_lazy) { |
| 1744 profiler_->Engage(); | 1756 profiler_->Engage(); |
| 1745 } | 1757 } |
| 1746 } | 1758 } |
| 1747 | 1759 |
| 1760 if (FLAG_log_timer_events) epoch_ = OS::Ticks(); |
| 1761 |
| 1748 return true; | 1762 return true; |
| 1749 } | 1763 } |
| 1750 | 1764 |
| 1751 | 1765 |
| 1752 void Logger::SetCodeEventHandler(uint32_t options, | 1766 void Logger::SetCodeEventHandler(uint32_t options, |
| 1753 JitCodeEventHandler event_handler) { | 1767 JitCodeEventHandler event_handler) { |
| 1754 code_event_handler_ = event_handler; | 1768 code_event_handler_ = event_handler; |
| 1755 | 1769 |
| 1756 if (code_event_handler_ != NULL && (options & kJitCodeEventEnumExisting)) { | 1770 if (code_event_handler_ != NULL && (options & kJitCodeEventEnumExisting)) { |
| 1757 HandleScope scope; | 1771 HandleScope scope; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { | 1882 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { |
| 1869 ASSERT(sampler->IsActive()); | 1883 ASSERT(sampler->IsActive()); |
| 1870 ScopedLock lock(active_samplers_mutex); | 1884 ScopedLock lock(active_samplers_mutex); |
| 1871 ASSERT(active_samplers_ != NULL); | 1885 ASSERT(active_samplers_ != NULL); |
| 1872 bool removed = active_samplers_->RemoveElement(sampler); | 1886 bool removed = active_samplers_->RemoveElement(sampler); |
| 1873 ASSERT(removed); | 1887 ASSERT(removed); |
| 1874 USE(removed); | 1888 USE(removed); |
| 1875 } | 1889 } |
| 1876 | 1890 |
| 1877 } } // namespace v8::internal | 1891 } } // namespace v8::internal |
| OLD | NEW |