| Index: src/sampler.cc
|
| diff --git a/src/sampler.cc b/src/sampler.cc
|
| index d72ed1acdb832e224c490b736954bf6d908ebb88..d10a5392204214ba6317d8a6b2a494922ef89458 100644
|
| --- a/src/sampler.cc
|
| +++ b/src/sampler.cc
|
| @@ -27,9 +27,11 @@
|
|
|
| #include "sampler.h"
|
|
|
| -#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) \
|
| - || defined(__NetBSD__) || defined(__sun) || defined(__ANDROID__) \
|
| - || defined(__native_client__)
|
| +#if V8_OS_DARWIN
|
| +
|
| +#include <mach/mach.h>
|
| +
|
| +#elif V8_OS_UNIX && !V8_OS_CYGWIN
|
|
|
| #define USE_SIGNALS
|
|
|
| @@ -38,23 +40,19 @@
|
| #include <signal.h>
|
| #include <sys/time.h>
|
| #include <sys/syscall.h>
|
| -#if !defined(__ANDROID__) || defined(__BIONIC_HAVE_UCONTEXT_T)
|
| +#if !V8_OS_ANDROID || defined(__BIONIC_HAVE_UCONTEXT_T)
|
| #include <ucontext.h>
|
| #endif
|
| #include <unistd.h>
|
|
|
| // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
|
| // Old versions of the C library <signal.h> didn't define the type.
|
| -#if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
|
| - defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
|
| +#if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
|
| + V8_HOST_ARCH_ARM && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
|
| #include <asm/sigcontext.h>
|
| #endif
|
|
|
| -#elif defined(__MACH__)
|
| -
|
| -#include <mach/mach.h>
|
| -
|
| -#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
|
| +#elif V8_OS_CYGWIN || V8_OS_WIN32
|
|
|
| #include "win32-headers.h"
|
|
|
| @@ -72,7 +70,7 @@
|
| #include "vm-state-inl.h"
|
|
|
|
|
| -#if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T)
|
| +#if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T)
|
|
|
| // Not all versions of Android's C library provide ucontext_t.
|
| // Detect this and provide custom but compatible definitions. Note that these
|
| @@ -81,7 +79,7 @@
|
| //
|
| // See http://code.google.com/p/android/issues/detail?id=34784
|
|
|
| -#if defined(__arm__)
|
| +#if V8_HOST_ARCH_ARM
|
|
|
| typedef struct sigcontext mcontext_t;
|
|
|
| @@ -93,7 +91,7 @@ typedef struct ucontext {
|
| // Other fields are not used by V8, don't define them here.
|
| } ucontext_t;
|
|
|
| -#elif defined(__mips__)
|
| +#elif V8_HOST_ARCH_MIPS
|
| // MIPS version of sigcontext, for Android bionic.
|
| typedef struct {
|
| uint32_t regmask;
|
| @@ -124,7 +122,7 @@ typedef struct ucontext {
|
| // Other fields are not used by V8, don't define them here.
|
| } ucontext_t;
|
|
|
| -#elif defined(__i386__)
|
| +#elif V8_HOST_ARCH_IA32
|
| // x86 version for Android.
|
| typedef struct {
|
| uint32_t gregs[19];
|
| @@ -144,7 +142,7 @@ typedef struct ucontext {
|
| enum { REG_EBP = 6, REG_ESP = 7, REG_EIP = 14 };
|
| #endif
|
|
|
| -#endif // __ANDROID__ && !defined(__BIONIC_HAVE_UCONTEXT_T)
|
| +#endif // V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T)
|
|
|
|
|
| namespace v8 {
|
| @@ -177,7 +175,7 @@ class Sampler::PlatformData : public PlatformDataCommon {
|
| pthread_t vm_tid_;
|
| };
|
|
|
| -#elif defined(__MACH__)
|
| +#elif V8_OS_DARWIN
|
|
|
| class Sampler::PlatformData : public PlatformDataCommon {
|
| public:
|
| @@ -197,7 +195,7 @@ class Sampler::PlatformData : public PlatformDataCommon {
|
| thread_act_t profiled_thread_;
|
| };
|
|
|
| -#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
|
| +#elif V8_OS_CYGWIN || V8_OS_WIN32
|
|
|
| // ----------------------------------------------------------------------------
|
| // Win32 profiler support. On Cygwin we use the same sampler implementation as
|
| @@ -301,7 +299,7 @@ bool SignalHandler::signal_handler_installed_ = false;
|
|
|
| void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
|
| void* context) {
|
| -#if defined(__native_client__)
|
| +#if V8_OS_NACL
|
| // As Native Client does not support signal handling, profiling
|
| // is disabled.
|
| return;
|
| @@ -331,7 +329,7 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
|
| // Extracting the sample from the context is extremely machine dependent.
|
| ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
|
| mcontext_t& mcontext = ucontext->uc_mcontext;
|
| -#if defined(__linux__) || defined(__ANDROID__)
|
| +#if V8_OS_LINUX
|
| #if V8_HOST_ARCH_IA32
|
| state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]);
|
| state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]);
|
| @@ -359,7 +357,7 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
|
| state.sp = reinterpret_cast<Address>(mcontext.gregs[29]);
|
| state.fp = reinterpret_cast<Address>(mcontext.gregs[30]);
|
| #endif // V8_HOST_ARCH_*
|
| -#elif defined(__FreeBSD__)
|
| +#elif V8_OS_FREEBSD
|
| #if V8_HOST_ARCH_IA32
|
| state.pc = reinterpret_cast<Address>(mcontext.mc_eip);
|
| state.sp = reinterpret_cast<Address>(mcontext.mc_esp);
|
| @@ -373,7 +371,7 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
|
| state.sp = reinterpret_cast<Address>(mcontext.mc_r13);
|
| state.fp = reinterpret_cast<Address>(mcontext.mc_r11);
|
| #endif // V8_HOST_ARCH_*
|
| -#elif defined(__NetBSD__)
|
| +#elif V8_OS_NETBSD
|
| #if V8_HOST_ARCH_IA32
|
| state.pc = reinterpret_cast<Address>(mcontext.__gregs[_REG_EIP]);
|
| state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_ESP]);
|
| @@ -383,7 +381,7 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
|
| state.sp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RSP]);
|
| state.fp = reinterpret_cast<Address>(mcontext.__gregs[_REG_RBP]);
|
| #endif // V8_HOST_ARCH_*
|
| -#elif defined(__OpenBSD__)
|
| +#elif V8_OS_OPENBSD
|
| USE(mcontext);
|
| #if V8_HOST_ARCH_IA32
|
| state.pc = reinterpret_cast<Address>(ucontext->sc_eip);
|
| @@ -394,11 +392,11 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info,
|
| state.sp = reinterpret_cast<Address>(ucontext->sc_rsp);
|
| state.fp = reinterpret_cast<Address>(ucontext->sc_rbp);
|
| #endif // V8_HOST_ARCH_*
|
| -#elif defined(__sun)
|
| +#elif V8_OS_SOLARIS
|
| state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]);
|
| state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]);
|
| state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]);
|
| -#endif // __sun
|
| +#endif // V8_OS_SOLARIS
|
| #endif // USE_SIMULATOR
|
| sampler->SampleStack(state);
|
| #endif // __native_client__
|
| @@ -493,7 +491,7 @@ class SamplerThread : public Thread {
|
| pthread_kill(tid, SIGPROF);
|
| }
|
|
|
| -#elif defined(__MACH__)
|
| +#elif V8_OS_DARWIN
|
|
|
| void SampleContext(Sampler* sampler) {
|
| thread_act_t profiled_thread = sampler->platform_data()->profiled_thread();
|
| @@ -546,7 +544,7 @@ class SamplerThread : public Thread {
|
| thread_resume(profiled_thread);
|
| }
|
|
|
| -#elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
|
| +#elif V8_OS_CYGWIN || V8_OS_WIN32
|
|
|
| void SampleContext(Sampler* sampler) {
|
| HANDLE profiled_thread = sampler->platform_data()->profiled_thread();
|
|
|