Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(929)

Unified Diff: src/platform-openbsd.cc

Issue 13845014: Fix cctest/test-cpu-profiler/CollectCpuProfile test on Arm and MIPS simulators (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updared OpenBSD Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform-macos.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-openbsd.cc
diff --git a/src/platform-openbsd.cc b/src/platform-openbsd.cc
index a53e30756d0ea4aae649c30972b18092381d3d63..aca03be3e5ac5197584f0614b8c089ae2a8e4a9b 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<ucontext_t*>(context);
+#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
#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<Address>(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;
« no previous file with comments | « src/platform-macos.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698