| Index: src/platform-freebsd.cc
|
| diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc
|
| index 57d49b699aeb25dced614df62a2957b8c5111e01..baab4714b9d05bce55982e8722a8b52d6819883c 100644
|
| --- a/src/platform-freebsd.cc
|
| +++ b/src/platform-freebsd.cc
|
| @@ -56,6 +56,7 @@
|
|
|
| #include "platform-posix.h"
|
| #include "platform.h"
|
| +#include "simulator.h"
|
| #include "vm-state-inl.h"
|
|
|
|
|
| @@ -690,12 +691,16 @@ static pthread_t GetThreadID() {
|
|
|
| class Sampler::PlatformData : public Malloced {
|
| public:
|
| - PlatformData() : vm_tid_(GetThreadID()) {}
|
| + PlatformData()
|
| + : vm_tid_(GetThreadID()),
|
| + profiled_thread_id_(ThreadId::Current()) {}
|
|
|
| pthread_t vm_tid() const { return vm_tid_; }
|
| + ThreadId profiled_thread_id() { return profiled_thread_id_; }
|
|
|
| private:
|
| pthread_t vm_tid_;
|
| + ThreadId profiled_thread_id_;
|
| };
|
|
|
|
|
| @@ -715,6 +720,18 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
| Sampler* sampler = isolate->logger()->sampler();
|
| if (sampler == NULL || !sampler->IsActive()) return;
|
|
|
| +#if defined(USE_SIMULATOR)
|
| +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS
|
| + ThreadId thread_id = sampler->platform_data()->profiled_thread_id();
|
| + Isolate::PerIsolateThreadData* per_thread_data = isolate->
|
| + FindPerThreadDataForThread(thread_id);
|
| + if (!per_thread_data) return;
|
| + Simulator* sim = per_thread_data->simulator();
|
| + // Check if there is active simulator before allocating TickSample.
|
| + if (!sim) return;
|
| +#endif
|
| +#endif // USE_SIMULATOR
|
| +
|
| TickSample sample_obj;
|
| TickSample* sample = isolate->cpu_profiler()->TickSampleEvent();
|
| if (sample == NULL) sample = &sample_obj;
|
| @@ -723,6 +740,17 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
| ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
|
| mcontext_t& mcontext = ucontext->uc_mcontext;
|
| sample->state = isolate->current_vm_state();
|
| +#if defined(USE_SIMULATOR)
|
| +#if V8_TARGET_ARCH_ARM
|
| + sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc));
|
| + sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp));
|
| + sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::r11));
|
| +#elif V8_TARGET_ARCH_MIPS
|
| + sample->pc = reinterpret_cast<Address>(sim->get_register(Simulator::pc));
|
| + sample->sp = reinterpret_cast<Address>(sim->get_register(Simulator::sp));
|
| + sample->fp = reinterpret_cast<Address>(sim->get_register(Simulator::fp));
|
| +#endif
|
| +#else
|
| #if V8_HOST_ARCH_IA32
|
| sample->pc = reinterpret_cast<Address>(mcontext.mc_eip);
|
| sample->sp = reinterpret_cast<Address>(mcontext.mc_esp);
|
| @@ -735,7 +763,8 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) {
|
| sample->pc = reinterpret_cast<Address>(mcontext.mc_r15);
|
| sample->sp = reinterpret_cast<Address>(mcontext.mc_r13);
|
| sample->fp = reinterpret_cast<Address>(mcontext.mc_r11);
|
| -#endif
|
| +#endif // V8_HOST_ARCH_*
|
| +#endif // USE_SIMULATOR
|
| sampler->SampleStack(sample);
|
| sampler->Tick(sample);
|
| }
|
|
|