OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/sampler.h" | 5 #include "src/sampler.h" |
6 | 6 |
7 #if V8_OS_POSIX && !V8_OS_CYGWIN | 7 #if V8_OS_POSIX && !V8_OS_CYGWIN |
8 | 8 |
9 #define USE_SIGNALS | 9 #define USE_SIGNALS |
10 | 10 |
11 #include <errno.h> | 11 #include <errno.h> |
12 #include <pthread.h> | 12 #include <pthread.h> |
13 #include <signal.h> | 13 #include <signal.h> |
14 #include <sys/time.h> | 14 #include <sys/time.h> |
15 | 15 |
16 #if !V8_OS_QNX && !V8_OS_NACL | 16 #if !(V8_OS_QNX || V8_OS_AIX) && !V8_OS_NACL |
Sven Panne
2015/01/27 11:47:06
De Morgan's law, please. :-)
michael_dawson
2015/01/29 00:08:29
Will do
| |
17 #include <sys/syscall.h> // NOLINT | 17 #include <sys/syscall.h> // NOLINT |
18 #endif | 18 #endif |
19 | 19 |
20 #if V8_OS_MACOSX | 20 #if V8_OS_MACOSX |
21 #include <mach/mach.h> | 21 #include <mach/mach.h> |
22 // OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h> | 22 // OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h> |
23 // and is a typedef for struct sigcontext. There is no uc_mcontext. | 23 // and is a typedef for struct sigcontext. There is no uc_mcontext. |
24 #elif(!V8_OS_ANDROID || defined(__BIONIC_HAVE_UCONTEXT_T)) && \ | 24 #elif(!V8_OS_ANDROID || defined(__BIONIC_HAVE_UCONTEXT_T)) && \ |
25 !V8_OS_OPENBSD && !V8_OS_NACL | 25 !V8_OS_OPENBSD && !V8_OS_NACL |
26 #include <ucontext.h> | 26 #include <ucontext.h> |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 sa.sa_flags = SA_RESTART | SA_SIGINFO; | 304 sa.sa_flags = SA_RESTART | SA_SIGINFO; |
305 #endif | 305 #endif |
306 signal_handler_installed_ = | 306 signal_handler_installed_ = |
307 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); | 307 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); |
308 #endif | 308 #endif |
309 } | 309 } |
310 | 310 |
311 static void Restore() { | 311 static void Restore() { |
312 #if !V8_OS_NACL | 312 #if !V8_OS_NACL |
313 if (signal_handler_installed_) { | 313 if (signal_handler_installed_) { |
314 #if V8_OS_AIX | |
315 // Ensure delivery of any pending SIGPROF before removing the handler | |
Sven Panne
2015/01/27 11:47:06
Hmmm, why is this AIX-specific? Why can't there be
michael_dawson
2015/01/29 00:08:29
We went to validate our explanation of why it was
| |
316 base::Thread::YieldCPU(); | |
317 #endif | |
314 sigaction(SIGPROF, &old_signal_handler_, 0); | 318 sigaction(SIGPROF, &old_signal_handler_, 0); |
315 signal_handler_installed_ = false; | 319 signal_handler_installed_ = false; |
316 } | 320 } |
317 #endif | 321 #endif |
318 } | 322 } |
319 | 323 |
320 #if !V8_OS_NACL | 324 #if !V8_OS_NACL |
321 static void HandleProfilerSignal(int signal, siginfo_t* info, void* context); | 325 static void HandleProfilerSignal(int signal, siginfo_t* info, void* context); |
322 #endif | 326 #endif |
323 // Protects the process wide state below. | 327 // Protects the process wide state below. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 #elif V8_OS_QNX | 476 #elif V8_OS_QNX |
473 #if V8_HOST_ARCH_IA32 | 477 #if V8_HOST_ARCH_IA32 |
474 state.pc = reinterpret_cast<Address>(mcontext.cpu.eip); | 478 state.pc = reinterpret_cast<Address>(mcontext.cpu.eip); |
475 state.sp = reinterpret_cast<Address>(mcontext.cpu.esp); | 479 state.sp = reinterpret_cast<Address>(mcontext.cpu.esp); |
476 state.fp = reinterpret_cast<Address>(mcontext.cpu.ebp); | 480 state.fp = reinterpret_cast<Address>(mcontext.cpu.ebp); |
477 #elif V8_HOST_ARCH_ARM | 481 #elif V8_HOST_ARCH_ARM |
478 state.pc = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_PC]); | 482 state.pc = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_PC]); |
479 state.sp = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_SP]); | 483 state.sp = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_SP]); |
480 state.fp = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_FP]); | 484 state.fp = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_FP]); |
481 #endif // V8_HOST_ARCH_* | 485 #endif // V8_HOST_ARCH_* |
482 #endif // V8_OS_QNX | 486 #elif V8_OS_AIX |
487 state.pc = reinterpret_cast<Address>(mcontext.jmp_context.iar); | |
488 state.sp = reinterpret_cast<Address>(mcontext.jmp_context.gpr[1]); | |
489 state.fp = reinterpret_cast<Address>(mcontext.jmp_context.gpr[31]); | |
490 #endif // V8_OS_AIX | |
483 #endif // USE_SIMULATOR | 491 #endif // USE_SIMULATOR |
484 sampler->SampleStack(state); | 492 sampler->SampleStack(state); |
485 } | 493 } |
486 #endif // V8_OS_NACL | 494 #endif // V8_OS_NACL |
487 | 495 |
488 #endif | 496 #endif |
489 | 497 |
490 | 498 |
491 class SamplerThread : public base::Thread { | 499 class SamplerThread : public base::Thread { |
492 public: | 500 public: |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
765 #endif // USE_SIMULATOR | 773 #endif // USE_SIMULATOR |
766 SampleStack(state); | 774 SampleStack(state); |
767 } | 775 } |
768 ResumeThread(profiled_thread); | 776 ResumeThread(profiled_thread); |
769 } | 777 } |
770 | 778 |
771 #endif // USE_SIGNALS | 779 #endif // USE_SIGNALS |
772 | 780 |
773 | 781 |
774 } } // namespace v8::internal | 782 } } // namespace v8::internal |
OLD | NEW |