| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <stdarg.h> | 5 #include <stdarg.h> |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/base/platform/platform.h" |
| 9 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| 10 #include "src/code-stubs.h" | 11 #include "src/code-stubs.h" |
| 11 #include "src/cpu-profiler.h" | 12 #include "src/cpu-profiler.h" |
| 12 #include "src/deoptimizer.h" | 13 #include "src/deoptimizer.h" |
| 13 #include "src/global-handles.h" | 14 #include "src/global-handles.h" |
| 14 #include "src/log.h" | 15 #include "src/log.h" |
| 15 #include "src/log-utils.h" | 16 #include "src/log-utils.h" |
| 16 #include "src/macro-assembler.h" | 17 #include "src/macro-assembler.h" |
| 17 #include "src/platform.h" | |
| 18 #include "src/runtime-profiler.h" | 18 #include "src/runtime-profiler.h" |
| 19 #include "src/serialize.h" | 19 #include "src/serialize.h" |
| 20 #include "src/string-stream.h" | 20 #include "src/string-stream.h" |
| 21 #include "src/vm-state-inl.h" | 21 #include "src/vm-state-inl.h" |
| 22 | 22 |
| 23 namespace v8 { | 23 namespace v8 { |
| 24 namespace internal { | 24 namespace internal { |
| 25 | 25 |
| 26 | 26 |
| 27 #define DECLARE_EVENT(ignore1, name) name, | 27 #define DECLARE_EVENT(ignore1, name) name, |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 const int PerfBasicLogger::kFilenameBufferPadding = 16; | 255 const int PerfBasicLogger::kFilenameBufferPadding = 16; |
| 256 | 256 |
| 257 PerfBasicLogger::PerfBasicLogger() | 257 PerfBasicLogger::PerfBasicLogger() |
| 258 : perf_output_handle_(NULL) { | 258 : perf_output_handle_(NULL) { |
| 259 // Open the perf JIT dump file. | 259 // Open the perf JIT dump file. |
| 260 int bufferSize = sizeof(kFilenameFormatString) + kFilenameBufferPadding; | 260 int bufferSize = sizeof(kFilenameFormatString) + kFilenameBufferPadding; |
| 261 ScopedVector<char> perf_dump_name(bufferSize); | 261 ScopedVector<char> perf_dump_name(bufferSize); |
| 262 int size = SNPrintF( | 262 int size = SNPrintF( |
| 263 perf_dump_name, | 263 perf_dump_name, |
| 264 kFilenameFormatString, | 264 kFilenameFormatString, |
| 265 OS::GetCurrentProcessId()); | 265 base::OS::GetCurrentProcessId()); |
| 266 CHECK_NE(size, -1); | 266 CHECK_NE(size, -1); |
| 267 perf_output_handle_ = OS::FOpen(perf_dump_name.start(), OS::LogFileOpenMode); | 267 perf_output_handle_ = |
| 268 base::OS::FOpen(perf_dump_name.start(), base::OS::LogFileOpenMode); |
| 268 CHECK_NE(perf_output_handle_, NULL); | 269 CHECK_NE(perf_output_handle_, NULL); |
| 269 setvbuf(perf_output_handle_, NULL, _IOFBF, kLogBufferSize); | 270 setvbuf(perf_output_handle_, NULL, _IOFBF, kLogBufferSize); |
| 270 } | 271 } |
| 271 | 272 |
| 272 | 273 |
| 273 PerfBasicLogger::~PerfBasicLogger() { | 274 PerfBasicLogger::~PerfBasicLogger() { |
| 274 fclose(perf_output_handle_); | 275 fclose(perf_output_handle_); |
| 275 perf_output_handle_ = NULL; | 276 perf_output_handle_ = NULL; |
| 276 } | 277 } |
| 277 | 278 |
| 278 | 279 |
| 279 void PerfBasicLogger::LogRecordedBuffer(Code* code, | 280 void PerfBasicLogger::LogRecordedBuffer(Code* code, |
| 280 SharedFunctionInfo*, | 281 SharedFunctionInfo*, |
| 281 const char* name, | 282 const char* name, |
| 282 int length) { | 283 int length) { |
| 283 ASSERT(code->instruction_start() == code->address() + Code::kHeaderSize); | 284 ASSERT(code->instruction_start() == code->address() + Code::kHeaderSize); |
| 284 | 285 |
| 285 OS::FPrint(perf_output_handle_, "%llx %x %.*s\n", | 286 base::OS::FPrint(perf_output_handle_, "%llx %x %.*s\n", |
| 286 reinterpret_cast<uint64_t>(code->instruction_start()), | 287 reinterpret_cast<uint64_t>(code->instruction_start()), |
| 287 code->instruction_size(), | 288 code->instruction_size(), length, name); |
| 288 length, name); | |
| 289 } | 289 } |
| 290 | 290 |
| 291 | 291 |
| 292 // Linux perf tool logging support | 292 // Linux perf tool logging support |
| 293 class PerfJitLogger : public CodeEventLogger { | 293 class PerfJitLogger : public CodeEventLogger { |
| 294 public: | 294 public: |
| 295 PerfJitLogger(); | 295 PerfJitLogger(); |
| 296 virtual ~PerfJitLogger(); | 296 virtual ~PerfJitLogger(); |
| 297 | 297 |
| 298 virtual void CodeMoveEvent(Address from, Address to) { } | 298 virtual void CodeMoveEvent(Address from, Address to) { } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 const int PerfJitLogger::kFilenameBufferPadding = 16; | 379 const int PerfJitLogger::kFilenameBufferPadding = 16; |
| 380 | 380 |
| 381 PerfJitLogger::PerfJitLogger() | 381 PerfJitLogger::PerfJitLogger() |
| 382 : perf_output_handle_(NULL) { | 382 : perf_output_handle_(NULL) { |
| 383 // Open the perf JIT dump file. | 383 // Open the perf JIT dump file. |
| 384 int bufferSize = sizeof(kFilenameFormatString) + kFilenameBufferPadding; | 384 int bufferSize = sizeof(kFilenameFormatString) + kFilenameBufferPadding; |
| 385 ScopedVector<char> perf_dump_name(bufferSize); | 385 ScopedVector<char> perf_dump_name(bufferSize); |
| 386 int size = SNPrintF( | 386 int size = SNPrintF( |
| 387 perf_dump_name, | 387 perf_dump_name, |
| 388 kFilenameFormatString, | 388 kFilenameFormatString, |
| 389 OS::GetCurrentProcessId()); | 389 base::OS::GetCurrentProcessId()); |
| 390 CHECK_NE(size, -1); | 390 CHECK_NE(size, -1); |
| 391 perf_output_handle_ = OS::FOpen(perf_dump_name.start(), OS::LogFileOpenMode); | 391 perf_output_handle_ = |
| 392 base::OS::FOpen(perf_dump_name.start(), base::OS::LogFileOpenMode); |
| 392 CHECK_NE(perf_output_handle_, NULL); | 393 CHECK_NE(perf_output_handle_, NULL); |
| 393 setvbuf(perf_output_handle_, NULL, _IOFBF, kLogBufferSize); | 394 setvbuf(perf_output_handle_, NULL, _IOFBF, kLogBufferSize); |
| 394 | 395 |
| 395 LogWriteHeader(); | 396 LogWriteHeader(); |
| 396 } | 397 } |
| 397 | 398 |
| 398 | 399 |
| 399 PerfJitLogger::~PerfJitLogger() { | 400 PerfJitLogger::~PerfJitLogger() { |
| 400 fclose(perf_output_handle_); | 401 fclose(perf_output_handle_); |
| 401 perf_output_handle_ = NULL; | 402 perf_output_handle_ = NULL; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 412 const char* code_name = name; | 413 const char* code_name = name; |
| 413 uint8_t* code_pointer = reinterpret_cast<uint8_t*>(code->instruction_start()); | 414 uint8_t* code_pointer = reinterpret_cast<uint8_t*>(code->instruction_start()); |
| 414 uint32_t code_size = code->instruction_size(); | 415 uint32_t code_size = code->instruction_size(); |
| 415 | 416 |
| 416 static const char string_terminator[] = "\0"; | 417 static const char string_terminator[] = "\0"; |
| 417 | 418 |
| 418 jr_code_load code_load; | 419 jr_code_load code_load; |
| 419 code_load.id = JIT_CODE_LOAD; | 420 code_load.id = JIT_CODE_LOAD; |
| 420 code_load.total_size = sizeof(code_load) + length + 1 + code_size; | 421 code_load.total_size = sizeof(code_load) + length + 1 + code_size; |
| 421 code_load.timestamp = | 422 code_load.timestamp = |
| 422 static_cast<uint64_t>(OS::TimeCurrentMillis() * 1000.0); | 423 static_cast<uint64_t>(base::OS::TimeCurrentMillis() * 1000.0); |
| 423 code_load.vma = 0x0; // Our addresses are absolute. | 424 code_load.vma = 0x0; // Our addresses are absolute. |
| 424 code_load.code_addr = reinterpret_cast<uint64_t>(code->instruction_start()); | 425 code_load.code_addr = reinterpret_cast<uint64_t>(code->instruction_start()); |
| 425 code_load.code_size = code_size; | 426 code_load.code_size = code_size; |
| 426 code_load.align = 0; | 427 code_load.align = 0; |
| 427 | 428 |
| 428 LogWriteBytes(reinterpret_cast<const char*>(&code_load), sizeof(code_load)); | 429 LogWriteBytes(reinterpret_cast<const char*>(&code_load), sizeof(code_load)); |
| 429 LogWriteBytes(code_name, length); | 430 LogWriteBytes(code_name, length); |
| 430 LogWriteBytes(string_terminator, 1); | 431 LogWriteBytes(string_terminator, 1); |
| 431 LogWriteBytes(reinterpret_cast<const char*>(code_pointer), code_size); | 432 LogWriteBytes(reinterpret_cast<const char*>(code_pointer), code_size); |
| 432 } | 433 } |
| 433 | 434 |
| 434 | 435 |
| 435 void PerfJitLogger::LogWriteBytes(const char* bytes, int size) { | 436 void PerfJitLogger::LogWriteBytes(const char* bytes, int size) { |
| 436 size_t rv = fwrite(bytes, 1, size, perf_output_handle_); | 437 size_t rv = fwrite(bytes, 1, size, perf_output_handle_); |
| 437 ASSERT(static_cast<size_t>(size) == rv); | 438 ASSERT(static_cast<size_t>(size) == rv); |
| 438 USE(rv); | 439 USE(rv); |
| 439 } | 440 } |
| 440 | 441 |
| 441 | 442 |
| 442 void PerfJitLogger::LogWriteHeader() { | 443 void PerfJitLogger::LogWriteHeader() { |
| 443 ASSERT(perf_output_handle_ != NULL); | 444 ASSERT(perf_output_handle_ != NULL); |
| 444 jitheader header; | 445 jitheader header; |
| 445 header.magic = kJitHeaderMagic; | 446 header.magic = kJitHeaderMagic; |
| 446 header.version = kJitHeaderVersion; | 447 header.version = kJitHeaderVersion; |
| 447 header.total_size = sizeof(jitheader); | 448 header.total_size = sizeof(jitheader); |
| 448 header.pad1 = 0xdeadbeef; | 449 header.pad1 = 0xdeadbeef; |
| 449 header.elf_mach = GetElfMach(); | 450 header.elf_mach = GetElfMach(); |
| 450 header.pid = OS::GetCurrentProcessId(); | 451 header.pid = base::OS::GetCurrentProcessId(); |
| 451 header.timestamp = static_cast<uint64_t>(OS::TimeCurrentMillis() * 1000.0); | 452 header.timestamp = |
| 453 static_cast<uint64_t>(base::OS::TimeCurrentMillis() * 1000.0); |
| 452 LogWriteBytes(reinterpret_cast<const char*>(&header), sizeof(header)); | 454 LogWriteBytes(reinterpret_cast<const char*>(&header), sizeof(header)); |
| 453 } | 455 } |
| 454 | 456 |
| 455 | 457 |
| 456 // Low-level logging support. | 458 // Low-level logging support. |
| 457 #define LL_LOG(Call) if (ll_logger_) ll_logger_->Call; | 459 #define LL_LOG(Call) if (ll_logger_) ll_logger_->Call; |
| 458 | 460 |
| 459 class LowLevelLogger : public CodeEventLogger { | 461 class LowLevelLogger : public CodeEventLogger { |
| 460 public: | 462 public: |
| 461 explicit LowLevelLogger(const char* file_name); | 463 explicit LowLevelLogger(const char* file_name); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 | 533 |
| 532 const char LowLevelLogger::kLogExt[] = ".ll"; | 534 const char LowLevelLogger::kLogExt[] = ".ll"; |
| 533 | 535 |
| 534 LowLevelLogger::LowLevelLogger(const char* name) | 536 LowLevelLogger::LowLevelLogger(const char* name) |
| 535 : ll_output_handle_(NULL) { | 537 : ll_output_handle_(NULL) { |
| 536 // Open the low-level log file. | 538 // Open the low-level log file. |
| 537 size_t len = strlen(name); | 539 size_t len = strlen(name); |
| 538 ScopedVector<char> ll_name(static_cast<int>(len + sizeof(kLogExt))); | 540 ScopedVector<char> ll_name(static_cast<int>(len + sizeof(kLogExt))); |
| 539 MemCopy(ll_name.start(), name, len); | 541 MemCopy(ll_name.start(), name, len); |
| 540 MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt)); | 542 MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt)); |
| 541 ll_output_handle_ = OS::FOpen(ll_name.start(), OS::LogFileOpenMode); | 543 ll_output_handle_ = |
| 544 base::OS::FOpen(ll_name.start(), base::OS::LogFileOpenMode); |
| 542 setvbuf(ll_output_handle_, NULL, _IOFBF, kLogBufferSize); | 545 setvbuf(ll_output_handle_, NULL, _IOFBF, kLogBufferSize); |
| 543 | 546 |
| 544 LogCodeInfo(); | 547 LogCodeInfo(); |
| 545 } | 548 } |
| 546 | 549 |
| 547 | 550 |
| 548 LowLevelLogger::~LowLevelLogger() { | 551 LowLevelLogger::~LowLevelLogger() { |
| 549 fclose(ll_output_handle_); | 552 fclose(ll_output_handle_); |
| 550 ll_output_handle_ = NULL; | 553 ll_output_handle_ = NULL; |
| 551 } | 554 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 | 751 |
| 749 code_event_handler_(&event); | 752 code_event_handler_(&event); |
| 750 } | 753 } |
| 751 | 754 |
| 752 | 755 |
| 753 // The Profiler samples pc and sp values for the main thread. | 756 // The Profiler samples pc and sp values for the main thread. |
| 754 // Each sample is appended to a circular buffer. | 757 // Each sample is appended to a circular buffer. |
| 755 // An independent thread removes data and writes it to the log. | 758 // An independent thread removes data and writes it to the log. |
| 756 // This design minimizes the time spent in the sampler. | 759 // This design minimizes the time spent in the sampler. |
| 757 // | 760 // |
| 758 class Profiler: public Thread { | 761 class Profiler: public base::Thread { |
| 759 public: | 762 public: |
| 760 explicit Profiler(Isolate* isolate); | 763 explicit Profiler(Isolate* isolate); |
| 761 void Engage(); | 764 void Engage(); |
| 762 void Disengage(); | 765 void Disengage(); |
| 763 | 766 |
| 764 // Inserts collected profiling data into buffer. | 767 // Inserts collected profiling data into buffer. |
| 765 void Insert(TickSample* sample) { | 768 void Insert(TickSample* sample) { |
| 766 if (paused_) | 769 if (paused_) |
| 767 return; | 770 return; |
| 768 | 771 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 797 | 800 |
| 798 Isolate* isolate_; | 801 Isolate* isolate_; |
| 799 // Cyclic buffer for communicating profiling samples | 802 // Cyclic buffer for communicating profiling samples |
| 800 // between the signal handler and the worker thread. | 803 // between the signal handler and the worker thread. |
| 801 static const int kBufferSize = 128; | 804 static const int kBufferSize = 128; |
| 802 TickSample buffer_[kBufferSize]; // Buffer storage. | 805 TickSample buffer_[kBufferSize]; // Buffer storage. |
| 803 int head_; // Index to the buffer head. | 806 int head_; // Index to the buffer head. |
| 804 int tail_; // Index to the buffer tail. | 807 int tail_; // Index to the buffer tail. |
| 805 bool overflow_; // Tell whether a buffer overflow has occurred. | 808 bool overflow_; // Tell whether a buffer overflow has occurred. |
| 806 // Sempahore used for buffer synchronization. | 809 // Sempahore used for buffer synchronization. |
| 807 Semaphore buffer_semaphore_; | 810 base::Semaphore buffer_semaphore_; |
| 808 | 811 |
| 809 // Tells whether profiler is engaged, that is, processing thread is stated. | 812 // Tells whether profiler is engaged, that is, processing thread is stated. |
| 810 bool engaged_; | 813 bool engaged_; |
| 811 | 814 |
| 812 // Tells whether worker thread should continue running. | 815 // Tells whether worker thread should continue running. |
| 813 bool running_; | 816 bool running_; |
| 814 | 817 |
| 815 // Tells whether we are currently recording tick samples. | 818 // Tells whether we are currently recording tick samples. |
| 816 bool paused_; | 819 bool paused_; |
| 817 }; | 820 }; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 848 | 851 |
| 849 private: | 852 private: |
| 850 Profiler* profiler_; | 853 Profiler* profiler_; |
| 851 }; | 854 }; |
| 852 | 855 |
| 853 | 856 |
| 854 // | 857 // |
| 855 // Profiler implementation. | 858 // Profiler implementation. |
| 856 // | 859 // |
| 857 Profiler::Profiler(Isolate* isolate) | 860 Profiler::Profiler(Isolate* isolate) |
| 858 : Thread("v8:Profiler"), | 861 : base::Thread("v8:Profiler"), |
| 859 isolate_(isolate), | 862 isolate_(isolate), |
| 860 head_(0), | 863 head_(0), |
| 861 tail_(0), | 864 tail_(0), |
| 862 overflow_(false), | 865 overflow_(false), |
| 863 buffer_semaphore_(0), | 866 buffer_semaphore_(0), |
| 864 engaged_(false), | 867 engaged_(false), |
| 865 running_(false), | 868 running_(false), |
| 866 paused_(false) { | 869 paused_(false) { |
| 867 } | 870 } |
| 868 | 871 |
| 869 | 872 |
| 870 void Profiler::Engage() { | 873 void Profiler::Engage() { |
| 871 if (engaged_) return; | 874 if (engaged_) return; |
| 872 engaged_ = true; | 875 engaged_ = true; |
| 873 | 876 |
| 874 std::vector<OS::SharedLibraryAddress> addresses = | 877 std::vector<base::OS::SharedLibraryAddress> addresses = |
| 875 OS::GetSharedLibraryAddresses(); | 878 base::OS::GetSharedLibraryAddresses(); |
| 876 for (size_t i = 0; i < addresses.size(); ++i) { | 879 for (size_t i = 0; i < addresses.size(); ++i) { |
| 877 LOG(isolate_, SharedLibraryEvent( | 880 LOG(isolate_, SharedLibraryEvent( |
| 878 addresses[i].library_path, addresses[i].start, addresses[i].end)); | 881 addresses[i].library_path, addresses[i].start, addresses[i].end)); |
| 879 } | 882 } |
| 880 | 883 |
| 881 // Start thread processing the profiler buffer. | 884 // Start thread processing the profiler buffer. |
| 882 running_ = true; | 885 running_ = true; |
| 883 Start(); | 886 Start(); |
| 884 | 887 |
| 885 // Register to get ticks. | 888 // Register to get ticks. |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 msg.WriteToLogFile(); | 1482 msg.WriteToLogFile(); |
| 1480 } | 1483 } |
| 1481 | 1484 |
| 1482 | 1485 |
| 1483 void Logger::CodeMovingGCEvent() { | 1486 void Logger::CodeMovingGCEvent() { |
| 1484 PROFILER_LOG(CodeMovingGCEvent()); | 1487 PROFILER_LOG(CodeMovingGCEvent()); |
| 1485 | 1488 |
| 1486 if (!is_logging_code_events()) return; | 1489 if (!is_logging_code_events()) return; |
| 1487 if (!log_->IsEnabled() || !FLAG_ll_prof) return; | 1490 if (!log_->IsEnabled() || !FLAG_ll_prof) return; |
| 1488 CALL_LISTENERS(CodeMovingGCEvent()); | 1491 CALL_LISTENERS(CodeMovingGCEvent()); |
| 1489 OS::SignalCodeMovingGC(); | 1492 base::OS::SignalCodeMovingGC(); |
| 1490 } | 1493 } |
| 1491 | 1494 |
| 1492 | 1495 |
| 1493 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { | 1496 void Logger::RegExpCodeCreateEvent(Code* code, String* source) { |
| 1494 PROFILER_LOG(RegExpCodeCreateEvent(code, source)); | 1497 PROFILER_LOG(RegExpCodeCreateEvent(code, source)); |
| 1495 | 1498 |
| 1496 if (!is_logging_code_events()) return; | 1499 if (!is_logging_code_events()) return; |
| 1497 CALL_LISTENERS(RegExpCodeCreateEvent(code, source)); | 1500 CALL_LISTENERS(RegExpCodeCreateEvent(code, source)); |
| 1498 | 1501 |
| 1499 if (!FLAG_log_code || !log_->IsEnabled()) return; | 1502 if (!FLAG_log_code || !log_->IsEnabled()) return; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 msg.WriteToLogFile(); | 1611 msg.WriteToLogFile(); |
| 1609 } | 1612 } |
| 1610 | 1613 |
| 1611 | 1614 |
| 1612 void Logger::ResourceEvent(const char* name, const char* tag) { | 1615 void Logger::ResourceEvent(const char* name, const char* tag) { |
| 1613 if (!log_->IsEnabled() || !FLAG_log) return; | 1616 if (!log_->IsEnabled() || !FLAG_log) return; |
| 1614 Log::MessageBuilder msg(log_); | 1617 Log::MessageBuilder msg(log_); |
| 1615 msg.Append("%s,%s,", name, tag); | 1618 msg.Append("%s,%s,", name, tag); |
| 1616 | 1619 |
| 1617 uint32_t sec, usec; | 1620 uint32_t sec, usec; |
| 1618 if (OS::GetUserTime(&sec, &usec) != -1) { | 1621 if (base::OS::GetUserTime(&sec, &usec) != -1) { |
| 1619 msg.Append("%d,%d,", sec, usec); | 1622 msg.Append("%d,%d,", sec, usec); |
| 1620 } | 1623 } |
| 1621 msg.Append("%.0f", OS::TimeCurrentMillis()); | 1624 msg.Append("%.0f", base::OS::TimeCurrentMillis()); |
| 1622 | 1625 |
| 1623 msg.Append('\n'); | 1626 msg.Append('\n'); |
| 1624 msg.WriteToLogFile(); | 1627 msg.WriteToLogFile(); |
| 1625 } | 1628 } |
| 1626 | 1629 |
| 1627 | 1630 |
| 1628 void Logger::SuspectReadEvent(Name* name, Object* obj) { | 1631 void Logger::SuspectReadEvent(Name* name, Object* obj) { |
| 1629 if (!log_->IsEnabled() || !FLAG_log_suspect) return; | 1632 if (!log_->IsEnabled() || !FLAG_log_suspect) return; |
| 1630 Log::MessageBuilder msg(log_); | 1633 Log::MessageBuilder msg(log_); |
| 1631 String* class_name = obj->IsJSObject() | 1634 String* class_name = obj->IsJSObject() |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1645 msg.WriteToLogFile(); | 1648 msg.WriteToLogFile(); |
| 1646 } | 1649 } |
| 1647 | 1650 |
| 1648 | 1651 |
| 1649 void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { | 1652 void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { |
| 1650 if (!log_->IsEnabled() || !FLAG_log_gc) return; | 1653 if (!log_->IsEnabled() || !FLAG_log_gc) return; |
| 1651 Log::MessageBuilder msg(log_); | 1654 Log::MessageBuilder msg(log_); |
| 1652 // Using non-relative system time in order to be able to synchronize with | 1655 // Using non-relative system time in order to be able to synchronize with |
| 1653 // external memory profiling events (e.g. DOM memory size). | 1656 // external memory profiling events (e.g. DOM memory size). |
| 1654 msg.Append("heap-sample-begin,\"%s\",\"%s\",%.0f\n", | 1657 msg.Append("heap-sample-begin,\"%s\",\"%s\",%.0f\n", |
| 1655 space, kind, OS::TimeCurrentMillis()); | 1658 space, kind, base::OS::TimeCurrentMillis()); |
| 1656 msg.WriteToLogFile(); | 1659 msg.WriteToLogFile(); |
| 1657 } | 1660 } |
| 1658 | 1661 |
| 1659 | 1662 |
| 1660 void Logger::HeapSampleEndEvent(const char* space, const char* kind) { | 1663 void Logger::HeapSampleEndEvent(const char* space, const char* kind) { |
| 1661 if (!log_->IsEnabled() || !FLAG_log_gc) return; | 1664 if (!log_->IsEnabled() || !FLAG_log_gc) return; |
| 1662 Log::MessageBuilder msg(log_); | 1665 Log::MessageBuilder msg(log_); |
| 1663 msg.Append("heap-sample-end,\"%s\",\"%s\"\n", space, kind); | 1666 msg.Append("heap-sample-end,\"%s\",\"%s\"\n", space, kind); |
| 1664 msg.WriteToLogFile(); | 1667 msg.WriteToLogFile(); |
| 1665 } | 1668 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1684 void Logger::DebugEvent(const char* event_type, Vector<uint16_t> parameter) { | 1687 void Logger::DebugEvent(const char* event_type, Vector<uint16_t> parameter) { |
| 1685 if (!log_->IsEnabled() || !FLAG_log) return; | 1688 if (!log_->IsEnabled() || !FLAG_log) return; |
| 1686 StringBuilder s(parameter.length() + 1); | 1689 StringBuilder s(parameter.length() + 1); |
| 1687 for (int i = 0; i < parameter.length(); ++i) { | 1690 for (int i = 0; i < parameter.length(); ++i) { |
| 1688 s.AddCharacter(static_cast<char>(parameter[i])); | 1691 s.AddCharacter(static_cast<char>(parameter[i])); |
| 1689 } | 1692 } |
| 1690 char* parameter_string = s.Finalize(); | 1693 char* parameter_string = s.Finalize(); |
| 1691 Log::MessageBuilder msg(log_); | 1694 Log::MessageBuilder msg(log_); |
| 1692 msg.Append("debug-queue-event,%s,%15.3f,%s\n", | 1695 msg.Append("debug-queue-event,%s,%15.3f,%s\n", |
| 1693 event_type, | 1696 event_type, |
| 1694 OS::TimeCurrentMillis(), | 1697 base::OS::TimeCurrentMillis(), |
| 1695 parameter_string); | 1698 parameter_string); |
| 1696 DeleteArray(parameter_string); | 1699 DeleteArray(parameter_string); |
| 1697 msg.WriteToLogFile(); | 1700 msg.WriteToLogFile(); |
| 1698 } | 1701 } |
| 1699 | 1702 |
| 1700 | 1703 |
| 1701 void Logger::TickEvent(TickSample* sample, bool overflow) { | 1704 void Logger::TickEvent(TickSample* sample, bool overflow) { |
| 1702 if (!log_->IsEnabled() || !FLAG_prof) return; | 1705 if (!log_->IsEnabled() || !FLAG_prof) return; |
| 1703 Log::MessageBuilder msg(log_); | 1706 Log::MessageBuilder msg(log_); |
| 1704 msg.Append("%s,", kLogEventsNames[TICK_EVENT]); | 1707 msg.Append("%s,", kLogEventsNames[TICK_EVENT]); |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1982 for (const char* p = file_name; *p; p++) { | 1985 for (const char* p = file_name; *p; p++) { |
| 1983 if (*p == '%') { | 1986 if (*p == '%') { |
| 1984 p++; | 1987 p++; |
| 1985 switch (*p) { | 1988 switch (*p) { |
| 1986 case '\0': | 1989 case '\0': |
| 1987 // If there's a % at the end of the string we back up | 1990 // If there's a % at the end of the string we back up |
| 1988 // one character so we can escape the loop properly. | 1991 // one character so we can escape the loop properly. |
| 1989 p--; | 1992 p--; |
| 1990 break; | 1993 break; |
| 1991 case 'p': | 1994 case 'p': |
| 1992 stream.Add("%d", OS::GetCurrentProcessId()); | 1995 stream.Add("%d", base::OS::GetCurrentProcessId()); |
| 1993 break; | 1996 break; |
| 1994 case 't': { | 1997 case 't': { |
| 1995 // %t expands to the current time in milliseconds. | 1998 // %t expands to the current time in milliseconds. |
| 1996 double time = OS::TimeCurrentMillis(); | 1999 double time = base::OS::TimeCurrentMillis(); |
| 1997 stream.Add("%.0f", FmtElm(time)); | 2000 stream.Add("%.0f", FmtElm(time)); |
| 1998 break; | 2001 break; |
| 1999 } | 2002 } |
| 2000 case '%': | 2003 case '%': |
| 2001 // %% expands (contracts really) to %. | 2004 // %% expands (contracts really) to %. |
| 2002 stream.Put('%'); | 2005 stream.Put('%'); |
| 2003 break; | 2006 break; |
| 2004 default: | 2007 default: |
| 2005 // All other %'s expand to themselves. | 2008 // All other %'s expand to themselves. |
| 2006 stream.Put('%'); | 2009 stream.Put('%'); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2123 if (jit_logger_) { | 2126 if (jit_logger_) { |
| 2124 removeCodeEventListener(jit_logger_); | 2127 removeCodeEventListener(jit_logger_); |
| 2125 delete jit_logger_; | 2128 delete jit_logger_; |
| 2126 jit_logger_ = NULL; | 2129 jit_logger_ = NULL; |
| 2127 } | 2130 } |
| 2128 | 2131 |
| 2129 return log_->Close(); | 2132 return log_->Close(); |
| 2130 } | 2133 } |
| 2131 | 2134 |
| 2132 } } // namespace v8::internal | 2135 } } // namespace v8::internal |
| OLD | NEW |