| 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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 sampler_thread->SampleContext(sampler); | 802 sampler_thread->SampleContext(sampler); |
| 803 } | 803 } |
| 804 | 804 |
| 805 static void DoRuntimeProfile(Sampler* sampler, void* ignored) { | 805 static void DoRuntimeProfile(Sampler* sampler, void* ignored) { |
| 806 if (!sampler->isolate()->IsInitialized()) return; | 806 if (!sampler->isolate()->IsInitialized()) return; |
| 807 sampler->isolate()->runtime_profiler()->NotifyTick(); | 807 sampler->isolate()->runtime_profiler()->NotifyTick(); |
| 808 } | 808 } |
| 809 | 809 |
| 810 void SampleContext(Sampler* sampler) { | 810 void SampleContext(Sampler* sampler) { |
| 811 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread(); | 811 thread_act_t profiled_thread = sampler->platform_data()->profiled_thread(); |
| 812 TickSample sample_obj; | 812 TickSample* sample = CpuProfiler::StartTickSampleEvent(sampler->isolate()); |
| 813 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate()); | 813 if (sample == NULL) return; |
| 814 if (sample == NULL) sample = &sample_obj; | |
| 815 | 814 |
| 816 if (KERN_SUCCESS != thread_suspend(profiled_thread)) return; | 815 if (KERN_SUCCESS != thread_suspend(profiled_thread)) return; |
| 817 | 816 |
| 818 #if V8_HOST_ARCH_X64 | 817 #if V8_HOST_ARCH_X64 |
| 819 thread_state_flavor_t flavor = x86_THREAD_STATE64; | 818 thread_state_flavor_t flavor = x86_THREAD_STATE64; |
| 820 x86_thread_state64_t state; | 819 x86_thread_state64_t state; |
| 821 mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; | 820 mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; |
| 822 #if __DARWIN_UNIX03 | 821 #if __DARWIN_UNIX03 |
| 823 #define REGISTER_FIELD(name) __r ## name | 822 #define REGISTER_FIELD(name) __r ## name |
| 824 #else | 823 #else |
| (...skipping 16 matching lines...) Expand all Loading... |
| 841 flavor, | 840 flavor, |
| 842 reinterpret_cast<natural_t*>(&state), | 841 reinterpret_cast<natural_t*>(&state), |
| 843 &count) == KERN_SUCCESS) { | 842 &count) == KERN_SUCCESS) { |
| 844 sample->state = sampler->isolate()->current_vm_state(); | 843 sample->state = sampler->isolate()->current_vm_state(); |
| 845 sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip)); | 844 sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip)); |
| 846 sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp)); | 845 sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp)); |
| 847 sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp)); | 846 sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp)); |
| 848 sampler->SampleStack(sample); | 847 sampler->SampleStack(sample); |
| 849 sampler->Tick(sample); | 848 sampler->Tick(sample); |
| 850 } | 849 } |
| 850 CpuProfiler::FinishTickSampleEvent(sampler->isolate()); |
| 851 thread_resume(profiled_thread); | 851 thread_resume(profiled_thread); |
| 852 } | 852 } |
| 853 | 853 |
| 854 const int interval_; | 854 const int interval_; |
| 855 RuntimeProfilerRateLimiter rate_limiter_; | 855 RuntimeProfilerRateLimiter rate_limiter_; |
| 856 | 856 |
| 857 // Protects the process wide state below. | 857 // Protects the process wide state below. |
| 858 static Mutex* mutex_; | 858 static Mutex* mutex_; |
| 859 static SamplerThread* instance_; | 859 static SamplerThread* instance_; |
| 860 | 860 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 | 913 |
| 914 | 914 |
| 915 void Sampler::Stop() { | 915 void Sampler::Stop() { |
| 916 ASSERT(IsActive()); | 916 ASSERT(IsActive()); |
| 917 SamplerThread::RemoveActiveSampler(this); | 917 SamplerThread::RemoveActiveSampler(this); |
| 918 SetActive(false); | 918 SetActive(false); |
| 919 } | 919 } |
| 920 | 920 |
| 921 | 921 |
| 922 } } // namespace v8::internal | 922 } } // namespace v8::internal |
| OLD | NEW |