diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-24 16:36:50 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-24 16:36:50 +0100 |
commit | ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (patch) | |
tree | b34b0daceb7c8e7fdde4b4ec43650ab7caadb0a9 /Source/JavaScriptCore/tools/CodeProfiling.cpp | |
parent | 03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (diff) | |
download | qtwebkit-ad0d549d4cc13433f77c1ac8f0ab379c83d93f28.tar.gz |
Imported WebKit commit bb52bf3c0119e8a128cd93afe5572413a8617de9 (http://svn.webkit.org/repository/webkit/trunk@108790)
Diffstat (limited to 'Source/JavaScriptCore/tools/CodeProfiling.cpp')
-rw-r--r-- | Source/JavaScriptCore/tools/CodeProfiling.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Source/JavaScriptCore/tools/CodeProfiling.cpp b/Source/JavaScriptCore/tools/CodeProfiling.cpp index d927a49f6..f11603854 100644 --- a/Source/JavaScriptCore/tools/CodeProfiling.cpp +++ b/Source/JavaScriptCore/tools/CodeProfiling.cpp @@ -33,6 +33,10 @@ #include <signal.h> #endif +#if OS(LINUX) +#include <sys/time.h> +#endif + namespace JSC { volatile CodeProfile* CodeProfiling::s_profileStack = 0; @@ -44,7 +48,7 @@ WTF::MetaAllocatorTracker* CodeProfiling::s_tracker = 0; #pragma clang diagnostic ignored "-Wmissing-noreturn" #endif -#if PLATFORM(MAC) && CPU(X86_64) +#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86)) // Helper function to start & stop the timer. // Presently we're using the wall-clock timer, since this seems to give the best results. static void setProfileTimer(unsigned usec) @@ -69,6 +73,13 @@ static void profilingTimer(int, siginfo_t*, void* uap) CodeProfiling::sample(reinterpret_cast<void*>(context->__ss.__rip), reinterpret_cast<void**>(context->__ss.__rbp)); } +#elif OS(LINUX) && CPU(X86) +static void profilingTimer(int, siginfo_t*, void* uap) +{ + mcontext_t context = static_cast<ucontext_t*>(uap)->uc_mcontext; + CodeProfiling::sample(reinterpret_cast<void*>(context.gregs[REG_EIP]), + reinterpret_cast<void**>(context.gregs[REG_EBP])); +} #endif // Callback triggered when the timer is fired. @@ -132,10 +143,10 @@ void CodeProfiling::begin(const SourceCode& source) if (alreadyProfiling) return; -#if PLATFORM(MAC) && CPU(X86_64) +#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86)) // Regsiter a signal handler & itimer. struct sigaction action; - action.sa_sigaction = reinterpret_cast<void (*)(int, struct __siginfo *, void *)>(profilingTimer); + action.sa_sigaction = reinterpret_cast<void (*)(int, siginfo_t *, void *)>(profilingTimer); sigfillset(&action.sa_mask); action.sa_flags = SA_SIGINFO; sigaction(SIGALRM, &action, 0); @@ -156,7 +167,7 @@ void CodeProfiling::end() if (s_profileStack) return; -#if PLATFORM(MAC) && CPU(X86_64) +#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86)) // Stop profiling setProfileTimer(0); #endif |