| 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 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 return; | 671 return; |
| 672 } | 672 } |
| 673 if (v8::Locker::IsActive() && | 673 if (v8::Locker::IsActive() && |
| 674 !isolate->thread_manager()->IsLockedByCurrentThread()) { | 674 !isolate->thread_manager()->IsLockedByCurrentThread()) { |
| 675 return; | 675 return; |
| 676 } | 676 } |
| 677 | 677 |
| 678 Sampler* sampler = isolate->logger()->sampler(); | 678 Sampler* sampler = isolate->logger()->sampler(); |
| 679 if (sampler == NULL || !sampler->IsActive()) return; | 679 if (sampler == NULL || !sampler->IsActive()) return; |
| 680 | 680 |
| 681 TickSample sample_obj; | 681 TickSample* sample = CpuProfiler::StartTickSampleEvent(isolate); |
| 682 TickSample* sample = CpuProfiler::TickSampleEvent(isolate); | 682 if (sample == NULL) return; |
| 683 if (sample == NULL) sample = &sample_obj; | |
| 684 | 683 |
| 685 // Extracting the sample from the context is extremely machine dependent. | 684 // Extracting the sample from the context is extremely machine dependent. |
| 686 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 685 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
| 687 mcontext_t& mcontext = ucontext->uc_mcontext; | 686 mcontext_t& mcontext = ucontext->uc_mcontext; |
| 688 sample->state = isolate->current_vm_state(); | 687 sample->state = isolate->current_vm_state(); |
| 689 #if V8_HOST_ARCH_IA32 | 688 #if V8_HOST_ARCH_IA32 |
| 690 sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); | 689 sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); |
| 691 sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); | 690 sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); |
| 692 sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); | 691 sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); |
| 693 #elif V8_HOST_ARCH_X64 | 692 #elif V8_HOST_ARCH_X64 |
| 694 sample->pc = reinterpret_cast<Address>(mcontext.mc_rip); | 693 sample->pc = reinterpret_cast<Address>(mcontext.mc_rip); |
| 695 sample->sp = reinterpret_cast<Address>(mcontext.mc_rsp); | 694 sample->sp = reinterpret_cast<Address>(mcontext.mc_rsp); |
| 696 sample->fp = reinterpret_cast<Address>(mcontext.mc_rbp); | 695 sample->fp = reinterpret_cast<Address>(mcontext.mc_rbp); |
| 697 #elif V8_HOST_ARCH_ARM | 696 #elif V8_HOST_ARCH_ARM |
| 698 sample->pc = reinterpret_cast<Address>(mcontext.mc_r15); | 697 sample->pc = reinterpret_cast<Address>(mcontext.mc_r15); |
| 699 sample->sp = reinterpret_cast<Address>(mcontext.mc_r13); | 698 sample->sp = reinterpret_cast<Address>(mcontext.mc_r13); |
| 700 sample->fp = reinterpret_cast<Address>(mcontext.mc_r11); | 699 sample->fp = reinterpret_cast<Address>(mcontext.mc_r11); |
| 701 #endif | 700 #endif |
| 702 sampler->SampleStack(sample); | 701 sampler->SampleStack(sample); |
| 703 sampler->Tick(sample); | 702 sampler->Tick(sample); |
| 703 CpuProfiler::FinishTickSampleEvent(isolate); |
| 704 } | 704 } |
| 705 | 705 |
| 706 | 706 |
| 707 class SignalSender : public Thread { | 707 class SignalSender : public Thread { |
| 708 public: | 708 public: |
| 709 enum SleepInterval { | 709 enum SleepInterval { |
| 710 HALF_INTERVAL, | 710 HALF_INTERVAL, |
| 711 FULL_INTERVAL | 711 FULL_INTERVAL |
| 712 }; | 712 }; |
| 713 | 713 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 897 | 897 |
| 898 | 898 |
| 899 void Sampler::Stop() { | 899 void Sampler::Stop() { |
| 900 ASSERT(IsActive()); | 900 ASSERT(IsActive()); |
| 901 SignalSender::RemoveActiveSampler(this); | 901 SignalSender::RemoveActiveSampler(this); |
| 902 SetActive(false); | 902 SetActive(false); |
| 903 } | 903 } |
| 904 | 904 |
| 905 | 905 |
| 906 } } // namespace v8::internal | 906 } } // namespace v8::internal |
| OLD | NEW |