| OLD | NEW |
| 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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 } | 818 } |
| 819 | 819 |
| 820 static void DoRuntimeProfile(Sampler* sampler, void* ignored) { | 820 static void DoRuntimeProfile(Sampler* sampler, void* ignored) { |
| 821 if (!sampler->isolate()->IsInitialized()) return; | 821 if (!sampler->isolate()->IsInitialized()) return; |
| 822 sampler->isolate()->runtime_profiler()->NotifyTick(); | 822 sampler->isolate()->runtime_profiler()->NotifyTick(); |
| 823 } | 823 } |
| 824 | 824 |
| 825 void SampleContext(Sampler* sampler) { | 825 void SampleContext(Sampler* sampler) { |
| 826 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread(); | 826 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread(); |
| 827 TickSample sample_obj; | 827 TickSample sample_obj; |
| 828 TickSample* sample = CpuProfiler::StartTickSampleEvent(sampler->isolate()); | 828 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate()); |
| 829 if (sample == NULL) sample = &sample_obj; | 829 if (sample == NULL) sample = &sample_obj; |
| 830 | 830 |
| 831 if (KERN_SUCCESS != thread_suspend(profiled_thread)) return; | 831 if (KERN_SUCCESS != thread_suspend(profiled_thread)) return; |
| 832 | 832 |
| 833 #if V8_HOST_ARCH_X64 | 833 #if V8_HOST_ARCH_X64 |
| 834 thread_state_flavor_t flavor = x86_THREAD_STATE64; | 834 thread_state_flavor_t flavor = x86_THREAD_STATE64; |
| 835 x86_thread_state64_t state; | 835 x86_thread_state64_t state; |
| 836 mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; | 836 mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; |
| 837 #if __DARWIN_UNIX03 | 837 #if __DARWIN_UNIX03 |
| 838 #define REGISTER_FIELD(name) __r ## name | 838 #define REGISTER_FIELD(name) __r ## name |
| (...skipping 17 matching lines...) Expand all Loading... |
| 856 flavor, | 856 flavor, |
| 857 reinterpret_cast<natural_t*>(&state), | 857 reinterpret_cast<natural_t*>(&state), |
| 858 &count) == KERN_SUCCESS) { | 858 &count) == KERN_SUCCESS) { |
| 859 sample->state = sampler->isolate()->current_vm_state(); | 859 sample->state = sampler->isolate()->current_vm_state(); |
| 860 sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip)); | 860 sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip)); |
| 861 sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp)); | 861 sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp)); |
| 862 sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp)); | 862 sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp)); |
| 863 sampler->SampleStack(sample); | 863 sampler->SampleStack(sample); |
| 864 sampler->Tick(sample); | 864 sampler->Tick(sample); |
| 865 } | 865 } |
| 866 CpuProfiler::FinishTickSampleEvent(sampler->isolate()); | |
| 867 thread_resume(profiled_thread); | 866 thread_resume(profiled_thread); |
| 868 } | 867 } |
| 869 | 868 |
| 870 const int interval_; | 869 const int interval_; |
| 871 RuntimeProfilerRateLimiter rate_limiter_; | 870 RuntimeProfilerRateLimiter rate_limiter_; |
| 872 | 871 |
| 873 // Protects the process wide state below. | 872 // Protects the process wide state below. |
| 874 static Mutex* mutex_; | 873 static Mutex* mutex_; |
| 875 static SamplerThread* instance_; | 874 static SamplerThread* instance_; |
| 876 | 875 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 data_ = new PlatformData; | 908 data_ = new PlatformData; |
| 910 } | 909 } |
| 911 | 910 |
| 912 | 911 |
| 913 Sampler::~Sampler() { | 912 Sampler::~Sampler() { |
| 914 ASSERT(!IsActive()); | 913 ASSERT(!IsActive()); |
| 915 delete data_; | 914 delete data_; |
| 916 } | 915 } |
| 917 | 916 |
| 918 | 917 |
| 919 void Sampler::DoSample() { | |
| 920 // TODO(rogulenko): implement | |
| 921 } | |
| 922 | |
| 923 | |
| 924 void Sampler::Start() { | 918 void Sampler::Start() { |
| 925 ASSERT(!IsActive()); | 919 ASSERT(!IsActive()); |
| 926 SetActive(true); | 920 SetActive(true); |
| 927 SamplerThread::AddActiveSampler(this); | 921 SamplerThread::AddActiveSampler(this); |
| 928 } | 922 } |
| 929 | 923 |
| 930 | 924 |
| 931 void Sampler::Stop() { | 925 void Sampler::Stop() { |
| 932 ASSERT(IsActive()); | 926 ASSERT(IsActive()); |
| 933 SamplerThread::RemoveActiveSampler(this); | 927 SamplerThread::RemoveActiveSampler(this); |
| 934 SetActive(false); | 928 SetActive(false); |
| 935 } | 929 } |
| 936 | 930 |
| 937 | 931 |
| 938 void Sampler::StartSampling() { | |
| 939 } | |
| 940 | |
| 941 | |
| 942 void Sampler::StopSampling() { | |
| 943 } | |
| 944 | |
| 945 | |
| 946 } } // namespace v8::internal | 932 } } // namespace v8::internal |
| OLD | NEW |