| 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 = CpuProfiler::StartTickSampleEvent(isolate); | 681   TickSample sample_obj; | 
| 682   if (sample == NULL) return; | 682   TickSample* sample = CpuProfiler::TickSampleEvent(isolate); | 
|  | 683   if (sample == NULL) sample = &sample_obj; | 
| 683 | 684 | 
| 684   // Extracting the sample from the context is extremely machine dependent. | 685   // Extracting the sample from the context is extremely machine dependent. | 
| 685   ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 686   ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 
| 686   mcontext_t& mcontext = ucontext->uc_mcontext; | 687   mcontext_t& mcontext = ucontext->uc_mcontext; | 
| 687   sample->state = isolate->current_vm_state(); | 688   sample->state = isolate->current_vm_state(); | 
| 688 #if V8_HOST_ARCH_IA32 | 689 #if V8_HOST_ARCH_IA32 | 
| 689   sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); | 690   sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); | 
| 690   sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); | 691   sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); | 
| 691   sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); | 692   sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); | 
| 692 #elif V8_HOST_ARCH_X64 | 693 #elif V8_HOST_ARCH_X64 | 
| 693   sample->pc = reinterpret_cast<Address>(mcontext.mc_rip); | 694   sample->pc = reinterpret_cast<Address>(mcontext.mc_rip); | 
| 694   sample->sp = reinterpret_cast<Address>(mcontext.mc_rsp); | 695   sample->sp = reinterpret_cast<Address>(mcontext.mc_rsp); | 
| 695   sample->fp = reinterpret_cast<Address>(mcontext.mc_rbp); | 696   sample->fp = reinterpret_cast<Address>(mcontext.mc_rbp); | 
| 696 #elif V8_HOST_ARCH_ARM | 697 #elif V8_HOST_ARCH_ARM | 
| 697   sample->pc = reinterpret_cast<Address>(mcontext.mc_r15); | 698   sample->pc = reinterpret_cast<Address>(mcontext.mc_r15); | 
| 698   sample->sp = reinterpret_cast<Address>(mcontext.mc_r13); | 699   sample->sp = reinterpret_cast<Address>(mcontext.mc_r13); | 
| 699   sample->fp = reinterpret_cast<Address>(mcontext.mc_r11); | 700   sample->fp = reinterpret_cast<Address>(mcontext.mc_r11); | 
| 700 #endif | 701 #endif | 
| 701   sampler->SampleStack(sample); | 702   sampler->SampleStack(sample); | 
| 702   sampler->Tick(sample); | 703   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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 877   data_ = new PlatformData; | 877   data_ = new PlatformData; | 
| 878 } | 878 } | 
| 879 | 879 | 
| 880 | 880 | 
| 881 Sampler::~Sampler() { | 881 Sampler::~Sampler() { | 
| 882   ASSERT(!IsActive()); | 882   ASSERT(!IsActive()); | 
| 883   delete data_; | 883   delete data_; | 
| 884 } | 884 } | 
| 885 | 885 | 
| 886 | 886 | 
| 887 void Sampler::DoSample() { |  | 
| 888   // TODO(rogulenko): implement |  | 
| 889 } |  | 
| 890 |  | 
| 891 |  | 
| 892 void Sampler::Start() { | 887 void Sampler::Start() { | 
| 893   ASSERT(!IsActive()); | 888   ASSERT(!IsActive()); | 
| 894   SetActive(true); | 889   SetActive(true); | 
| 895   SignalSender::AddActiveSampler(this); | 890   SignalSender::AddActiveSampler(this); | 
| 896 } | 891 } | 
| 897 | 892 | 
| 898 | 893 | 
| 899 void Sampler::Stop() { | 894 void Sampler::Stop() { | 
| 900   ASSERT(IsActive()); | 895   ASSERT(IsActive()); | 
| 901   SignalSender::RemoveActiveSampler(this); | 896   SignalSender::RemoveActiveSampler(this); | 
| 902   SetActive(false); | 897   SetActive(false); | 
| 903 } | 898 } | 
| 904 | 899 | 
| 905 | 900 | 
| 906 } }  // namespace v8::internal | 901 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|