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 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
720 return false; | 720 return false; |
721 } | 721 } |
722 | 722 |
723 | 723 |
724 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { | 724 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { |
725 #ifndef V8_HOST_ARCH_MIPS | 725 #ifndef V8_HOST_ARCH_MIPS |
726 USE(info); | 726 USE(info); |
727 if (signal != SIGPROF) return; | 727 if (signal != SIGPROF) return; |
728 if (active_sampler_ == NULL) return; | 728 if (active_sampler_ == NULL) return; |
729 | 729 |
730 TickSample sample; | 730 #ifdef ENABLE_CPP_PROFILES_PROCESSOR |
731 if (Logger::state() == GC || !IsVmThread()) return; | |
732 | |
733 TickSample* sample = NULL; | |
734 #else | |
735 TickSample sample_obj, *sample = &sample_obj; | |
Kevin Millikin (Chromium)
2010/04/06 09:10:47
This is probably better as:
TickSample sample_obj
mnaganov (inactive)
2010/04/06 10:31:42
Done.
| |
731 | 736 |
732 // We always sample the VM state. | 737 // We always sample the VM state. |
733 sample.state = Logger::state(); | 738 sample->state = Logger::state(); |
739 #endif | |
734 | 740 |
735 // If profiling, we extract the current pc and sp. | 741 // If profiling, we extract the current pc and sp. |
736 if (active_sampler_->IsProfiling()) { | 742 if (active_sampler_->IsProfiling()) { |
737 // Extracting the sample from the context is extremely machine dependent. | 743 // Extracting the sample from the context is extremely machine dependent. |
738 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 744 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
739 mcontext_t& mcontext = ucontext->uc_mcontext; | 745 mcontext_t& mcontext = ucontext->uc_mcontext; |
746 #ifdef ENABLE_CPP_PROFILES_PROCESSOR | |
747 sample = CpuProfiler::TickSampleEvent(); | |
748 #endif | |
749 if (sample != NULL) { | |
740 #if V8_HOST_ARCH_IA32 | 750 #if V8_HOST_ARCH_IA32 |
741 sample.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); | 751 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
742 sample.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); | 752 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); |
743 sample.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); | 753 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); |
744 #elif V8_HOST_ARCH_X64 | 754 #elif V8_HOST_ARCH_X64 |
745 sample.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); | 755 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); |
746 sample.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); | 756 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); |
747 sample.fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]); | 757 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]); |
748 #elif V8_HOST_ARCH_ARM | 758 #elif V8_HOST_ARCH_ARM |
749 // An undefined macro evaluates to 0, so this applies to Android's Bionic also. | 759 // An undefined macro evaluates to 0, so this applies to Android's Bionic also. |
750 #if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | 760 #if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
751 sample.pc = reinterpret_cast<Address>(mcontext.gregs[R15]); | 761 sample->pc = reinterpret_cast<Address>(mcontext.gregs[R15]); |
752 sample.sp = reinterpret_cast<Address>(mcontext.gregs[R13]); | 762 sample->sp = reinterpret_cast<Address>(mcontext.gregs[R13]); |
753 sample.fp = reinterpret_cast<Address>(mcontext.gregs[R11]); | 763 sample->fp = reinterpret_cast<Address>(mcontext.gregs[R11]); |
754 #else | 764 #else |
755 sample.pc = reinterpret_cast<Address>(mcontext.arm_pc); | 765 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); |
756 sample.sp = reinterpret_cast<Address>(mcontext.arm_sp); | 766 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); |
757 sample.fp = reinterpret_cast<Address>(mcontext.arm_fp); | 767 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); |
758 #endif | 768 #endif |
759 #elif V8_HOST_ARCH_MIPS | 769 #elif V8_HOST_ARCH_MIPS |
760 // Implement this on MIPS. | 770 // Implement this on MIPS. |
761 UNIMPLEMENTED(); | 771 UNIMPLEMENTED(); |
762 #endif | 772 #endif |
763 if (IsVmThread()) | 773 #ifdef ENABLE_CPP_PROFILES_PROCESSOR |
Søren Thygesen Gjesse
2010/04/06 10:37:43
If this #ifdef block needed? From above IsVmThread
mnaganov (inactive)
2010/04/06 11:44:52
Right, not needed actually. I will remove it in my
| |
764 active_sampler_->SampleStack(&sample); | 774 active_sampler_->SampleStack(sample); |
775 #else | |
776 if (IsVmThread()) { | |
777 active_sampler_->SampleStack(sample); | |
778 } | |
779 #endif | |
780 } | |
765 } | 781 } |
766 | 782 #ifndef ENABLE_CPP_PROFILES_PROCESSOR |
767 active_sampler_->Tick(&sample); | 783 active_sampler_->Tick(sample); |
784 #endif | |
768 #endif | 785 #endif |
769 } | 786 } |
770 | 787 |
771 | 788 |
772 class Sampler::PlatformData : public Malloced { | 789 class Sampler::PlatformData : public Malloced { |
773 public: | 790 public: |
774 PlatformData() { | 791 PlatformData() { |
775 signal_handler_installed_ = false; | 792 signal_handler_installed_ = false; |
776 } | 793 } |
777 | 794 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
831 | 848 |
832 // This sampler is no longer the active sampler. | 849 // This sampler is no longer the active sampler. |
833 active_sampler_ = NULL; | 850 active_sampler_ = NULL; |
834 active_ = false; | 851 active_ = false; |
835 } | 852 } |
836 | 853 |
837 | 854 |
838 #endif // ENABLE_LOGGING_AND_PROFILING | 855 #endif // ENABLE_LOGGING_AND_PROFILING |
839 | 856 |
840 } } // namespace v8::internal | 857 } } // namespace v8::internal |
OLD | NEW |