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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 } | 731 } |
732 if (v8::Locker::IsActive() && | 732 if (v8::Locker::IsActive() && |
733 !isolate->thread_manager()->IsLockedByCurrentThread()) { | 733 !isolate->thread_manager()->IsLockedByCurrentThread()) { |
734 return; | 734 return; |
735 } | 735 } |
736 | 736 |
737 Sampler* sampler = isolate->logger()->sampler(); | 737 Sampler* sampler = isolate->logger()->sampler(); |
738 if (sampler == NULL || !sampler->IsActive()) return; | 738 if (sampler == NULL || !sampler->IsActive()) return; |
739 | 739 |
740 TickSample sample_obj; | 740 TickSample sample_obj; |
741 TickSample* sample = CpuProfiler::StartTickSampleEvent(isolate); | 741 TickSample* sample = CpuProfiler::TickSampleEvent(isolate); |
742 if (sample == NULL) sample = &sample_obj; | 742 if (sample == NULL) sample = &sample_obj; |
743 | 743 |
744 // Extracting the sample from the context is extremely machine dependent. | 744 // Extracting the sample from the context is extremely machine dependent. |
745 sample->state = isolate->current_vm_state(); | 745 sample->state = isolate->current_vm_state(); |
746 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 746 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
747 #ifdef __NetBSD__ | 747 #ifdef __NetBSD__ |
748 mcontext_t& mcontext = ucontext->uc_mcontext; | 748 mcontext_t& mcontext = ucontext->uc_mcontext; |
749 #if V8_HOST_ARCH_IA32 | 749 #if V8_HOST_ARCH_IA32 |
750 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]); | 750 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]); |
751 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]); | 751 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]); |
752 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_EBP]); | 752 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_EBP]); |
753 #elif V8_HOST_ARCH_X64 | 753 #elif V8_HOST_ARCH_X64 |
754 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_RIP]); | 754 sample->pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_RIP]); |
755 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]); | 755 sample->sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]); |
756 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]); | 756 sample->fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]); |
757 #endif // V8_HOST_ARCH | 757 #endif // V8_HOST_ARCH |
758 #else // OpenBSD | 758 #else // OpenBSD |
759 #if V8_HOST_ARCH_IA32 | 759 #if V8_HOST_ARCH_IA32 |
760 sample->pc = reinterpret_cast<Address>(ucontext->sc_eip); | 760 sample->pc = reinterpret_cast<Address>(ucontext->sc_eip); |
761 sample->sp = reinterpret_cast<Address>(ucontext->sc_esp); | 761 sample->sp = reinterpret_cast<Address>(ucontext->sc_esp); |
762 sample->fp = reinterpret_cast<Address>(ucontext->sc_ebp); | 762 sample->fp = reinterpret_cast<Address>(ucontext->sc_ebp); |
763 #elif V8_HOST_ARCH_X64 | 763 #elif V8_HOST_ARCH_X64 |
764 sample->pc = reinterpret_cast<Address>(ucontext->sc_rip); | 764 sample->pc = reinterpret_cast<Address>(ucontext->sc_rip); |
765 sample->sp = reinterpret_cast<Address>(ucontext->sc_rsp); | 765 sample->sp = reinterpret_cast<Address>(ucontext->sc_rsp); |
766 sample->fp = reinterpret_cast<Address>(ucontext->sc_rbp); | 766 sample->fp = reinterpret_cast<Address>(ucontext->sc_rbp); |
767 #endif // V8_HOST_ARCH | 767 #endif // V8_HOST_ARCH |
768 #endif // __NetBSD__ | 768 #endif // __NetBSD__ |
769 sampler->SampleStack(sample); | 769 sampler->SampleStack(sample); |
770 sampler->Tick(sample); | 770 sampler->Tick(sample); |
771 CpuProfiler::FinishTickSampleEvent(isolate); | |
772 } | 771 } |
773 | 772 |
774 | 773 |
775 class Sampler::PlatformData : public Malloced { | 774 class Sampler::PlatformData : public Malloced { |
776 public: | 775 public: |
777 PlatformData() : vm_tid_(GetThreadID()) {} | 776 PlatformData() : vm_tid_(GetThreadID()) {} |
778 | 777 |
779 pthread_t vm_tid() const { return vm_tid_; } | 778 pthread_t vm_tid() const { return vm_tid_; } |
780 | 779 |
781 private: | 780 private: |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 data_ = new PlatformData; | 963 data_ = new PlatformData; |
965 } | 964 } |
966 | 965 |
967 | 966 |
968 Sampler::~Sampler() { | 967 Sampler::~Sampler() { |
969 ASSERT(!IsActive()); | 968 ASSERT(!IsActive()); |
970 delete data_; | 969 delete data_; |
971 } | 970 } |
972 | 971 |
973 | 972 |
974 void Sampler::DoSample() { | |
975 // TODO(rogulenko): implement | |
976 } | |
977 | |
978 | |
979 void Sampler::Start() { | 973 void Sampler::Start() { |
980 ASSERT(!IsActive()); | 974 ASSERT(!IsActive()); |
981 SetActive(true); | 975 SetActive(true); |
982 SignalSender::AddActiveSampler(this); | 976 SignalSender::AddActiveSampler(this); |
983 } | 977 } |
984 | 978 |
985 | 979 |
986 void Sampler::Stop() { | 980 void Sampler::Stop() { |
987 ASSERT(IsActive()); | 981 ASSERT(IsActive()); |
988 SignalSender::RemoveActiveSampler(this); | 982 SignalSender::RemoveActiveSampler(this); |
989 SetActive(false); | 983 SetActive(false); |
990 } | 984 } |
991 | 985 |
992 | 986 |
993 void Sampler::StartSampling() { | |
994 } | |
995 | |
996 | |
997 void Sampler::StopSampling() { | |
998 } | |
999 | |
1000 | |
1001 } } // namespace v8::internal | 987 } } // namespace v8::internal |
OLD | NEW |