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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 #include <stdarg.h> | 49 #include <stdarg.h> |
50 #include <limits.h> | 50 #include <limits.h> |
51 | 51 |
52 #undef MAP_TYPE | 52 #undef MAP_TYPE |
53 | 53 |
54 #include "v8.h" | 54 #include "v8.h" |
55 #include "v8threads.h" | 55 #include "v8threads.h" |
56 | 56 |
57 #include "platform-posix.h" | 57 #include "platform-posix.h" |
58 #include "platform.h" | 58 #include "platform.h" |
59 #include "simulator.h" | |
59 #include "vm-state-inl.h" | 60 #include "vm-state-inl.h" |
60 | 61 |
61 | 62 |
62 namespace v8 { | 63 namespace v8 { |
63 namespace internal { | 64 namespace internal { |
64 | 65 |
65 // 0 is never a valid thread id on FreeBSD since tids and pids share a | 66 // 0 is never a valid thread id on FreeBSD since tids and pids share a |
66 // name space and pid 0 is used to kill the group (see man 2 kill). | 67 // name space and pid 0 is used to kill the group (see man 2 kill). |
67 static const pthread_t kNoThread = (pthread_t) 0; | 68 static const pthread_t kNoThread = (pthread_t) 0; |
68 | 69 |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
708 return; | 709 return; |
709 } | 710 } |
710 if (v8::Locker::IsActive() && | 711 if (v8::Locker::IsActive() && |
711 !isolate->thread_manager()->IsLockedByCurrentThread()) { | 712 !isolate->thread_manager()->IsLockedByCurrentThread()) { |
712 return; | 713 return; |
713 } | 714 } |
714 | 715 |
715 Sampler* sampler = isolate->logger()->sampler(); | 716 Sampler* sampler = isolate->logger()->sampler(); |
716 if (sampler == NULL || !sampler->IsActive()) return; | 717 if (sampler == NULL || !sampler->IsActive()) return; |
717 | 718 |
719 #if defined(USE_SIMULATOR) | |
720 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS | |
721 Isolate::PerIsolateThreadData* per_thread_data = | |
Sven Panne
2013/04/11 13:11:18
Can we stash the thread id into PlatformData on *n
yurys
2013/04/11 14:16:06
Done. Changed implementation on all platforms to u
| |
722 isolate->FindPerThreadDataForThisThread(); | |
723 if (!per_thread_data) return; | |
724 Simulator* sim = per_thread_data->simulator(); | |
725 // Check if there is active simulator before allocating TickSample. | |
726 if (!sim) return; | |
727 #endif | |
728 #endif // USE_SIMULATOR | |
729 | |
718 TickSample sample_obj; | 730 TickSample sample_obj; |
719 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); | 731 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); |
720 if (sample == NULL) sample = &sample_obj; | 732 if (sample == NULL) sample = &sample_obj; |
721 | 733 |
722 // Extracting the sample from the context is extremely machine dependent. | 734 // Extracting the sample from the context is extremely machine dependent. |
723 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 735 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
724 mcontext_t& mcontext = ucontext->uc_mcontext; | 736 mcontext_t& mcontext = ucontext->uc_mcontext; |
725 sample->state = isolate->current_vm_state(); | 737 sample->state = isolate->current_vm_state(); |
738 #if defined(USE_SIMULATOR) | |
739 #if V8_TARGET_ARCH_ARM | |
740 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); | |
741 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); | |
742 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11)); | |
743 #elif V8_TARGET_ARCH_MIPS | |
744 sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc)); | |
745 sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp)); | |
746 sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp)); | |
747 #endif | |
748 #else | |
726 #if V8_HOST_ARCH_IA32 | 749 #if V8_HOST_ARCH_IA32 |
727 sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); | 750 sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); |
728 sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); | 751 sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); |
729 sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); | 752 sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); |
730 #elif V8_HOST_ARCH_X64 | 753 #elif V8_HOST_ARCH_X64 |
731 sample->pc = reinterpret_cast<Address>(mcontext.mc_rip); | 754 sample->pc = reinterpret_cast<Address>(mcontext.mc_rip); |
732 sample->sp = reinterpret_cast<Address>(mcontext.mc_rsp); | 755 sample->sp = reinterpret_cast<Address>(mcontext.mc_rsp); |
733 sample->fp = reinterpret_cast<Address>(mcontext.mc_rbp); | 756 sample->fp = reinterpret_cast<Address>(mcontext.mc_rbp); |
734 #elif V8_HOST_ARCH_ARM | 757 #elif V8_HOST_ARCH_ARM |
735 sample->pc = reinterpret_cast<Address>(mcontext.mc_r15); | 758 sample->pc = reinterpret_cast<Address>(mcontext.mc_r15); |
736 sample->sp = reinterpret_cast<Address>(mcontext.mc_r13); | 759 sample->sp = reinterpret_cast<Address>(mcontext.mc_r13); |
737 sample->fp = reinterpret_cast<Address>(mcontext.mc_r11); | 760 sample->fp = reinterpret_cast<Address>(mcontext.mc_r11); |
738 #endif | 761 #endif // V8_HOST_ARCH_* |
762 #endif // USE_SIMULATOR | |
739 sampler->SampleStack(sample); | 763 sampler->SampleStack(sample); |
740 sampler->Tick(sample); | 764 sampler->Tick(sample); |
741 } | 765 } |
742 | 766 |
743 | 767 |
744 class SignalSender : public Thread { | 768 class SignalSender : public Thread { |
745 public: | 769 public: |
746 static const int kSignalSenderStackSize = 64 * KB; | 770 static const int kSignalSenderStackSize = 64 * KB; |
747 | 771 |
748 explicit SignalSender(int interval) | 772 explicit SignalSender(int interval) |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
891 | 915 |
892 | 916 |
893 void Sampler::Stop() { | 917 void Sampler::Stop() { |
894 ASSERT(IsActive()); | 918 ASSERT(IsActive()); |
895 SignalSender::RemoveActiveSampler(this); | 919 SignalSender::RemoveActiveSampler(this); |
896 SetActive(false); | 920 SetActive(false); |
897 } | 921 } |
898 | 922 |
899 | 923 |
900 } } // namespace v8::internal | 924 } } // namespace v8::internal |
OLD | NEW |