| OLD | NEW |
| 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 28 matching lines...) Expand all Loading... |
| 39 #include <sys/time.h> | 39 #include <sys/time.h> |
| 40 #include <sys/syscall.h> | 40 #include <sys/syscall.h> |
| 41 #if !defined(__ANDROID__) || defined(__BIONIC_HAVE_UCONTEXT_T) | 41 #if !defined(__ANDROID__) || defined(__BIONIC_HAVE_UCONTEXT_T) |
| 42 #include <ucontext.h> | 42 #include <ucontext.h> |
| 43 #endif | 43 #endif |
| 44 #include <unistd.h> | 44 #include <unistd.h> |
| 45 | 45 |
| 46 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. | 46 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. |
| 47 // Old versions of the C library <signal.h> didn't define the type. | 47 // Old versions of the C library <signal.h> didn't define the type. |
| 48 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ | 48 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ |
| 49 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) | 49 (defined(__arm__) || defined(__aarch64__)) && \ |
| 50 !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) |
| 50 #include <asm/sigcontext.h> | 51 #include <asm/sigcontext.h> |
| 51 #endif | 52 #endif |
| 52 | 53 |
| 53 #elif defined(__MACH__) | 54 #elif defined(__MACH__) |
| 54 | 55 |
| 55 #include <mach/mach.h> | 56 #include <mach/mach.h> |
| 56 | 57 |
| 57 #elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) | 58 #elif defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__) |
| 58 | 59 |
| 59 #include "win32-headers.h" | 60 #include "win32-headers.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 | 74 |
| 74 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) | 75 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) |
| 75 | 76 |
| 76 // Not all versions of Android's C library provide ucontext_t. | 77 // Not all versions of Android's C library provide ucontext_t. |
| 77 // Detect this and provide custom but compatible definitions. Note that these | 78 // Detect this and provide custom but compatible definitions. Note that these |
| 78 // follow the GLibc naming convention to access register values from | 79 // follow the GLibc naming convention to access register values from |
| 79 // mcontext_t. | 80 // mcontext_t. |
| 80 // | 81 // |
| 81 // See http://code.google.com/p/android/issues/detail?id=34784 | 82 // See http://code.google.com/p/android/issues/detail?id=34784 |
| 82 | 83 |
| 83 // TODO(jbramley): This is not (and has never been) defined for A64. Does A64's | |
| 84 // Android provide ucontext_t? Should we add an A64 variant? | |
| 85 | |
| 86 #if defined(__arm__) | 84 #if defined(__arm__) |
| 87 | 85 |
| 88 typedef struct sigcontext mcontext_t; | 86 typedef struct sigcontext mcontext_t; |
| 89 | 87 |
| 90 typedef struct ucontext { | 88 typedef struct ucontext { |
| 91 uint32_t uc_flags; | 89 uint32_t uc_flags; |
| 92 struct ucontext* uc_link; | 90 struct ucontext* uc_link; |
| 93 stack_t uc_stack; | 91 stack_t uc_stack; |
| 94 mcontext_t uc_mcontext; | 92 mcontext_t uc_mcontext; |
| 95 // Other fields are not used by V8, don't define them here. | 93 // Other fields are not used by V8, don't define them here. |
| 96 } ucontext_t; | 94 } ucontext_t; |
| 97 | 95 |
| 96 #elif defined(__aarch64__) |
| 97 |
| 98 typedef struct sigcontext mcontext_t; |
| 99 |
| 100 typedef struct ucontext { |
| 101 uint64_t uc_flags; |
| 102 struct ucontext *uc_link; |
| 103 stack_t uc_stack; |
| 104 mcontext_t uc_mcontext; |
| 105 // Other fields are not used by V8, don't define them here. |
| 106 } ucontext_t; |
| 107 |
| 98 #elif defined(__mips__) | 108 #elif defined(__mips__) |
| 99 // MIPS version of sigcontext, for Android bionic. | 109 // MIPS version of sigcontext, for Android bionic. |
| 100 typedef struct { | 110 typedef struct { |
| 101 uint32_t regmask; | 111 uint32_t regmask; |
| 102 uint32_t status; | 112 uint32_t status; |
| 103 uint64_t pc; | 113 uint64_t pc; |
| 104 uint64_t gregs[32]; | 114 uint64_t gregs[32]; |
| 105 uint64_t fpregs[32]; | 115 uint64_t fpregs[32]; |
| 106 uint32_t acx; | 116 uint32_t acx; |
| 107 uint32_t fpc_csr; | 117 uint32_t fpc_csr; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 state.pc = reinterpret_cast<Address>(mcontext.gregs[R15]); | 379 state.pc = reinterpret_cast<Address>(mcontext.gregs[R15]); |
| 370 state.sp = reinterpret_cast<Address>(mcontext.gregs[R13]); | 380 state.sp = reinterpret_cast<Address>(mcontext.gregs[R13]); |
| 371 state.fp = reinterpret_cast<Address>(mcontext.gregs[R11]); | 381 state.fp = reinterpret_cast<Address>(mcontext.gregs[R11]); |
| 372 #else | 382 #else |
| 373 state.pc = reinterpret_cast<Address>(mcontext.arm_pc); | 383 state.pc = reinterpret_cast<Address>(mcontext.arm_pc); |
| 374 state.sp = reinterpret_cast<Address>(mcontext.arm_sp); | 384 state.sp = reinterpret_cast<Address>(mcontext.arm_sp); |
| 375 state.fp = reinterpret_cast<Address>(mcontext.arm_fp); | 385 state.fp = reinterpret_cast<Address>(mcontext.arm_fp); |
| 376 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && | 386 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && |
| 377 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | 387 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
| 378 #elif V8_HOST_ARCH_A64 | 388 #elif V8_HOST_ARCH_A64 |
| 379 sample->pc = reinterpret_cast<Address>(mcontext.pc); | 389 state.pc = reinterpret_cast<Address>(mcontext.pc); |
| 380 sample->sp = reinterpret_cast<Address>(mcontext.sp); | 390 state.sp = reinterpret_cast<Address>(mcontext.sp); |
| 381 // FP is an alias for x29. | 391 // FP is an alias for x29. |
| 382 sample->fp = reinterpret_cast<Address>(mcontext.regs[29]); | 392 state.fp = reinterpret_cast<Address>(mcontext.regs[29]); |
| 383 #elif V8_HOST_ARCH_MIPS | 393 #elif V8_HOST_ARCH_MIPS |
| 384 state.pc = reinterpret_cast<Address>(mcontext.pc); | 394 state.pc = reinterpret_cast<Address>(mcontext.pc); |
| 385 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 395 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
| 386 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 396 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
| 387 #endif // V8_HOST_ARCH_* | 397 #endif // V8_HOST_ARCH_* |
| 388 #elif defined(__FreeBSD__) | 398 #elif defined(__FreeBSD__) |
| 389 #if V8_HOST_ARCH_IA32 | 399 #if V8_HOST_ARCH_IA32 |
| 390 state.pc = reinterpret_cast<Address>(mcontext.mc_eip); | 400 state.pc = reinterpret_cast<Address>(mcontext.mc_eip); |
| 391 state.sp = reinterpret_cast<Address>(mcontext.mc_esp); | 401 state.sp = reinterpret_cast<Address>(mcontext.mc_esp); |
| 392 state.fp = reinterpret_cast<Address>(mcontext.mc_ebp); | 402 state.fp = reinterpret_cast<Address>(mcontext.mc_ebp); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 sample->Init(isolate_, state); | 728 sample->Init(isolate_, state); |
| 719 if (is_counting_samples_) { | 729 if (is_counting_samples_) { |
| 720 if (sample->state == JS || sample->state == EXTERNAL) { | 730 if (sample->state == JS || sample->state == EXTERNAL) { |
| 721 ++js_and_external_sample_count_; | 731 ++js_and_external_sample_count_; |
| 722 } | 732 } |
| 723 } | 733 } |
| 724 Tick(sample); | 734 Tick(sample); |
| 725 } | 735 } |
| 726 | 736 |
| 727 } } // namespace v8::internal | 737 } } // namespace v8::internal |
| OLD | NEW |