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

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

Issue 11437016: Use count-based profiling exclusively. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments Created 8 years 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-linux.cc ('k') | src/platform-openbsd.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 delete instance_; 780 delete instance_;
781 instance_ = NULL; 781 instance_ = NULL;
782 } 782 }
783 } 783 }
784 784
785 // Implement Thread::Run(). 785 // Implement Thread::Run().
786 virtual void Run() { 786 virtual void Run() {
787 SamplerRegistry::State state; 787 SamplerRegistry::State state;
788 while ((state = SamplerRegistry::GetState()) != 788 while ((state = SamplerRegistry::GetState()) !=
789 SamplerRegistry::HAS_NO_SAMPLERS) { 789 SamplerRegistry::HAS_NO_SAMPLERS) {
790 bool cpu_profiling_enabled =
791 (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS);
792 bool runtime_profiler_enabled = RuntimeProfiler::IsEnabled();
793 // When CPU profiling is enabled both JavaScript and C++ code is 790 // When CPU profiling is enabled both JavaScript and C++ code is
794 // profiled. We must not suspend. 791 // profiled. We must not suspend.
795 if (!cpu_profiling_enabled) { 792 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) {
793 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this);
794 } else {
796 if (rate_limiter_.SuspendIfNecessary()) continue; 795 if (rate_limiter_.SuspendIfNecessary()) continue;
797 } 796 }
798 if (cpu_profiling_enabled) {
799 if (!SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this)) {
800 return;
801 }
802 }
803 if (runtime_profiler_enabled) {
804 if (!SamplerRegistry::IterateActiveSamplers(&DoRuntimeProfile, NULL)) {
805 return;
806 }
807 }
808 OS::Sleep(interval_); 797 OS::Sleep(interval_);
809 } 798 }
810 } 799 }
811 800
812 static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) { 801 static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) {
813 if (!sampler->isolate()->IsInitialized()) return; 802 if (!sampler->isolate()->IsInitialized()) return;
814 if (!sampler->IsProfiling()) return; 803 if (!sampler->IsProfiling()) return;
815 SamplerThread* sampler_thread = 804 SamplerThread* sampler_thread =
816 reinterpret_cast<SamplerThread*>(raw_sampler_thread); 805 reinterpret_cast<SamplerThread*>(raw_sampler_thread);
817 sampler_thread->SampleContext(sampler); 806 sampler_thread->SampleContext(sampler);
818 } 807 }
819 808
820 static void DoRuntimeProfile(Sampler* sampler, void* ignored) {
821 if (!sampler->isolate()->IsInitialized()) return;
822 sampler->isolate()->runtime_profiler()->NotifyTick();
823 }
824
825 void SampleContext(Sampler* sampler) { 809 void SampleContext(Sampler* sampler) {
826 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread(); 810 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread();
827 TickSample sample_obj; 811 TickSample sample_obj;
828 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate()); 812 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate());
829 if (sample == NULL) sample = &sample_obj; 813 if (sample == NULL) sample = &sample_obj;
830 814
831 if (KERN_SUCCESS != thread_suspend(profiled_thread)) return; 815 if (KERN_SUCCESS != thread_suspend(profiled_thread)) return;
832 816
833 #if V8_HOST_ARCH_X64 817 #if V8_HOST_ARCH_X64
834 thread_state_flavor_t flavor = x86_THREAD_STATE64; 818 thread_state_flavor_t flavor = x86_THREAD_STATE64;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 907
924 908
925 void Sampler::Stop() { 909 void Sampler::Stop() {
926 ASSERT(IsActive()); 910 ASSERT(IsActive());
927 SamplerThread::RemoveActiveSampler(this); 911 SamplerThread::RemoveActiveSampler(this);
928 SetActive(false); 912 SetActive(false);
929 } 913 }
930 914
931 915
932 } } // namespace v8::internal 916 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698