| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 69 |
| 70 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) | 70 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) |
| 71 | 71 |
| 72 // Not all versions of Android's C library provide ucontext_t. | 72 // Not all versions of Android's C library provide ucontext_t. |
| 73 // Detect this and provide custom but compatible definitions. Note that these | 73 // Detect this and provide custom but compatible definitions. Note that these |
| 74 // follow the GLibc naming convention to access register values from | 74 // follow the GLibc naming convention to access register values from |
| 75 // mcontext_t. | 75 // mcontext_t. |
| 76 // | 76 // |
| 77 // See http://code.google.com/p/android/issues/detail?id=34784 | 77 // See http://code.google.com/p/android/issues/detail?id=34784 |
| 78 | 78 |
| 79 // TODO(jbramley): This is not (and has never been) defined for A64. Does A64's |
| 80 // Android provide ucontext_t? Should we add an A64 variant? |
| 81 |
| 79 #if defined(__arm__) | 82 #if defined(__arm__) |
| 80 | 83 |
| 81 typedef struct sigcontext mcontext_t; | 84 typedef struct sigcontext mcontext_t; |
| 82 | 85 |
| 83 typedef struct ucontext { | 86 typedef struct ucontext { |
| 84 uint32_t uc_flags; | 87 uint32_t uc_flags; |
| 85 struct ucontext* uc_link; | 88 struct ucontext* uc_link; |
| 86 stack_t uc_stack; | 89 stack_t uc_stack; |
| 87 mcontext_t uc_mcontext; | 90 mcontext_t uc_mcontext; |
| 88 // Other fields are not used by V8, don't define them here. | 91 // Other fields are not used by V8, don't define them here. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // Check if there is active simulator before allocating TickSample. | 242 // Check if there is active simulator before allocating TickSample. |
| 240 if (!simulator_) return NULL; | 243 if (!simulator_) return NULL; |
| 241 #endif // USE_SIMULATOR | 244 #endif // USE_SIMULATOR |
| 242 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); | 245 TickSample* sample = isolate->cpu_profiler()->TickSampleEvent(); |
| 243 if (sample == NULL) sample = &sample_obj; | 246 if (sample == NULL) sample = &sample_obj; |
| 244 return sample; | 247 return sample; |
| 245 } | 248 } |
| 246 | 249 |
| 247 #if defined(USE_SIMULATOR) | 250 #if defined(USE_SIMULATOR) |
| 248 inline void FillRegisters(TickSample* sample) { | 251 inline void FillRegisters(TickSample* sample) { |
| 252 #if V8_TARGET_ARCH_ARM |
| 249 sample->pc = reinterpret_cast<Address>(simulator_->get_pc()); | 253 sample->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
| 250 sample->sp = reinterpret_cast<Address>(simulator_->get_register( | 254 sample->sp = reinterpret_cast<Address>(simulator_->get_register( |
| 251 Simulator::sp)); | 255 Simulator::sp)); |
| 252 #if V8_TARGET_ARCH_ARM | |
| 253 sample->fp = reinterpret_cast<Address>(simulator_->get_register( | 256 sample->fp = reinterpret_cast<Address>(simulator_->get_register( |
| 254 Simulator::r11)); | 257 Simulator::r11)); |
| 258 #elif V8_TARGET_ARCH_A64 |
| 259 sample->pc = reinterpret_cast<Address>(simulator_->pc()); |
| 260 sample->sp = reinterpret_cast<Address>(simulator_->sp()); |
| 261 sample->fp = reinterpret_cast<Address>(simulator_->lr()); |
| 255 #elif V8_TARGET_ARCH_MIPS | 262 #elif V8_TARGET_ARCH_MIPS |
| 263 sample->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
| 264 sample->sp = reinterpret_cast<Address>(simulator_->get_register( |
| 265 Simulator::sp)); |
| 256 sample->fp = reinterpret_cast<Address>(simulator_->get_register( | 266 sample->fp = reinterpret_cast<Address>(simulator_->get_register( |
| 257 Simulator::fp)); | 267 Simulator::fp)); |
| 258 #endif | 268 #endif |
| 259 } | 269 } |
| 260 #endif // USE_SIMULATOR | 270 #endif // USE_SIMULATOR |
| 261 | 271 |
| 262 private: | 272 private: |
| 263 #if defined(USE_SIMULATOR) | 273 #if defined(USE_SIMULATOR) |
| 264 Simulator* simulator_; | 274 Simulator* simulator_; |
| 265 #endif | 275 #endif |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // values from mcontext_t. | 361 // values from mcontext_t. |
| 352 sample->pc = reinterpret_cast<Address>(mcontext.gregs[R15]); | 362 sample->pc = reinterpret_cast<Address>(mcontext.gregs[R15]); |
| 353 sample->sp = reinterpret_cast<Address>(mcontext.gregs[R13]); | 363 sample->sp = reinterpret_cast<Address>(mcontext.gregs[R13]); |
| 354 sample->fp = reinterpret_cast<Address>(mcontext.gregs[R11]); | 364 sample->fp = reinterpret_cast<Address>(mcontext.gregs[R11]); |
| 355 #else | 365 #else |
| 356 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); | 366 sample->pc = reinterpret_cast<Address>(mcontext.arm_pc); |
| 357 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); | 367 sample->sp = reinterpret_cast<Address>(mcontext.arm_sp); |
| 358 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); | 368 sample->fp = reinterpret_cast<Address>(mcontext.arm_fp); |
| 359 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && | 369 #endif // defined(__GLIBC__) && !defined(__UCLIBC__) && |
| 360 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) | 370 // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) |
| 371 #elif V8_HOST_ARCH_A64 |
| 372 sample->pc = reinterpret_cast<Address>(mcontext.pc); |
| 373 sample->sp = reinterpret_cast<Address>(mcontext.sp); |
| 374 // FP is an alias for x29. |
| 375 sample->fp = reinterpret_cast<Address>(mcontext.regs[29]); |
| 361 #elif V8_HOST_ARCH_MIPS | 376 #elif V8_HOST_ARCH_MIPS |
| 362 sample->pc = reinterpret_cast<Address>(mcontext.pc); | 377 sample->pc = reinterpret_cast<Address>(mcontext.pc); |
| 363 sample->sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 378 sample->sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
| 364 sample->fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 379 sample->fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
| 365 #endif // V8_HOST_ARCH_* | 380 #endif // V8_HOST_ARCH_* |
| 366 #elif defined(__FreeBSD__) | 381 #elif defined(__FreeBSD__) |
| 367 #if V8_HOST_ARCH_IA32 | 382 #if V8_HOST_ARCH_IA32 |
| 368 sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); | 383 sample->pc = reinterpret_cast<Address>(mcontext.mc_eip); |
| 369 sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); | 384 sample->sp = reinterpret_cast<Address>(mcontext.mc_esp); |
| 370 sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); | 385 sample->fp = reinterpret_cast<Address>(mcontext.mc_ebp); |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 SamplerThread::RemoveActiveSampler(this); | 700 SamplerThread::RemoveActiveSampler(this); |
| 686 SetActive(false); | 701 SetActive(false); |
| 687 } | 702 } |
| 688 | 703 |
| 689 void Sampler::SampleStack(TickSample* sample) { | 704 void Sampler::SampleStack(TickSample* sample) { |
| 690 sample->Trace(isolate_); | 705 sample->Trace(isolate_); |
| 691 if (++samples_taken_ < 0) samples_taken_ = 0; | 706 if (++samples_taken_ < 0) samples_taken_ = 0; |
| 692 } | 707 } |
| 693 | 708 |
| 694 } } // namespace v8::internal | 709 } } // namespace v8::internal |
| OLD | NEW |