| 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 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 } | 678 } |
| 679 if (v8::Locker::IsActive() && | 679 if (v8::Locker::IsActive() && |
| 680 !isolate->thread_manager()->IsLockedByCurrentThread()) { | 680 !isolate->thread_manager()->IsLockedByCurrentThread()) { |
| 681 return; | 681 return; |
| 682 } | 682 } |
| 683 | 683 |
| 684 Sampler* sampler = isolate->logger()->sampler(); | 684 Sampler* sampler = isolate->logger()->sampler(); |
| 685 if (sampler == NULL || !sampler->IsActive()) return; | 685 if (sampler == NULL || !sampler->IsActive()) return; |
| 686 | 686 |
| 687 TickSample sample_obj; | 687 TickSample sample_obj; |
| 688 TickSample* sample = CpuProfiler::StartTickSampleEvent(isolate); | 688 TickSample* sample = CpuProfiler::TickSampleEvent(isolate); |
| 689 if (sample == NULL) sample = &sample_obj; | 689 if (sample == NULL) sample = &sample_obj; |
| 690 | 690 |
| 691 // Extracting the sample from the context is extremely machine dependent. | 691 // Extracting the sample from the context is extremely machine dependent. |
| 692 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 692 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
| 693 mcontext_t& mcontext = ucontext->uc_mcontext; | 693 mcontext_t& mcontext = ucontext->uc_mcontext; |
| 694 sample->state = isolate->current_vm_state(); | 694 sample->state = isolate->current_vm_state(); |
| 695 #if V8_HOST_ARCH_IA32 | 695 #if V8_HOST_ARCH_IA32 |
| 696 sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); | 696 sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); |
| 697 sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); | 697 sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); |
| 698 sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); | 698 sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); |
| 699 #elif V8_HOST_ARCH_X64 | 699 #elif V8_HOST_ARCH_X64 |
| 700 sample->pc = reinterpret_cast<Address>(mcontext.mc_rip); | 700 sample->pc = reinterpret_cast<Address>(mcontext.mc_rip); |
| 701 sample->sp = reinterpret_cast<Address>(mcontext.mc_rsp); | 701 sample->sp = reinterpret_cast<Address>(mcontext.mc_rsp); |
| 702 sample->fp = reinterpret_cast<Address>(mcontext.mc_rbp); | 702 sample->fp = reinterpret_cast<Address>(mcontext.mc_rbp); |
| 703 #elif V8_HOST_ARCH_ARM | 703 #elif V8_HOST_ARCH_ARM |
| 704 sample->pc = reinterpret_cast<Address>(mcontext.mc_r15); | 704 sample->pc = reinterpret_cast<Address>(mcontext.mc_r15); |
| 705 sample->sp = reinterpret_cast<Address>(mcontext.mc_r13); | 705 sample->sp = reinterpret_cast<Address>(mcontext.mc_r13); |
| 706 sample->fp = reinterpret_cast<Address>(mcontext.mc_r11); | 706 sample->fp = reinterpret_cast<Address>(mcontext.mc_r11); |
| 707 #endif | 707 #endif |
| 708 sampler->SampleStack(sample); | 708 sampler->SampleStack(sample); |
| 709 sampler->Tick(sample); | 709 sampler->Tick(sample); |
| 710 CpuProfiler::FinishTickSampleEvent(isolate); | |
| 711 } | 710 } |
| 712 | 711 |
| 713 | 712 |
| 714 class SignalSender : public Thread { | 713 class SignalSender : public Thread { |
| 715 public: | 714 public: |
| 716 enum SleepInterval { | 715 enum SleepInterval { |
| 717 HALF_INTERVAL, | 716 HALF_INTERVAL, |
| 718 FULL_INTERVAL | 717 FULL_INTERVAL |
| 719 }; | 718 }; |
| 720 | 719 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 data_ = new PlatformData; | 883 data_ = new PlatformData; |
| 885 } | 884 } |
| 886 | 885 |
| 887 | 886 |
| 888 Sampler::~Sampler() { | 887 Sampler::~Sampler() { |
| 889 ASSERT(!IsActive()); | 888 ASSERT(!IsActive()); |
| 890 delete data_; | 889 delete data_; |
| 891 } | 890 } |
| 892 | 891 |
| 893 | 892 |
| 894 void Sampler::DoSample() { | |
| 895 // TODO(rogulenko): implement | |
| 896 } | |
| 897 | |
| 898 | |
| 899 void Sampler::Start() { | 893 void Sampler::Start() { |
| 900 ASSERT(!IsActive()); | 894 ASSERT(!IsActive()); |
| 901 SetActive(true); | 895 SetActive(true); |
| 902 SignalSender::AddActiveSampler(this); | 896 SignalSender::AddActiveSampler(this); |
| 903 } | 897 } |
| 904 | 898 |
| 905 | 899 |
| 906 void Sampler::Stop() { | 900 void Sampler::Stop() { |
| 907 ASSERT(IsActive()); | 901 ASSERT(IsActive()); |
| 908 SignalSender::RemoveActiveSampler(this); | 902 SignalSender::RemoveActiveSampler(this); |
| 909 SetActive(false); | 903 SetActive(false); |
| 910 } | 904 } |
| 911 | 905 |
| 912 | 906 |
| 913 void Sampler::StartSampling() { | |
| 914 } | |
| 915 | |
| 916 | |
| 917 void Sampler::StopSampling() { | |
| 918 } | |
| 919 | |
| 920 | |
| 921 } } // namespace v8::internal | 907 } } // namespace v8::internal |
| OLD | NEW |