Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1115)

Side by Side Diff: src/sampler.cc

Issue 61153009: Add support for the QNX operating system. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Address latest review comments Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/qnx-math.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 17 matching lines...) Expand all
28 #include "sampler.h" 28 #include "sampler.h"
29 29
30 #if V8_OS_POSIX && !V8_OS_CYGWIN 30 #if V8_OS_POSIX && !V8_OS_CYGWIN
31 31
32 #define USE_SIGNALS 32 #define USE_SIGNALS
33 33
34 #include <errno.h> 34 #include <errno.h>
35 #include <pthread.h> 35 #include <pthread.h>
36 #include <signal.h> 36 #include <signal.h>
37 #include <sys/time.h> 37 #include <sys/time.h>
38
39 #if !V8_OS_QNX
38 #include <sys/syscall.h> 40 #include <sys/syscall.h>
41 #endif
39 42
40 #if V8_OS_MACOSX 43 #if V8_OS_MACOSX
41 #include <mach/mach.h> 44 #include <mach/mach.h>
42 // OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h> 45 // OpenBSD doesn't have <ucontext.h>. ucontext_t lives in <signal.h>
43 // and is a typedef for struct sigcontext. There is no uc_mcontext. 46 // and is a typedef for struct sigcontext. There is no uc_mcontext.
44 #elif(!V8_OS_ANDROID || defined(__BIONIC_HAVE_UCONTEXT_T)) \ 47 #elif(!V8_OS_ANDROID || defined(__BIONIC_HAVE_UCONTEXT_T)) \
45 && !V8_OS_OPENBSD 48 && !V8_OS_OPENBSD
46 #include <ucontext.h> 49 #include <ucontext.h>
47 #endif 50 #endif
51
48 #include <unistd.h> 52 #include <unistd.h>
49 53
50 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. 54 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'.
51 // Old versions of the C library <signal.h> didn't define the type. 55 // Old versions of the C library <signal.h> didn't define the type.
52 #if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ 56 #if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
53 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) 57 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
54 #include <asm/sigcontext.h> 58 #include <asm/sigcontext.h>
55 #endif 59 #endif
56 60
57 #elif V8_OS_WIN || V8_OS_CYGWIN 61 #elif V8_OS_WIN || V8_OS_CYGWIN
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 263
260 static bool Installed() { 264 static bool Installed() {
261 return signal_handler_installed_; 265 return signal_handler_installed_;
262 } 266 }
263 267
264 private: 268 private:
265 static void Install() { 269 static void Install() {
266 struct sigaction sa; 270 struct sigaction sa;
267 sa.sa_sigaction = &HandleProfilerSignal; 271 sa.sa_sigaction = &HandleProfilerSignal;
268 sigemptyset(&sa.sa_mask); 272 sigemptyset(&sa.sa_mask);
273 #if V8_OS_QNX
274 sa.sa_flags = SA_SIGINFO;
275 #else
269 sa.sa_flags = SA_RESTART | SA_SIGINFO; 276 sa.sa_flags = SA_RESTART | SA_SIGINFO;
277 #endif
270 signal_handler_installed_ = 278 signal_handler_installed_ =
271 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); 279 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0);
272 } 280 }
273 281
274 static void Restore() { 282 static void Restore() {
275 if (signal_handler_installed_) { 283 if (signal_handler_installed_) {
276 sigaction(SIGPROF, &old_signal_handler_, 0); 284 sigaction(SIGPROF, &old_signal_handler_, 0);
277 signal_handler_installed_ = false; 285 signal_handler_installed_ = false;
278 } 286 }
279 } 287 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 state.fp = reinterpret_cast<Address>(ucontext->sc_ebp); 416 state.fp = reinterpret_cast<Address>(ucontext->sc_ebp);
409 #elif V8_HOST_ARCH_X64 417 #elif V8_HOST_ARCH_X64
410 state.pc = reinterpret_cast<Address>(ucontext->sc_rip); 418 state.pc = reinterpret_cast<Address>(ucontext->sc_rip);
411 state.sp = reinterpret_cast<Address>(ucontext->sc_rsp); 419 state.sp = reinterpret_cast<Address>(ucontext->sc_rsp);
412 state.fp = reinterpret_cast<Address>(ucontext->sc_rbp); 420 state.fp = reinterpret_cast<Address>(ucontext->sc_rbp);
413 #endif // V8_HOST_ARCH_* 421 #endif // V8_HOST_ARCH_*
414 #elif V8_OS_SOLARIS 422 #elif V8_OS_SOLARIS
415 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]); 423 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_PC]);
416 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]); 424 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_SP]);
417 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]); 425 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_FP]);
418 #endif // V8_OS_SOLARIS 426 #elif V8_OS_QNX
427 #if V8_HOST_ARCH_IA32
428 state.pc = reinterpret_cast<Address>(mcontext.cpu.eip);
429 state.sp = reinterpret_cast<Address>(mcontext.cpu.esp);
430 state.fp = reinterpret_cast<Address>(mcontext.cpu.ebp);
431 #elif V8_HOST_ARCH_ARM
432 state.pc = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_PC]);
433 state.sp = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_SP]);
434 state.fp = reinterpret_cast<Address>(mcontext.cpu.gpr[ARM_REG_FP]);
435 #endif // V8_HOST_ARCH_*
436 #endif // V8_OS_QNX
419 #endif // USE_SIMULATOR 437 #endif // USE_SIMULATOR
420 sampler->SampleStack(state); 438 sampler->SampleStack(state);
421 #endif // V8_OS_NACL 439 #endif // V8_OS_NACL
422 } 440 }
423 441
424 #endif 442 #endif
425 443
426 444
427 class SamplerThread : public Thread { 445 class SamplerThread : public Thread {
428 public: 446 public:
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 #endif // USE_SIMULATOR 696 #endif // USE_SIMULATOR
679 SampleStack(state); 697 SampleStack(state);
680 } 698 }
681 ResumeThread(profiled_thread); 699 ResumeThread(profiled_thread);
682 } 700 }
683 701
684 #endif // USE_SIGNALS 702 #endif // USE_SIGNALS
685 703
686 704
687 } } // namespace v8::internal 705 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/qnx-math.h ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698