Ignore:
Timestamp:
02/16/12 23:10:12 (3 years ago)
Author:
yuqiang.xian@intel.com
Message:

Add JSC code profiling support on Linux x86
https://bugs.webkit.org/show_bug.cgi?id=78871

Reviewed by Gavin Barraclough.

We don't unwind the stack for now as we cannot guarantee all the
libraries are compiled without -fomit-frame-pointer.

  • tools/CodeProfile.cpp:

(JSC::CodeProfile::sample):

  • tools/CodeProfiling.cpp:

(JSC):
(JSC::profilingTimer):
(JSC::CodeProfiling::begin):
(JSC::CodeProfiling::end):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/tools/CodeProfiling.cpp

    r106796 r108037  
    3434#endif 
    3535 
     36#if OS(LINUX) 
     37#include <sys/time.h> 
     38#endif 
     39 
    3640namespace JSC { 
    3741 
     
    4549#endif 
    4650 
    47 #if PLATFORM(MAC) && CPU(X86_64) 
     51#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86)) 
    4852// Helper function to start & stop the timer. 
    4953// Presently we're using the wall-clock timer, since this seems to give the best results. 
     
    6973    CodeProfiling::sample(reinterpret_cast<void*>(context->__ss.__rip), 
    7074                          reinterpret_cast<void**>(context->__ss.__rbp)); 
     75} 
     76#elif OS(LINUX) && CPU(X86) 
     77static void profilingTimer(int, siginfo_t*, void* uap) 
     78{ 
     79    mcontext_t context = static_cast<ucontext_t*>(uap)->uc_mcontext; 
     80    CodeProfiling::sample(reinterpret_cast<void*>(context.gregs[REG_EIP]), 
     81                          reinterpret_cast<void**>(context.gregs[REG_EBP])); 
    7182} 
    7283#endif 
     
    133144        return; 
    134145 
    135 #if PLATFORM(MAC) && CPU(X86_64) 
     146#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86)) 
    136147    // Regsiter a signal handler & itimer. 
    137148    struct sigaction action; 
    138     action.sa_sigaction = reinterpret_cast<void (*)(int, struct __siginfo *, void *)>(profilingTimer); 
     149    action.sa_sigaction = reinterpret_cast<void (*)(int, siginfo_t *, void *)>(profilingTimer); 
    139150    sigfillset(&action.sa_mask); 
    140151    action.sa_flags = SA_SIGINFO; 
     
    157168        return; 
    158169 
    159 #if PLATFORM(MAC) && CPU(X86_64) 
     170#if (PLATFORM(MAC) && CPU(X86_64)) || (OS(LINUX) && CPU(X86)) 
    160171    // Stop profiling 
    161172    setProfileTimer(0); 
Note: See TracChangeset for help on using the changeset viewer.