From 719fe8c310f5aa42bbdb7d7cf0c39175db08ed92 Mon Sep 17 00:00:00 2001 From: "yurys@chromium.org" Date: Thu, 11 Apr 2013 14:22:04 +0000 Subject: [PATCH] Fix cctest/test-cpu-profiler/CollectCpuProfile test on Arm and MIPS simulators Signal handler on simulator now retrieve registers from the simulator not from the host machine. BUG=v8:2621 Review URL: https://codereview.chromium.org/13845014 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14235 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/isolate.cc | 6 ++++++ src/isolate.h | 4 ++++ src/platform-cygwin.cc | 38 +++++++++++++++++++++++++++++----- src/platform-freebsd.cc | 33 ++++++++++++++++++++++++++++-- src/platform-linux.cc | 51 ++++++++++++++++++++++++++++++++++++---------- src/platform-macos.cc | 30 ++++++++++++++++++++++++++- src/platform-openbsd.cc | 52 +++++++++++++++++++++++++++++++++++++---------- src/platform-solaris.cc | 51 +++++++++++++++++++++++++++++++++++++--------- src/platform-win32.cc | 38 +++++++++++++++++++++++++++++----- test/cctest/cctest.status | 9 -------- 10 files changed, 258 insertions(+), 54 deletions(-) diff --git a/src/isolate.cc b/src/isolate.cc index 537828c..cd6ee47 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -371,6 +371,12 @@ Isolate::PerIsolateThreadData* Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThisThread() { ThreadId thread_id = ThreadId::Current(); + return FindPerThreadDataForThread(thread_id); +} + + +Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread( + ThreadId thread_id) { PerIsolateThreadData* per_thread = NULL; { ScopedLock lock(process_wide_mutex_); diff --git a/src/isolate.h b/src/isolate.h index 0c60cde..078dc50 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -497,6 +497,10 @@ class Isolate { // If one does not yet exist, return null. PerIsolateThreadData* FindPerThreadDataForThisThread(); + // Find the PerThread for given (isolate, thread) combination + // If one does not yet exist, return null. + PerIsolateThreadData* FindPerThreadDataForThread(ThreadId thread_id); + #ifdef ENABLE_DEBUGGER_SUPPORT // Get the debugger from the default isolate. Preinitializes the // default isolate if needed. diff --git a/src/platform-cygwin.cc b/src/platform-cygwin.cc index 9b345dc..042b2e5 100644 --- a/src/platform-cygwin.cc +++ b/src/platform-cygwin.cc @@ -43,6 +43,7 @@ #include "platform-posix.h" #include "platform.h" +#include "simulator.h" #include "v8threads.h" #include "vm-state-inl.h" #include "win32-headers.h" @@ -604,11 +605,13 @@ class Sampler::PlatformData : public Malloced { // going to use it in the sampler thread. Using GetThreadHandle() will // not work in this case. We're using OpenThread because DuplicateHandle // for some reason doesn't work in Chrome's sandbox. - PlatformData() : profiled_thread_(OpenThread(THREAD_GET_CONTEXT | - THREAD_SUSPEND_RESUME | - THREAD_QUERY_INFORMATION, - false, - GetCurrentThreadId())) {} + PlatformData() + : profiled_thread_(OpenThread(THREAD_GET_CONTEXT | + THREAD_SUSPEND_RESUME | + THREAD_QUERY_INFORMATION, + false, + GetCurrentThreadId())), + profiled_thread_id_(ThreadId::Current()) {} ~PlatformData() { if (profiled_thread_ != NULL) { @@ -618,9 +621,11 @@ class Sampler::PlatformData : public Malloced { } HANDLE profiled_thread() { return profiled_thread_; } + ThreadId profiled_thread_id() { return profiled_thread_id_; } private: HANDLE profiled_thread_; + ThreadId profiled_thread_id_; }; @@ -687,6 +692,17 @@ class SamplerThread : public Thread { memset(&context, 0, sizeof(context)); Isolate* isolate = sampler->isolate(); +#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; @@ -697,6 +713,17 @@ class SamplerThread : public Thread { context.ContextFlags = CONTEXT_FULL; if (GetThreadContext(profiled_thread, &context) != 0) { +#if defined(USE_SIMULATOR) +#if V8_TARGET_ARCH_ARM + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::r11)); +#elif V8_TARGET_ARCH_MIPS + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::fp)); +#endif +#else #if V8_HOST_ARCH_X64 sample->pc = reinterpret_cast
(context.Rip); sample->sp = reinterpret_cast
(context.Rsp); @@ -706,6 +733,7 @@ class SamplerThread : public Thread { sample->sp = reinterpret_cast
(context.Esp); sample->fp = reinterpret_cast
(context.Ebp); #endif +#endif // USE_SIMULATOR sampler->SampleStack(sample); sampler->Tick(sample); } diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc index 57d49b6..baab471 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(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
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::r11)); +#elif V8_TARGET_ARCH_MIPS + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::fp)); +#endif +#else #if V8_HOST_ARCH_IA32 sample->pc = reinterpret_cast
(mcontext.mc_eip); sample->sp = reinterpret_cast
(mcontext.mc_esp); @@ -735,7 +763,8 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { sample->pc = reinterpret_cast
(mcontext.mc_r15); sample->sp = reinterpret_cast
(mcontext.mc_r13); sample->fp = reinterpret_cast
(mcontext.mc_r11); -#endif +#endif // V8_HOST_ARCH_* +#endif // USE_SIMULATOR sampler->SampleStack(sample); sampler->Tick(sample); } diff --git a/src/platform-linux.cc b/src/platform-linux.cc index 398e954..af47d05 100644 --- a/src/platform-linux.cc +++ b/src/platform-linux.cc @@ -68,6 +68,7 @@ #include "platform-posix.h" #include "platform.h" +#include "simulator.h" #include "v8threads.h" #include "vm-state-inl.h" @@ -1076,6 +1077,21 @@ static int GetThreadID() { } +class Sampler::PlatformData : public Malloced { + public: + 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_; +}; + + static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { #if defined(__native_client__) // As Native Client does not support signal handling, profiling @@ -1097,10 +1113,33 @@ 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; +#if defined(USE_SIMULATOR) +#if V8_TARGET_ARCH_ARM + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::r11)); +#elif V8_TARGET_ARCH_MIPS + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::fp)); +#endif +#else // Extracting the sample from the context is extremely machine dependent. ucontext_t* ucontext = reinterpret_cast(context); mcontext_t& mcontext = ucontext->uc_mcontext; @@ -1132,23 +1171,13 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { sample->sp = reinterpret_cast
(mcontext.gregs[29]); sample->fp = reinterpret_cast
(mcontext.gregs[30]); #endif // V8_HOST_ARCH_* +#endif // USE_SIMULATOR sampler->SampleStack(sample); sampler->Tick(sample); #endif // __native_client__ } -class Sampler::PlatformData : public Malloced { - public: - PlatformData() : vm_tid_(GetThreadID()) {} - - int vm_tid() const { return vm_tid_; } - - private: - const int vm_tid_; -}; - - class SignalSender : public Thread { public: static const int kSignalSenderStackSize = 64 * KB; diff --git a/src/platform-macos.cc b/src/platform-macos.cc index 5582d58..898c93f 100644 --- a/src/platform-macos.cc +++ b/src/platform-macos.cc @@ -60,6 +60,7 @@ #include "platform-posix.h" #include "platform.h" +#include "simulator.h" #include "vm-state-inl.h" // Manually define these here as weak imports, rather than including execinfo.h. @@ -744,7 +745,9 @@ Semaphore* OS::CreateSemaphore(int count) { class Sampler::PlatformData : public Malloced { public: - PlatformData() : profiled_thread_(mach_thread_self()) {} + PlatformData() + : profiled_thread_(mach_thread_self()), + profiled_thread_id_(ThreadId::Current()) {} ~PlatformData() { // Deallocate Mach port for thread. @@ -752,12 +755,14 @@ class Sampler::PlatformData : public Malloced { } thread_act_t profiled_thread() { return profiled_thread_; } + ThreadId profiled_thread_id() { return profiled_thread_id_; } private: // Note: for profiled_thread_ Mach primitives are used instead of PThread's // because the latter doesn't provide thread manipulation primitives required. // For details, consult "Mac OS X Internals" book, Section 7.3. thread_act_t profiled_thread_; + ThreadId profiled_thread_id_; }; @@ -818,6 +823,17 @@ class SamplerThread : public Thread { void SampleContext(Sampler* sampler) { thread_act_t profiled_thread = sampler->platform_data()->profiled_thread(); Isolate* isolate = sampler->isolate(); +#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; @@ -851,9 +867,21 @@ class SamplerThread : public Thread { reinterpret_cast(&state), &count) == KERN_SUCCESS) { sample->state = isolate->current_vm_state(); +#if defined(USE_SIMULATOR) +#if V8_TARGET_ARCH_ARM + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::r11)); +#elif V8_TARGET_ARCH_MIPS + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::fp)); +#endif +#else sample->pc = reinterpret_cast
(state.REGISTER_FIELD(ip)); sample->sp = reinterpret_cast
(state.REGISTER_FIELD(sp)); sample->fp = reinterpret_cast
(state.REGISTER_FIELD(bp)); +#endif // USE_SIMULATOR sampler->SampleStack(sample); sampler->Tick(sample); } diff --git a/src/platform-openbsd.cc b/src/platform-openbsd.cc index a53e307..aca03be 100644 --- a/src/platform-openbsd.cc +++ b/src/platform-openbsd.cc @@ -53,6 +53,7 @@ #include "platform-posix.h" #include "platform.h" +#include "simulator.h" #include "v8threads.h" #include "vm-state-inl.h" @@ -732,6 +733,22 @@ static pthread_t GetThreadID() { return pthread_self(); } + +class Sampler::PlatformData : public Malloced { + public: + 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_; +}; + + static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { USE(info); if (signal != SIGPROF) return; @@ -748,6 +765,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; @@ -755,6 +784,17 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { // Extracting the sample from the context is extremely machine dependent. sample->state = isolate->current_vm_state(); ucontext_t* ucontext = reinterpret_cast(context); +#if defined(USE_SIMULATOR) +#if V8_TARGET_ARCH_ARM + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::r11)); +#elif V8_TARGET_ARCH_MIPS + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::fp)); +#endif +#else #ifdef __NetBSD__ mcontext_t& mcontext = ucontext->uc_mcontext; #if V8_HOST_ARCH_IA32 @@ -777,22 +817,12 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { sample->fp = reinterpret_cast
(ucontext->sc_rbp); #endif // V8_HOST_ARCH #endif // __NetBSD__ +#endif // USE_SIMULATOR sampler->SampleStack(sample); sampler->Tick(sample); } -class Sampler::PlatformData : public Malloced { - public: - PlatformData() : vm_tid_(GetThreadID()) {} - - pthread_t vm_tid() const { return vm_tid_; } - - private: - pthread_t vm_tid_; -}; - - class SignalSender : public Thread { public: static const int kSignalSenderStackSize = 64 * KB; diff --git a/src/platform-solaris.cc b/src/platform-solaris.cc index 6e02a25..392e73a 100644 --- a/src/platform-solaris.cc +++ b/src/platform-solaris.cc @@ -54,6 +54,7 @@ #include "platform-posix.h" #include "platform.h" +#include "simulator.h" #include "v8threads.h" #include "vm-state-inl.h" @@ -666,6 +667,22 @@ static pthread_t GetThreadID() { return pthread_self(); } + +class Sampler::PlatformData : public Malloced { + public: + 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_; +}; + + static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { USE(info); if (signal != SIGPROF) return; @@ -686,29 +703,43 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); if (sample == NULL) sample = &sample_obj; +#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 + // Extracting the sample from the context is extremely machine dependent. ucontext_t* ucontext = reinterpret_cast(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
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::r11)); +#elif V8_TARGET_ARCH_MIPS + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::fp)); +#endif +#else sample->pc = reinterpret_cast
(mcontext.gregs[REG_PC]); sample->sp = reinterpret_cast
(mcontext.gregs[REG_SP]); sample->fp = reinterpret_cast
(mcontext.gregs[REG_FP]); +#endif // USE_SIMULATOR sampler->SampleStack(sample); sampler->Tick(sample); } -class Sampler::PlatformData : public Malloced { - public: - PlatformData() : vm_tid_(GetThreadID()) {} - - pthread_t vm_tid() const { return vm_tid_; } - - private: - pthread_t vm_tid_; -}; - class SignalSender : public Thread { public: diff --git a/src/platform-win32.cc b/src/platform-win32.cc index eae6394..da2b741 100644 --- a/src/platform-win32.cc +++ b/src/platform-win32.cc @@ -45,6 +45,7 @@ #include "codegen.h" #include "platform.h" +#include "simulator.h" #include "vm-state-inl.h" #ifdef _MSC_VER @@ -1981,11 +1982,13 @@ class Sampler::PlatformData : public Malloced { // going to use it in the sampler thread. Using GetThreadHandle() will // not work in this case. We're using OpenThread because DuplicateHandle // for some reason doesn't work in Chrome's sandbox. - PlatformData() : profiled_thread_(OpenThread(THREAD_GET_CONTEXT | - THREAD_SUSPEND_RESUME | - THREAD_QUERY_INFORMATION, - false, - GetCurrentThreadId())) {} + PlatformData() + : profiled_thread_(OpenThread(THREAD_GET_CONTEXT | + THREAD_SUSPEND_RESUME | + THREAD_QUERY_INFORMATION, + false, + GetCurrentThreadId())), + profiled_thread_id_(ThreadId::Current()) {} ~PlatformData() { if (profiled_thread_ != NULL) { @@ -1995,9 +1998,11 @@ class Sampler::PlatformData : public Malloced { } HANDLE profiled_thread() { return profiled_thread_; } + ThreadId profiled_thread_id() { return profiled_thread_id_; } private: HANDLE profiled_thread_; + ThreadId profiled_thread_id_; }; @@ -2064,6 +2069,17 @@ class SamplerThread : public Thread { memset(&context, 0, sizeof(context)); Isolate* isolate = sampler->isolate(); +#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; @@ -2074,6 +2090,17 @@ class SamplerThread : public Thread { context.ContextFlags = CONTEXT_FULL; if (GetThreadContext(profiled_thread, &context) != 0) { +#if defined(USE_SIMULATOR) +#if V8_TARGET_ARCH_ARM + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::r11)); +#elif V8_TARGET_ARCH_MIPS + sample->pc = reinterpret_cast
(sim->get_register(Simulator::pc)); + sample->sp = reinterpret_cast
(sim->get_register(Simulator::sp)); + sample->fp = reinterpret_cast
(sim->get_register(Simulator::fp)); +#endif +#else #if V8_HOST_ARCH_X64 sample->pc = reinterpret_cast
(context.Rip); sample->sp = reinterpret_cast
(context.Rsp); @@ -2083,6 +2110,7 @@ class SamplerThread : public Thread { sample->sp = reinterpret_cast
(context.Esp); sample->fp = reinterpret_cast
(context.Ebp); #endif +#endif // USE_SIMULATOR sampler->SampleStack(sample); sampler->Tick(sample); } diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status index 00941c2..616f712 100644 --- a/test/cctest/cctest.status +++ b/test/cctest/cctest.status @@ -77,9 +77,6 @@ test-serialize/DeserializeFromSecondSerializationAndRunScript2: SKIP test-serialize/DeserializeAndRunScript2: SKIP test-serialize/DeserializeFromSecondSerialization: SKIP -# BUG(2621): Stack traversal doesn't work properly on Arm simulator. -test-cpu-profiler/CollectCpuProfile: SKIP - ############################################################################## [ $arch == android_arm || $arch == android_ia32 ] @@ -106,9 +103,3 @@ test-log/ProfLazyMode: SKIP test-debug/DebuggerAgent: SKIP test-debug/DebuggerAgentProtocolOverflowHeader: SKIP test-sockets/Socket: SKIP - -############################################################################## -[ $arch == mipsel ] - -# BUG(2621): Stack traversal doesn't work properly on MIPS simulator. -test-cpu-profiler/CollectCpuProfile: SKIP -- 2.7.4