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 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 state->pc = reinterpret_cast<Address>(simulator_->pc()); | 250 state->pc = reinterpret_cast<Address>(simulator_->pc()); |
251 state->sp = reinterpret_cast<Address>(simulator_->sp()); | 251 state->sp = reinterpret_cast<Address>(simulator_->sp()); |
252 state->fp = reinterpret_cast<Address>(simulator_->fp()); | 252 state->fp = reinterpret_cast<Address>(simulator_->fp()); |
253 #elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 253 #elif V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
254 state->pc = reinterpret_cast<Address>(simulator_->get_pc()); | 254 state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
255 state->sp = reinterpret_cast<Address>(simulator_->get_register( | 255 state->sp = reinterpret_cast<Address>(simulator_->get_register( |
256 Simulator::sp)); | 256 Simulator::sp)); |
257 state->fp = reinterpret_cast<Address>(simulator_->get_register( | 257 state->fp = reinterpret_cast<Address>(simulator_->get_register( |
258 Simulator::fp)); | 258 Simulator::fp)); |
| 259 #elif V8_TARGET_ARCH_PPC |
| 260 state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
| 261 state->sp = |
| 262 reinterpret_cast<Address>(simulator_->get_register(Simulator::sp)); |
| 263 state->fp = |
| 264 reinterpret_cast<Address>(simulator_->get_register(Simulator::fp)); |
259 #endif | 265 #endif |
260 } | 266 } |
261 | 267 |
262 private: | 268 private: |
263 Simulator* simulator_; | 269 Simulator* simulator_; |
264 }; | 270 }; |
265 #endif // USE_SIMULATOR | 271 #endif // USE_SIMULATOR |
266 | 272 |
267 | 273 |
268 #if defined(USE_SIGNALS) | 274 #if defined(USE_SIGNALS) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 if (!helper.Init(isolate)) return; | 360 if (!helper.Init(isolate)) return; |
355 helper.FillRegisters(&state); | 361 helper.FillRegisters(&state); |
356 // It possible that the simulator is interrupted while it is updating | 362 // It possible that the simulator is interrupted while it is updating |
357 // the sp or fp register. ARM64 simulator does this in two steps: | 363 // the sp or fp register. ARM64 simulator does this in two steps: |
358 // first setting it to zero and then setting it to the new value. | 364 // first setting it to zero and then setting it to the new value. |
359 // Bailout if sp/fp doesn't contain the new value. | 365 // Bailout if sp/fp doesn't contain the new value. |
360 if (state.sp == 0 || state.fp == 0) return; | 366 if (state.sp == 0 || state.fp == 0) return; |
361 #else | 367 #else |
362 // Extracting the sample from the context is extremely machine dependent. | 368 // Extracting the sample from the context is extremely machine dependent. |
363 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 369 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
364 #if !V8_OS_OPENBSD | 370 #if !(V8_OS_OPENBSD || (V8_OS_LINUX && V8_HOST_ARCH_PPC)) |
365 mcontext_t& mcontext = ucontext->uc_mcontext; | 371 mcontext_t& mcontext = ucontext->uc_mcontext; |
366 #endif | 372 #endif |
367 #if V8_OS_LINUX | 373 #if V8_OS_LINUX |
368 #if V8_HOST_ARCH_IA32 | 374 #if V8_HOST_ARCH_IA32 |
369 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); | 375 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_EIP]); |
370 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); | 376 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_ESP]); |
371 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); | 377 state.fp = reinterpret_cast<Address>(mcontext.gregs[REG_EBP]); |
372 #elif V8_HOST_ARCH_X64 | 378 #elif V8_HOST_ARCH_X64 |
373 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); | 379 state.pc = reinterpret_cast<Address>(mcontext.gregs[REG_RIP]); |
374 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); | 380 state.sp = reinterpret_cast<Address>(mcontext.gregs[REG_RSP]); |
(...skipping 16 matching lines...) Expand all Loading... |
391 // FP is an alias for x29. | 397 // FP is an alias for x29. |
392 state.fp = reinterpret_cast<Address>(mcontext.regs[29]); | 398 state.fp = reinterpret_cast<Address>(mcontext.regs[29]); |
393 #elif V8_HOST_ARCH_MIPS | 399 #elif V8_HOST_ARCH_MIPS |
394 state.pc = reinterpret_cast<Address>(mcontext.pc); | 400 state.pc = reinterpret_cast<Address>(mcontext.pc); |
395 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 401 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
396 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 402 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
397 #elif V8_HOST_ARCH_MIPS64 | 403 #elif V8_HOST_ARCH_MIPS64 |
398 state.pc = reinterpret_cast<Address>(mcontext.pc); | 404 state.pc = reinterpret_cast<Address>(mcontext.pc); |
399 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); | 405 state.sp = reinterpret_cast<Address>(mcontext.gregs[29]); |
400 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); | 406 state.fp = reinterpret_cast<Address>(mcontext.gregs[30]); |
| 407 #elif V8_HOST_ARCH_PPC |
| 408 state.pc = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->nip); |
| 409 state.sp = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->gpr[PT_R1]); |
| 410 state.fp = reinterpret_cast<Address>(ucontext->uc_mcontext.regs->gpr[PT_R31]); |
401 #endif // V8_HOST_ARCH_* | 411 #endif // V8_HOST_ARCH_* |
402 #elif V8_OS_MACOSX | 412 #elif V8_OS_MACOSX |
403 #if V8_HOST_ARCH_X64 | 413 #if V8_HOST_ARCH_X64 |
404 #if __DARWIN_UNIX03 | 414 #if __DARWIN_UNIX03 |
405 state.pc = reinterpret_cast<Address>(mcontext->__ss.__rip); | 415 state.pc = reinterpret_cast<Address>(mcontext->__ss.__rip); |
406 state.sp = reinterpret_cast<Address>(mcontext->__ss.__rsp); | 416 state.sp = reinterpret_cast<Address>(mcontext->__ss.__rsp); |
407 state.fp = reinterpret_cast<Address>(mcontext->__ss.__rbp); | 417 state.fp = reinterpret_cast<Address>(mcontext->__ss.__rbp); |
408 #else // !__DARWIN_UNIX03 | 418 #else // !__DARWIN_UNIX03 |
409 state.pc = reinterpret_cast<Address>(mcontext->ss.rip); | 419 state.pc = reinterpret_cast<Address>(mcontext->ss.rip); |
410 state.sp = reinterpret_cast<Address>(mcontext->ss.rsp); | 420 state.sp = reinterpret_cast<Address>(mcontext->ss.rsp); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 #endif // USE_SIMULATOR | 765 #endif // USE_SIMULATOR |
756 SampleStack(state); | 766 SampleStack(state); |
757 } | 767 } |
758 ResumeThread(profiled_thread); | 768 ResumeThread(profiled_thread); |
759 } | 769 } |
760 | 770 |
761 #endif // USE_SIGNALS | 771 #endif // USE_SIGNALS |
762 | 772 |
763 | 773 |
764 } } // namespace v8::internal | 774 } } // namespace v8::internal |
OLD | NEW |