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

Unified Diff: src/platform-macos.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-linux.cc ('k') | src/platform-openbsd.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-macos.cc
diff --git a/src/platform-macos.cc b/src/platform-macos.cc
index 5582d58ab647161af6f7e6a531493dcb6df273e2..898c93f39a346003ae53724cc290df362c12d5ed 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<natural_t*>(&state),
&count) == KERN_SUCCESS) {
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
sample->pc = reinterpret_cast<Address>(state.REGISTER_FIELD(ip));
sample->sp = reinterpret_cast<Address>(state.REGISTER_FIELD(sp));
sample->fp = reinterpret_cast<Address>(state.REGISTER_FIELD(bp));
+#endif // USE_SIMULATOR
sampler->SampleStack(sample);
sampler->Tick(sample);
}
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-openbsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698