From d3eeaf1757f925c7b5228f4cbfd782dc351b8380 Mon Sep 17 00:00:00 2001 From: "whesse@chromium.org" Date: Thu, 6 Aug 2009 15:47:58 +0000 Subject: [PATCH] X64: Implement tickprocessor sampling on 64-bit MacOS. This issue on codereview has been accidentally reused from an earlier issue by a process mistake. Review URL: http://codereview.chromium.org/151004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2640 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/platform-macos.cc | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/platform-macos.cc b/src/platform-macos.cc index 445f588d67..c0ecdac0ec 100644 --- a/src/platform-macos.cc +++ b/src/platform-macos.cc @@ -515,35 +515,31 @@ class Sampler::PlatformData : public Malloced { thread_state_flavor_t flavor = x86_THREAD_STATE64; x86_thread_state64_t state; mach_msg_type_number_t count = x86_THREAD_STATE64_COUNT; +#if __DARWIN_UNIX03 +#define REGISTER_FIELD(name) __r ## name +#else +#define REGISTER_FIELD(name) r ## name +#endif // __DARWIN_UNIX03 #elif V8_HOST_ARCH_IA32 thread_state_flavor_t flavor = i386_THREAD_STATE; i386_thread_state_t state; mach_msg_type_number_t count = i386_THREAD_STATE_COUNT; +#if __DARWIN_UNIX03 +#define REGISTER_FIELD(name) __e ## name +#else +#define REGISTER_FIELD(name) e ## name +#endif // __DARWIN_UNIX03 #else #error Unsupported Mac OS X host architecture. -#endif // V8_TARGET_ARCH_IA32 +#endif // V8_HOST_ARCH + if (thread_get_state(profiled_thread_, flavor, reinterpret_cast(&state), &count) == KERN_SUCCESS) { -#if V8_HOST_ARCH_X64 - UNIMPLEMENTED(); - sample.pc = 0; - sample.sp = 0; - sample.fp = 0; -#elif V8_HOST_ARCH_IA32 -#if __DARWIN_UNIX03 - sample.pc = state.__eip; - sample.sp = state.__esp; - sample.fp = state.__ebp; -#else // !__DARWIN_UNIX03 - sample.pc = state.eip; - sample.sp = state.esp; - sample.fp = state.ebp; -#endif // __DARWIN_UNIX03 -#else -#error Unsupported Mac OS X host architecture. -#endif // V8_HOST_ARCH_IA32 + sample.pc = state.REGISTER_FIELD(ip); + sample.sp = state.REGISTER_FIELD(sp); + sample.fp = state.REGISTER_FIELD(bp); sampler_->SampleStack(&sample); } thread_resume(profiled_thread_); @@ -560,6 +556,8 @@ class Sampler::PlatformData : public Malloced { } }; +#undef REGISTER_FIELD + // Entry point for sampler thread. static void* SamplerEntry(void* arg) {