| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 14 matching lines...) Expand all Loading... |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <stdarg.h> | 28 #include <stdarg.h> |
| 29 | 29 |
| 30 #include "v8.h" | 30 #include "v8.h" |
| 31 | 31 |
| 32 #include "log.h" | 32 #include "log.h" |
| 33 #include "platform.h" | 33 #include "platform.h" |
| 34 #include "string-stream.h" | 34 #include "string-stream.h" |
| 35 #include "assembler.h" |
| 35 | 36 |
| 36 namespace v8 { namespace internal { | 37 namespace v8 { namespace internal { |
| 37 | 38 |
| 38 #ifdef ENABLE_LOGGING_AND_PROFILING | 39 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 39 | 40 |
| 40 // | 41 // |
| 41 // Sliding state window. Updates counters to keep track of the last | 42 // Sliding state window. Updates counters to keep track of the last |
| 42 // window of kBufferSize states. This is useful to track where we | 43 // window of kBufferSize states. This is useful to track where we |
| 43 // spent our time. | 44 // spent our time. |
| 44 // | 45 // |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 ScopedLock sl(mutex_); | 550 ScopedLock sl(mutex_); |
| 550 | 551 |
| 551 fprintf(logfile_, "code-creation,%s,0x%x,%d,\"args_count: %d\"\n", tag, | 552 fprintf(logfile_, "code-creation,%s,0x%x,%d,\"args_count: %d\"\n", tag, |
| 552 reinterpret_cast<unsigned int>(code->address()), | 553 reinterpret_cast<unsigned int>(code->address()), |
| 553 code->instruction_size(), | 554 code->instruction_size(), |
| 554 args_count); | 555 args_count); |
| 555 #endif | 556 #endif |
| 556 } | 557 } |
| 557 | 558 |
| 558 | 559 |
| 560 void Logger::CodeAllocateEvent(Code* code, Assembler* assem) { |
| 561 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 562 if (logfile_ == NULL || !FLAG_log_code) return; |
| 563 ScopedLock sl(mutex_); |
| 564 |
| 565 fprintf(logfile_, "code-allocate,0x%x,0x%x\n", |
| 566 reinterpret_cast<unsigned int>(code->address()), |
| 567 reinterpret_cast<unsigned int>(assem)); |
| 568 #endif |
| 569 } |
| 570 |
| 571 |
| 559 void Logger::CodeMoveEvent(Address from, Address to) { | 572 void Logger::CodeMoveEvent(Address from, Address to) { |
| 560 #ifdef ENABLE_LOGGING_AND_PROFILING | 573 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 561 if (logfile_ == NULL || !FLAG_log_code) return; | 574 if (logfile_ == NULL || !FLAG_log_code) return; |
| 562 ScopedLock sl(mutex_); | 575 ScopedLock sl(mutex_); |
| 563 fprintf(logfile_, "code-move,0x%x,0x%x\n", | 576 fprintf(logfile_, "code-move,0x%x,0x%x\n", |
| 564 reinterpret_cast<unsigned int>(from), | 577 reinterpret_cast<unsigned int>(from), |
| 565 reinterpret_cast<unsigned int>(to)); | 578 reinterpret_cast<unsigned int>(to)); |
| 566 #endif | 579 #endif |
| 567 } | 580 } |
| 568 | 581 |
| 569 | 582 |
| 570 void Logger::CodeDeleteEvent(Address from) { | 583 void Logger::CodeDeleteEvent(Address from) { |
| 571 #ifdef ENABLE_LOGGING_AND_PROFILING | 584 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 572 if (logfile_ == NULL || !FLAG_log_code) return; | 585 if (logfile_ == NULL || !FLAG_log_code) return; |
| 573 ScopedLock sl(mutex_); | 586 ScopedLock sl(mutex_); |
| 574 fprintf(logfile_, "code-delete,0x%x\n", reinterpret_cast<unsigned int>(from)); | 587 fprintf(logfile_, "code-delete,0x%x\n", reinterpret_cast<unsigned int>(from)); |
| 575 #endif | 588 #endif |
| 576 } | 589 } |
| 577 | 590 |
| 578 | 591 |
| 592 void Logger::BeginCodeRegionEvent(CodeRegion* region, |
| 593 Assembler* masm, |
| 594 const char* name) { |
| 595 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 596 if (logfile_ == NULL || !FLAG_log_code) return; |
| 597 ScopedLock sl(mutex_); |
| 598 fprintf(logfile_, "begin-code-region,0x%x,0x%x,0x%x,%s\n", |
| 599 reinterpret_cast<unsigned int>(region), |
| 600 reinterpret_cast<unsigned int>(masm), |
| 601 masm->pc_offset(), |
| 602 name); |
| 603 #endif |
| 604 } |
| 605 |
| 606 |
| 607 void Logger::EndCodeRegionEvent(CodeRegion* region, Assembler* masm) { |
| 608 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 609 if (logfile_ == NULL || !FLAG_log_code) return; |
| 610 ScopedLock sl(mutex_); |
| 611 fprintf(logfile_, "end-code-region,0x%x,0x%x,0x%x\n", |
| 612 reinterpret_cast<unsigned int>(region), |
| 613 reinterpret_cast<unsigned int>(masm), |
| 614 masm->pc_offset()); |
| 615 #endif |
| 616 } |
| 617 |
| 618 |
| 579 void Logger::ResourceEvent(const char* name, const char* tag) { | 619 void Logger::ResourceEvent(const char* name, const char* tag) { |
| 580 #ifdef ENABLE_LOGGING_AND_PROFILING | 620 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 581 if (logfile_ == NULL || !FLAG_log) return; | 621 if (logfile_ == NULL || !FLAG_log) return; |
| 582 ScopedLock sl(mutex_); | 622 ScopedLock sl(mutex_); |
| 583 fprintf(logfile_, "%s,%s,", name, tag); | 623 fprintf(logfile_, "%s,%s,", name, tag); |
| 584 | 624 |
| 585 uint32_t sec, usec; | 625 uint32_t sec, usec; |
| 586 if (OS::GetUserTime(&sec, &usec) != -1) { | 626 if (OS::GetUserTime(&sec, &usec) != -1) { |
| 587 fprintf(logfile_, "%d,%d,", sec, usec); | 627 fprintf(logfile_, "%d,%d,", sec, usec); |
| 588 } | 628 } |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 if (FLAG_log_state_changes) { | 886 if (FLAG_log_state_changes) { |
| 847 LOG(StringEvent("Leaving", StateToString(state_))); | 887 LOG(StringEvent("Leaving", StateToString(state_))); |
| 848 if (previous_) { | 888 if (previous_) { |
| 849 LOG(StringEvent("To", StateToString(previous_->state_))); | 889 LOG(StringEvent("To", StateToString(previous_->state_))); |
| 850 } | 890 } |
| 851 } | 891 } |
| 852 } | 892 } |
| 853 #endif | 893 #endif |
| 854 | 894 |
| 855 } } // namespace v8::internal | 895 } } // namespace v8::internal |
| OLD | NEW |