Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(746)

Side by Side Diff: src/platform-linux.cc

Issue 3845006: Try to simplify the semantics of the profiling code by making... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform.h ('k') | src/platform-macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 } 741 }
742 return false; 742 return false;
743 } 743 }
744 744
745 745
746 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { 746 static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
747 #ifndef V8_HOST_ARCH_MIPS 747 #ifndef V8_HOST_ARCH_MIPS
748 USE(info); 748 USE(info);
749 if (signal != SIGPROF) return; 749 if (signal != SIGPROF) return;
750 if (active_sampler_ == NULL) return; 750 if (active_sampler_ == NULL) return;
751 if (!IsVmThread()) return;
751 752
752 TickSample sample_obj; 753 TickSample sample_obj;
753 TickSample* sample = CpuProfiler::TickSampleEvent(); 754 TickSample* sample = CpuProfiler::TickSampleEvent();
754 if (sample == NULL) sample = &sample_obj; 755 if (sample == NULL) sample = &sample_obj;
755 756
756 // We always sample the VM state. 757 // We always sample the VM state.
757 sample->state = VMState::current_state(); 758 sample->state = VMState::current_state();
759
758 // If profiling, we extract the current pc and sp. 760 // If profiling, we extract the current pc and sp.
759 if (active_sampler_->IsProfiling()) { 761 if (active_sampler_->IsProfiling()) {
760 // Extracting the sample from the context is extremely machine dependent. 762 // Extracting the sample from the context is extremely machine dependent.
761 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); 763 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
762 mcontext_t& mcontext = ucontext->uc_mcontext; 764 mcontext_t& mcontext = ucontext->uc_mcontext;
763 #if V8_HOST_ARCH_IA32 765 #if V8_HOST_ARCH_IA32
764 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); 766 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]);
765 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); 767 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]);
766 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); 768 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]);
767 #elif V8_HOST_ARCH_X64 769 #elif V8_HOST_ARCH_X64
768 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); 770 sample->pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]);
769 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); 771 sample->sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]);
770 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]); 772 sample->fp = reinterpret_cast<Address>(mcontext.gregs[REG_RBP]);
771 #elif V8_HOST_ARCH_ARM 773 #elif V8_HOST_ARCH_ARM
772 // An undefined macro evaluates to 0, so this applies to Android's Bionic also. 774 // An undefined macro evaluates to 0, so this applies to Android's Bionic also.
773 #if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) 775 #if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3))
774 sample->pc = reinterpret_cast<Address>(mcontext.gregs[R15]); 776 sample->pc = reinterpret_cast<Address>(mcontext.gregs[R15]);
775 sample->sp = reinterpret_cast<Address>(mcontext.gregs[R13]); 777 sample->sp = reinterpret_cast<Address>(mcontext.gregs[R13]);
776 sample->fp = reinterpret_cast<Address>(mcontext.gregs[R11]); 778 sample->fp = reinterpret_cast<Address>(mcontext.gregs[R11]);
777 #else 779 #else
778 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); 780 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc);
779 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); 781 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp);
780 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); 782 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp);
781 #endif 783 #endif
782 #elif V8_HOST_ARCH_MIPS 784 #elif V8_HOST_ARCH_MIPS
783 // Implement this on MIPS. 785 // Implement this on MIPS.
784 UNIMPLEMENTED(); 786 UNIMPLEMENTED();
785 #endif 787 #endif
786 if (IsVmThread()) { 788 active_sampler_->SampleStack(sample);
787 active_sampler_->SampleStack(sample);
788 }
789 } 789 }
790 790
791 active_sampler_->Tick(sample); 791 active_sampler_->Tick(sample);
792 #endif 792 #endif
793 } 793 }
794 794
795 795
796 class Sampler::PlatformData : public Malloced { 796 class Sampler::PlatformData : public Malloced {
797 public: 797 public:
798 PlatformData() { 798 PlatformData() {
799 signal_handler_installed_ = false; 799 signal_handler_installed_ = false;
800 } 800 }
801 801
802 bool signal_handler_installed_; 802 bool signal_handler_installed_;
803 struct sigaction old_signal_handler_; 803 struct sigaction old_signal_handler_;
804 struct itimerval old_timer_value_; 804 struct itimerval old_timer_value_;
805 }; 805 };
806 806
807 807
808 Sampler::Sampler(int interval, bool profiling) 808 Sampler::Sampler(int interval, bool profiling)
809 : interval_(interval), profiling_(profiling), active_(false) { 809 : interval_(interval),
810 profiling_(profiling),
811 synchronous_(profiling),
812 active_(false) {
810 data_ = new PlatformData(); 813 data_ = new PlatformData();
811 } 814 }
812 815
813 816
814 Sampler::~Sampler() { 817 Sampler::~Sampler() {
815 delete data_; 818 delete data_;
816 } 819 }
817 820
818 821
819 void Sampler::Start() { 822 void Sampler::Start() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 858
856 // This sampler is no longer the active sampler. 859 // This sampler is no longer the active sampler.
857 active_sampler_ = NULL; 860 active_sampler_ = NULL;
858 active_ = false; 861 active_ = false;
859 } 862 }
860 863
861 864
862 #endif // ENABLE_LOGGING_AND_PROFILING 865 #endif // ENABLE_LOGGING_AND_PROFILING
863 866
864 } } // namespace v8::internal 867 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698